blob: b72333a02dc8c5c89198d40d67e6eb9b1d427495 [file] [log] [blame]
Holger Hans Peter Freyther48c83a82019-02-27 08:27:46 +00001# 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
20from abc import ABCMeta, abstractmethod
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020021from ..core import log
Pau Espin Pedrolea8c3d42020-05-04 12:05:05 +020022from ..core import schema
23
24def 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 Freyther48c83a82019-02-27 08:27:46 +000037
38class 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 Puschmann22ec00a2020-03-24 09:58:06 +010052 def apn_ipaddr(self):
53 return self._conf.get('apn_ipaddr', 'dynamic')
54
Holger Hans Peter Freyther48c83a82019-02-27 08:27:46 +000055 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 Freyther10501cc2019-02-25 03:20:16 +000067 pass