Improved MM7/SOAP schema handling
This commit is contained in:
parent
c49a4bbe57
commit
65c185e3eb
|
@ -1,3 +1,5 @@
|
|||
2007-04-12 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Improved MM7/SOAP message composition: better handling of different schema versions
|
||||
2007-04-10 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
* Added outgoing Digest/MD5 HTTP authentication support (thanks to Gert Horne <gert@bluetin.co.za> for funding)
|
||||
2007-04-10 P. A. Bagyenda <bagyenda@dsmagic.com>
|
||||
|
|
|
@ -360,6 +360,13 @@ static void output_rcpt(char *hdr, List *hdrs, Octstr *p)
|
|||
http_destroy_headers(l);
|
||||
}
|
||||
|
||||
/* compare two mm7 version xmlns strings. Crude, but should generally work. */
|
||||
static int ver_compare(MM7Version_t *v1, MM7Version_t *v2)
|
||||
{
|
||||
return (v1->major-v2->major)*1000 + (v1->minor1-v2->minor1)*100 + (v1->minor2-v2->minor2);
|
||||
}
|
||||
|
||||
|
||||
#define XMLNSMM7 "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-%d-MM7-%d-%d"
|
||||
#define SOAP_ENV "SOAP-ENV"
|
||||
|
||||
|
@ -367,12 +374,12 @@ static void output_rcpt(char *hdr, List *hdrs, Octstr *p)
|
|||
static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver)
|
||||
{
|
||||
Octstr *s = octstr_create("<?xml version='1.0' encoding='UTF-8'?>\n");
|
||||
Octstr *xmlns = octstr_format(XMLNSMM7, ver->major, ver->minor1, ver->minor2);
|
||||
|
||||
Octstr *xmlns = octstr_format(XMLNSMM7, ver->major, ver->minor1, ver->minor2);
|
||||
Octstr *p, *q, *r, *fault, *mtype;
|
||||
int i, n;
|
||||
int i, n, mtag;
|
||||
time_t t;
|
||||
int mtag;
|
||||
|
||||
MM7Version_t min_ver = {5,1,0}; /* minimum version we deal with. */
|
||||
|
||||
octstr_append_cstr(s,
|
||||
"<" SOAP_ENV ":Envelope xmlns:" SOAP_ENV "=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
|
||||
|
@ -431,8 +438,13 @@ static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver)
|
|||
|
||||
if (r) {
|
||||
Octstr *xx = octstr_create("");
|
||||
append_address(xx, r);
|
||||
octstr_format_append(s, "<mm7:SenderAddress>%S</mm7:SenderAddress>\n", xx);
|
||||
if (ver_compare(ver,&min_ver) > 0)
|
||||
append_address(xx, r);
|
||||
else if (octstr_get_char(r, 0) != '-') /* not display only. */
|
||||
octstr_format_append(xx, "%s", octstr_get_cstr(r) + 1);
|
||||
|
||||
if (octstr_len(xx) > 0)
|
||||
octstr_format_append(s, "<mm7:SenderAddress>%S</mm7:SenderAddress>\n", xx);
|
||||
octstr_destroy(xx);
|
||||
}
|
||||
|
||||
|
@ -494,8 +506,13 @@ static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver)
|
|||
break;
|
||||
case MM7_TAG_Sender:
|
||||
p = octstr_create("");
|
||||
append_address(p, v);
|
||||
octstr_format_append(s, "<mm7:Sender>%S</mm7:Sender>\n", p);
|
||||
if (ver_compare(ver,&min_ver) > 0)
|
||||
append_address(p, v);
|
||||
else if (octstr_get_char(v, 0) != '-') /* not display only. */
|
||||
octstr_format_append(p, "%s", octstr_get_cstr(v) + 1);
|
||||
|
||||
if (octstr_len(p) > 0)
|
||||
octstr_format_append(s, "<mm7:Sender>%S</mm7:Sender>\n", p);
|
||||
octstr_destroy(p);
|
||||
skip = 1;
|
||||
break;
|
||||
|
@ -900,18 +917,14 @@ static MSoapMsg_t *mm7_soap_create(int msgtype, Octstr *otransid)
|
|||
|
||||
MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
||||
Octstr *transid, Octstr *srvcode,
|
||||
Octstr *linkedid,
|
||||
int isclientside,
|
||||
Octstr *linkedid, int isclientside,
|
||||
char *vaspid, char *vasid)
|
||||
{
|
||||
int mtype = mms_messagetype(msg);
|
||||
int i, n, mtype = mms_messagetype(msg);
|
||||
MSoapMsg_t *m = NULL;
|
||||
Octstr *s;
|
||||
int i, n;
|
||||
Octstr *xfrom;
|
||||
List *headers;
|
||||
Octstr *xfrom = (from != NULL) ? octstr_format("+ %S", from) : NULL, *s;
|
||||
|
||||
xfrom = octstr_format("+ %S", from ? from : octstr_imm("anon@anon"));
|
||||
switch(mtype) {
|
||||
case MMS_MSGTYPE_SEND_REQ:
|
||||
case MMS_MSGTYPE_RETRIEVE_CONF:
|
||||
|
@ -933,9 +946,10 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
|||
|
||||
if (linkedid)
|
||||
http_header_add(m->envelope, "LinkedID", octstr_get_cstr(linkedid));
|
||||
http_header_add(m->envelope,
|
||||
isclientside ? "SenderAddress" : "Sender",
|
||||
octstr_get_cstr(xfrom));
|
||||
if (xfrom)
|
||||
http_header_add(m->envelope,
|
||||
isclientside ? "SenderAddress" : "Sender",
|
||||
octstr_get_cstr(xfrom));
|
||||
|
||||
if ((s = mms_get_header_value(msg, octstr_imm("Date"))) != NULL) {
|
||||
http_header_add(m->envelope, "TimeStamp", octstr_get_cstr(s));
|
||||
|
@ -1011,7 +1025,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
|||
MM7_TAG_ReadReplyReq : MM7_TAG_DeliveryReportReq,
|
||||
transid);
|
||||
|
||||
http_header_add(m->envelope, "Sender", octstr_get_cstr(xfrom));
|
||||
if (xfrom)
|
||||
http_header_add(m->envelope, "Sender", octstr_get_cstr(xfrom));
|
||||
|
||||
if (xto && gwlist_len(xto) > 0) {
|
||||
Octstr *xx = octstr_format("+ %S", gwlist_get(xto, 0));
|
||||
|
@ -1045,7 +1060,8 @@ MSoapMsg_t *mm7_mmsmsg_to_soap(MmsMsg *msg, Octstr *from, List *xto,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
octstr_destroy(xfrom);
|
||||
if (xfrom)
|
||||
octstr_destroy(xfrom);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
|
|
@ -368,8 +368,8 @@ void unpack_mimeheaders(MIMEEntity *mm)
|
|||
if (l) gwlist_destroy(l, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
|
||||
loop:
|
||||
if (header) octstr_destroy(header);
|
||||
if (value) octstr_destroy(value);
|
||||
octstr_destroy(header);
|
||||
octstr_destroy(value);
|
||||
}
|
||||
|
||||
mime_replace_headers(mm, h);
|
||||
|
@ -408,10 +408,8 @@ void unbase64_mimeparts(MIMEEntity *m)
|
|||
|
||||
/* XXX may be we should deal with other transfer encodings here as well... */
|
||||
|
||||
if (ctype)
|
||||
octstr_destroy(ctype);
|
||||
if (te)
|
||||
octstr_destroy(te);
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(te);
|
||||
http_destroy_headers(headers);
|
||||
}
|
||||
}
|
||||
|
@ -447,10 +445,8 @@ void base64_mimeparts(MIMEEntity *m)
|
|||
mime_entity_set_body(m, body);
|
||||
mime_replace_headers(m, headers);
|
||||
}
|
||||
if (ctype)
|
||||
octstr_destroy(ctype);
|
||||
if (te)
|
||||
octstr_destroy(te);
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(te);
|
||||
octstr_destroy(body);
|
||||
http_destroy_headers(headers);
|
||||
}
|
||||
|
@ -507,8 +503,8 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
|
|||
addmmscname(value, myhostname);
|
||||
http_header_add(l, "To", octstr_get_cstr(value));
|
||||
loop:
|
||||
if (value) octstr_destroy(value);
|
||||
if (name) octstr_destroy(name);
|
||||
octstr_destroy(value);
|
||||
octstr_destroy(name);
|
||||
}
|
||||
|
||||
http_destroy_headers(lto);
|
||||
|
@ -526,8 +522,8 @@ static int send2email(Octstr *to, Octstr *from, Octstr *subject,
|
|||
addmmscname(value, myhostname);
|
||||
http_header_add(l, "Cc", octstr_get_cstr(value));
|
||||
loop2:
|
||||
if (value) octstr_destroy(value);
|
||||
if (name) octstr_destroy(name);
|
||||
octstr_destroy(value);
|
||||
octstr_destroy(name);
|
||||
}
|
||||
|
||||
http_destroy_headers(lcc);
|
||||
|
@ -1104,11 +1100,9 @@ int parse_cgivars(List *request_headers, Octstr *request_body,
|
|||
}
|
||||
octstr_destroy(name);
|
||||
}
|
||||
if (ct)
|
||||
octstr_destroy(ct);
|
||||
|
||||
if (cd)
|
||||
octstr_destroy(cd);
|
||||
|
||||
octstr_destroy(ct);
|
||||
octstr_destroy(cd);
|
||||
octstr_destroy(body);
|
||||
http_destroy_headers(headers);
|
||||
mime_entity_destroy(mp);
|
||||
|
@ -1118,10 +1112,8 @@ int parse_cgivars(List *request_headers, Octstr *request_body,
|
|||
} else /* else it is nothing that we know about, so simply go away... */
|
||||
ret = -1;
|
||||
done:
|
||||
if (ctype)
|
||||
octstr_destroy(ctype);
|
||||
if (charset)
|
||||
octstr_destroy(charset);
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(charset);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1149,14 +1141,12 @@ void strip_boundary_element(List *headers, char *s)
|
|||
gw_assert(headers);
|
||||
|
||||
if ((n = get_content_type(headers, &ctype, ¶ms)) < 0) {
|
||||
if (ctype)
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(ctype);
|
||||
ctype = NULL; /* no ctype found, so do not replace it! */
|
||||
}
|
||||
|
||||
if (s) {/* we are replacing the content type as well as stripping */
|
||||
if (ctype)
|
||||
octstr_destroy(ctype);
|
||||
octstr_destroy(ctype);
|
||||
ctype = octstr_create(s);
|
||||
}
|
||||
|
||||
|
@ -1177,10 +1167,9 @@ void strip_boundary_element(List *headers, char *s)
|
|||
http_header_remove_all(headers, "Content-Type");
|
||||
http_header_add(headers, "Content-Type", octstr_get_cstr(value));
|
||||
}
|
||||
if (ctype != value && ctype != NULL)
|
||||
if (ctype != value)
|
||||
octstr_destroy(ctype);
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
octstr_destroy(value);
|
||||
}
|
||||
|
||||
static int fetch_url_with_auth(HTTPCaller *c, int method, Octstr *url, List *request_headers,
|
||||
|
@ -1233,8 +1222,7 @@ int mms_url_fetch_content(int method, Octstr *url, List *request_headers,
|
|||
octstr_destroy(h);
|
||||
}
|
||||
|
||||
if (n)
|
||||
octstr_destroy(n);
|
||||
octstr_destroy(n);
|
||||
|
||||
*reply_body = data;
|
||||
*reply_headers = http_create_empty_headers();
|
||||
|
@ -1257,8 +1245,8 @@ int mms_url_fetch_content(int method, Octstr *url, List *request_headers,
|
|||
}
|
||||
http_caller_destroy(c);
|
||||
}
|
||||
if (furl)
|
||||
octstr_destroy(furl);
|
||||
|
||||
octstr_destroy(furl);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -1453,25 +1441,17 @@ static int fetch_url_with_auth(HTTPCaller *c, int method, Octstr *url, List *req
|
|||
#endif
|
||||
done:
|
||||
octstr_destroy(xauth_value);
|
||||
if (realm)
|
||||
octstr_destroy(realm);
|
||||
if (domain)
|
||||
octstr_destroy(domain);
|
||||
if (nonce)
|
||||
octstr_destroy(nonce);
|
||||
if (opaque)
|
||||
octstr_destroy(opaque);
|
||||
if (algo)
|
||||
octstr_destroy(algo);
|
||||
if (xurl)
|
||||
octstr_destroy(xurl);
|
||||
if (qop)
|
||||
gwlist_destroy(qop, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
|
||||
octstr_destroy(realm);
|
||||
octstr_destroy(domain);
|
||||
octstr_destroy(nonce);
|
||||
octstr_destroy(opaque);
|
||||
octstr_destroy(algo);
|
||||
octstr_destroy(xurl);
|
||||
octstr_destroy(cnonce);
|
||||
gwlist_destroy(qop, (gwlist_item_destructor_t *)octstr_destroy);
|
||||
if (h)
|
||||
http_urlparse_destroy(h);
|
||||
if (cnonce)
|
||||
octstr_destroy(cnonce);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
mreq ? (char *)msgtype : "Null");
|
||||
|
||||
if (!mreq) {
|
||||
mresp = mm7_make_resp(NULL, MM7_SOAP_FORMAT_CORRUPT, NULL,1);
|
||||
mresp = mm7_make_resp(NULL, MM7_SOAP_FORMAT_CORRUPT, NULL,1);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -191,8 +191,11 @@ static void mm7soap_receive(MmsHTTPClientInfo *h)
|
|||
if (linkedid)
|
||||
octstr_destroy(linkedid);
|
||||
octstr_destroy(value);
|
||||
} else
|
||||
} else {
|
||||
error(0, "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);
|
||||
break;
|
||||
|
||||
|
|
|
@ -1645,8 +1645,11 @@ static void mm7soap_dispatch(MmsHTTPClientInfo *h)
|
|||
h->ua, NULL);
|
||||
if (value)
|
||||
octstr_destroy(value);
|
||||
} else
|
||||
} else {
|
||||
error(0, "Failed to convert received MM7/SOAP SubmitReq message from vasp=%s to MMS Message!",
|
||||
octstr_get_cstr(h->vasp->id));
|
||||
status = 4004;
|
||||
}
|
||||
mresp = mm7_make_resp(mreq, status, msgid,0);
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in New Issue