From eef6e9b967f2c62873cd44e0fb6ef7e9f19105e4 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Thu, 21 Jun 2007 12:56:29 +0000 Subject: [PATCH] better mm7 namespace handling --- mbuni/ChangeLog | 2 ++ mbuni/doc/userguide.shtml | 38 +++++++++++++++++++++++++++++++++----- mbuni/mmlib/mms_cfg.def | 2 ++ mbuni/mmlib/mms_mm7soap.c | 7 ++++--- mbuni/mmlib/mms_mm7soap.h | 7 ++++++- mbuni/mmlib/mms_util.c | 8 ++++++-- mbuni/mmlib/mms_util.h | 8 +++++++- mbuni/mmsbox/mmsbox_cfg.c | 16 ++++++++++++---- mbuni/mmsc/mmsc_cfg.c | 14 +++++++++++--- 9 files changed, 83 insertions(+), 19 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 8c1f042..ed2b1db 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2007-06-21 P. A. Bagyenda + * Better configurability of MM7/SOAP namespace URI and MM7 version. 2007-06-12 P. A. Bagyenda * Improved DLR reporting over MM4 interface - set receipient as from address 2007-05-08 P. A. Bagyenda diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 0b5f71d..3d68d4a 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -1697,13 +1697,27 @@ vasp-url String - Optional. The MM7 version to use on this interface. (defaults are "5.1.0" for + Optional. The MM7 version to use on this interface. (defaults are "5.3.0" for XML/SOAP, "3.0" for EAIF.) For SOAP, this is - used primarily to build the XML Namespace URL. For EAIF it is + used as the value for the MM7Version XML node. For EAIF it is reported in the HTTP headers. + + + mm7-soap-xmlns + + + String + + + Optional. The namespace URI for the "mm7:" XML + namespace. Only valid for MM7/SOAP, and is used in the SOAP message + to identify the namespace for all MM7/SOAP specific elements. Default value is http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0 + + + @@ -2030,13 +2044,27 @@ Supported configuration parameters are: String - Optional. The MM7 version to use on this interface. (defaults are "5.1.0" for - XML/SOAP, "3.0" for EAIF.) For SOAP, this is - used primarily to build the XML Namespace URL. For EAIF it is + Optional. The MM7 version to use on this interface. (defaults are "5.3.0" for + MM7/SOAP, "3.0" for EAIF.) For SOAP, this is + used in the MM7Version tag. For EAIF it is reported in the HTTP headers. + + + mm7-soap-xmlns + + + String + + + Optional. The namespace URI for the "mm7:" XML + namespace. Only valid for MM7/SOAP, and is used in the SOAP message + to identify the namespace for all MM7/SOAP specific elements. Default value is http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0 + + + mmsc-url diff --git a/mbuni/mmlib/mms_cfg.def b/mbuni/mmlib/mms_cfg.def index fe678d4..e2b57e1 100644 --- a/mbuni/mmlib/mms_cfg.def +++ b/mbuni/mmlib/mms_cfg.def @@ -98,6 +98,7 @@ MULTI_GROUP(mms-vasp, OCTSTR(vasp-id) OCTSTR(type) OCTSTR(mm7-version) + OCTSTR(mm7-soap-xmlns) OCTSTR(short-code) OCTSTR(vasp-username) OCTSTR(vasp-password) @@ -129,6 +130,7 @@ MULTI_GROUP(mmsc, OCTSTR(max-throughput) OCTSTR(type) OCTSTR(mm7-version) + OCTSTR(mm7-soap-xmlns) ) MULTI_GROUP(mms-service, diff --git a/mbuni/mmlib/mms_mm7soap.c b/mbuni/mmlib/mms_mm7soap.c index c27a01d..e0d0877 100644 --- a/mbuni/mmlib/mms_mm7soap.c +++ b/mbuni/mmlib/mms_mm7soap.c @@ -393,14 +393,14 @@ static int ver_compare(MM7Version_t *v1, MM7Version_t *v2) } -#define XMLNSMM7 "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-%d-MM7-%d-%d" +#define XMLNSMM7 "http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL-5-MM7-1-0" #define SOAP_ENV "SOAP-ENV" /* Construct by hand. */ static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver) { Octstr *s = octstr_create("\n"); - Octstr *xmlns = octstr_format(XMLNSMM7, ver->major, ver->minor1, ver->minor2); + Octstr *xmlns = octstr_create((ver->xmlns[0]) ? ver->xmlns : XMLNSMM7); Octstr *p, *q, *r, *fault, *mtype; int i, n, mtag; time_t t; @@ -448,7 +448,8 @@ static Octstr *headers_to_soapxml(List *hdrs, MM7Version_t *ver) octstr_format_append(s, "%S\n", p); octstr_destroy(p); } else - octstr_format_append(s, "%s\n", MM7_VERSION); + octstr_format_append(s, "%d.%d.%d\n", + ver->major, ver->minor1, ver->minor2); p = http_header_value(hdrs, octstr_imm("VASPID")); q = http_header_value(hdrs, octstr_imm("VASID")); diff --git a/mbuni/mmlib/mms_mm7soap.h b/mbuni/mmlib/mms_mm7soap.h index 38cb33d..3073d02 100644 --- a/mbuni/mmlib/mms_mm7soap.h +++ b/mbuni/mmlib/mms_mm7soap.h @@ -19,14 +19,19 @@ #define MM7_SOAP_COMMAND_REJECTED 3005 #define MM7_SOAP_UNSUPPORTED_OPERATION 4003 #define MM7_SOAP_STATUS_OK(e) ((e) / 1000 == 1) -#define MM7_DEFAULT_VERSION MMS_3GPP_VERSION +#if 0 +#define MM7_DEFAULT_VERSION MMS_3GPP_VERSION #define MM7_VERSION "5.3.0" +#endif + +#define DEFAULT_MM7_VERSION MAKE_VERSION(5,3,0) typedef struct MSoapMsg_t MSoapMsg_t; typedef struct MM7Version_t { int major, minor1, minor2; /* e.g. 5.1.0. */ + char xmlns[128]; } MM7Version_t; /* Parse SOAP message given http headers and body. */ diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index a9f1978..af73943 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -695,11 +695,15 @@ int mms_sendtoemail(Octstr *from, Octstr *to, http_header_add(newhdrs, "Message-ID", msgid ? octstr_get_cstr(msgid) : ""); http_header_add(newhdrs, "MIME-Version", "1.0"); } else { - char *x; + char *x, tmp[32]; Octstr *xsender = octstr_format("system-user@%S", myhostname); http_header_add(newhdrs, "X-Mms-Message-ID", msgid ? octstr_get_cstr(msgid) : ""); - http_header_add(newhdrs, "X-Mms-3GPP-MMS-Version", MMS_3GPP_VERSION); + sprintf(tmp, "%d.%d.%d", + MAJOR_VERSION(MMS_3GPP_VERSION), + MINOR1_VERSION(MMS_3GPP_VERSION), + MINOR2_VERSION(MMS_3GPP_VERSION)); + http_header_add(newhdrs, "X-Mms-3GPP-MMS-Version", tmp); http_header_add(newhdrs, "X-Mms-Originator-System", octstr_get_cstr(xsender)); http_header_remove_all(headers, "X-Mms-Message-Type"); diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h index 165da91..81bfafb 100644 --- a/mbuni/mmlib/mms_util.h +++ b/mbuni/mmlib/mms_util.h @@ -24,7 +24,13 @@ #include "mms_mmbox.h" /* supported 3GPP MMS version */ -#define MMS_3GPP_VERSION "5.5.0" +#define MAKE_VERSION(a,b,c) ((a)<<16 | (b)<<8 | (c)) + +#define MAJOR_VERSION(v) (((v)>>16)&0xF) +#define MINOR1_VERSION(v) (((v)>>8)&0xF) +#define MINOR2_VERSION(v) ((v)&0xF) + +#define MMS_3GPP_VERSION MAKE_VERSION(5,5,0) /* Send errors */ #define MMS_SEND_OK 0 diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index 8935308..f99baf7 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -142,6 +142,7 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) int ssl = 0; Octstr *type; Octstr *xver; + Octstr *s; memset(m, 0, sizeof *m); @@ -188,16 +189,23 @@ int mms_load_mmsbox_settings(mCfg *cfg, gwthread_func_t *mmsc_handler_func) "%d.%d.%d", &m->ver.major, &m->ver.minor1, &m->ver.minor2); else { /* Put in some defaults. */ - if (m->type == SOAP_MMSC) { - m->ver.major = 5; - m->ver.minor1 = 1; - m->ver.minor2 = 2; + if (m->type == SOAP_MMSC) { + m->ver.major = MAJOR_VERSION(DEFAULT_MM7_VERSION); + m->ver.minor1 = MINOR1_VERSION(DEFAULT_MM7_VERSION); + m->ver.minor2 = MINOR2_VERSION(DEFAULT_MM7_VERSION); } else if (m->type == EAIF_MMSC) { m->ver.major = 3; m->ver.minor1 = 0; } } + if ((s = mms_cfg_get(x, octstr_imm("mm7-soap-xmlns"))) != NULL) { + strncpy(m->ver.xmlns, octstr_get_cstr(s), sizeof m->ver.xmlns); + m->ver.xmlns[-1 + sizeof m->ver.xmlns] = 0; /* NULL terminate, just in case. */ + octstr_destroy(s); + } else + m->ver.xmlns[0] = 0; + octstr_destroy(xver); octstr_destroy(type); diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c index 1818832..7da9895 100644 --- a/mbuni/mmsc/mmsc_cfg.c +++ b/mbuni/mmsc/mmsc_cfg.c @@ -314,9 +314,9 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) sscanf(octstr_get_cstr(s), "%d.%d.%d", &mv->ver.major, &mv->ver.minor1, &mv->ver.minor2); else { if (mv->type == SOAP_VASP) { - mv->ver.major = 5; - mv->ver.minor1 = 1; - mv->ver.minor2 = 2; + mv->ver.major = MAJOR_VERSION(DEFAULT_MM7_VERSION); + mv->ver.minor1 = MINOR1_VERSION(DEFAULT_MM7_VERSION); + mv->ver.minor2 = MINOR2_VERSION(DEFAULT_MM7_VERSION); } else if (mv->type == EAIF_VASP) { mv->ver.major = 3; mv->ver.minor1 = 0; @@ -324,6 +324,14 @@ MmscSettings *mms_load_mmsc_settings(mCfg *cfg, List **proxyrelays) } octstr_destroy(s); + if ((s = mms_cfg_get(grp, octstr_imm("mm7-soap-xmlns"))) != NULL) { + strncpy(mv->ver.xmlns, octstr_get_cstr(s), sizeof mv->ver.xmlns); + + mv->ver.xmlns[-1 + sizeof mv->ver.xmlns] = 0; /* NULL terminate, just in case. */ + octstr_destroy(s); + } else + mv->ver.xmlns[0] = 0; + /* Set the handler vasp accounts. */ if (mms_cfg_get_bool(grp, octstr_imm("mms-to-email-handler"), &ibool) == 0 && ibool) {