blob: 4837f37a18fa4ff2cdd2fdbb15ec8b4eefe965c7 [file] [log] [blame]
Pau Espin Pedrol2d16f6f2017-05-30 15:33:57 +02001# osmo_gsm_tester: smsc interface
2#
3# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
4#
5# Author: Pau Espin Pedrol <pespin@sysmocom.de>
6#
7# This program is free software: you can redistribute it and/or modify
8# it under the terms of the GNU Affero General Public License as
9# published by the Free Software Foundation, either version 3 of the
10# License, or (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU Affero General Public License for more details.
16#
17# You should have received a copy of the GNU Affero General Public License
18# along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20from . import log, config, util, template, process
21
22class Smsc:
23 esmes = None
24
25 SMSC_POLICY_CLOSED = 'closed'
26 SMSC_POLICY_ACCEPT_ALL = 'accept-all'
27
28 def __init__(self, smpp_addr_port):
29 self.addr_port = smpp_addr_port
30 self.policy = self.SMSC_POLICY_CLOSED
31 self.esmes = []
32
33 def get_config(self):
34 values = { 'smsc': { 'policy': self.policy } }
35 esme_list = []
36 for esme in self.esmes:
37 esme_list.append(esme.conf_for_smsc())
38 config.overlay(values, dict(smsc=dict(esme_list=esme_list)))
39 return values
40
41 def esme_add(self, esme):
42 if esme.system_id == '':
43 raise log.Error('esme system_id cannot be empty')
44 self.esmes.append(esme)
45 esme.set_smsc(self)
46
47 def set_smsc_policy(self, smsc_policy):
48 self.policy = smsc_policy
49
50# vim: expandtab tabstop=4 shiftwidth=4