diff --git a/mbuni/ChangeLog b/mbuni/ChangeLog index 71d7470..1cf6d60 100644 --- a/mbuni/ChangeLog +++ b/mbuni/ChangeLog @@ -1,6 +1,7 @@ 2008-12-10 P. A. Bagyenda * Extra mbuni headers in mmsbox url service call * mmsbox EAIF receiver bug fix thanks to Marcin Bockowski (bocian@gmail.com) + * Fix for email2mms handling when mms2email VASP defined 2008-12-09 P. A. Bagyenda * MSISDN and IP request headers now list (MMSC) 2008-12-04 P. A. Bagyenda diff --git a/mbuni/mmsc/mmsfromemail.c b/mbuni/mmsc/mmsfromemail.c index db53c83..53cff70 100644 --- a/mbuni/mmsc/mmsfromemail.c +++ b/mbuni/mmsc/mmsfromemail.c @@ -41,7 +41,7 @@ static struct { static int find_own(int i, int argc, char *argv[]); -static void fixup_recipient(void); +static void fixup_recipient(Octstr **host); static void fixup_sender(void); static void fixup_addresses(List *headers); @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) MmsMsg *msg; Octstr *email, *me, *rstatus, *fname; - Octstr *home_mmsc = NULL; + Octstr *home_mmsc = NULL, *rhost = NULL; List *headers, *h2; Octstr *mm4_type = NULL, *transid, *ack, *msgid, *orig_sys; Octstr *newmsgid = NULL; @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) /* normalize recipient address, then if phone number, * check whether we are allowed to process. */ - fixup_recipient(); + fixup_recipient(&rhost); fixup_sender(); if (xto && ttype == TPLMN) /* Get the home mmsc domain for this recipient. */ @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) switch(mtype) { case MM4_FORWARD_REQ: - if (ttype != TPLMN) { + if (ttype != TPLMN && settings->mms2email == NULL) { err = "Error-service-denied"; mms_error(0, "MM4", NULL, "Not allowed to send to non-phone recipient, to=%s!", octstr_get_cstr(xto)); } else { @@ -258,7 +258,10 @@ int main(int argc, char *argv[]) int dlr; - octstr_format_append(xto, "/TYPE=PLMN"); + if (ttype == TPLMN) + octstr_format_append(xto, "/TYPE=PLMN"); + else + octstr_format_append(xto, "@%S", rhost); gwlist_append(lto, xto); if (dreport && @@ -299,15 +302,17 @@ int main(int argc, char *argv[]) } break; case MM4_DELIVERY_REPORT_REQ: - if (ttype != TPLMN) { /* We only send to phones from this interface */ + if (ttype != TPLMN && settings->mms2email == NULL) { /* We only send to phones from this interface */ mms_error(0, "MM4", NULL, "Not allowed to send to %s!", octstr_get_cstr(xto)); err = "Error-service-denied"; } else { List *lto = gwlist_create(); Octstr *qf; - - octstr_format_append(xto, "/TYPE=PLMN"); + if (ttype == TPLMN) + octstr_format_append(xto, "/TYPE=PLMN"); + else + octstr_format_append(xto, "@%S", rhost); gwlist_append(lto, xto); qf = settings->qfs->mms_queue_add(xfrom, lto, NULL, xproxy, NULL, @@ -333,14 +338,18 @@ int main(int argc, char *argv[]) break; case MM4_READ_REPLY_REPORT_REQ: - if (ttype != TPLMN) { /* We only send to phones from this interface */ + if (ttype != TPLMN && settings->mms2email == NULL) { /* We only send to phones from this interface */ mms_error(0, "MM4", NULL, "Not allowed to send to %s!", octstr_get_cstr(xto)); err = "Error-service-denied"; } else { List *lto = gwlist_create(); Octstr *qf; - octstr_format_append(xto, "/TYPE=PLMN"); + if (ttype == TPLMN) + octstr_format_append(xto, "/TYPE=PLMN"); + else + octstr_format_append(xto, "@%S", rhost); + gwlist_append(lto, xto); qf = settings->qfs->mms_queue_add(xfrom, lto, NULL, xproxy, NULL, @@ -482,6 +491,8 @@ int main(int argc, char *argv[]) octstr_destroy(xproxy); octstr_destroy(me); + octstr_destroy(rhost); + mms_destroy(msg); mms_cleanup_mmsc_settings(settings); mms_lib_shutdown(); @@ -516,7 +527,7 @@ static int find_own(int i, int argc, char *argv[]) } -static void fixup_recipient(void) +static void fixup_recipient(Octstr **host) { int i; Octstr *typ = NULL; @@ -525,8 +536,11 @@ static void fixup_recipient(void) if (!xto) return; i = octstr_search_char(xto, '@', 0); /* Remove '@' */ - if (i>0) + if (i>0) { + *host = octstr_copy(xto, i+1, octstr_len(xto)); octstr_delete(xto, i, octstr_len(xto)); + } else + *host = octstr_create("localhost"); i = octstr_search(xto, octstr_imm("/TYPE="), 0); if (i > 0) { diff --git a/mbuni/mmsc/mmsglobalsender.c b/mbuni/mmsc/mmsglobalsender.c index a97748d..e3dc371 100644 --- a/mbuni/mmsc/mmsglobalsender.c +++ b/mbuni/mmsc/mmsglobalsender.c @@ -172,7 +172,10 @@ static int sendMsg(MmsEnvelope *e) if (octstr_search_char(e->from, '@', 0) < 0) octstr_format_append(pfrom,"@%S", settings->hostname); - if (settings->mms2email) + if (settings->mms2email && /* send, but don't loop back on it */ + !(strcmp(e->src_interface, "MM7") == 0 && + e->vaspid && settings->mms2email->id && + octstr_compare(e->vaspid, settings->mms2email->id) == 0)) res = mms_sendtovasp(settings->mms2email, e->from, to->rcpt, e->msgId,