Hi Kevin,
Yes there is interest for this patch please provide the documentation to
enable it to be submitted.
We hope the Kannel maintainers will include this useful patch.
thanks
----------------------------------------------------------------------
Date: Tue, 2 Jul 2013 13:27:44 -0500
From: "Porter, Kelvin" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Add receiver based smsc-route to opensmppbox
Message-ID:
<73E6BC00A0E3DC4FB8B924269261D52D2E042B82FE@mail1.hypercube-llc.com>
Content-Type: text/plain; charset="us-ascii"
Hi,
I am faced with a need to do receiver-based routing to different SMSC
connections within a opensmppbox and bearerbox configuration. I have a
large number of numbers that need to be routed and they do not share a
common prefix. I have not seen a way to do this using existing
functionality.
I have developed the following enhancement to opensmppbox. I have added
"receiver-shortcode" to the group "smsc-route". "receiver-shortcode"
enables the user to specify that a message should be assigned to a smsc-id
based upon the _receiver_ of a message; not the _sender_. The
receiver-based routing takes higher precedence than the sender "shortcode"
or "smsbox-id" or combination. I did not implement a combination logic;
although I could consider it, if it was desired....
I have included the patch below. If there is interest in incorporating it,
then I can develop a patch for the documentation, as well.
Please share any feedback.
Thank you.
Regards,
Kelvin R. Porter
Index: gw/opensmppbox-cfg.def
===================================================================
--- gw/opensmppbox-cfg.def (revision 72)
+++ gw/opensmppbox-cfg.def (working copy)
@@ -86,4 +86,5 @@
OCTSTR(smsc-id)
OCTSTR(smsbox-id)
OCTSTR(shortcode)
+ OCTSTR(receiver-shortcode)
)
Index: gw/opensmppbox.c
===================================================================
--- gw/opensmppbox.c (revision 72)
+++ gw/opensmppbox.c (working copy)
@@ -116,6 +116,7 @@
static long smpp_dest_addr_ton = -1;
static long smpp_dest_addr_npi = -1;
+static Dict *smsc_by_receiver = NULL;
static Dict *smsc_by_smsbox_id = NULL;
static Dict *smsc_by_sender = NULL;
static Dict *smsc_by_sender_smsbox_id = NULL; @@ -1784,10 +1785,17 @@
if (msg->sms.smsc_id != NULL)
return msg->sms.smsc_id;
- os = octstr_format("%s:%s", octstr_get_cstr(msg->sms.sender),
- octstr_get_cstr(box->boxc_id));
+ char *receiver = octstr_get_cstr(msg->sms.receiver);
+ if ( (receiver) && (strlen(receiver) > 0) ) {
+ smsc_id = dict_get(smsc_by_receiver, msg->sms.receiver);
+ os = octstr_format("receiver:%s", receiver);
+ };
- smsc_id = dict_get(smsc_by_sender_smsbox_id, os);
+ if (!smsc_id) {
+ os = octstr_format("%s:%s",
octstr_get_cstr(msg->sms.sender),
+ octstr_get_cstr(box->boxc_id));
+ smsc_id = dict_get(smsc_by_sender_smsbox_id, os);
+ };
if (!smsc_id)
smsc_id = dict_get(smsc_by_sender,
msg->sms.sender);
if (!smsc_id)
@@ -2251,14 +2259,15 @@
{
CfgGroup *grp;
List *list, *items;
- Octstr *smsc_id, *boxc_ids, *shortcodes;
+ Octstr *smsc_id, *boxc_ids, *shortcodes, *receiver_shortcodes;
int i, j;
+ smsc_by_receiver = dict_create(1000, (void(*)(void *))
+ octstr_destroy);
smsc_by_smsbox_id = dict_create(30, (void(*)(void *)) octstr_destroy);
smsc_by_sender = dict_create(50, (void(*)(void *)) octstr_destroy);
smsc_by_sender_smsbox_id = dict_create(50, (void(*)(void *))
octstr_destroy);
- smsc_id = boxc_ids = shortcodes = NULL;
+ smsc_id = boxc_ids = shortcodes = receiver_shortcodes = NULL;
list = items = NULL;
list = cfg_get_multi_group(cfg, octstr_imm("smsc-route")); @@ -2281,7
+2290,26 @@
*/
boxc_ids = cfg_get(grp, octstr_imm("smsbox-id"));
shortcodes = cfg_get(grp, octstr_imm("shortcode"));
+ receiver_shortcodes = cfg_get(grp,
octstr_imm("receiver-shortcode"));
+ /* Consider the receiver options: receiver-shortcode. */
+ {
+ /* receiver-shortcode applies to all MTs from all smscs */
+ items = octstr_split(receiver_shortcodes, octstr_imm(";"));
+ for (i = 0; i < gwlist_len(items); i++) {
+ Octstr *item = gwlist_get(items, i);
+ octstr_strip_blanks(item);
+
+ debug("opensmppbox",0,"Adding smsc routing to id <%s> for
receiver no <%s>",
+ octstr_get_cstr(smsc_id), octstr_get_cstr(item));
+
+ if (!dict_put_once(smsc_by_receiver, item,
octstr_duplicate(smsc_id)))
+ panic(0, "Routing for receiver no <%s> already
exists!",
+ octstr_get_cstr(item));
+ }
+ gwlist_destroy(items, octstr_destroy_item);
+ };
+
/* consider now the 3 possibilities: */
if (boxc_ids && !shortcodes) {
/* smsbox-id only, so all MT traffic */ @@ -2311,7 +2339,7 @@
octstr_get_cstr(smsc_id), octstr_get_cstr(item));
if (!dict_put_once(smsc_by_sender, item,
octstr_duplicate(smsc_id)))
- panic(0, "Routing for receiver no <%s> already
exists!",
+ panic(0, "Routing for sender no <%s> already
+ exists!",
octstr_get_cstr(item));
}
gwlist_destroy(items, octstr_destroy_item); @@ -2354,6 +2382,9
@@ static void destroy_smsc_routes(void) {
+ dict_destroy(smsc_by_receiver);
+ smsc_by_receiver = NULL;
+
dict_destroy(smsc_by_smsbox_id);
smsc_by_smsbox_id = NULL;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.