Skip to content

Instantly share code, notes, and snippets.

@dynax60
Created July 30, 2015 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dynax60/b956cd29f78fed8cac87 to your computer and use it in GitHub Desktop.
Save dynax60/b956cd29f78fed8cac87 to your computer and use it in GitHub Desktop.
diff -dur gateway.orig/gw/bb_boxc.c gateway/gw/bb_boxc.c
--- gateway.orig/gw/bb_boxc.c 2015-07-15 12:01:59.993723709 +0000
+++ gateway/gw/bb_boxc.c 2015-07-23 11:38:23.449299990 +0000
@@ -111,6 +111,7 @@
static Dict *smsbox_by_smsc;
static Dict *smsbox_by_receiver;
static Dict *smsbox_by_smsc_receiver;
+static Dict *smsbox_by_sender;
static long smsbox_port;
static int smsbox_port_ssl;
@@ -1066,6 +1067,8 @@
smsbox_by_receiver = NULL;
dict_destroy(smsbox_by_smsc_receiver);
smsbox_by_smsc_receiver = NULL;
+ dict_destroy(smsbox_by_sender);
+ smsbox_by_sender = NULL;
gwlist_remove_producer(flow_threads);
}
@@ -1120,10 +1123,10 @@
{
CfgGroup *grp;
List *list, *items;
- Octstr *boxc_id, *smsc_ids, *shortcuts;
+ Octstr *boxc_id, *smsc_ids, *shortcuts, *senders;
int i, j;
- boxc_id = smsc_ids = shortcuts = NULL;
+ boxc_id = smsc_ids = shortcuts = senders = NULL;
list = cfg_get_multi_group(cfg, octstr_imm("smsbox-route"));
@@ -1146,8 +1149,9 @@
*/
smsc_ids = cfg_get(grp, octstr_imm("smsc-id"));
shortcuts = cfg_get(grp, octstr_imm("shortcode"));
+ senders = cfg_get(grp, octstr_imm("sender"));
- /* consider now the 3 possibilities: */
+ /* consider now the 4 possibilities: */
if (smsc_ids && !shortcuts) {
/* smsc-id only, so all MO traffic */
items = octstr_split(smsc_ids, octstr_imm(";"));
@@ -1165,6 +1169,23 @@
gwlist_destroy(items, octstr_destroy_item);
octstr_destroy(smsc_ids);
}
+ else if (!smsc_ids && senders) {
+ /* senders only, so these MOs from specified numbers */
+ items = octstr_split(senders, octstr_imm(";"));
+ for (i = 0; i < gwlist_len(items); i++) {
+ Octstr *item = gwlist_get(items, i);
+ octstr_strip_blanks(item);
+
+ debug("bb.boxc",0,"Adding smsbox routing to id <%s> for sender no <%s>",
+ octstr_get_cstr(boxc_id), octstr_get_cstr(item));
+
+ if (!dict_put_once(smsbox_by_sender, item, octstr_duplicate(boxc_id)))
+ panic(0, "Routing for sender no <%s> already exists!",
+ octstr_get_cstr(item));
+ }
+ gwlist_destroy(items, octstr_destroy_item);
+ octstr_destroy(sender);
+ }
else if (!smsc_ids && shortcuts) {
/* shortcode only, so these MOs from all smscs */
items = octstr_split(shortcuts, octstr_imm(";"));
@@ -1270,6 +1291,7 @@
smsbox_by_smsc = dict_create(30, (void(*)(void *)) octstr_destroy);
smsbox_by_receiver = dict_create(50, (void(*)(void *)) octstr_destroy);
smsbox_by_smsc_receiver = dict_create(50, (void(*)(void *)) octstr_destroy);
+ smsbox_by_sender = dict_create(60, (void(*)(void *)) octstr_destroy);
/* load the defined smsbox routing rules */
init_smsbox_routes(cfg);
@@ -1511,7 +1533,7 @@
int route_incoming_to_boxc(Msg *msg)
{
Boxc *bc = NULL;
- Octstr *s, *r, *rs, *boxc_id = NULL;
+ Octstr *s, *r, *rs, *boxc_id = NULL, *sender;
long len, b, i;
int full_found = 0;
@@ -1551,10 +1573,14 @@
rs = (os ? dict_get(smsbox_by_smsc_receiver, os) : NULL);
octstr_destroy(os);
+ sender = (msg->sms.sender ? dict_get(smsbox_by_sender, msg->sms.sender) : NULL);
+
if (rs)
boxc_id = rs;
+ else if (sender)
+ boxc_id = sender;
else if (r)
- boxc_id = r;
+ boxc_id = r;
else if (s)
boxc_id = s;
}
Only in gateway/gw: t.c
diff -dur gateway.orig/gwlib/cfg.def gateway/gwlib/cfg.def
--- gateway.orig/gwlib/cfg.def 2015-07-15 12:01:49.277732262 +0000
+++ gateway/gwlib/cfg.def 2015-07-23 10:10:23.866855352 +0000
@@ -303,6 +303,7 @@
OCTSTR(smsbox-id)
OCTSTR(smsc-id)
OCTSTR(shortcode)
+ OCTSTR(sender)
)
@g10host
Copy link

g10host commented Sep 21, 2015

Hello, I noticed that you made a sms api, could direct me to a supplier of SMS shortcode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment