summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2015-07-06 16:41:30 +0200
committerIvan Kluchnikov <kluchnikovi@gmail.com>2015-08-20 19:19:18 +0300
commit85a304a4fe71e2b74e1881cc517c23950252796a (patch)
tree89366aee1b404533525e53cacd1eb43d490f263d
parent8a62c5021884ac1dec7f7a338bf591657080a2d5 (diff)
sms: Add a way to always route SMS through SMPP systems
default-route would only be looked at after there has been no subscriber in the local database. Depending on the setup this is not what one wants. This has been discussed at the OsmoDevCon and there have been hacks in some branches. Let's introduce a VTY command to select if SMPP should be consulted first and then fallback to the current behavior.
-rw-r--r--openbsc/src/libmsc/gsm_04_11.c21
-rw-r--r--openbsc/src/libmsc/smpp_openbsc.c5
-rw-r--r--openbsc/src/libmsc/smpp_smsc.h3
-rw-r--r--openbsc/src/libmsc/smpp_vty.c22
-rw-r--r--openbsc/tests/vty_test_runner.py22
5 files changed, 73 insertions, 0 deletions
diff --git a/openbsc/src/libmsc/gsm_04_11.c b/openbsc/src/libmsc/gsm_04_11.c
index 2b6966d..b316d62 100644
--- a/openbsc/src/libmsc/gsm_04_11.c
+++ b/openbsc/src/libmsc/gsm_04_11.c
@@ -280,6 +280,27 @@ int sms_route_mt_sms(struct gsm_subscriber_connection *conn, struct msgb *msg,
{
int rc;
+#ifdef BUILD_SMPP
+ /*
+ * Route through SMPP first before going to the local database. In case
+ * of a unroutable message and no local subscriber, SMPP will be tried
+ * twice. In case of an unknown subscriber continue with the normal
+ * delivery of the SMS.
+ */
+ if (smpp_route_smpp_first(gsms, conn)) {
+ rc = smpp_try_deliver(gsms, conn);
+ if (rc == 1)
+ goto try_local;
+ if (rc < 0) {
+ rc = 21; /* cause 21: short message transfer rejected */
+ /* FIXME: handle the error somehow? */
+ }
+ return rc;
+ }
+
+try_local:
+#endif
+
/* determine gsms->receiver based on dialled number */
gsms->receiver = subscr_get_by_extension(conn->bts->network->subscr_group,
gsms->dst.addr);
diff --git a/openbsc/src/libmsc/smpp_openbsc.c b/openbsc/src/libmsc/smpp_openbsc.c
index b17222f..057a9d0 100644
--- a/openbsc/src/libmsc/smpp_openbsc.c
+++ b/openbsc/src/libmsc/smpp_openbsc.c
@@ -539,6 +539,11 @@ static int deliver_to_esme(struct osmo_esme *esme, struct gsm_sms *sms,
static struct smsc *g_smsc;
+int smpp_route_smpp_first(struct gsm_sms *sms, struct gsm_subscriber_connection *conn)
+{
+ return g_smsc->smpp_first;
+}
+
int smpp_try_deliver(struct gsm_sms *sms, struct gsm_subscriber_connection *conn)
{
struct osmo_esme *esme;
diff --git a/openbsc/src/libmsc/smpp_smsc.h b/openbsc/src/libmsc/smpp_smsc.h
index 8d31b2b..3dd6562 100644
--- a/openbsc/src/libmsc/smpp_smsc.h
+++ b/openbsc/src/libmsc/smpp_smsc.h
@@ -92,6 +92,7 @@ struct smsc {
uint16_t listen_port;
char system_id[SMPP_SYS_ID_LEN+1];
int accept_all;
+ int smpp_first;
struct osmo_smpp_acl *def_route;
void *priv;
};
@@ -137,6 +138,8 @@ int smpp_determine_scheme(uint8_t dcs, uint8_t *data_coding, int *mode);
struct gsm_sms;
struct gsm_subscriber_connection;
+int smpp_route_smpp_first(struct gsm_sms *sms,
+ struct gsm_subscriber_connection *conn);
int smpp_try_deliver(struct gsm_sms *sms,
struct gsm_subscriber_connection *conn);
#endif
diff --git a/openbsc/src/libmsc/smpp_vty.c b/openbsc/src/libmsc/smpp_vty.c
index 75427a9..c0695fe 100644
--- a/openbsc/src/libmsc/smpp_vty.c
+++ b/openbsc/src/libmsc/smpp_vty.c
@@ -58,6 +58,24 @@ DEFUN(cfg_smpp, cfg_smpp_cmd,
return CMD_SUCCESS;
}
+DEFUN(cfg_smpp_first, cfg_smpp_first_cmd,
+ "smpp-first",
+ "Try SMPP routes before the subscriber DB\n")
+{
+ struct smsc *smsc = smsc_from_vty(vty);
+ smsc->smpp_first = 1;
+ return CMD_SUCCESS;
+}
+
+DEFUN(cfg_no_smpp_first, cfg_no_smpp_first_cmd,
+ "no smpp-first",
+ NO_STR "Try SMPP before routes before the subscriber DB\n")
+{
+ struct smsc *smsc = smsc_from_vty(vty);
+ smsc->smpp_first = 0;
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_smpp_port, cfg_smpp_port_cmd,
"local-tcp-port <1-65535>",
"Set the local TCP port on which we listen for SMPP\n"
@@ -125,6 +143,8 @@ static int config_write_smpp(struct vty *vty)
vty_out(vty, " system-id %s%s", smsc->system_id, VTY_NEWLINE);
vty_out(vty, " policy %s%s",
smsc->accept_all ? "accept-all" : "closed", VTY_NEWLINE);
+ vty_out(vty, " %ssmpp-first%s",
+ smsc->smpp_first ? "" : "no ", VTY_NEWLINE);
return CMD_SUCCESS;
}
@@ -512,6 +532,8 @@ int smpp_vty_init(void)
vty_install_default(SMPP_NODE);
install_element(CONFIG_NODE, &cfg_smpp_cmd);
+ install_element(SMPP_NODE, &cfg_smpp_first_cmd);
+ install_element(SMPP_NODE, &cfg_no_smpp_first_cmd);
install_element(SMPP_NODE, &cfg_smpp_port_cmd);
install_element(SMPP_NODE, &cfg_smpp_sys_id_cmd);
install_element(SMPP_NODE, &cfg_smpp_policy_cmd);
diff --git a/openbsc/tests/vty_test_runner.py b/openbsc/tests/vty_test_runner.py
index 3581b67..928eb86 100644
--- a/openbsc/tests/vty_test_runner.py
+++ b/openbsc/tests/vty_test_runner.py
@@ -154,6 +154,28 @@ class TestVTYNITB(TestVTYGenericBSC):
res = self.vty.command("list")
return "smpp" in res
+ def testSmppFirst(self):
+ if not self.checkForSmpp():
+ return
+
+ # enable the configuration
+ self.vty.enable()
+ self.vty.command("configure terminal")
+ self.vty.command("smpp")
+
+ # check the default
+ res = self.vty.command("write terminal")
+ self.assert_(res.find(' no smpp-first') > 0)
+
+ self.vty.verify("smpp-first", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find(' smpp-first') > 0)
+ self.assertEquals(res.find('no smpp-first'), -1)
+
+ self.vty.verify("no smpp-first", [''])
+ res = self.vty.command("write terminal")
+ self.assert_(res.find('no smpp-first') > 0)
+
def testVtyTree(self):
self.vty.enable()
self.assertTrue(self.vty.verify("configure terminal", ['']))