1
0
Fork 0

VAS GW fixes for DLR

This commit is contained in:
bagyenda 2007-07-27 16:39:19 +00:00
parent f7da8933d8
commit 99318916ea
3 changed files with 95 additions and 144 deletions

View File

@ -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.

View File

@ -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

View File

@ -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,12 +103,11 @@ 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(rb);
octstr_destroy(url);
if (rph)
http_destroy_headers(rph);
http_destroy_headers(rph);
http_destroy_headers(rh);
/* At what point do we delete it? For now, when we get a read report,
@ -191,8 +191,7 @@ 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(linkedid);
octstr_destroy(value);
} else {
error(0, "Failed to convert received MM7/SOAP DeliverReq message from mmc=%s to MMS Message!",
@ -210,13 +209,11 @@ 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);
octstr_destroy(desc);
octstr_destroy(value);
mms_log("DeliveryReport",
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
mresp = mm7_make_resp(mreq, status, NULL,1);
@ -227,11 +224,10 @@ 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);
octstr_destroy(value);
mms_log("ReadReport",
from, NULL, -1, msgid, NULL, h->m->id, "MMSBox", h->ua, NULL);
mresp = mm7_make_resp(mreq, status, NULL,1);
@ -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);
octstr_destroy(from);
octstr_destroy(subject);
octstr_destroy(vasid);
octstr_destroy(msgid);
octstr_destroy(qf);
mms_destroy(m);
http_destroy_headers(rh);
octstr_destroy(reply_body);
mm7_soap_destroy(mresp);
mm7_soap_destroy(mreq);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
}
static void mm7eaif_receive(MmsHTTPClientInfo *h)
@ -330,8 +309,7 @@ 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);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
to = gwlist_create();
for (i = 0, n = gwlist_len(hto); i < n; i++) {
Octstr *h = NULL, *v = NULL;
@ -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,8 +345,7 @@ static void mm7eaif_receive(MmsHTTPClientInfo *h)
dlr = 1;
else
dlr = 0;
if (value)
octstr_destroy(value);
octstr_destroy(value);
if (deliveryt < 0)
deliveryt = time(NULL);
@ -406,23 +383,20 @@ 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);
octstr_destroy(value);
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);
octstr_destroy(value);
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);
http_destroy_headers(hto);
gwlist_destroy(to, (gwlist_item_destructor_t *)octstr_destroy);
octstr_destroy(hfrom);
octstr_destroy(subject);
octstr_destroy(otransid);
octstr_destroy(msgid);
http_destroy_headers(mh);
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);
octstr_destroy(h->ip);
octstr_destroy(h->url);
octstr_destroy(h->ua);
octstr_destroy(h->body);
http_destroy_cgiargs(h->cgivars);
http_destroy_headers(h->headers);
if (freeh) gw_free(h);
if (h->url)
octstr_destroy(h->url);
if (h->ua) octstr_destroy(h->ua);
if (h->body) octstr_destroy(h->body);
if (h->cgivars)
http_destroy_cgiargs(h->cgivars);
if (h->headers)
http_destroy_headers(h->headers);
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,10 +593,12 @@ 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);
http_destroy_headers(rh);
@ -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,19 +678,20 @@ 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);
mms_destroy(mresp);
}
if (hstatus < 0)
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)
octstr_destroy(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,21 +832,20 @@ 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)
* XXX can this happen here??...
*/
e->lasttry = time(NULL);
e->attempts++; /* Update count of number of delivery attempts. */
e->sendt = e->lasttry + mmsbox_send_back_off * e->attempts;
if (mms_queue_update(e) != 1)
mms_queue_free_env(e);
}
return 1; /* always delete queue entry. */
mms_destroy(msg);
if (e) { /* Update the queue if it is still valid (e.g. recipients not handled)
* XXX can this happen here??...
*/
e->lasttry = time(NULL);
e->attempts++; /* Update count of number of delivery attempts. */
e->sendt = e->lasttry + mmsbox_send_back_off * e->attempts;
if (mms_queue_update(e) != 1)
mms_queue_free_env(e);
}
return 1; /* always delete queue entry. */
}
void mmsbox_outgoing_queue_runner(int *rstop)