1
0
Fork 0

added misc logging stuff

master
bagyenda 13 years ago
parent bf5c6e2c6c
commit 20ae441d94

@ -1,3 +1,7 @@
2010-10-19 P. A. Bagyenda <bagyenda@dsmagic.com>
* Added new func to mms_cfg -- make it easier to implement module-based configuration
* Extended mmsbox_cfg load functions to make it easier to configure using modules
* Added alarm callback, event logging.
2010-09-21 P. A. Bagyenda <bagyenda@dsmagic.com>
* Patch to allow compilation under FreeBSD 8.1 (thanks to Piotr Isajew <pki at ex.com.pl>)
2010-08-09 P. A. Bagyenda <bagyenda@dsmagic.com>

@ -123,6 +123,19 @@ static void check_and_add_field(mCfgGrp *grp, Octstr *field, Octstr *value, int
octstr_get_cstr(field), lineno);
}
static mCfg *make_cfg(Octstr *file)
{
mCfg *cfg;
cfg = gw_malloc(sizeof *cfg);
cfg->file = file ? octstr_duplicate(file) : NULL;
cfg->grps = dict_create(7, NULL);
cfg->xcfg = NULL;
cfg->cfg_funcs = NULL;
return cfg;
}
mCfg *mms_cfg_read(Octstr *file)
{
Octstr *sf;
@ -139,12 +152,7 @@ mCfg *mms_cfg_read(Octstr *file)
return NULL;
}
cfg = gw_malloc(sizeof *cfg);
cfg->file = octstr_duplicate(file);
cfg->grps = dict_create(7, NULL);
cfg->xcfg = NULL;
cfg->cfg_funcs = NULL;
cfg = make_cfg(file);
lines = octstr_split(sf, octstr_imm("\n"));
for (i = 0, n = gwlist_len(lines); i < n; i++) {
@ -236,6 +244,26 @@ mCfg *mms_cfg_read(Octstr *file)
return cfg;
}
mCfg *mms_cfg_read2(mCfgImpFuncs *cfgfuncs, Octstr *init)
{
mCfg *cfg;
gw_assert(cfgfuncs);
cfg = make_cfg(NULL);
cfg->cfg_funcs = cfgfuncs;
if (cfg->cfg_funcs->read == NULL ||
(cfg->xcfg = cfg->cfg_funcs->read(init)) == NULL) {
mms_error(0, "mms_cfg", NULL, "Failed to load cfg reader: read failed in cfg_read2!");
mms_cfg_destroy(cfg);
cfg = NULL;
}
return cfg;
}
static void mGrp_destroy(mCfgGrp *grp)
{
octstr_destroy(grp->name);

@ -20,11 +20,14 @@
typedef struct mCfg mCfg; /* config file structure. */
typedef struct mCfgGrp mCfgGrp; /* A config group. */
struct mCfgImpFuncs; /* Defined in mms_cfg-impl.h */
/* Read a config file, return the structure. */
mCfg *mms_cfg_read(Octstr *file);
/* Read conf from a module */
mCfg *mms_cfg_read2(struct mCfgImpFuncs *cfgfuncs, Octstr *init);
/* Destroy it all . */
void mms_cfg_destroy(mCfg *cfg);

@ -755,7 +755,7 @@ int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, MM7Version_t *ver, List **hdrs, Octstr
int mm7_msgtype(MSoapMsg_t *m)
{
Octstr *typ = http_header_value(m->envelope, octstr_imm("MessageType"));
Octstr *typ = m != NULL ? http_header_value(m->envelope, octstr_imm("MessageType")) : NULL;
int ret;
if (!typ)
@ -1011,6 +1011,30 @@ static MSoapMsg_t *mm7_soap_create(int msgtype, Octstr *otransid)
return m;
}
int mm7_msgtype_to_soaptype(int mtype, int isclientside)
{
int t;
switch (mtype) {
case MMS_MSGTYPE_SEND_REQ:
case MMS_MSGTYPE_RETRIEVE_CONF:
t = isclientside ? MM7_TAG_SubmitReq : MM7_TAG_DeliverReq;
break;
case MMS_MSGTYPE_READ_ORIG_IND:
t = MM7_TAG_ReadReplyReq;
break;
case MMS_MSGTYPE_DELIVERY_IND:
t = MM7_TAG_DeliveryReportReq;
break;
case -1:
t = isclientside ? MM7_TAG_RSErrorRsp : MM7_TAG_VASPErrorRsp;
break;
default:
t = 0;
break;
}
return t;
}
MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
Octstr *transid, Octstr *srvcode,
Octstr *linkedid, int isclientside,
@ -1019,33 +1043,47 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
time_t uaprof_tstamp,
List *hdrs)
{
int i, n, mtype = mms_messagetype(msg);
int i, n, mtype = mms_messagetype(msg), mm7type = mm7_msgtype_to_soaptype(mtype, isclientside);
MSoapMsg_t *m = NULL;
Octstr *xfrom = (from != NULL) ? octstr_format("+ %S", from) : NULL, *s;
Octstr *xuaprof_val = (uaprof) ? octstr_format("%S,%ld", uaprof, uaprof_tstamp) : NULL;
int tchanged = 0;
switch(mtype) {
case MMS_MSGTYPE_SEND_REQ:
case MMS_MSGTYPE_RETRIEVE_CONF:
m = mm7_soap_create(isclientside ? MM7_TAG_SubmitReq : MM7_TAG_DeliverReq,
transid);
m->msg = mms_tomime(msg,1);
s = hdrs ? http_header_value(hdrs, octstr_imm("X-Mbuni-MM7-Type")) : NULL;
if (s) { /* Might be Cancel or Replace instead of Send */
mm7type = mms_string_to_mm7tag(s);
gw_assert(mm7type >= 0);
octstr_destroy(s);
tchanged = 1;
}
m = mm7_soap_create(mm7type, transid);
if (mm7type != MM7_TAG_CancelReq) /* No body for cancel */
m->msg = mms_tomime(msg,1);
strip_non_essential_headers(m->msg);
for (i = 0, n = xto ? gwlist_len(xto) : 0; i < n; i++) { /* Add recipients. */
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
http_header_add(m->envelope, "To",
octstr_get_cstr(xx));
octstr_destroy(xx);
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq) /* No recipients for replace and cancel*/
for (i = 0, n = xto ? gwlist_len(xto) : 0; i < n; i++) { /* Add recipients. */
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, i));
http_header_add(m->envelope, "To",
octstr_get_cstr(xx));
octstr_destroy(xx);
}
else if ((s = http_header_value(hdrs, /* For replace and cancel, add message id */
octstr_imm("X-Mbuni-Message-ID"))) != NULL) {
http_header_add(m->envelope, "MessageID", octstr_get_cstr(s));
octstr_destroy(s);
}
if (srvcode)
if (srvcode && mm7type != MM7_TAG_CancelReq)
http_header_add(m->envelope,
isclientside ? "ServiceCode" : "MMSRelayServerID",
octstr_get_cstr(srvcode));
if (linkedid)
if (linkedid && mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "LinkedID", octstr_get_cstr(linkedid));
if (xfrom)
http_header_add(m->envelope,
@ -1062,7 +1100,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
http_header_add(m->envelope, "VASID", vasid);
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Message-Class"))) != NULL) {
http_header_add(m->envelope, "MessageClass", octstr_get_cstr(s));
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "MessageClass", octstr_get_cstr(s));
octstr_destroy(s);
}
@ -1070,26 +1109,28 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Allow-Adaptations"))) != NULL) {
char *val = (octstr_case_compare(s, octstr_imm("true")) == 0) ?
"true" : "false";
http_header_add(m->envelope, "allowAdaptations", val);
if (mm7type != MM7_TAG_CancelReq)
http_header_add(m->envelope, "allowAdaptations", val);
octstr_destroy(s);
}
if (distrib_indicator)
if (distrib_indicator && mm7type != MM7_TAG_CancelReq)
http_header_add(m->envelope, "DistributionIndicator",
octstr_str_case_compare(distrib_indicator, "true") == 0 ? "true" : "false");
if (cparty)
if (cparty && mm7type != MM7_TAG_CancelReq)
http_header_add(m->envelope, "ChargedParty",
octstr_get_cstr(cparty));
octstr_destroy(distrib_indicator);
octstr_destroy(cparty);
} else { /* not clientside. */
if (xuaprof_val) /* only on DeliverReq. */
if (xuaprof_val && mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq) /* only on DeliverReq. */
http_header_add(m->envelope, "UACapabilities", octstr_get_cstr(xuaprof_val));
}
if ((s = mms_get_header_value(msg, octstr_imm("Date"))) != NULL) {
http_header_add(m->envelope, "TimeStamp", octstr_get_cstr(s));
if (mm7type != MM7_TAG_CancelReq)
http_header_add(m->envelope, "TimeStamp", octstr_get_cstr(s));
octstr_destroy(s);
}
@ -1097,36 +1138,41 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
* care about the order of XML fields.
*/
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Expiry"))) != NULL) {
http_header_add(m->envelope, "ExpiryDate", octstr_get_cstr(s));
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "ExpiryDate", octstr_get_cstr(s));
octstr_destroy(s);
}
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Delivery-Report"))) != NULL) {
char *val = (octstr_case_compare(s, octstr_imm("Yes")) == 0) ?
"true" : "false";
http_header_add(m->envelope, "DeliveryReport", val);
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "DeliveryReport", val);
octstr_destroy(s);
}
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Read-Report"))) != NULL) {
char *val = (octstr_case_compare(s, octstr_imm("Yes")) == 0) ?
"true" : "false";
http_header_add(m->envelope, "ReadReply", val);
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "ReadReply", val);
octstr_destroy(s);
}
}
if ((s = mms_get_header_value(msg, octstr_imm("X-Mms-Priority"))) != NULL) {
http_header_add(m->envelope, "Priority", octstr_get_cstr(s));
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "Priority", octstr_get_cstr(s));
octstr_destroy(s);
}
if ((s = mms_get_header_value(msg, octstr_imm("Subject"))) != NULL) {
http_header_add(m->envelope, "Subject", octstr_get_cstr(s));
if (mm7type != MM7_TAG_CancelReq && mm7type != MM7_TAG_ReplaceReq)
http_header_add(m->envelope, "Subject", octstr_get_cstr(s));
octstr_destroy(s);
}
#if 0 /* handled above. */
/* Should we bother to strip message part of headers??? */
headers = mime_entity_headers(m->msg);
@ -1144,9 +1190,7 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
break;
case MMS_MSGTYPE_READ_ORIG_IND:
case MMS_MSGTYPE_DELIVERY_IND:
m = mm7_soap_create((mtype == MMS_MSGTYPE_READ_ORIG_IND) ?
MM7_TAG_ReadReplyReq : MM7_TAG_DeliveryReportReq,
transid);
m = mm7_soap_create(mm7type, transid);
if (xfrom)
http_header_add(m->envelope, "Sender", octstr_get_cstr(xfrom));
@ -1188,10 +1232,37 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
break;
}
if (m) { /* Add custom headers, hope caller knows what they are doing */
List *l = http_header_find_all(hdrs, "X-Mbuni-MM7-Headers");
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name = NULL, *value = NULL;
int j;
http_header_get(l, i, &name, &value);
if (value && (j = octstr_search_char(value, ':', 0)) > 0) {
Octstr *h = octstr_copy(value, 0, j - 1);
Octstr *v = octstr_copy(value, j+1, octstr_len(value));
octstr_strip_blanks(h);
octstr_strip_blanks(v);
http_header_add(m->envelope, octstr_get_cstr(h), octstr_get_cstr(v));
octstr_destroy(h);
octstr_destroy(v);
}
octstr_destroy(name);
octstr_destroy(value);
}
http_destroy_headers(l);
}
octstr_destroy(xfrom);
octstr_destroy(xuaprof_val);
return m;
}

