Holger Hans Peter Freyther | 48c83a8 | 2019-02-27 08:27:46 +0000 | [diff] [blame] | 1 | # osmo_gsm_tester: Base class for Mobile Stations (MS) |
| 2 | # |
| 3 | # Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Neels Hofmeyr <neels@hofmeyr.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU 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 General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | from abc import ABCMeta, abstractmethod |
Pau Espin Pedrol | e1a58bd | 2020-04-10 20:46:07 +0200 | [diff] [blame] | 21 | from ..core import log |
Pau Espin Pedrol | ea8c3d4 | 2020-05-04 12:05:05 +0200 | [diff] [blame^] | 22 | from ..core import schema |
| 23 | |
| 24 | def on_register_schemas(): |
| 25 | resource_schema = { |
| 26 | 'type': schema.STR, |
| 27 | 'label': schema.STR, |
| 28 | 'path': schema.STR, |
| 29 | 'imsi': schema.IMSI, |
| 30 | 'ki': schema.KI, |
| 31 | 'auth_algo': schema.AUTH_ALGO, |
| 32 | 'apn_ipaddr': schema.IPV4, |
| 33 | 'ciphers[]': schema.CIPHER, |
| 34 | 'features[]': schema.MODEM_FEATURE |
| 35 | } |
| 36 | schema.register_resource_schema('modem', resource_schema) |
Holger Hans Peter Freyther | 48c83a8 | 2019-02-27 08:27:46 +0000 | [diff] [blame] | 37 | |
| 38 | class MS(log.Origin, metaclass=ABCMeta): |
| 39 | """Base for everything about mobile/modem and SIMs.""" |
| 40 | |
| 41 | def __init__(self, name, conf): |
| 42 | super().__init__(log.C_TST, name) |
| 43 | self._conf = conf |
| 44 | self.msisdn = None |
| 45 | |
| 46 | def imsi(self): |
| 47 | return self._conf.get('imsi') |
| 48 | |
| 49 | def ki(self): |
| 50 | return self._conf.get('ki') |
| 51 | |
Andre Puschmann | 22ec00a | 2020-03-24 09:58:06 +0100 | [diff] [blame] | 52 | def apn_ipaddr(self): |
| 53 | return self._conf.get('apn_ipaddr', 'dynamic') |
| 54 | |
Holger Hans Peter Freyther | 48c83a8 | 2019-02-27 08:27:46 +0000 | [diff] [blame] | 55 | def auth_algo(self): |
| 56 | return self._conf.get('auth_algo', None) |
| 57 | |
| 58 | def set_msisdn(self, msisdn): |
| 59 | self.msisdn = msisdn |
| 60 | |
| 61 | def msisdn(self): |
| 62 | return self.msisdn |
| 63 | |
| 64 | @abstractmethod |
| 65 | def cleanup(self): |
| 66 | """Cleans up resources allocated.""" |
Holger Hans Peter Freyther | 10501cc | 2019-02-25 03:20:16 +0000 | [diff] [blame] | 67 | pass |