path: root/src/osmo_gsm_tester/smsc.py
diff options
authorPau Espin Pedrol <pespin@sysmocom.de>2017-05-30 15:33:57 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-06-18 08:48:09 +0000
commit2d16f6fd2c88844c9e9b5257795cdc85877e6235 (patch)
tree4b18677c253b5ae553cfd0c3747534f437dc72d3 /src/osmo_gsm_tester/smsc.py
parent640c7760e9cad7e26de685838378293805478413 (diff)
Add support for SMPP testing
As defined in [1], the different related actors are implemented in this commit: ESME and SMSC. SMSC: In Osmocom, the SMSC is currently implemented inside the NITB or the MSC. A new Smsc abstract class is created to shared code between the NITB and the MSC, and also makes it easier for later when the SMSC is splitted. ESMEs can be dynamically added to its configuration in a similar way to how the BTSs are added. ESME: A new class Esme is created which can be used by tests to control an ESME to interact with the SMSC. The ESME functionalities are implemented using python-smpplib. Required version of this library is at least 43cc6f819ec76b2c0a9d36d1d439308634716227, which contains support for python 3 and some required features to poll the socket. This commit already contains a few tests which checks different features and tests the API. Extending tested features or scenarios can be later done quite easily. The tests are not enabled by default right now, because there are several of them in a suite and the ip_address resources are not freed after every tests which ends up in the suite failing due to missing reserved resources. All the tests run alone work though. When the issue is fixed they can then be added to the default list of tests to be run. [1] http://opensmpp.org/specs/SMPP_v3_4_Issue1_2.pdf Change-Id: I14ca3cb009d6d646a449ca99b0200da12085c0da
Diffstat (limited to 'src/osmo_gsm_tester/smsc.py')
1 files changed, 50 insertions, 0 deletions
diff --git a/src/osmo_gsm_tester/smsc.py b/src/osmo_gsm_tester/smsc.py
new file mode 100644
index 0000000..4837f37
--- /dev/null
+++ b/src/osmo_gsm_tester/smsc.py
@@ -0,0 +1,50 @@
+# osmo_gsm_tester: smsc interface
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+# Author: Pau Espin Pedrol <pespin@sysmocom.de>
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# GNU Affero General Public License for more details.
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+from . import log, config, util, template, process
+class Smsc:
+ esmes = None
+ SMSC_POLICY_ACCEPT_ALL = 'accept-all'
+ def __init__(self, smpp_addr_port):
+ self.addr_port = smpp_addr_port
+ self.policy = self.SMSC_POLICY_CLOSED
+ self.esmes = []
+ def get_config(self):
+ values = { 'smsc': { 'policy': self.policy } }
+ esme_list = []
+ for esme in self.esmes:
+ esme_list.append(esme.conf_for_smsc())
+ config.overlay(values, dict(smsc=dict(esme_list=esme_list)))
+ return values
+ def esme_add(self, esme):
+ if esme.system_id == '':
+ raise log.Error('esme system_id cannot be empty')
+ self.esmes.append(esme)
+ esme.set_smsc(self)
+ def set_smsc_policy(self, smsc_policy):
+ self.policy = smsc_policy
+# vim: expandtab tabstop=4 shiftwidth=4