@ -39,6 +39,9 @@ typedef struct MM7Version_t {
/* Parse SOAP message given http headers and body. */
extern MSoapMsg_t *mm7_parse_soap(List *headers, Octstr *body);
/* Convert message type to mm7 type code */
extern int mm7_msgtype_to_soaptype(int mtype, int isclientside);
/* Convert SOAP message to http headers and body. */
extern int mm7_soapmsg_to_httpmsg(MSoapMsg_t *m, MM7Version_t *ver, List **hdrs, Octstr **body);

@ -1955,7 +1955,7 @@ MmsMsg *mms_deleteconf(int menc, char *transid)
return m;
}
static int mms_msgsize(MmsMsg *m)
int mms_msgsize(MmsMsg *m)
{
Octstr *s;
int n;

@ -130,4 +130,7 @@ int mms_putbody(MmsMsg *msg, void *body, int ismultipart);
* returns 0 on success.
*/
int mms_make_sendreq(MmsMsg *retrieveconf);
/* Compute message size -- not altogether efficiently */
int mms_msgsize(MmsMsg *m);
#endif

@ -1171,77 +1171,80 @@ void mms_collect_envdata_from_msgheaders(List *mh, List **xto,
{
Octstr *s;
List *l = http_header_find_all(mh, "To");
if (l) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
}
l = http_header_find_all(mh, "Cc");
if (l) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
}
l = http_header_find_all(mh, "Bcc");
if (l) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
List *l;
if (xto) {
l = http_header_find_all(mh, "To");
if (l != NULL) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
}
l = http_header_find_all(mh, "Cc");
if (l) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
}
l = http_header_find_all(mh, "Bcc");
if (l) {
int i, n;
for (i = 0, n = gwlist_len(l); i<n; i++) {
Octstr *name, *value;
http_header_get(l, i, &name, &value);
_mms_fixup_address(&value, unified_prefix, strip_prefixes, 1);
gwlist_append(*xto, value);
octstr_destroy(name);
}
http_destroy_headers(l);
}
}
/* Find expiry and delivery times */
if (expiryt) {
s = http_header_value(mh, octstr_imm("X-Mms-Expiry"));
if (s) {
*expiryt = date_parse_http(s);
octstr_destroy(s);
} else
*expiryt = time(NULL) + default_msgexpiry;
if (max_msgexpiry > 0
&& (*expiryt - time(NULL)) > max_msgexpiry)
*expiryt = time(NULL) + max_msgexpiry;
s = http_header_value(mh, octstr_imm("X-Mms-Expiry"));
if (s) {
*expiryt = date_parse_http(s);
octstr_destroy(s);
} else
*expiryt = time(NULL) + default_msgexpiry;
if (max_msgexpiry > 0
&& (*expiryt - time(NULL)) > max_msgexpiry)
*expiryt = time(NULL) + max_msgexpiry;
}
if (deliveryt) {
s = http_header_value(mh, octstr_imm("X-Mms-Delivery-Time"));
if (s) {
*deliveryt = date_parse_http(s);
octstr_destroy(s);
} else
*deliveryt = 0;
s = http_header_value(mh, octstr_imm("X-Mms-Delivery-Time"));
if (s) {
*deliveryt = date_parse_http(s);
octstr_destroy(s);
} else
*deliveryt = 0;
}
if (subject)
*subject = http_header_value(mh, octstr_imm("Subject"));
*subject = http_header_value(mh, octstr_imm("Subject"));
if (otransid)
*otransid = http_header_value(mh, octstr_imm("X-Mms-Transaction-ID"));
*otransid = http_header_value(mh, octstr_imm("X-Mms-Transaction-ID"));
}
unsigned long _mshash(char *s)
@ -2155,41 +2158,41 @@ MIMEEntity *multipart_from_urls(List *url_list)
http_header_add(rh, "User-Agent", MM_NAME "/" VERSION);
for (i = 0, n = gwlist_len(url_list); i<n; i++) {
List *rph = NULL;
Octstr *rbody = NULL;
Octstr *url = gwlist_get(url_list, i);
if (mms_url_fetch_content(HTTP_METHOD_GET,
url, rh, NULL, &rph, &rbody) == HTTP_OK) {
List *mh = http_create_empty_headers();
Octstr *x;
MIMEEntity *mx;
if ((x = http_header_value(rph, octstr_imm("Content-Type"))) != NULL) {
http_header_add(mh, "Content-Type", octstr_get_cstr(x));
octstr_destroy(x);
} else
http_header_add(mh, "Content-Type", "application/content-stream");
if ((x = http_header_value(rph, octstr_imm("Content-ID"))) != NULL) {
http_header_add(mh, "Content-ID", octstr_get_cstr(x));
octstr_destroy(x);
}
if ((x = http_header_value(rph, octstr_imm("Content-Location"))) != NULL) {
http_header_add(mh, "Content-Location", octstr_get_cstr(x));
octstr_destroy(x);
}
mx = mime_http_to_entity(mh, rbody);
mime_entity_add_part(m, mx);
http_destroy_headers(mh);
mime_entity_destroy(mx);
} else
mms_error(0, "multipart_from_urls", NULL, "Failed to load URL content for URL [%s]",
octstr_get_cstr(url));
octstr_destroy(rbody);
http_destroy_headers(rph);
List *rph = NULL;
Octstr *rbody = NULL;
Octstr *url = gwlist_get(url_list, i);
if (mms_url_fetch_content(HTTP_METHOD_GET,
url, rh, NULL, &rph, &rbody) == HTTP_OK) {
List *mh = http_create_empty_headers();
Octstr *x;
MIMEEntity *mx;
if ((x = http_header_value(rph, octstr_imm("Content-Type"))) != NULL) {
http_header_add(mh, "Content-Type", octstr_get_cstr(x));
octstr_destroy(x);
} else
http_header_add(mh, "Content-Type", "application/content-stream");
if ((x = http_header_value(rph, octstr_imm("Content-ID"))) != NULL) {
http_header_add(mh, "Content-ID", octstr_get_cstr(x));
octstr_destroy(x);
}
if ((x = http_header_value(rph, octstr_imm("Content-Location"))) != NULL) {
http_header_add(mh, "Content-Location", octstr_get_cstr(x));
octstr_destroy(x);
}
mx = mime_http_to_entity(mh, rbody);
mime_entity_add_part(m, mx);
http_destroy_headers(mh);
mime_entity_destroy(mx);
} else
mms_error(0, "multipart_from_urls", NULL, "Failed to load URL content for URL [%s]",
octstr_get_cstr(url));
octstr_destroy(rbody);
http_destroy_headers(rph);
}
http_destroy_headers(rh);

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