1
0
Fork 0

minor mmsbox dlr improvements

This commit is contained in:
bagyenda 2008-11-21 05:19:43 +00:00
parent b064ee14f0
commit f10b0e4e41
3 changed files with 67 additions and 168 deletions

View File

@ -1,3 +1,5 @@
2008-11-21 P. A. Bagyenda <bagyenda@dsmagic.com>
* Minor improvements in DLR processing (mmsbox)
2008-11-20 P. A. Bagyenda <bagyenda@dsmagic.com>
* Improved DLR status messages in mmsbox
* Minor memory leak fixed in MM7/SOAP processing

View File

@ -149,6 +149,40 @@ static void fixup_relayed_report(MmsMsg *m, MmscGrp *mmc, char *rtype, Octstr *s
octstr_destroy(value);
}
/* returns the DLR/RR URL, fills in the queue header info. */
Octstr *mmsbox_get_report_info(MmsMsg *m, MmscGrp *mmsc, Octstr *out_mmc_id, char *report_type,
Octstr *status, List *qhdr, Octstr *uaprof,
time_t uaprof_tstamp,
Octstr *msgid)
{
Octstr *res;
if (out_mmc_id != NULL) { /* internal routing. */
if (m)
fixup_relayed_report(m, mmsc, report_type, octstr_imm(""));
res = NULL;
} else {
Octstr *transid = NULL;
res = get_dlr_notify_url(msgid, report_type,mmsc->group_id, mmsc->id,
status, &transid);
http_header_add(qhdr, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(mmsc->group_id));
if (transid) {
http_header_add(qhdr, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (uaprof) {
Octstr *sx = date_format_http(uaprof_tstamp);
http_header_add(qhdr, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
http_header_add(qhdr, "X-Mbuni-Timestamp", octstr_get_cstr(sx));
octstr_destroy(sx);
}
}
return res;
}
/* These functions are very similar to those in mmsproxy */
static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
{
@ -279,32 +313,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
}
m = mm7_soap_to_mmsmsg(mreq, from);
if (mmc_id != NULL) { /* internal routing. */
if (m)
fixup_relayed_report(m, h->m, "delivery-report",
value); /* fix it up if it is relayed. */
value2 = NULL;
} else { /* routing to URL -- get it. */
Octstr *transid = NULL;
value2 = get_dlr_notify_url(msgid, "delivery-report",h->m->group_id, h->m->id,
value, &transid);
http_header_add(qhdr, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(qhdr, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (uaprof) {
Octstr *sx = date_format_http(uaprof_tstamp);
http_header_add(qhdr, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
http_header_add(qhdr, "X-Mbuni-Timestamp", octstr_get_cstr(sx));
octstr_destroy(sx);
}
}
value2 = mmsbox_get_report_info(m, h->m, mmc_id, "delivery-report",
value, qhdr, uaprof, uaprof_tstamp, msgid);
qf = qfs->mms_queue_add(from, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -332,31 +342,8 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
value = mm7_soap_header_value(mreq, octstr_imm("MMStatus"));
msgid = mm7_soap_header_value(mreq, octstr_imm("MessageID"));
if (mmc_id != NULL) { /* internal routing. */
if (m)
fixup_relayed_report(m, h->m, "read-report", octstr_imm(""));
value2 = NULL;
} else {
Octstr *transid = NULL;
value2 = mmsbox_get_report_info(m, h->m, mmc_id, "read-report", value, qhdr, uaprof, uaprof_tstamp, msgid);
value2 = get_dlr_notify_url(msgid, "read-report",h->m->group_id, h->m->id,
value, &transid);
http_header_add(qhdr, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(qhdr, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (uaprof) {
Octstr *sx = date_format_http(uaprof_tstamp);
http_header_add(qhdr, "X-Mbuni-UAProf", octstr_get_cstr(uaprof));
http_header_add(qhdr, "X-Mbuni-Timestamp", octstr_get_cstr(sx));
octstr_destroy(sx);
}
}
qf = qfs->mms_queue_add(from, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -414,21 +401,6 @@ static int mm7soap_receive(MmsBoxHTTPClientInfo *h)
return MM7_SOAP_STATUS_OK(status) ? 0 : -1;
}
#if 0
/* Helper func to avoid code duplication below. */
static void handle_report_dispatch(MmscGrp *m, Octstr *hfrom, char *rtype, List *mh, Octstr *status_hdr)
{
Octstr *value = http_header_value(mh, status_hdr);
Octstr *value2 = http_header_value(mh, octstr_imm("Message-ID"));
Octstr *value3 = http_header_value(mh, octstr_imm("X-Mbuni-Orig-Message-ID"));
mmsbox_send_report(hfrom, rtype, NULL, value, value2, value3, m->id,
m->group_id, NULL, NULL, -1);
octstr_destroy(value);
octstr_destroy(value2);
octstr_destroy(value3);
}
#endif
/* helper function for queueing delivery reports. */
static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octstr *status, char *interf, List *errl)
@ -446,22 +418,8 @@ static int queue_dlr(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *msgid, Octs
gwlist_append(lto, octstr_duplicate(to));
qdir = get_mmsbox_queue_dir(from, lto, mmc, &mmc_id); /* get routing info. */
if (mmc_id != NULL) /* internal routing. */
fixup_relayed_report(m, mmc, "delivery-report", status); /* fix it up if it is relayed. */
else {
Octstr *transid = NULL;
rr_uri = get_dlr_notify_url(msgid, "delivery-report",
mmc->group_id, mmc->id,
status, &transid);
http_header_add(rqh, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(mmc->group_id));
if (transid) {
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
}
rr_uri = mmsbox_get_report_info(m, mmc, mmc_id, "delivery-report", status, rqh, NULL, 0, msgid);
qf = qfs->mms_queue_add(from, lto, NULL,
mmc->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -623,23 +581,12 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
value = mms_get_header_value(m, octstr_imm("X-Mms-Status"));
value2 = mms_get_header_value(m, octstr_imm("X-Mbuni-Orig-Message-ID"));
if (mmc_id != NULL) /* internal routing. */
fixup_relayed_report(m, h->m, "delivery-report", value); /* fix it up if it is relayed. */
else {
Octstr *transid = NULL;
rr_uri = get_dlr_notify_url(msgid, "delivery-report",
h->m->group_id, h->m->id,
value, &transid);
http_header_add(rqh, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
}
rr_uri = mmsbox_get_report_info(m, h->m, mmc_id, "delivery-report",
value, rqh, NULL, 0, msgid);
if (value2 && mmc_id == NULL)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
qf = qfs->mms_queue_add(hfrom, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -666,24 +613,12 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
value = mms_get_header_value(m, octstr_imm("X-Mms-Read-Status"));
value2 = mms_get_header_value(m, octstr_imm("X-Mbuni-Orig-Message-ID"));
if (mmc_id != NULL) /* internal routing. */
fixup_relayed_report(m, h->m, "read-report", octstr_imm("")); /* fix it up if it is relayed. */
else {
Octstr *transid = NULL;
rr_uri = get_dlr_notify_url(msgid, "read-report",
h->m->group_id, h->m->id,
value, &transid);
http_header_add(rqh, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
}
rr_uri = mmsbox_get_report_info(m, h->m, mmc_id, "read-report",
value, rqh, NULL, 0, msgid);
if (value2 && mmc_id == NULL)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
qf = qfs->mms_queue_add(hfrom, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -720,6 +655,7 @@ static int mm7eaif_receive(MmsBoxHTTPClientInfo *h)
octstr_destroy(msgid);
octstr_destroy(qf);
octstr_destroy(mmc_id);
octstr_destroy(rr_uri);
http_destroy_headers(mh);
mms_destroy(m);
@ -883,23 +819,11 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
value = mms_get_header_value(m, octstr_imm("X-Mms-Status"));
value2 = mms_get_header_value(m, octstr_imm("X-Mbuni-Orig-Message-ID"));
if (mmc_id != NULL) /* internal routing. */
fixup_relayed_report(m, h->m, "delivery-report", value); /* fix it up if it is relayed. */
else {
Octstr *transid = NULL;
rr_uri = get_dlr_notify_url(msgid, "delivery-report",
h->m->group_id, h->m->id,
value, &transid);
http_header_add(rqh, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
}
rr_uri = mmsbox_get_report_info(m, h->m, mmc_id, "delivery-report",
value, rqh, NULL, 0, msgid);
if (mmc_id == NULL && value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
qf = qfs->mms_queue_add(hfrom, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -926,24 +850,11 @@ static int mm7http_receive(MmsBoxHTTPClientInfo *h)
value = mms_get_header_value(m, octstr_imm("X-Mms-Read-Status"));
value2 = mms_get_header_value(m, octstr_imm("X-Mbuni-Orig-Message-ID"));
if (mmc_id != NULL) /* internal routing. */
fixup_relayed_report(m, h->m, "read-report", octstr_imm(""));
else {
Octstr *transid = NULL;
rr_uri = get_dlr_notify_url(msgid, "read-report",
h->m->group_id, h->m->id,
value, &transid);
http_header_add(rqh, "X-Mbuni-Mmsc-GroupID", octstr_get_cstr(h->m->group_id));
if (transid) {
http_header_add(rqh, "X-Mbuni-TransactionID", octstr_get_cstr(transid));
octstr_destroy(transid);
}
if (value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
rr_uri = mmsbox_get_report_info(m, h->m, mmc_id, "read-report",
value, rqh, NULL, 0, msgid);
if (mmc_id == NULL && value2)
http_header_add(rqh, "X-Mbuni-Orig-Message-ID", octstr_get_cstr(value2));
}
qf = qfs->mms_queue_add(hfrom, to, NULL,
h->m->id, mmc_id,
0, time(NULL) + default_msgexpiry, m, NULL,
@ -1541,11 +1452,6 @@ static int sendMsg(MmsEnvelope *e)
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
queue_dlr(mmc, e->from, to->rcpt, new_msgid, octstr_imm("Forwarded"), "MM7-Out", errl);
#if 0
mmsbox_send_report(to->rcpt, "delivery-report", e->url1,
octstr_imm("Forwarded"), new_msgid, NULL,
mmc->id, mmc->group_id, otransid, NULL, -1);
#endif
} else if (res == MMS_SEND_ERROR_FATAL && mmc) {
if (e->msgtype == MMS_MSGTYPE_SEND_REQ ||
e->msgtype == MMS_MSGTYPE_RETRIEVE_CONF) /* queue dlr as needed. */
@ -1553,13 +1459,6 @@ static int sendMsg(MmsEnvelope *e)
(e->expiryt != 0 && e->expiryt < tnow) ?
octstr_imm("Expired") : octstr_imm("Rejected"),
"MM7-Out", errl);
#if 0
mmsbox_send_report(to->rcpt, "delivery-report",
e->url1,
(e->expiryt != 0 && e->expiryt < tnow) ?
octstr_imm("Expired") : octstr_imm("Rejected"),
e->msgId, NULL, mmc->id, mmc->group_id, otransid, NULL, -1);
#endif
}
if (res == MMS_SEND_ERROR_FATAL)
to->process = 0; /* No more attempts. */

View File

@ -18,14 +18,12 @@ extern int rstop;
void mms_dlr_url_put(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr *dlr_url, Octstr *transid);
int mms_dlr_url_get(Octstr *msgid, char *rtype, Octstr *mmc_gid, Octstr **dlr_url, Octstr **transid);
void mms_dlr_url_remove(Octstr *msgid, char *rtype, Octstr *mmc_gid);
#if 0
int mmsbox_send_report(Octstr *from, char *report_type,
Octstr *dlr_url, Octstr *status,
Octstr *msgid, Octstr *orig_msgid,
Octstr *mmc_id, Octstr *mmc_gid,
Octstr *orig_transid, Octstr *uaprof,
time_t uaprof_tstamp);
#endif
Octstr *mmsbox_get_report_info(MmsMsg *m, MmscGrp *mmsc, Octstr *out_mmc_id,
char *report_type,
Octstr *status, List *qhdr, Octstr *uaprof,
time_t uaprof_tstamp,
Octstr *msgid);
void mmsc_receive_func(MmscGrp *m);
void mmsbox_outgoing_queue_runner(int *rstop);