diff --git a/mbuni/mmlib/mms_queue.c b/mbuni/mmlib/mms_queue.c index 749b8e2..d8bdf33 100644 --- a/mbuni/mmlib/mms_queue.c +++ b/mbuni/mmlib/mms_queue.c @@ -263,7 +263,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho if (mms_validate_address(e->from) != 0) { warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " "Attempting fixup.", res, xqf); - _mms_fixup_address(&e->from, NULL); + _mms_fixup_address(&e->from, NULL, 1); } break; case 'R': @@ -272,7 +272,7 @@ static MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int sho if (mms_validate_address(t) != 0) { warning(0, "mms_queueread: Mal-formed address [%s] in file %s! " "Attempting fixup.", res, xqf); - _mms_fixup_address(&t, NULL); + _mms_fixup_address(&t, NULL, 1); } to = gw_malloc(sizeof *to); to->rcpt = t; diff --git a/mbuni/mmlib/mms_util.c b/mbuni/mmlib/mms_util.c index e2e2589..61312e4 100644 --- a/mbuni/mmlib/mms_util.c +++ b/mbuni/mmlib/mms_util.c @@ -963,7 +963,7 @@ int isphonenum(Octstr *s) } /* Doesn't handle IP addresses very well */ -void _mms_fixup_address(Octstr **address, char *unified_prefix) +void _mms_fixup_address(Octstr **address, char *unified_prefix, int keep_suffix) { int i; Octstr *typ; @@ -983,11 +983,11 @@ void _mms_fixup_address(Octstr **address, char *unified_prefix) if (isphonenum(*address) || (typ && octstr_str_compare(typ, "/TYPE=PLMN") == 0)) { if (unified_prefix) normalize_number(unified_prefix, address); - octstr_append(*address, octstr_imm("/TYPE=PLMN")); + octstr_append(*address, keep_suffix ? octstr_imm("/TYPE=PLMN") : octstr_imm("")); } else if (typ) - octstr_append(*address, typ); + octstr_append(*address, keep_suffix ? typ : octstr_imm("")); else - octstr_append(*address, octstr_imm("@unknown")); + octstr_append(*address, keep_suffix ? octstr_imm("@unknown") : octstr_imm("")); octstr_destroy(typ); } diff --git a/mbuni/mmlib/mms_util.h b/mbuni/mmlib/mms_util.h index f563c17..78d590a 100644 --- a/mbuni/mmlib/mms_util.h +++ b/mbuni/mmlib/mms_util.h @@ -153,8 +153,8 @@ unsigned long _mshash(char *s); /* Tell us whether address is a phone number. */ int isphonenum(Octstr *s); -/* Fixup an address: Normalize number (if prefix given), Add type, etc. */ -void _mms_fixup_address(Octstr **address, char *unified_prefix); +/* Fixup an address: Normalize number (if prefix given), Add type (if keep_suffix is set), etc. */ +void _mms_fixup_address(Octstr **address, char *unified_prefix, int keep_suffix); /* Check that host is one of hosts in semi-colon separated list in host_list */ int is_allowed_host(Octstr *host, Octstr *host_list); diff --git a/mbuni/mmsbox/mmsbox.c b/mbuni/mmsbox/mmsbox.c index 9862a86..9526efd 100644 --- a/mbuni/mmsbox/mmsbox.c +++ b/mbuni/mmsbox/mmsbox.c @@ -866,7 +866,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, for (j = 0; j < gwlist_len(hv); j++) { Octstr *v = gwlist_get(hv, j); /* Fix the address. */ - _mms_fixup_address(&v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1); gwlist_append(xto, v); } octstr_destroy(v); @@ -922,7 +922,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers, xservice_code = octstr_duplicate(hsvc_code); if (from) - _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1); /* Now get the data. */ if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0) @@ -1263,7 +1263,7 @@ static void sendmms_func(void *unused) if ((from = http_cgi_variable(cgivars, "from")) != NULL) { from = octstr_duplicate(from); - _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL); + _mms_fixup_address(&from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL, 1); http_header_add(rh, "X-Mbuni-From", octstr_get_cstr(from)); octstr_destroy(from); } else if (!u->faked_sender) diff --git a/mbuni/mmsbox/mmsbox_cfg.c b/mbuni/mmsbox/mmsbox_cfg.c index c3b6bfb..69a0378 100644 --- a/mbuni/mmsbox/mmsbox_cfg.c +++ b/mbuni/mmsbox/mmsbox_cfg.c @@ -492,11 +492,17 @@ Octstr *get_mmsbox_queue_dir(Octstr *from, List *to, MmscGrp *m, if (gwlist_len(to) > 0) { /* we route based on first recipient XXX */ Octstr *fto = gwlist_extract_first(to); - - normalize_number(octstr_get_cstr(unified_prefix), &fto); - _mcid = rfs->mmsbox_resolve(from,fto,octstr_get_cstr(m->id), rfs_data, rfs_settings); + Octstr *xfrom = octstr_duplicate(from); - gwlist_insert(to, 0, fto); /* put it back, after modification. */ + _mms_fixup_address(&xfrom, octstr_get_cstr(unified_prefix), 0); + _mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 0); + + _mcid = rfs->mmsbox_resolve(xfrom,fto,octstr_get_cstr(m->id), rfs_data, rfs_settings); + + _mms_fixup_address(&fto, octstr_get_cstr(unified_prefix), 1); + if (fto) + gwlist_insert(to, 0, fto); /* put it back, after modification. */ + octstr_destroy(xfrom); } else _mcid = NULL; diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c index 32266bf..a7adf45 100644 --- a/mbuni/mmsc/mmsglobalsender.c +++ b/mbuni/mmsc/mmsglobalsender.c @@ -79,7 +79,7 @@ static int sendMsg(MmsEnvelope *e) MmsEnvelopeTo *to = gwlist_get(e->to, i); Octstr *s = octstr_duplicate(to->rcpt); - _mms_fixup_address(&s, octstr_get_cstr(settings->unified_prefix)); + _mms_fixup_address(&s, octstr_get_cstr(settings->unified_prefix), 1); gwlist_append(l, s); } diff --git a/mbuni/mmsc/mmssend.c b/mbuni/mmsc/mmssend.c index 180a2c8..a6310ee 100644 --- a/mbuni/mmsc/mmssend.c +++ b/mbuni/mmsc/mmssend.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) while ((x = gwlist_extract_first(to)) != NULL) { octstr_strip_blanks(x); _mms_fixup_address(&x, - settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); + settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, 1); gwlist_append(l, x); } gwlist_destroy(to, NULL); @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) /* fix from address. */ _mms_fixup_address(&from, - settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL); + settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL, 1); #if 0 mms_start_profile_engine(octstr_get_cstr(settings->ua_profile_cache_dir));