blob: 5f695ed884f4c18bda793c7e4c6c75998fedcd8c [file] [log] [blame]
Harald Weltede4c14c2022-07-16 11:53:59 +02001# -*- coding: utf-8 -*-
2
3# without this, pylint will fail when inner classes are used
4# within the 'nested' kwarg of our TlvMeta metaclass on python 3.7 :(
5# pylint: disable=undefined-variable
6
7"""
Harald Weltea0452212022-07-17 21:23:21 +02008DF_PHONEBOOK, DF_MULTIMEDIA as specified in 3GPP TS 31.102 V16.6.0
Harald Weltede4c14c2022-07-16 11:53:59 +02009Needs to be a separate python module to avoid cyclic imports
10"""
11
12#
13# Copyright (C) 2022 Harald Welte <laforge@osmocom.org>
14#
15# This program is free software: you can redistribute it and/or modify
16# it under the terms of the GNU General Public License as published by
17# the Free Software Foundation, either version 2 of the License, or
18# (at your option) any later version.
19#
20# This program is distributed in the hope that it will be useful,
21# but WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23# GNU General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program. If not, see <http://www.gnu.org/licenses/>.
27#
28
29from pySim.tlv import *
30from pySim.filesystem import *
31from pySim.construct import *
32from construct import Optional as COptional
33from construct import *
34
35# TS 31.102 Section 4.4.2.1
36class EF_PBR(LinFixedEF):
37 def __init__(self, fid='4F30', name='EF.PBR', desc='Phone Book Reference', **kwargs):
38 super().__init__(fid, name=name, desc=desc, **kwargs)
39 #self._tlv = FIXME
40
41# TS 31.102 Section 4.4.2.12.2
42class EF_PSC(TransparentEF):
43 _construct = Struct('synce_counter'/Int32ub)
44 def __init__(self, fid='4F22', name='EF.PSC', desc='Phone Book Synchronization Counter', **kwargs):
45 super().__init__(fid, name=name, desc=desc, **kwargs)
46 #self._tlv = FIXME
47
48# TS 31.102 Section 4.4.2.12.3
49class EF_CC(TransparentEF):
50 _construct = Struct('change_counter'/Int16ub)
51 def __init__(self, fid='4F23', name='EF.CC', desc='Change Counter', **kwargs):
52 super().__init__(fid, name=name, desc=desc, **kwargs)
53
54# TS 31.102 Section 4.4.2.12.4
55class EF_PUID(TransparentEF):
56 _construct = Struct('previous_uid'/Int16ub)
57 def __init__(self, fid='4F24', name='EF.PUID', desc='Previous Unique Identifer', **kwargs):
58 super().__init__(fid, name=name, desc=desc, **kwargs)
59
60# TS 31.102 Section 4.4.2
61class DF_PHONEBOOK(CardDF):
62 def __init__(self, fid='5F3A', name='DF.PHONEBOOK', desc='Phonebook', **kwargs):
63 super().__init__(fid=fid, name=name, desc=desc, **kwargs)
64 files = [
65 EF_PBR(),
66 EF_PSC(),
67 EF_CC(),
68 EF_PUID(),
69 # FIXME: Those 4Fxx entries with unspecified FID...
70 ]
71 self.add_files(files)
Harald Weltea0452212022-07-17 21:23:21 +020072
73
74
75# TS 31.102 Section 4.6.3.1
76class EF_MML(BerTlvEF):
77 def __init__(self, fid='4F47', name='EF.MML', desc='Multimedia Messages List', **kwargs):
78 super().__init__(fid, name=name, desc=desc, **kwargs)
79
80# TS 31.102 Section 4.6.3.2
81class EF_MMDF(BerTlvEF):
82 def __init__(self, fid='4F48', name='EF.MMDF', desc='Multimedia Messages Data File', **kwargs):
83 super().__init__(fid, name=name, desc=desc, **kwargs)
84
85class DF_MULTIMEDIA(CardDF):
86 def __init__(self, fid='5F3B', name='DF.MULTIMEDIA', desc='Multimedia', **kwargs):
87 super().__init__(fid=fid, name=name, desc=desc, **kwargs)
88 files = [
89 EF_MML(),
90 EF_MMDF(),
91 ]
92 self.add_files(files)