Hello Users!
Here is the story. I`m working in mobile telecommunications company.
We are using Kannel WAP and SMS gateway for serving our customers.
For some newer phones we also run squid http-proxy. WAP-aware phones
are served by our dedicated Cisco AS5300 network access server.
A few month ago we decided to run Mbuni MMS gateway. Almost everything
works good, but one problem: MSISDN! By default, incoming MMS messages
are signed with IP-address of sender, not the MSISDN. It is
unacceptable for us.
Mbuni expects special http-header (X-WAP-Network-Client) to be set
by Kannel.
This header contains user MSISDN. The Kannel configuration, in its
turn, must
be RADIUS-aware. So, Kannel get`s MSISDN from the RADIUS server and
passes
special http-header toward Mbuni.
Looks fine? But what about "some newer phones", which use squid
instead
of Kannel`s wapbox? Squid is unable to set a magic MSISDN header
for us.
May be there is a better way to solve this problem (e.g. see Mbuni
detokenizer
library), but I have my own. It consists of three pieces. They are
1. Patch for Mbuni 1.0.0
2. Tiny perl script with RSH Cisco commands
3. Snippet of Cisco configuration to work with Remote shell (RSH)
The main idea is very simple. Suppose that WAP-phone is currently
connected to the Cisco.
# show call calltracker active
This Cisco command shows active calls.
Command output (phone numbers are changed):
-------------------------- call handle= 2154
--------------------------
status=Active, service=PPP, origin=Answer, category=Modem
DS0 slot/port/ds1/chan=0/0/0/1, called=123, calling=123456789
userid=wap, ip=aaa.bbb.ccc.ddd, mask=0.0.0.0
setup=09/27/2005 15:01:59, conn=0.10, phys=22.77, service=36.59,
authen=36.59
init rx/tx b-rate=33600/31200, rx/tx chars=193160/1155850
resource slot/port=1/47, mp bundle=0, charged units=0, account id=0
idb handle=0x61EED7E8, tty handle=0x619C4C84, tcb handle=0x0
----------------------------------------------------------------------
------
We see that user with MSISDN '123456789' called the number 123.
User IP-address is aaa.bbb.ccc.ddd. This is exactly we want: mapping
between IP-address and MSISDN!
Using this patch, Mbuni will run RSH command 'show call calltracker
active'
to find MSISDN of a user with a given IP-address.
To run RSH commands on Cisco you need something like this:
=8<===============
no ip rcmd domain-lookup
ip rcmd rsh-enable
ip rcmd remote-host Cisco_user aaa.bbb.ccc.ddd mbuni enable
=8<===============
First lines are used to enable RSH on Cisco.
Last line permits RSH for user 'mbuni' from host aaa.bbb.ccc.ddd.
Cisco_user is a valid user on Cisco NAS.
--
Good luck!
Alexander Simakov.
<get_msisdn.pl>
diff -Naur mbuni-orig/mmlib/mms_util.c mbuni-1.0.0/mmlib/mms_util.c
--- mbuni-orig/mmlib/mms_util.c 2005-07-26 08:44:58.000000000 +0400
+++ mbuni-1.0.0/mmlib/mms_util.c 2005-09-12 17:10:51.000000000
+0400
@@ -26,6 +26,8 @@
#include "mms_queue.h"
#include "mms_uaprof.h"
+#define GET_MSISDN "/usr/local/bin/get_msisdn.pl"
+
#define MAXQTRIES 100
#define BACKOFF_FACTOR 5*60 /* In seconds */
#define QUEUERUN_INTERVAL 15*60 /* 15 minutes. */
@@ -422,28 +424,30 @@
}
-Octstr *mms_find_sender_msisdn(Octstr *send_url, List
*request_hdrs, Octstr *msisdn_header,
- MmsDetokenizerFuncStruct* detokenizerfuncs)
+Octstr *mms_find_sender_msisdn(List *request_hdrs, Octstr *ip_header)
{
- /* Either we have a WAP gateway header as defined, or we look
for
- * last part of url, pass it to detokenizer lib if defined,
and back comes our number.
- */
-
- Octstr *phonenum = http_header_value(request_hdrs,
- msisdn_header);
-
- if (!phonenum || octstr_len(phonenum) == 0) {
- List *l = octstr_split(send_url, octstr_imm("/"));
-
- if (l && list_len(l) > 1) {
- if (detokenizerfuncs)
- phonenum = detokenizerfuncs->mms_detokenize(list_get
(l, list_len(l) - 1));
+ Octstr *ip = http_header_value(request_hdrs, ip_header);
+ Octstr *cmd = NULL, *msisdn = NULL;
+ FILE *fp;
+ char buf[4096];
+
+ info(0, "Resolving user MSISDN");
+
+ cmd = octstr_format("%s %s", GET_MSISDN, octstr_get_cstr(ip));
+ info(0, "Calling \"%s\"", octstr_get_cstr(cmd));
+ if ((fp = popen(octstr_get_cstr(cmd), "r"))) {
+ if (fgets(buf, sizeof buf, fp) != NULL) {
+ msisdn = octstr_create(buf);
+ octstr_strip_crlfs(msisdn);
}
- if (l)
- list_destroy(l, (list_item_destructor_t *)octstr_destroy);
+ pclose(fp);
}
-
- return phonenum;
+ info(0, "%s \"%s\", returned msisdn = %s",
+ fp ? "Called" : "Failed to call",
+ octstr_get_cstr(cmd),
+ msisdn ? octstr_get_cstr(msisdn) : "null");
+ octstr_destroy(cmd);
+ return msisdn;
}
Octstr *mms_find_sender_ip(List *request_hdrs, Octstr *ip_header,
Octstr *ip, int *isv6)
diff -Naur mbuni-orig/mmlib/mms_util.h mbuni-1.0.0/mmlib/mms_util.h
--- mbuni-orig/mmlib/mms_util.h 2005-07-26 08:44:59.000000000 +0400
+++ mbuni-1.0.0/mmlib/mms_util.h 2005-09-12 17:11:02.000000000
+0400
@@ -146,7 +146,7 @@
extern int mms_decodefetchurl(Octstr *fetch_url,
Octstr **qf, Octstr **token, int *loc);
-Octstr *mms_find_sender_msisdn(Octstr *send_url, List
*request_hdrs, Octstr *msisdn_header, MmsDetokenizerFuncStruct
*detokenizerfuncs);
+Octstr *mms_find_sender_msisdn(List *request_hdrs, Octstr
*ip_header);
Octstr *mms_find_sender_ip(List *request_hdrs, Octstr *ip_header,
Octstr *ip, int *isv6);
extern Octstr *mms_isodate(time_t t);
diff -Naur mbuni-orig/mmsc/mmsproxy.c mbuni-1.0.0/mmsc/mmsproxy.c
--- mbuni-orig/mmsc/mmsproxy.c 2005-07-26 08:44:57.000000000 +0400
+++ mbuni-1.0.0/mmsc/mmsproxy.c 2005-09-12 17:11:42.000000000 +0400
@@ -141,10 +141,7 @@
h.prof = mms_make_ua_profile(h.headers);
/* Get the sender address. */
- h.base_client_addr = mms_find_sender_msisdn(h.url,
- h.headers,
- settings->wap_gw_msisdn_header,
- settings->mms_detokenizefuncs);
+ h.base_client_addr = mms_find_sender_msisdn(h.headers,
settings->wap_gw_ip_header);
if (!h.base_client_addr) { /* Set to IP sender... XXXX
assumes ipv4 only for now*/
if (settings->allow_ip_type) {
_______________________________________________
Users mailing list
Users@mbuni.org
http://mbuni.org/mailman/listinfo/users_mbuni.org