Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 1 | # 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 | |
Holger Hans Peter Freyther | d03acdf | 2018-09-23 18:06:48 +0100 | [diff] [blame] | 20 | from . import log, config |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 21 | |
| 22 | class Smsc: |
Pau Espin Pedrol | 2d16f6f | 2017-05-30 15:33:57 +0200 | [diff] [blame] | 23 | |
| 24 | SMSC_POLICY_CLOSED = 'closed' |
| 25 | SMSC_POLICY_ACCEPT_ALL = 'accept-all' |
| 26 | |
| 27 | def __init__(self, smpp_addr_port): |
| 28 | self.addr_port = smpp_addr_port |
| 29 | self.policy = self.SMSC_POLICY_CLOSED |
| 30 | self.esmes = [] |
| 31 | |
| 32 | def get_config(self): |
| 33 | values = { 'smsc': { 'policy': self.policy } } |
| 34 | esme_list = [] |
| 35 | for esme in self.esmes: |
| 36 | esme_list.append(esme.conf_for_smsc()) |
| 37 | config.overlay(values, dict(smsc=dict(esme_list=esme_list))) |
| 38 | return values |
| 39 | |
| 40 | def esme_add(self, esme): |
| 41 | if esme.system_id == '': |
| 42 | raise log.Error('esme system_id cannot be empty') |
| 43 | self.esmes.append(esme) |
| 44 | esme.set_smsc(self) |
| 45 | |
| 46 | def set_smsc_policy(self, smsc_policy): |
| 47 | self.policy = smsc_policy |
| 48 | |
| 49 | # vim: expandtab tabstop=4 shiftwidth=4 |