diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index c7bbc57..b645868 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2008-10-16 P. A. Bagyenda + * Minor fix for DLR relaying (mmsbox). 2008-10-02 P. A. Bagyenda * Added vasp-id param to mmsbox mmsc config (thanks to Christian Theil Have ) 2008-09-30 P. A. Bagyenda diff --git a/mbuni/mmsbox/bearerbox.c b/mbuni/mmsbox/bearerbox.c index fc30238..18c70fb 100644 --- a/mbuni/mmsbox/bearerbox.c +++ b/mbuni/mmsbox/bearerbox.c @@ -149,7 +149,7 @@ done: return 0; } -static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype) +static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype, Octstr *status) { Octstr *value = mms_get_header_value(m, octstr_imm("Message-ID")); @@ -166,8 +166,13 @@ static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype) mms_replace_header_value(m, "Message-ID", octstr_get_cstr(newmsgid)); /* Add it back as original. */ mms_replace_header_value(m, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value)); - - mms_dlr_url_remove(value, "delivery-report", mmc->group_id); + + if (strcmp(rtype, "read-report") == 0 || + (octstr_case_compare(status, octstr_imm("Deferred")) != 0 && + octstr_case_compare(status, octstr_imm("Forwarded")) != 0)) + mms_dlr_url_remove(value, "delivery-report", mmc->group_id); /* only remove if not + * interim status + */ } octstr_destroy(newmsgid); octstr_destroy(transid); @@ -215,6 +220,7 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) qdir = get_mmsbox_queue_dir(from, to, h->m, &mmc_id); /* get routing info. */ switch (mm7_msgtype(mreq)) { + Octstr *value; case MM7_TAG_DeliverReq: m = mm7_soap_to_mmsmsg(mreq, from); if (m) { @@ -222,7 +228,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) Octstr *linkedid = mm7_soap_header_value(mreq, octstr_imm("LinkedID")); List *qh = http_create_empty_headers(); int dlr; - Octstr *value = mms_get_header_value(m, octstr_imm("X-Mms-Delivery-Report")); + + value = mms_get_header_value(m, octstr_imm("X-Mms-Delivery-Report")); if (value && octstr_case_compare(value, octstr_imm("Yes")) == 0) @@ -273,10 +280,13 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) break; case MM7_TAG_DeliveryReportReq: + value = mm7_soap_header_value(mreq, octstr_imm("MMStatus")); if (mmc_id != NULL) { /* internal routing. */ m = mm7_soap_to_mmsmsg(mreq, from); if (m) { - fixup_relayed_report(m, h->m, "delivery-report"); /* fix it up if it is relayed. */ + + fixup_relayed_report(m, h->m, "delivery-report", + value); /* fix it up if it is relayed. */ qf = qfs->mms_queue_add(from, to, NULL, h->m->id, mmc_id, 0, time(NULL) + default_msgexpiry, m, NULL, @@ -296,7 +306,6 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) status = 4000; } else { Octstr *desc = mm7_soap_header_value(mreq, octstr_imm("StatusText")); - Octstr *value = mm7_soap_header_value(mreq, octstr_imm("MMStatus")); msgid = mm7_soap_header_value(mreq, octstr_imm("MessageID")); @@ -309,10 +318,9 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) mms_log("DeliveryReport", from, NULL, -1, msgid, value, h->m->id, "MMSBox", h->ua, NULL); octstr_destroy(desc); - octstr_destroy(value); - } mresp = mm7_make_resp(mreq, status, NULL,1); + octstr_destroy(value); break; case MM7_TAG_ReadReplyReq: @@ -320,7 +328,7 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h) m = mm7_soap_to_mmsmsg(mreq, from); if (m) { - fixup_relayed_report(m, h->m, "read-report"); /* fix it up if it is relayed. */ + fixup_relayed_report(m, h->m, "read-report", octstr_imm("")); qf = qfs->mms_queue_add(from, to, NULL, h->m->id, mmc_id, 0, time(NULL) + default_msgexpiry, m, NULL, @@ -414,7 +422,7 @@ static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octs if (mmc_id != NULL) { /* internal routing. */ Octstr *qf; - fixup_relayed_report(m, mmc, "delivery-report"); /* fix it up if it is relayed. */ + fixup_relayed_report(m, mmc, "delivery-report", status); /* fix it up if it is relayed. */ qf = qfs->mms_queue_add(from, lto, NULL, mmc->id, mmc_id, 0, time(NULL) + default_msgexpiry, m, NULL, @@ -573,7 +581,8 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h) break; case MMS_MSGTYPE_DELIVERY_IND: if (mmc_id != NULL) { /* internal routing. */ - fixup_relayed_report(m, h->m, "delivery-report"); /* fix it up if it is relayed. */ + Octstr *svalue = mms_get_header_value(m, octstr_imm("X-Mms-Status")); + fixup_relayed_report(m, h->m, "delivery-report", svalue); /* fix it up if it is relayed. */ qf = qfs->mms_queue_add(hfrom, to, NULL, h->m->id, mmc_id, 0, time(NULL) + default_msgexpiry, m, NULL, @@ -591,6 +600,7 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h) hstatus = HTTP_NO_CONTENT; } else hstatus = HTTP_INTERNAL_SERVER_ERROR; + octstr_destroy(svalue); } else handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status")); break; @@ -598,7 +608,7 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h) case MMS_MSGTYPE_READ_ORIG_IND: if (mmc_id != NULL) { /* internal routing. */ - fixup_relayed_report(m, h->m, "read-report"); /* fix it up if it is relayed. */ + fixup_relayed_report(m, h->m, "read-report", octstr_imm("")); /* fix it up if it is relayed. */ qf = qfs->mms_queue_add(hfrom, to, NULL, h->m->id, mmc_id, 0, time(NULL) + default_msgexpiry, m, NULL, @@ -796,8 +806,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h) break; case MMS_MSGTYPE_DELIVERY_IND: if (mmc_id != NULL) { /* internal routing. */ - - fixup_relayed_report(m, h->m, "delivery-report"); /* fix it up if it is relayed. */ + Octstr *svalue = mms_get_header_value(m, octstr_imm("X-Mms-Status")); + fixup_relayed_report(m, h->m, "delivery-report", svalue); /* fix it up if it is relayed. */ qf = qfs->mms_queue_add(hfrom, to, NULL, h->m->id, mmc_id, @@ -816,6 +826,8 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h) hstatus = HTTP_OK; } else hstatus = HTTP_INTERNAL_SERVER_ERROR; + + octstr_destroy(svalue); } else handle_report_dispatch(h->m, hfrom, "delivery-report", mh, octstr_imm("X-Mms-Status")); break; @@ -823,7 +835,7 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h) case MMS_MSGTYPE_READ_ORIG_IND: if (mmc_id != NULL) { /* internal routing. */ - fixup_relayed_report(m, h->m, "read-report"); /* fix it up if it is relayed. */ + fixup_relayed_report(m, h->m, "read-report", octstr_imm("")); qf = qfs->mms_queue_add(hfrom, to, NULL, h->m->id, mmc_id,