|
|
|
@ -40,8 +40,6 @@
|
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int auth_check(Octstr *user, Octstr *pass, List *headers, int *has_auth_hdr)
|
|
|
|
|
{
|
|
|
|
|
int i, res = -1;
|
|
|
|
@ -145,8 +143,8 @@ static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype, Octstr *s
|
|
|
|
|
(octstr_case_compare(status, octstr_imm("Deferred")) != 0 &&
|
|
|
|
|
octstr_case_compare(status, octstr_imm("Forwarded")) != 0))
|
|
|
|
|
mms_dlr_url_remove(value, rtype, mmc->group_id); /* only remove if not
|
|
|
|
|
* interim status
|
|
|
|
|
*/
|
|
|
|
|
* interim status
|
|
|
|
|
*/
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(newmsgid);
|
|
|
|
@ -208,11 +206,16 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
unsigned char *msgtype = (unsigned char *)"";
|
|
|
|
|
Octstr *qf = NULL, *mmc_id = NULL, *qdir = NULL;
|
|
|
|
|
List *qhdr = http_create_empty_headers();
|
|
|
|
|
|
|
|
|
|
Octstr *r, *s, *transid = NULL, *value = NULL;
|
|
|
|
|
|
|
|
|
|
if (h->body)
|
|
|
|
|
mreq = mm7_parse_soap(h->headers, h->body);
|
|
|
|
|
if (mreq)
|
|
|
|
|
if (mreq) {
|
|
|
|
|
msgtype = mms_mm7tag_to_cstr(mm7_msgtype(mreq));
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
} else
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
|
|
|
|
|
debug("mmsbox.mm7sendinterface", 0,
|
|
|
|
|
" --> Enterred mm7dispatch interface, mreq=[%s] mtype=[%s] <-- ",
|
|
|
|
|
mreq ? "Ok" : "Null",
|
|
|
|
@ -230,10 +233,11 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
if (!from)
|
|
|
|
|
from = octstr_create("anon@anon");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qdir = get_mmsbox_queue_dir(from, to, h->m, &mmc_id); /* get routing info. */
|
|
|
|
|
|
|
|
|
|
switch (mm7_msgtype(mreq)) {
|
|
|
|
|
Octstr *value, *value2;
|
|
|
|
|
Octstr *value2;
|
|
|
|
|
|
|
|
|
|
case MM7_TAG_DeliverReq:
|
|
|
|
|
m = mm7_soap_to_mmsmsg(mreq, from);
|
|
|
|
@ -282,20 +286,23 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
mms_error(0, "MM7", h->m->id,
|
|
|
|
|
"Failed to write queue entry for received MM7/SOAP DeliverReq message from mmc=%s to MMS Message!",
|
|
|
|
|
octstr_get_cstr(h->m->id));
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
|
|
|
|
|
msgid = mms_make_msgid(octstr_get_cstr(qf), NULL);
|
|
|
|
|
mms_log("Received", from, to, -1, msgid, NULL, h->m->id, "MMSBox",
|
|
|
|
|
h->ua, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
octstr_destroy(linkedid);
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
|
|
|
|
|
http_destroy_headers(qh);
|
|
|
|
|
} else {
|
|
|
|
|
mms_error(0, "MM7", h->m->id,
|
|
|
|
|
"Failed to convert received MM7/SOAP DeliverReq message from mmc=%s to MMS Message!",
|
|
|
|
|
octstr_get_cstr(h->m->id));
|
|
|
|
|
"Failed to convert received MM7/SOAP DeliverReq message from mmc=%s to MMS Message!",
|
|
|
|
|
octstr_get_cstr(h->m->id));
|
|
|
|
|
status = 4000;
|
|
|
|
|
}
|
|
|
|
|
mresp = mm7_make_resp(mreq, status, NULL,1);
|
|
|
|
@ -333,14 +340,17 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
octstr_get_cstr(qdir),
|
|
|
|
|
"MM7/SOAP-IN",
|
|
|
|
|
NULL);
|
|
|
|
|
if (qf)
|
|
|
|
|
if (qf) {
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received DLR", from, to, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
else
|
|
|
|
|
status = 4000;
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
status = 4000;
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR,3);
|
|
|
|
|
}
|
|
|
|
|
mresp = mm7_make_resp(mreq, status, NULL,1);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -362,15 +372,16 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
octstr_get_cstr(qdir),
|
|
|
|
|
"MM7/SOAP-IN",
|
|
|
|
|
NULL);
|
|
|
|
|
if (qf)
|
|
|
|
|
if (qf) {
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received RR", from, to, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
else
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
status = 4000;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
mresp = mm7_make_resp(mreq, status, NULL,1);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -380,12 +391,34 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
/* Invoke call back */
|
|
|
|
|
s = mm7_soap_header_value(mreq, octstr_imm("MM7Version"));
|
|
|
|
|
r = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
|
|
|
|
transid = mm7_soap_header_value(mreq, octstr_imm("TransactionID"));
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7_msgtype(mreq), 0, s, 0,
|
|
|
|
|
octstr_len(h->body), 0, from,
|
|
|
|
|
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL, r, transid, NULL, value);
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
octstr_destroy(r);
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
if (mresp && mm7_soapmsg_to_httpmsg(mresp, &h->m->ver, &rh, &reply_body) == 0)
|
|
|
|
|
http_send_reply(h->client, hstatus, rh, reply_body);
|
|
|
|
|
else
|
|
|
|
|
http_close_client(h->client);
|
|
|
|
|
|
|
|
|
|
if (mresp) {
|
|
|
|
|
Octstr *s = octstr_format("%d.%d.%d", h->m->ver.major, h->m->ver.minor1, h->m->ver.minor2);
|
|
|
|
|
Octstr *r = mm7_soap_header_value(mresp, octstr_imm("MessageID"));
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7_msgtype(mresp), 0, s, status,
|
|
|
|
|
octstr_len(reply_body), 0, to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
|
|
|
|
from, r, transid, NULL, NULL);
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
octstr_destroy(r);
|
|
|
|
|
} else
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 2);
|
|
|
|
|
|
|
|
|
|
debug("mmsbox.mm7sendinterface", 0,
|
|
|
|
|
" --> leaving mm7dispatch interface, mresp=[%s], body=[%s], mm7_status=[%d] <-- ",
|
|
|
|
|
mresp ? "ok" : "(null)",
|
|
|
|
@ -405,6 +438,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
|
|
|
|
octstr_destroy(mmc_id);
|
|
|
|
|
http_destroy_headers(qhdr);
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
octstr_destroy(transid);
|
|
|
|
|
|
|
|
|
|
return MM7_SOAP_STATUS_OK(status) ? 0 : -1;
|
|
|
|
|
}
|
|
|
|
@ -446,9 +481,12 @@ static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octs
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received DLR", from, lto, -1, msgid, status, mmc ? mmc->id : NULL, "MMSBox", NULL, NULL);
|
|
|
|
|
ret = 0;
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
ret = -1;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
octstr_destroy(qf);
|
|
|
|
|
http_destroy_headers(rqh);
|
|
|
|
|
octstr_destroy(rr_uri);
|
|
|
|
@ -470,13 +508,13 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
Octstr *reply_body = NULL, *value = NULL, *value2 = NULL;
|
|
|
|
|
|
|
|
|
|
List *to = gwlist_create(), *hto = NULL;
|
|
|
|
|
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL;
|
|
|
|
|
Octstr *subject = NULL, *otransid = NULL, *msgid = NULL, *s;
|
|
|
|
|
Octstr *hfrom = NULL, *rr_uri = NULL;
|
|
|
|
|
time_t expiryt = -1, deliveryt = -1;
|
|
|
|
|
Octstr *qf = NULL, *xver = NULL, *mmc_id = NULL, *qdir = NULL;
|
|
|
|
|
int msize = h->body ? octstr_len(h->body) : 0;
|
|
|
|
|
int dlr;
|
|
|
|
|
int mtype;
|
|
|
|
|
int mtype = -1, mm7type = -1;
|
|
|
|
|
|
|
|
|
|
debug("mmsbox.mm7eaif.sendinterface", 0,
|
|
|
|
|
" --> Enterred eaif send interface, blen=[%d] <--- ",
|
|
|
|
@ -488,12 +526,15 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
http_header_add(rh, "Content-Type", "text/plain");
|
|
|
|
|
hstatus = HTTP_BAD_REQUEST;
|
|
|
|
|
reply_body = octstr_format("Unexpected MMS message, no body?");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE,2);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
|
|
|
|
|
/* XXXX handle delivery reports differently. */
|
|
|
|
|
mtype = mms_messagetype(m);
|
|
|
|
|
mm7type = mm7_msgtype_to_soaptype(mtype, 1);
|
|
|
|
|
mh = mms_message_headers(m);
|
|
|
|
|
/* Now get sender and receiver data.
|
|
|
|
|
* for now we ignore adaptation flags.
|
|
|
|
@ -581,12 +622,13 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
if (qf) {
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received", hfrom, to, msize, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hstatus = HTTP_NO_CONTENT;
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
case MMS_MSGTYPE_DELIVERY_IND:
|
|
|
|
@ -613,11 +655,12 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
if (qf) {
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("DeliveryReport", hfrom, to, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
hstatus = HTTP_NO_CONTENT;
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -645,22 +688,37 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received RR", hfrom, to, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
hstatus = HTTP_NO_CONTENT;
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
s = http_header_value(h->headers, octstr_imm("X-NOKIA-MMSC-Version"));
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7type, 0, s, 0,
|
|
|
|
|
msize, 0, hfrom,
|
|
|
|
|
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
|
|
|
|
msgid, otransid, NULL, value);
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
xver = octstr_format(EAIF_VERSION, h->m->ver.major, h->m->ver.minor1);
|
|
|
|
|
http_header_add(rh, "X-NOKIA-MMSC-Version", octstr_get_cstr(xver));
|
|
|
|
|
octstr_destroy(xver);
|
|
|
|
|
|
|
|
|
|
http_send_reply(h->client, hstatus, rh, octstr_imm(""));
|
|
|
|
|
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp, 0,
|
|
|
|
|
xver, hstatus,
|
|
|
|
|
0, 0, to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
|
|
|
|
hfrom,
|
|
|
|
|
msgid, otransid, NULL, reply_body);
|
|
|
|
|
|
|
|
|
|
http_send_reply(h->client, hstatus, rh, reply_body ? reply_body : octstr_imm(""));
|
|
|
|
|
|
|
|
|
|
octstr_destroy(xver);
|
|
|
|
|
http_destroy_headers(hto);
|
|
|
|
|
http_destroy_headers(rqh);
|
|
|
|
|
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
|
|
|
@ -671,7 +729,8 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
octstr_destroy(qf);
|
|
|
|
|
octstr_destroy(mmc_id);
|
|
|
|
|
octstr_destroy(rr_uri);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
|
|
|
|
|
http_destroy_headers(mh);
|
|
|
|
|
mms_destroy(m);
|
|
|
|
|
|
|
|
|
@ -690,10 +749,10 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
Octstr *hto = NULL, *subject = NULL, *msgid = NULL;
|
|
|
|
|
Octstr *hfrom = NULL, *body, *rr_uri = NULL, *dlr_uri = NULL;
|
|
|
|
|
time_t expiryt = -1, deliveryt = -1;
|
|
|
|
|
Octstr *qf = NULL, *mmc_id = NULL, *qdir = NULL, *s;
|
|
|
|
|
Octstr *qf = NULL, *mmc_id = NULL, *qdir = NULL, *value = NULL, *s;
|
|
|
|
|
int msize;
|
|
|
|
|
int dlr, rr;
|
|
|
|
|
int mtype;
|
|
|
|
|
int mtype = -1, mm7type = -1;
|
|
|
|
|
List *cgivars_ctypes = NULL, *rqh = http_create_empty_headers();
|
|
|
|
|
|
|
|
|
|
parse_cgivars(h->headers, h->body, &h->cgivars, &cgivars_ctypes);
|
|
|
|
@ -712,7 +771,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
http_header_add(rh, "Content-Type", "text/plain");
|
|
|
|
|
hstatus = HTTP_BAD_REQUEST;
|
|
|
|
|
reply_body = octstr_format("Missing 'to' argument");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
} else if (hfrom == NULL) {
|
|
|
|
@ -720,6 +780,7 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
hstatus = HTTP_BAD_REQUEST;
|
|
|
|
|
reply_body = octstr_format("Missing 'from' argument");
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
|
|
} else if (body == NULL || /* A message is required, and must parse */
|
|
|
|
@ -728,13 +789,16 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
hstatus = HTTP_BAD_REQUEST;
|
|
|
|
|
reply_body = octstr_format("Unexpected MMS message, no content?");
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
goto done;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
to = octstr_split_words(hto);
|
|
|
|
|
|
|
|
|
|
mtype = mms_messagetype(m);
|
|
|
|
|
mm7type = mm7_msgtype_to_soaptype(mtype, 1);
|
|
|
|
|
mh = mms_message_headers(m);
|
|
|
|
|
|
|
|
|
|
/* find interesting headers. */
|
|
|
|
@ -757,7 +821,7 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
qdir = get_mmsbox_queue_dir(hfrom, to, h->m, &mmc_id); /* get routing info. */
|
|
|
|
|
|
|
|
|
|
switch(mtype) {
|
|
|
|
|
Octstr *value, *value2;
|
|
|
|
|
Octstr *value2;
|
|
|
|
|
case MMS_MSGTYPE_SEND_REQ:
|
|
|
|
|
case MMS_MSGTYPE_RETRIEVE_CONF:
|
|
|
|
|
|
|
|
|
@ -779,7 +843,7 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
rr = 1;
|
|
|
|
|
else
|
|
|
|
|
rr = 0;
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (deliveryt < 0)
|
|
|
|
|
deliveryt = time(NULL);
|
|
|
|
@ -796,8 +860,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (qdir == outgoing_qdir) { /* We need to remember the old message ID so we can re-write it
|
|
|
|
|
* if a DLR is relayed backwards.
|
|
|
|
|
*/
|
|
|
|
|
* if a DLR is relayed backwards.
|
|
|
|
|
*/
|
|
|
|
|
Octstr *t = mms_maketransid(NULL, octstr_imm(MM_NAME)); /* make a fake transaction id so dlr works*/
|
|
|
|
|
|
|
|
|
|
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(t));
|
|
|
|
@ -823,11 +887,14 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
|
|
|
|
|
if (qf) {
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
mms_log("Received", hfrom, to, msize, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
|
|
|
|
|
hstatus = HTTP_OK;
|
|
|
|
|
} else
|
|
|
|
|
} else {
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case MMS_MSGTYPE_DELIVERY_IND:
|
|
|
|
|
msgid = mms_get_header_value(m, octstr_imm("Message-ID"));
|
|
|
|
@ -854,9 +921,11 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
mms_log("DeliveryReport", hfrom, to, -1, msgid,value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
|
|
|
|
|
hstatus = HTTP_OK;
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
@ -884,18 +953,32 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
/* Log to access log */
|
|
|
|
|
mms_log("Received RR", hfrom, to, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL);
|
|
|
|
|
hstatus = HTTP_NO_CONTENT;
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR);
|
|
|
|
|
} else {
|
|
|
|
|
hstatus = HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
MMSC_ISSUE_ALARM(h->m, MMSBOX_ALARM_QUEUE_WRITE_ERROR, 4);
|
|
|
|
|
}
|
|
|
|
|
octstr_destroy(value2);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7type, 0, octstr_imm("1.0"), 0,
|
|
|
|
|
msize, 0, hfrom,
|
|
|
|
|
to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
|
|
|
|
msgid, octstr_imm("0000"), NULL, value);
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mmsbox_event_cb(h->m->id, mm7type >= 0 ? mm7type + 1 : MM7_TAG_VASPErrorRsp, 0,
|
|
|
|
|
octstr_imm("1.0"), hstatus,
|
|
|
|
|
0, 0, to && gwlist_len(to) > 0 ? gwlist_get(to,0) : NULL,
|
|
|
|
|
hfrom,
|
|
|
|
|
msgid, octstr_imm("0001"), NULL, reply_body);
|
|
|
|
|
|
|
|
|
|
http_header_add(rh, "X-Mbuni-Version", VERSION);
|
|
|
|
|
|
|
|
|
|
http_send_reply(h->client, hstatus, rh, msgid ? msgid : (qf ? qf : octstr_imm("")));
|
|
|
|
|
http_send_reply(h->client, hstatus, rh, msgid ? msgid : reply_body ? reply_body : qf ? qf : octstr_imm(""));
|
|
|
|
|
|
|
|
|
|
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
|
|
|
|
|
|
|
|
@ -904,13 +987,14 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
|
|
|
|
|
octstr_destroy(qf);
|
|
|
|
|
octstr_destroy(mmc_id);
|
|
|
|
|
octstr_destroy(msgid);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(reply_body);
|
|
|
|
|
http_destroy_headers(mh);
|
|
|
|
|
http_destroy_headers(rh);
|
|
|
|
|
http_destroy_headers(rqh);
|
|
|
|
|
octstr_destroy(value);
|
|
|
|
|
octstr_destroy(hfrom);
|
|
|
|
|
|
|
|
|
|
if (m)
|
|
|
|
|
mms_destroy(m);
|
|
|
|
|
mms_destroy(m);
|
|
|
|
|
|
|
|
|
|
http_destroy_cgiargs(cgivars_ctypes);
|
|
|
|
|
|
|
|
|
@ -923,6 +1007,7 @@ static void dispatch_mm7_recv(List *rl)
|
|
|
|
|
|
|
|
|
|
MmsBoxHTTPClientInfo *h;
|
|
|
|
|
|
|
|
|
|
hmon->register_thread();
|
|
|
|
|
while ((h = gwlist_consume(rl)) != NULL) {
|
|
|
|
|
int ret = -1, has_auth = 0;
|
|
|
|
|
MmscGrp *m = h->m;
|
|
|
|
@ -956,6 +1041,7 @@ static void dispatch_mm7_recv(List *rl)
|
|
|
|
|
h->m->mo_errors++;
|
|
|
|
|
free_mmsbox_http_clientInfo(h, 1);
|
|
|
|
|
}
|
|
|
|
|
hmon->unregister_thread();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void mmsc_receive_func(MmscGrp *m)
|
|
|
|
@ -967,6 +1053,8 @@ void mmsc_receive_func(MmscGrp *m)
|
|
|
|
|
|
|
|
|
|
gwlist_add_producer(mmsc_incoming_reqs);
|
|
|
|
|
|
|
|
|
|
hmon->register_thread();
|
|
|
|
|
|
|
|
|
|
for (i = 0; i<maxthreads; i++)
|
|
|
|
|
thids[i] = gwthread_create((gwthread_func_t *)dispatch_mm7_recv, mmsc_incoming_reqs);
|
|
|
|
|
|
|
|
|
@ -1000,9 +1088,9 @@ void mmsc_receive_func(MmscGrp *m)
|
|
|
|
|
h.ua = http_header_value(h.headers, octstr_imm("User-Agent"));
|
|
|
|
|
|
|
|
|
|
mms_error_ex("auth",0, "MM7", m->id, "HTTP: Incoming IP denied MMSC[%s] ip=[%s], ua=[%s], disconnected",
|
|
|
|
|
m->id ? octstr_get_cstr(m->id) : "(none)",
|
|
|
|
|
h.ip ? octstr_get_cstr(h.ip) : "(none)",
|
|
|
|
|
h.ua ? octstr_get_cstr(h.ua) : "(none)");
|
|
|
|
|
m->id ? octstr_get_cstr(m->id) : "(none)",
|
|
|
|
|
h.ip ? octstr_get_cstr(h.ip) : "(none)",
|
|
|
|
|
h.ua ? octstr_get_cstr(h.ua) : "(none)");
|
|
|
|
|
|
|
|
|
|
http_send_reply(h.client, HTTP_FORBIDDEN, NULL,
|
|
|
|
|
octstr_imm("Access denied."));
|
|
|
|
@ -1019,6 +1107,7 @@ void mmsc_receive_func(MmscGrp *m)
|
|
|
|
|
gwlist_destroy(mmsc_incoming_reqs, NULL);
|
|
|
|
|
gw_free(thids);
|
|
|
|
|
|
|
|
|
|
hmon->unregister_thread();
|
|
|
|
|
debug("proxy", 0, "MMSBox: MM7 receiver [mmc=%s] Shutting down complete.", octstr_get_cstr(m->id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1033,11 +1122,12 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
Octstr *linkedid,
|
|
|
|
|
char *vasid,
|
|
|
|
|
Octstr *service_code,
|
|
|
|
|
List *hdrs,
|
|
|
|
|
MmsEnvelope *e,
|
|
|
|
|
MmsMsg *m, Octstr **error,
|
|
|
|
|
List **errl,
|
|
|
|
|
int *retry)
|
|
|
|
|
{
|
|
|
|
|
List *hdrs = e ? e->hdrs : NULL;
|
|
|
|
|
Octstr *ret = NULL;
|
|
|
|
|
int mtype = mms_messagetype(m);
|
|
|
|
|
int hstatus = HTTP_OK, tstatus = -1;
|
|
|
|
@ -1045,13 +1135,15 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
MSoapMsg_t *mreq = NULL, *mresp = NULL;
|
|
|
|
|
List *rh = NULL, *ph = NULL;
|
|
|
|
|
Octstr *body = NULL, *rbody = NULL, *url = NULL;
|
|
|
|
|
Octstr *s;
|
|
|
|
|
Octstr *s, *r, *status_details = NULL;
|
|
|
|
|
char *xvasid = vasid ? vasid : (mmc->default_vasid ? octstr_get_cstr(mmc->default_vasid) : NULL);
|
|
|
|
|
|
|
|
|
|
if (e == NULL || mmc == NULL)
|
|
|
|
|
goto done1;
|
|
|
|
|
mms_info(0, "MM7", mmc->id, "MMSBox: Send[soap] to MMSC[%s], msg type [%s], from %s, to %s",
|
|
|
|
|
mmc->id ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
mms_message_type_to_cstr(mtype),
|
|
|
|
|
octstr_get_cstr(from), octstr_get_cstr(to));
|
|
|
|
|
mmc->id ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
mms_message_type_to_cstr(mtype),
|
|
|
|
|
octstr_get_cstr(from), octstr_get_cstr(to));
|
|
|
|
|
|
|
|
|
|
gwlist_append(xto, to);
|
|
|
|
|
|
|
|
|
@ -1078,14 +1170,30 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
if (http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
|
|
|
|
|
*error = octstr_format("Failed to contact MMC[url=%S] => HTTP returned status=[%d]!",
|
|
|
|
|
mmc->mmsc_url, hstatus);
|
|
|
|
|
if (hstatus < 0)
|
|
|
|
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED, 3);
|
|
|
|
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT, 3);
|
|
|
|
|
goto done1;
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_NON_200_RESULT);
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_SOCKET_CONNECT_FAILED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Invoke call back */
|
|
|
|
|
s = mm7_soap_header_value(mreq, octstr_imm("MM7Version"));
|
|
|
|
|
r = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
|
|
|
|
|
mmsbox_event_cb(mmc->id, mm7_msgtype(mreq), 0, s, 0,
|
|
|
|
|
mms_msgsize(m), e->attempts, e->from,
|
|
|
|
|
to,r, transid, hdrs, NULL);
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
octstr_destroy(r);
|
|
|
|
|
if ((mresp = mm7_parse_soap(ph, rbody)) == NULL) {
|
|
|
|
|
*error = octstr_format("Failed to parse MMSC[url=%S, id=%S] response!",
|
|
|
|
|
mmc->mmsc_url, mmc->id);
|
|
|
|
|
|
|
|
|
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
goto done1;
|
|
|
|
|
}
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
|
|
|
|
|
if (errl) { /* Pick up status stuff -- for DLR */
|
|
|
|
|
if (*errl == NULL)
|
|
|
|
@ -1105,36 +1213,46 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
if ((s = mm7_soap_header_value(mresp, octstr_imm("StatusCode"))) != NULL) {
|
|
|
|
|
tstatus = atoi(octstr_get_cstr(s));
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
} else if ((s = mm7_soap_header_value(mresp, octstr_imm("faultstring"))) != NULL) {
|
|
|
|
|
tstatus = atoi(octstr_get_cstr(s));
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
} else
|
|
|
|
|
MMSC_CLEAR_ALARM(mmc, MMSBOX_ALARM_MM7_PARSING_FAILURE);
|
|
|
|
|
} else {
|
|
|
|
|
MMSC_ISSUE_ALARM(mmc, MMSBOX_ALARM_MM7_PARSING_FAILURE, 3);
|
|
|
|
|
tstatus = MM7_SOAP_FORMAT_CORRUPT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!MM7_SOAP_STATUS_OK(tstatus) && tstatus != MM7_SOAP_COMMAND_REJECTED) {
|
|
|
|
|
Octstr *detail = mm7_soap_header_value(mresp, octstr_imm("Details"));
|
|
|
|
|
char *tmp = (char *)mms_soap_status_to_cstr(tstatus);
|
|
|
|
|
|
|
|
|
|
Octstr *detail = mm7_soap_header_value(mresp, octstr_imm("Details"));
|
|
|
|
|
if (detail == NULL)
|
|
|
|
|
detail = mm7_soap_header_value(mresp, octstr_imm("faultcode"));
|
|
|
|
|
ret = NULL;
|
|
|
|
|
mms_info(0, "MM7", mmc->id, "Send to MMSC[%s], failed, code=[%d=>%s], detail=[%s]",
|
|
|
|
|
mmc ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
tstatus, tmp ? tmp : "",
|
|
|
|
|
detail ? octstr_get_cstr(detail) : "");
|
|
|
|
|
mmc ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
tstatus, tmp ? tmp : "",
|
|
|
|
|
detail ? octstr_get_cstr(detail) : "");
|
|
|
|
|
|
|
|
|
|
*error = octstr_format("Failed to deliver to MMC[url=%S, id=%S], status=[%d=>%s]!",
|
|
|
|
|
mmc->mmsc_url,
|
|
|
|
|
mmc->id,
|
|
|
|
|
tstatus,
|
|
|
|
|
tmp ? tmp : "");
|
|
|
|
|
octstr_destroy(detail);
|
|
|
|
|
tmp ? tmp : "");
|
|
|
|
|
status_details = detail ? octstr_duplicate(detail) : tmp ? octstr_create(tmp) : octstr_imm("");
|
|
|
|
|
octstr_destroy(detail);
|
|
|
|
|
} else {
|
|
|
|
|
ret = mm7_soap_header_value(mresp, octstr_imm("MessageID"));
|
|
|
|
|
mms_info(0, "MM7", NULL, "Sent to MMC[%s], code=[%d=>%s], msgid=[%s]", octstr_get_cstr(mmc->id),
|
|
|
|
|
tstatus, mms_soap_status_to_cstr(tstatus), ret ? octstr_get_cstr(ret) : "(none)");
|
|
|
|
|
tstatus, mms_soap_status_to_cstr(tstatus), ret ? octstr_get_cstr(ret) : "(none)");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s = mm7_soap_header_value(mresp, octstr_imm("MM7Version"));
|
|
|
|
|
mmsbox_event_cb(mmc->id, mm7_msgtype(mresp), 0, s, tstatus,
|
|
|
|
|
0, e->attempts, e->from,
|
|
|
|
|
to, ret, transid, hdrs, status_details);
|
|
|
|
|
octstr_destroy(s);
|
|
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
|
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
|
|
|
|
@ -1148,31 +1266,36 @@ done1:
|
|
|
|
|
http_destroy_headers(ph);
|
|
|
|
|
octstr_destroy(rbody);
|
|
|
|
|
octstr_destroy(url);
|
|
|
|
|
|
|
|
|
|
gwlist_destroy(xto, NULL);
|
|
|
|
|
|
|
|
|
|
octstr_destroy(status_details);
|
|
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
Octstr *transid,
|
|
|
|
|
char *vasid,
|
|
|
|
|
List *hdrs,
|
|
|
|
|
MmsEnvelope *e,
|
|
|
|
|
MmsMsg *m, Octstr **error,
|
|
|
|
|
int *retry)
|
|
|
|
|
{
|
|
|
|
|
List *hdrs = e ? e->hdrs : NULL;
|
|
|
|
|
Octstr *ret = NULL, *resp = NULL;
|
|
|
|
|
int mtype = mms_messagetype(m);
|
|
|
|
|
int hstatus = HTTP_OK;
|
|
|
|
|
List *rh = http_create_empty_headers(), *ph = NULL;
|
|
|
|
|
Octstr *body = NULL, *rbody = NULL, *xver = NULL;
|
|
|
|
|
char *msgtype;
|
|
|
|
|
MmsMsg *mresp = NULL;
|
|
|
|
|
int mresp_type = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e == NULL || mmc == NULL)
|
|
|
|
|
goto done;
|
|
|
|
|
mms_info(0, "MM7", mmc->id, "MMSBox: Send [eaif] to MMC[%s], msg type [%s], from %s, to %s",
|
|
|
|
|
mmc ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
mms_message_type_to_cstr(mtype),
|
|
|
|
|
octstr_get_cstr(from), octstr_get_cstr(to));
|
|
|
|
|
mmc && mmc->id ? octstr_get_cstr(mmc->id) : "",
|
|
|
|
|
mms_message_type_to_cstr(mtype),
|
|
|
|
|
octstr_get_cstr(from), octstr_get_cstr(to));
|
|
|
|
|
|
|
|
|
|
http_header_remove_all(rh, "X-Mms-Allow-Adaptations");
|
|
|
|
|
http_header_add(rh, "X-NOKIA-MMSC-To", octstr_get_cstr(to));
|
|
|
|
@ -1180,7 +1303,7 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|
|
|
|
|
|
|
|
|
xver = octstr_format(EAIF_VERSION, mmc->ver.major, mmc->ver.minor1);
|
|
|
|
|
http_header_add(rh, "X-NOKIA-MMSC-Version", octstr_get_cstr(xver));
|
|
|
|
|
octstr_destroy(xver);
|
|