Harald Welte | de4c14c | 2022-07-16 11:53:59 +0200 | [diff] [blame^] | 1 | # -*- 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 | """ |
| 8 | DF_PHONEBOOK as specified in 3GPP TS 31.102 V16.6.0 |
| 9 | Needs 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 | |
| 29 | from pySim.tlv import * |
| 30 | from pySim.filesystem import * |
| 31 | from pySim.construct import * |
| 32 | from construct import Optional as COptional |
| 33 | from construct import * |
| 34 | |
| 35 | # TS 31.102 Section 4.4.2.1 |
| 36 | class 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 |
| 42 | class 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 |
| 49 | class 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 |
| 55 | class 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 |
| 61 | class 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) |