diff options
author | Harald Welte <laforge@osmocom.org> | 2021-06-05 11:26:36 +0200 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-06-13 22:15:45 +0200 |
commit | 592b32ec919dd6b78e82bb0ab85af0d465125a88 (patch) | |
tree | 279727137460f7c0785d3d6f4ec1a27adf0b9229 | |
parent | f12979dd58f57b4aa9c3a8c1fc55269ba0a5d2aa (diff) |
ts_31_102: Fully support USIM EF.AD
The USIM EF.AD has quite some more bits, it should have a separate
implementation and not reuse te DF.GSM/EF.AD implementation.
Change-Id: Iaf195cb63d5d12fc906a7e7cd85e3fd44589a41e
-rw-r--r-- | pySim/ts_31_102.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 78307a4..24d0f52 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -280,13 +280,15 @@ EF_USIM_ADF_map = { # ADF.USIM ###################################################################### +import enum from struct import unpack, pack from construct import * +from construct import Optional as COptional from pySim.construct import * from pySim.filesystem import * from pySim.tlv import * from pySim.ts_102_221 import EF_ARR -from pySim.ts_51_011 import EF_IMSI, EF_xPLMNwAcT, EF_SPN, EF_CBMI, EF_ACC, EF_PLMNsel, EF_AD +from pySim.ts_51_011 import EF_IMSI, EF_xPLMNwAcT, EF_SPN, EF_CBMI, EF_ACC, EF_PLMNsel from pySim.ts_51_011 import EF_CBMID, EF_CBMIR, EF_ADN, EF_SMS, EF_MSISDN, EF_SMSP, EF_SMSS from pySim.ts_51_011 import EF_SMSR, EF_DCK, EF_EXT, EF_CNL, EF_OPL, EF_MBI, EF_MWIS from pySim.ts_51_011 import EF_MMSN, EF_MMSICP, EF_MMSUP, EF_MMSUCP, EF_VGCS, EF_VGCSS, EF_NIA @@ -559,6 +561,28 @@ class EF_LOCI(TransparentEF): super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size) self._construct = Struct('tmsi'/HexAdapter(Bytes(4)), 'lai'/HexAdapter(Bytes(5)), 'rfu'/Int8ub, 'lu_status'/Int8ub) +# TS 31.102 Section 4.2.18 +class EF_AD(TransparentEF): + class OP_MODE(enum.IntEnum): + normal = 0x00 + type_approval = 0x80 + normal_and_specific_facilities = 0x01 + type_approval_and_specific_facilities = 0x81 + maintenance_off_line = 0x02 + cell_test = 0x04 + + def __init__(self, fid='6fad', sfid=0x03, name='EF.AD', desc='Administrative Data', size={4,6}): + super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size) + self._construct = BitStruct( + # Byte 1 + 'ms_operation_mode'/Bytewise(Enum(Byte, EF_AD.OP_MODE)), + # Byte 2 + 3 + 'additional_info'/Bytewise(FlagsEnum(Int16ub, ciphering_indicator=1, csg_display_control=2, + prose_services=4, extended_drx=8)), + 'rfu'/BitsRFU(4), + 'mnc_len'/BitsInteger(4), + 'extensions'/COptional(Bytewise(GreedyBytesRFU)) + ) # TS 31.102 Section 4.2.23 class EF_PSLOCI(TransparentEF): @@ -821,7 +845,7 @@ class ADF_USIM(CardADF): EF_ACC(sfid=0x06), EF_PLMNsel('6f7b', 0x0d, 'EF.FPLMN', 'Forbidden PLMNs', size={12,None}), EF_LOCI(), - EF_AD(sfid=0x03), + EF_AD(), EF_CBMID(sfid=0x0e), EF_ECC(), EF_CBMIR(), |