1
0
Fork 0

Improved handling of MM4 ACK messages

This commit is contained in:
bagyenda 2007-04-13 10:50:59 +00:00
parent 65c185e3eb
commit e59b517fb8
9 changed files with 55 additions and 37 deletions

View File

@ -1,3 +1,5 @@
2007-04-13 P. A. Bagyenda <bagyenda@dsmagic.com>
* Minor fixups on handling of MM4 Forward ACK messages.
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>

View File

@ -212,7 +212,7 @@ MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int shouldbloc
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);
_mms_fixup_address(e->from, NULL);
}
break;
case 'R':
@ -221,7 +221,7 @@ MmsEnvelope *mms_queue_readenvelope(char *qf, char *mms_queuedir, int shouldbloc
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);
_mms_fixup_address(t, NULL);
}
to = gw_malloc(sizeof *to);
to->rcpt = t;

View File

@ -938,25 +938,33 @@ int isphonenum(Octstr *s)
return 1;
}
/* Doesn't handle IP addresses. */
void _mms_fixup_address(Octstr *address)
/* Doesn't handle IP addresses very well */
void _mms_fixup_address(Octstr *address, char *unified_prefix)
{
int i;
Octstr *typ;
if (!address) return;
i = octstr_search_char(address, '@', 0);
if (i>0)
if (i>0) /* an email address. */
return;
i = octstr_search(address, octstr_imm("/TYPE="), 0);
if (i > 0)
return;
if (i > 0) {
typ = octstr_copy(address, i, octstr_len(address));
octstr_delete(address, i, octstr_len(address));
} else
typ = NULL;
if (isphonenum(address))
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"));
else
} else if (typ)
octstr_append(address, typ);
else
octstr_append(address, octstr_imm("@unknown"));
octstr_destroy(typ);
}
/* compare, reversed result! */

View File

@ -142,8 +142,8 @@ unsigned long _mshash(char *s);
/* Tell us whether address is a phone number. */
int isphonenum(Octstr *s);
/* Fixup an address: Add type, etc. */
void _mms_fixup_address(Octstr *address);
/* Fixup an address: Normalize number (if prefix given), Add type, etc. */
void _mms_fixup_address(Octstr *address, char *unified_prefix);
/* Check that host is one of hosts in semi-colon separated list in host_list */
int is_allowed_host(Octstr *host, Octstr *host_list);

View File

@ -861,7 +861,7 @@ static int make_and_queue_msg(Octstr *data, Octstr *ctype, List *reply_headers,
xservice_code = http_header_value(reply_headers, octstr_imm("X-Mbuni-ServiceCode"));
if (from)
_mms_fixup_address(from);
_mms_fixup_address(from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL);
/* start with the easy one... */
if (octstr_case_compare(ctype, octstr_imm("application/vnd.wap.mms-message")) == 0)
@ -953,7 +953,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);
_mms_fixup_address(v, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL);
gwlist_append(xto, v);
}
octstr_destroy(v);
@ -1182,7 +1182,7 @@ static void sendmms_func(void *unused)
if ((from = http_cgi_variable(cgivars, "from")) != NULL) {
from = octstr_duplicate(from);
_mms_fixup_address(from);
_mms_fixup_address(from, unified_prefix ? octstr_get_cstr(unified_prefix) : NULL);
http_header_add(rh, "X-Mbuni-From", octstr_get_cstr(from));
octstr_destroy(from);
} else if (!u->faked_sender)

