VAS GW fixes for DLR
This commit is contained in:
parent
f7da8933d8
commit
99318916ea
|
@ -1,3 +1,5 @@
|
|||
2007-07-27 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Misc. fixes for DLR reporting, VAS GW
|
||||
2007-07-13 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Introduced ability to filter MT MMS on the VAS side using a generalized module.
|
||||
* send-mms interface now allows you to push content by specifying a url using content-url CGI param.
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#define MM7_SOAP_COMMAND_REJECTED 3005
|
||||
#define MM7_SOAP_UNSUPPORTED_OPERATION 4003
|
||||
#define MM7_SOAP_STATUS_OK(e) (((e) / 1000) == 1)
|
||||
#define MM7_SOAP_CLIENT_ERROR(e) (((e) / 1000) == 2)
|
||||
|
||||
#if 0
|
||||
#define MM7_DEFAULT_VERSION MMS_3GPP_VERSION
|
||||
|
|
|
@ -77,11 +77,12 @@ done:
|
|||
return res;
|
||||
}
|
||||
|
||||
static int send_report(Octstr *from, char *report_type, Octstr *status,
|
||||
static int send_report(Octstr *from, char *report_type,
|
||||
Octstr *dlr_url, Octstr *status,
|
||||
Octstr *msgid, Octstr *mmc_id, Octstr *mmc_gid)
|
||||
{
|
||||
|
||||
Octstr *url = mms_dlr_url_get(msgid, report_type, mmc_gid);
|
||||
Octstr *url = dlr_url ? octstr_duplicate(dlr_url) : mms_dlr_url_get(msgid, report_type, mmc_gid);
|
||||
List *rh, *rph = NULL;
|
||||
Octstr *rb = NULL;
|
||||
|
||||
|
@ -102,11 +103,10 @@ static int send_report(Octstr *from, char *report_type, Octstr *status,
|
|||
|
||||
|
||||
mms_url_fetch_content(HTTP_METHOD_GET, url, rh, octstr_imm(""), &rph, &rb);
|
||||
if (rb)
|
||||
|
||||
octstr_destroy(rb);
|
||||
octstr_destroy(url);
|
||||
|
||||
if (rph)
|
||||
http_destroy_headers(rph);
|
||||
http_destroy_headers(rh);
|
||||
|
||||
|
@ -191,7 +191,6 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
msgid = mms_maketransid(octstr_get_cstr(qf), octstr_imm(MM_NAME));
|
||||
mms_log("Received", from, to, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
||||
|
||||
if (linkedid)
|
||||
octstr_destroy(linkedid);
|
||||
octstr_destroy(value);
|
||||
} else {
|
||||
|
@ -210,12 +209,10 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
info(0, "Sending delivery-report [FROM:%s] [VALUE:%s] [DESC:%s] [MSGID:%s]",
|
||||
octstr_get_cstr(from), octstr_get_cstr(value), octstr_get_cstr(desc),
|
||||
octstr_get_cstr(h->m->id));
|
||||
send_report(from, "delivery-report",
|
||||
send_report(from, "delivery-report", NULL,
|
||||
value, msgid, h->m->id, h->m->group_id);
|
||||
|
||||
if (desc)
|
||||
octstr_destroy(desc);
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
mms_log("DeliveryReport",
|
||||
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
||||
|
@ -227,10 +224,9 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
value = mm7_soap_header_value(mreq, octstr_imm("MMStatus"));
|
||||
|
||||
send_report(from,
|
||||
"read-report", value, msgid,
|
||||
"read-report", NULL, value, msgid,
|
||||
h->m->id, h->m->group_id);
|
||||
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
mms_log("ReadReport",
|
||||
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
|
||||
|
@ -254,34 +250,17 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
mresp ? "ok" : "(null)",
|
||||
reply_body ? "ok" : "(null)", status);
|
||||
|
||||
|
||||
if (from)
|
||||
octstr_destroy(from);
|
||||
|
||||
if (subject)
|
||||
octstr_destroy(subject);
|
||||
if (vasid)
|
||||
octstr_destroy(vasid);
|
||||
if (msgid)
|
||||
octstr_destroy(msgid);
|
||||
|
||||
if (qf)
|
||||
octstr_destroy(qf);
|
||||
if (m)
|
||||
mms_destroy(m);
|
||||
if (rh)
|
||||
http_destroy_headers(rh);
|
||||
if (reply_body)
|
||||
octstr_destroy(reply_body);
|
||||
|
||||
if (mresp)
|
||||
mm7_soap_destroy(mresp);
|
||||
if (mreq)
|
||||
mm7_soap_destroy(mreq);
|
||||
|
||||
if (to)
|
||||
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
|
||||
}
|
||||
|
||||
static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
||||
|
@ -330,7 +309,6 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
|||
gwlist_len(hto) > 0) { /* To address is in headers. */
|
||||
int i, n;
|
||||
|
||||
if (to)
|
||||
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
to = gwlist_create();
|
||||
for (i = 0, n = gwlist_len(hto); i < n; i++) {
|
||||
|
@ -345,8 +323,8 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
|||
gwlist_append(to, gwlist_get(l, j));
|
||||
|
||||
gwlist_destroy(l, NULL);
|
||||
if (h) octstr_destroy(h);
|
||||
if (v) octstr_destroy(v);
|
||||
octstr_destroy(h);
|
||||
octstr_destroy(v);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -367,7 +345,6 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
|||
dlr = 1;
|
||||
else
|
||||
dlr = 0;
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
|
||||
if (deliveryt < 0)
|
||||
|
@ -406,22 +383,19 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
|||
case MMS_MSGTYPE_DELIVERY_IND:
|
||||
value = http_header_value(mh, octstr_imm("X-Mms-Status"));
|
||||
value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
||||
send_report(hfrom, "delivery-report", value, value2, h->m->id, h->m->group_id);
|
||||
send_report(hfrom, "delivery-report", NULL, value, value2, h->m->id, h->m->group_id);
|
||||
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
if (value2)
|
||||
octstr_destroy(value2);
|
||||
break;
|
||||
|
||||
case MMS_MSGTYPE_READ_ORIG_IND:
|
||||
value = http_header_value(mh, octstr_imm("X-Mms-Read-Status"));
|
||||
value2 = http_header_value(mh, octstr_imm("Message-ID"));
|
||||
send_report(hfrom, "read-report", value, value2, h->m->id, h->m->group_id);
|
||||
send_report(hfrom, "read-report", NULL, value, value2, h->m->id, h->m->group_id);
|
||||
|
||||
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
if (value2)
|
||||
octstr_destroy(value2);
|
||||
break;
|
||||
}
|
||||
|
@ -434,22 +408,14 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
|
|||
|
||||
http_send_reply(h->client, hstatus, rh, octstr_imm(""));
|
||||
|
||||
if (hto)
|
||||
http_destroy_headers(hto);
|
||||
if (to)
|
||||
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
if (hfrom)
|
||||
octstr_destroy(hfrom);
|
||||
if (subject)
|
||||
octstr_destroy(subject);
|
||||
if (otransid)
|
||||
octstr_destroy(otransid);
|
||||
if (msgid)
|
||||
octstr_destroy(msgid);
|
||||
if (mh)
|
||||
http_destroy_headers(mh);
|
||||
|
||||
if (m) mms_destroy(m);
|
||||
mms_destroy(m);
|
||||
}
|
||||
|
||||
|
||||
|
@ -520,28 +486,16 @@ static void free_clientInfo(MmsHTTPClientInfo *h, int freeh)
|
|||
debug("free info", 0,
|
||||
" entered free_clientinfo %d, ip=[%ld]", freeh, (long)h->ip);
|
||||
|
||||
if (h->ip)
|
||||
octstr_destroy(h->ip);
|
||||
|
||||
|
||||
if (h->url)
|
||||
octstr_destroy(h->url);
|
||||
if (h->ua) octstr_destroy(h->ua);
|
||||
|
||||
|
||||
if (h->body) octstr_destroy(h->body);
|
||||
|
||||
if (h->cgivars)
|
||||
octstr_destroy(h->ua);
|
||||
octstr_destroy(h->body);
|
||||
http_destroy_cgiargs(h->cgivars);
|
||||
|
||||
if (h->headers)
|
||||
http_destroy_headers(h->headers);
|
||||
|
||||
if (freeh)
|
||||
gw_free(h);
|
||||
if (freeh) gw_free(h);
|
||||
|
||||
debug("free info", 0,
|
||||
" left free_clientinfo");
|
||||
debug("free info", 0, " left free_clientinfo");
|
||||
}
|
||||
|
||||
|
||||
|
@ -557,11 +511,12 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
char *vasid,
|
||||
Octstr *service_code,
|
||||
List *hdrs,
|
||||
MmsMsg *m, Octstr **error)
|
||||
MmsMsg *m, Octstr **error,
|
||||
int *retry)
|
||||
{
|
||||
Octstr *ret = NULL;
|
||||
int mtype = mms_messagetype(m);
|
||||
int hstatus = HTTP_OK, tstatus;
|
||||
int hstatus = HTTP_OK, tstatus = -1;
|
||||
List *xto = gwlist_create();
|
||||
MSoapMsg_t *mreq = NULL, *mresp = NULL;
|
||||
List *rh = NULL, *ph = NULL;
|
||||
|
@ -638,9 +593,11 @@ static Octstr *mm7soap_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
tstatus, mms_soap_status_to_cstr(tstatus), ret ? octstr_get_cstr(ret) : "(none)");
|
||||
}
|
||||
|
||||
|
||||
if (ret)
|
||||
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
|
||||
done1:
|
||||
*retry = (ret == NULL && (!MM7_SOAP_CLIENT_ERROR(tstatus) || tstatus < 0));
|
||||
|
||||
mm7_soap_destroy(mreq);
|
||||
mm7_soap_destroy(mresp);
|
||||
|
@ -659,7 +616,8 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
Octstr *transid,
|
||||
char *vasid,
|
||||
List *hdrs,
|
||||
MmsMsg *m, Octstr **error)
|
||||
MmsMsg *m, Octstr **error,
|
||||
int *retry)
|
||||
{
|
||||
Octstr *ret = NULL, *resp = NULL;
|
||||
int mtype = mms_messagetype(m);
|
||||
|
@ -720,7 +678,6 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
else if (mresp)
|
||||
ret = mms_get_header_value(mresp, octstr_imm("Message-ID"));
|
||||
|
||||
if (mresp)
|
||||
mms_destroy(mresp);
|
||||
}
|
||||
|
||||
|
@ -728,11 +685,13 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
ret = NULL;
|
||||
else {
|
||||
hstatus = http_status_class(hstatus);
|
||||
if (hstatus == HTTP_STATUS_SERVER_ERROR)
|
||||
if (hstatus == HTTP_STATUS_SERVER_ERROR ||
|
||||
hstatus == HTTP_STATUS_CLIENT_ERROR)
|
||||
ret = NULL;
|
||||
else if (!ret)
|
||||
ret = http_header_value(ph, octstr_imm("X-Nokia-MMSC-Message-Id"));
|
||||
}
|
||||
*retry = (ret == NULL && (hstatus == HTTP_STATUS_SERVER_ERROR || hstatus < 0));
|
||||
|
||||
if (ret)
|
||||
mms_log2("Sent", from, to, -1, ret, NULL, mmc->id, "MMSBox", NULL, NULL);
|
||||
|
@ -741,42 +700,31 @@ static Octstr *mm7eaif_send(MmscGrp *mmc, Octstr *from, Octstr *to,
|
|||
octstr_get_cstr(mmc->id),
|
||||
hstatus, resp ? octstr_get_cstr(resp) : "(none)", ret ? octstr_get_cstr(ret) : "(none)");
|
||||
|
||||
if (rh)
|
||||
http_destroy_headers(rh);
|
||||
if (body)
|
||||
octstr_destroy(body);
|
||||
if (ph)
|
||||
http_destroy_headers(ph);
|
||||
if (rbody)
|
||||
octstr_destroy(rbody);
|
||||
if (url)
|
||||
octstr_destroy(url);
|
||||
|
||||
if (resp)
|
||||
http_destroy_headers(rh);
|
||||
octstr_destroy(body);
|
||||
http_destroy_headers(ph);
|
||||
octstr_destroy(rbody);
|
||||
octstr_destroy(url);
|
||||
octstr_destroy(resp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int mms_sendtommsc(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *transid,
|
||||
Octstr *linkedid,
|
||||
char *vasid,
|
||||
Octstr *service_code,
|
||||
MmsMsg *m,
|
||||
Octstr *dlr_url,
|
||||
Octstr *rr_url,
|
||||
List *hdrs,
|
||||
Octstr **err)
|
||||
Octstr *linkedid, char *vasid, Octstr *service_code,
|
||||
MmsMsg *m, Octstr *dlr_url, Octstr *rr_url,
|
||||
List *hdrs, Octstr **err)
|
||||
{
|
||||
Octstr *id = NULL, *groupid = NULL;
|
||||
int ret = 0;
|
||||
int ret = 0, retry = 0;
|
||||
unsigned long throughput = 0;
|
||||
|
||||
mutex_lock(mmc->mutex); { /* Grab a lock on it. */
|
||||
if (mmc->type == SOAP_MMSC)
|
||||
id = mm7soap_send(mmc, from, to, transid, linkedid, vasid, service_code, hdrs, m, err);
|
||||
id = mm7soap_send(mmc, from, to, transid, linkedid, vasid, service_code, hdrs, m, err, &retry);
|
||||
else if (mmc->type == EAIF_MMSC)
|
||||
id = mm7eaif_send(mmc, from, to, transid, vasid, hdrs, m, err);
|
||||
id = mm7eaif_send(mmc, from, to, transid, vasid, hdrs, m, err, &retry);
|
||||
else
|
||||
error(0, "MMC[%s] of unknown type, can't send!",
|
||||
mmc->id ? octstr_get_cstr(mmc->id) : "");
|
||||
|
@ -789,7 +737,7 @@ static int mms_sendtommsc(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *transi
|
|||
if (id) {
|
||||
if (dlr_url) { /* remember the url's for reporting purposes. */
|
||||
mms_dlr_url_put(id, "delivery-report", groupid, dlr_url);
|
||||
send_report(from, "delivery-report",
|
||||
send_report(from, "delivery-report", dlr_url,
|
||||
octstr_imm("Sent"), id, mmc->id, groupid);
|
||||
}
|
||||
|
||||
|
@ -799,7 +747,7 @@ static int mms_sendtommsc(MmscGrp *mmc, Octstr *from, Octstr *to, Octstr *transi
|
|||
octstr_destroy(id);
|
||||
ret = MMS_SEND_OK;
|
||||
} else
|
||||
ret = MMS_SEND_ERROR_TRANSIENT; /* don't kill entry, wait a little. */
|
||||
ret = retry ? MMS_SEND_ERROR_TRANSIENT : MMS_SEND_ERROR_FATAL;
|
||||
|
||||
octstr_destroy(groupid);
|
||||
if (id && throughput > 0)
|
||||
|
@ -863,6 +811,7 @@ static int sendMsg(MmsEnvelope *e)
|
|||
to->process = 0;
|
||||
else if (res == MMS_SEND_ERROR_FATAL && mmc)
|
||||
send_report(to->rcpt, "delivery-report",
|
||||
e->url1,
|
||||
(e->expiryt != 0 && e->expiryt < tnow) ?
|
||||
octstr_imm("Expired") : octstr_imm("Rejected"),
|
||||
e->msgId, mmc->id, mmc->group_id);
|
||||
|
@ -883,7 +832,6 @@ static int sendMsg(MmsEnvelope *e)
|
|||
|
||||
}
|
||||
|
||||
if (msg)
|
||||
mms_destroy(msg);
|
||||
|
||||
if (e) { /* Update the queue if it is still valid (e.g. recipients not handled)
|
||||
|
|
Loading…
Reference in New Issue