From 6b472bf22b3bf8e25427a481a89b2d3ea11604b8 Mon Sep 17 00:00:00 2001 From: bagyenda <> Date: Tue, 13 May 2008 10:53:01 +0000 Subject: [PATCH] MM4 number normalisation --- mbuni/ChangeLog | 2 ++ mbuni/doc/userguide.shtml | 41 ++++++++++++++++++++++++++++++++++++ mbuni/mmlib/mms_cfg.def | 2 ++ mbuni/mmsc/mmsc_cfg.c | 10 ++++++++- mbuni/mmsc/mmsc_cfg.h | 4 ++++ mbuni/mmsc/mmsglobalsender.c | 14 +++++++++++- 6 files changed, 71 insertions(+), 2 deletions(-) diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 81185fd..00c84e1 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,3 +1,5 @@ +2008-05-13 P. A. Bagyenda + * Separate number normalisation for each MM4 connection. 2008-05-05 P. A. Bagyenda * Normalisation of numbers inside messages as well * Added strip-prefixes config parameter diff --git a/mbuni/doc/userguide.shtml b/mbuni/doc/userguide.shtml index 956254e..436e654 100644 --- a/mbuni/doc/userguide.shtml +++ b/mbuni/doc/userguide.shtml @@ -2070,6 +2070,47 @@ denied-prefix + + + + strip-prefixes + +     + + + + Number list +     + + A semi-colon (;) separated string of prefixes that should (if + found) be stripped of the phone number prior to number + normalisation and message sending, as described below. Only the first prefix that matches + will be stripped. +     + + + + + unified-prefix + +     + + + + Number list +     + + A string to + unify received phone numbers, so that routing works correctly. Format is that + first comes the unified prefix, + then all prefixes which are replaced by the unified prefix, separated with + comma (','). For example "+256,000256,0;+,000" should + ensure correct UG prefixes. If + there are several unified prefixes, separate their rules with semicolon (';') +     + + +

diff --git a/mbuni/mmlib/mms_cfg.def b/mbuni/mmlib/mms_cfg.def index 1305cfb..ba6bb60 100644 --- a/mbuni/mmlib/mms_cfg.def +++ b/mbuni/mmlib/mms_cfg.def @@ -98,6 +98,8 @@ MULTI_GROUP(mmsproxy, OCTSTR(allowed-prefix) OCTSTR(denied-prefix) OCTSTR(confirmed-delivery) + OCTSTR(unified-prefix) + OCTSTR(strip-prefixes) ) MULTI_GROUP(mms-vasp, diff --git a/mbuni/mmsc/mmsc_cfg.c b/mbuni/mmsc/mmsc_cfg.c index 52c26e3..fd011e7 100644 --- a/mbuni/mmsc/mmsc_cfg.c +++ b/mbuni/mmsc/mmsc_cfg.c @@ -356,7 +356,8 @@ List *mms_proxy_relays(mCfg *cfg, Octstr *myhostname) for (i = 0, n = gwlist_len(gl); i < n; i++) { mCfgGrp *grp = gwlist_get(gl, i); MmsProxyRelay *m = gw_malloc(sizeof *m); - + Octstr *s; + m->host = _mms_cfg_getx(grp, octstr_imm("host")); m->name = _mms_cfg_getx(grp, octstr_imm("name")); m->allowed_prefix = _mms_cfg_getx(grp, octstr_imm("allowed-prefix")); @@ -364,6 +365,13 @@ List *mms_proxy_relays(mCfg *cfg, Octstr *myhostname) if (mms_cfg_get_bool(grp, octstr_imm("confirmed-delivery"), &m->confirmed_mm4) < 0) m->confirmed_mm4 = 1; + m->unified_prefix = mms_cfg_get(grp, octstr_imm("unified-prefix")); + if ((s = mms_cfg_get(grp, octstr_imm("strip-prefixes"))) != NULL) { + m->strip_prefixes = octstr_split(s, octstr_imm(";")); + octstr_destroy(s); + } else + m->strip_prefixes = NULL; + if (octstr_compare(m->host, myhostname) == 0) warning(0, "MMSC Config: Found MM4 Proxy %s with same hostname as local host!", octstr_get_cstr(m->name)); diff --git a/mbuni/mmsc/mmsc_cfg.h b/mbuni/mmsc/mmsc_cfg.h index 3d9cb94..063fc3c 100644 --- a/mbuni/mmsc/mmsc_cfg.h +++ b/mbuni/mmsc/mmsc_cfg.h @@ -23,6 +23,10 @@ typedef struct MmsProxyRelay { Octstr *name; Octstr *allowed_prefix; Octstr *denied_prefix; + + Octstr *unified_prefix; + List *strip_prefixes; + int confirmed_mm4; } MmsProxyRelay; diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c index a9ac459..dab15d7 100644 --- a/mbuni/mmsc/mmsglobalsender.c +++ b/mbuni/mmsc/mmsglobalsender.c @@ -292,13 +292,25 @@ static int sendMsg(MmsEnvelope *e) if (octstr_compare(mp->host, mmsc) == 0) { Octstr *xtransid = mms_maketransid(e->xqfname, settings->host_alias); - res = mms_sendtoproxy(e->from, to->rcpt, + Octstr *xfrom = e->from ? octstr_duplicate(e->from) : octstr_create("anon@anon"); + Octstr *xto = octstr_duplicate(to->rcpt); + + _mms_fixup_address(&xfrom, + mp->unified_prefix ? octstr_get_cstr(mp->unified_prefix) : NULL, + mp->strip_prefixes, 1); + + _mms_fixup_address(&xto, + mp->unified_prefix ? octstr_get_cstr(mp->unified_prefix) : NULL, + mp->strip_prefixes, 1); + res = mms_sendtoproxy(xfrom, xto, e->subject, mp->host, octstr_get_cstr(xtransid), e->msgId, e->expiryt, msg, mp->confirmed_mm4, &err); sent = 1; octstr_destroy(xtransid); + octstr_destroy(xfrom); + octstr_destroy(xto); break; } }