View File

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
octstr_destroy(fname);
info(0, "----------------------------------------");
info(0, " MMSC Email2MMS Tool version %s starting", MMSC_VERSION);
info(0, " MMSC Email2MMS/MM4 Incoming Tool version %s starting", MMSC_VERSION);
/* Load settings. */
settings = mms_load_mmsc_settings(cfg, &proxyrelays);
@ -167,9 +167,9 @@ int main(int argc, char *argv[])
msgid = http_header_value(headers, octstr_imm("Message-ID"));
if (msgid)
octstr_strip_nonalphanums(msgid);
octstr_strip_blanks(msgid);
if (transid)
octstr_strip_nonalphanums(transid);
octstr_strip_blanks(transid);
/* ... and remove non-essential ones */
http_header_remove_all(headers, "X-Mms-3GPP-MMS-Version");
@ -348,6 +348,9 @@ int main(int argc, char *argv[])
/* Pull the number out of the fake transaction ID */
if ((i = octstr_search_char(transid, '-',0)) > 0) {
o_to = octstr_copy(transid, 0, i);
#if 0
_mms_fixup_address(o_to, settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL);
#endif
octstr_delete(transid, 0, i+1);
} else
o_to = NULL;
@ -357,7 +360,7 @@ int main(int argc, char *argv[])
octstr_get_cstr(settings->global_queuedir),
1);
if (!e)
warning(0, "MM4 Received %s from %s but cannot load queue entry %s [%s] in queue!",
warning(0, "MM4 Received %s from %s but cannot find queue entry for transaction %s [%s]!",
mm4_types[mtype].mm4str,
octstr_get_cstr(xproxy),
octstr_get_cstr(transid),
@ -366,14 +369,16 @@ int main(int argc, char *argv[])
else {
MmsEnvelopeTo *t;
int i, n;
int processed = 0;
for (i = 0, n = gwlist_len(e->to); i<n; i++)
if ((t = gwlist_get(e->to, i)) != NULL &&
(o_to == NULL || octstr_case_compare(o_to, t->rcpt) == 0))
(o_to == NULL || octstr_case_compare(o_to, t->rcpt) == 0)) {
t->process = 0; /* Should make it go away. */
processed = 1;
}
/* write CDR if it is a forward confirmation */
if (mtype == MM4_FORWARD_RES &&
if (processed && mtype == MM4_FORWARD_RES &&
rstatus && octstr_str_case_compare(rstatus, "Ok") == 0) {
MmsCdrStruct _cdr, *cdr = &_cdr;
@ -387,14 +392,17 @@ int main(int argc, char *argv[])
settings->mms_billfuncs->mms_logcdr(cdr);
}
mms_queue_update(e);
info(0, "MM4 received %s from proxy %s to %s from %s => %s, status: %s",
info(0, "MM4 received %s from proxy %s to %s from %s => %s, status: [%s, %s]",
mm4_types[mtype].mm4str,
octstr_get_cstr(xproxy), o_to ? octstr_get_cstr(o_to) : octstr_get_cstr(xto),
octstr_get_cstr(xfrom),
octstr_get_cstr(qf),
rstatus ? octstr_get_cstr(rstatus) : "");
rstatus ? octstr_get_cstr(rstatus) : "",
processed ? "Sender number matched in queue file" : "Sender number not matched in queue file");
if (mms_queue_update(e) != 1)
mms_queue_free_env(e);
}
} else
@ -402,8 +410,7 @@ int main(int argc, char *argv[])
mm4_types[mtype].mm4str,
octstr_get_cstr(transid));
if (o_to)
octstr_destroy(o_to);
octstr_destroy(o_to);
}
break;
@ -490,7 +497,7 @@ static void fixup_recipient(void)
typ = octstr_copy(xto, i+1, octstr_len(xto));
octstr_delete(xto, i, octstr_len(xto));
}
/* XXX may be we should use fixup function in mmlib/mms_util.c ?? */
if (isphonenum(xto) &&
(!typ || octstr_str_compare(typ, "TYPE=PLMN") == 0)) { /* A phone number. */
normalize_number(octstr_get_cstr(settings->unified_prefix), &xto);

View File

@ -535,7 +535,7 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
MSoapMsg_t *mreq = NULL, *mresp = NULL;
List *rh = NULL, *ph = NULL;
Octstr *body = NULL, *rbody = NULL;
void *xx;
Octstr *s;
info(0, "MMS Relay: Send[soap] to VASP[%s], msg_type=[%s], from=[%s], to=[%s]",
@ -561,8 +561,8 @@ static int mm7soap_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgId,
hstatus = mms_url_fetch_content(HTTP_METHOD_POST, vasp->vasp_url, rh, body, &ph, &rbody);
if (http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d, id=%s !",
octstr_get_cstr(vasp->vasp_url), hstatus, xx ? "Ok" : "not OK");
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d!",
octstr_get_cstr(vasp->vasp_url), hstatus);
goto done1;
}
@ -628,7 +628,6 @@ static int mm7eaif_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgid,
int hstatus = HTTP_OK;
List *rh = http_create_empty_headers(), *ph = NULL;
Octstr *body = NULL, *rbody = NULL, *url = NULL, *xver;
void *xx;
char *msgtype;
@ -662,8 +661,8 @@ static int mm7eaif_send(MmsVasp *vasp, Octstr *from, Octstr *to, Octstr *msgid,
hstatus = mms_url_fetch_content(HTTP_METHOD_POST, vasp->vasp_url, rh, body, &ph, &rbody);
if (http_status_class(hstatus) != HTTP_STATUS_SUCCESSFUL) {
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d, id=%s !",
octstr_get_cstr(vasp->vasp_url), hstatus, xx ? "Ok" : "not OK");
*error = octstr_format("Failed to contact VASP[url=%s] => HTTP returned status = %d!",
octstr_get_cstr(vasp->vasp_url), hstatus);
} else
info(0, "Sent to VASP[%s], code=[%d]", octstr_get_cstr(vasp->id), hstatus);

View File

@ -144,7 +144,7 @@ int main(int argc, char *argv[])
if (x >= 0)
octstr_delete(h.profile_url, x, octstr_len(h.profile_url));
}
octstr_strip_nonalphanums(h.profile_url);
octstr_strip_blanks(h.profile_url);
}
/* Get the sender address. */

View File

@ -34,7 +34,8 @@ static int find_own(int i, int argc, char *argv[])
if (argv[i][1] == 'f')
if (i + 1 < argc) {
from = octstr_create(argv[i+1]);
_mms_fixup_address(from);
_mms_fixup_address(from,
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL);
return 1;
} else
return -1;
@ -48,7 +49,8 @@ static int find_own(int i, int argc, char *argv[])
octstr_imm(":"));
for (j = 0, m = gwlist_len(l); j < m; j++) {
Octstr *x = gwlist_get(l, j);
_mms_fixup_address(x);
_mms_fixup_address(x,
settings->unified_prefix ? octstr_get_cstr(settings->unified_prefix) : NULL);
gwlist_append(to, x);
}
gwlist_destroy(l, NULL);