laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/38472?usp=email )
Change subject: pySim.ts_31_102: Add support for EF.EARFCNList ......................................................................
pySim.ts_31_102: Add support for EF.EARFCNList
This adds a construct + pyosmocore.tlv based declarative encoder/decoder for the EF.EARFCNList file used in the context of NB-IoT in later release USIMs.
Change-Id: I16797ca58c3ad6ebaf588d04fec011a0cbcfcef3 --- M pySim/ts_31_102.py M tests/pySim-shell_test/export/export.script.ok M tests/pySim-shell_test/file_specific/test_ef_ust.ok M tests/pySim-shell_test/fsdump/fsdump.json.ok 4 files changed, 103 insertions(+), 4 deletions(-)
Approvals: dexter: Looks good to me, approved Jenkins Builder: Verified
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index b82c411..636cf37 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -30,7 +30,7 @@
from construct import Optional as COptional from construct import Int32ub, Nibble, GreedyRange, Struct, FlagsEnum, Switch, this, Int16ub, Padding -from construct import Bytewise, Int24ub, PaddedString, PrefixedArray, If +from construct import Bytewise, Int24ub, Int24sb, PaddedString, PrefixedArray, If
from osmocom.utils import is_hexstr from osmocom.tlv import * @@ -893,6 +893,54 @@ super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) self._construct = BitStruct('rfu'/BitsRFU(7), 'from_preferred'/Flag)
+# TS 31.102 Section 4.2.112 + TS 23.032 Section 6.1 +GadPoint = Struct('latitude'/Int24sb, 'longitude'/Int24sb) + +# TS 31.102 Section 4.2.112 (Rel ??) +class EF_EARFCNList(TransparentEF): + _test_de_encode = [ + # single data object with one EARFCN + one area of 3 points + ('a01a8004000100008112000001100001000002100002000003100003', + [{'earfcn_list_tlv': [{'earfcn': 65536}, + {'geographical_area': [{'latitude': 1, 'longitude': 1048577}, + {'latitude': 2, 'longitude': 1048578}, + {'latitude': 3, 'longitude': 1048579}] }]}] ), + # single data object with one EARFCN + two areas of 3 + 4 points + ('a03480040001000081120000011000010000021000020000031000038118000001100001000002100002000003100003000004100004', + [{'earfcn_list_tlv': [{'earfcn': 65536}, + {'geographical_area': [{'latitude': 1, 'longitude': 1048577}, + {'latitude': 2, 'longitude': 1048578}, + {'latitude': 3, 'longitude': 1048579}] }, + {'geographical_area': [{'latitude': 1, 'longitude': 1048577}, + {'latitude': 2, 'longitude': 1048578}, + {'latitude': 3, 'longitude': 1048579}, + {'latitude': 4, 'longitude': 1048580}] } + ] }] ), + # two concatenated data objects with 3 points each + ('a01a8004000100008112000001100001000002100002000003100003a01a8004000200008112000011100011000012100012000013100013', + [{'earfcn_list_tlv': [{'earfcn': 65536}, + {'geographical_area': [{'latitude': 1, 'longitude': 1048577}, + {'latitude': 2, 'longitude': 1048578}, + {'latitude': 3, 'longitude': 1048579}] }]}, + {'earfcn_list_tlv': [{'earfcn': 131072}, + {'geographical_area': [{'latitude': 17, 'longitude': 1048593}, + {'latitude': 18, 'longitude': 1048594}, + {'latitude': 19, 'longitude': 1048595}] }]} ]), + ] + class Earfcn(BER_TLV_IE, tag=0x80): + _construct = Int32ub + class GeographicalArea(BER_TLV_IE, tag=0x81): + _construct = GreedyRange(GadPoint) + class EarfcnListTlv(BER_TLV_IE, tag=0xa0, nested=[Earfcn,GeographicalArea]): + pass + # we need a collection as there might be multiple concatenated instances + class EarfcnListTlvCollection(TLV_IE_Collection, nested=[EarfcnListTlv]): + pass + def __init__(self, fid='6ffd', sfid=None, name='EF.EARFCNList', size=(30, 100), + desc='EARFCN list for MTC/NB-IOT UEs', **kwargs): + super().__init__(fid, sfid=sfid, name=name, desc=desc, size=size, **kwargs) + self._tlv = self.EarfcnListTlvCollection + # TS 31.102 Section 4.2.114 (Rel 18) class EF_eAKA(TransparentEF): def __init__(self, fid='6f01', sfid=None, name='EF.eAKA', size=(1, 1), @@ -1675,7 +1723,7 @@ # TODO: EF.3GPPPSDATAOFF # TODO: EF.3GPPPSDATAOFFservicelist EF_XCAPConfigData(service=120), - # TODO: EF.EARFCNList + EF_EARFCNList(service=121), EF_MuDMiDConfigData(service=134), EF_eAKA(), EF_OCST(service=148), diff --git a/tests/pySim-shell_test/export/export.script.ok b/tests/pySim-shell_test/export/export.script.ok index 1c3f052..2b8e6b0 100644 --- a/tests/pySim-shell_test/export/export.script.ok +++ b/tests/pySim-shell_test/export/export.script.ok @@ -3604,6 +3604,17 @@ # bad file: MF/ADF.USIM/EF.XCAPConfigData/EF.XCAPConfigData, SW match failed! Expected 9000 and got 6a82: Wrong parameters - File not found # ################################################################################ +# MF/ADF.USIM/EF.EARFCNList # +################################################################################ +# directory: MF/ADF.USIM/EF.EARFCNList (3f00/a0000000871002/6ffd) +# file: EF.EARFCNList (6ffd) +# structure: transparent +# RAW FCP Template: 621e8202412183026ffda506d00120d2010f8a01058b036f0606800200808800 +# Decoded FCP Template: {'file_descriptor': {'file_descriptor_byte': {'shareable': True, 'file_type': 'working_ef', 'structure': 'transparent'}, 'record_len': None, 'num_of_rec': None}, 'file_identifier': '6ffd', 'proprietary_information': {'unknown_ber_tlv_ie_d0': {'raw': '20'}, 'toolkit_access_conditions': {'rfm_create': True, 'rfm_delete_terminate': True, 'other_applet_create': True, 'other_applet_delete_terminate': True}}, 'life_cycle_status_integer': 'operational_activated', 'security_attrib_referenced': {'ef_arr_file_id': '6f06', 'ef_arr_record_nr': 6}, 'file_size': 128, 'short_file_identifier': None} +select MF/ADF.USIM/EF.EARFCNList +update_binary ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff +# +################################################################################ # MF/ADF.USIM/EF.MuDMiDConfigData # ################################################################################ # directory: MF/ADF.USIM/EF.MuDMiDConfigData (3f00/a0000000871002/6ffe) @@ -4873,7 +4884,7 @@ ################################################################################ # Export summary # ################################################################################ -# total files visited: 345 +# total files visited: 346 # bad files: 63 # MF/DF.GSM/EF.SUME/EF.SUME, SW match failed! Expected 9000 and got 6982: Command not allowed - Security status not satisfied # MF/DF.GSM/EF.CPBCCH/EF.CPBCCH, SW match failed! Expected 9000 and got 6a82: Wrong parameters - File not found diff --git a/tests/pySim-shell_test/file_specific/test_ef_ust.ok b/tests/pySim-shell_test/file_specific/test_ef_ust.ok index 8d5596a..332fdc8 100644 --- a/tests/pySim-shell_test/file_specific/test_ef_ust.ok +++ b/tests/pySim-shell_test/file_specific/test_ef_ust.ok @@ -80,6 +80,7 @@ Checking service No 114 (inactive) Checking service No 115 (inactive) Checking service No 120 (inactive) +Checking service No 121 (inactive) Checking service No 122 (active) Checking service No 123 (active) Checking service No 124 (inactive) @@ -104,7 +105,7 @@ Checking service No 147 (inactive) Checking service No 148 (inactive) Checking service No 150 (inactive) -===> 75 service / file inconsistencies detected +===> 76 service / file inconsistencies detected beff9f9de73e04080000ff730000000600000000 beff9f9de73e04080000ff730000000600002000 beff9f9de73e04080000ff730000000600000000 diff --git a/tests/pySim-shell_test/fsdump/fsdump.json.ok b/tests/pySim-shell_test/fsdump/fsdump.json.ok index 9943982..6b82ef4 100644 --- a/tests/pySim-shell_test/fsdump/fsdump.json.ok +++ b/tests/pySim-shell_test/fsdump/fsdump.json.ok @@ -10105,6 +10105,45 @@ "message": "Wrong parameters - File not found" } }, + "MF/ADF.USIM/EF.EARFCNList": { + "path": [ + "MF", + "ADF.USIM", + "EF.EARFCNList" + ], + "fcp_raw": "621e8202412183026ffda506d00120d2010f8a01058b036f0606800200808800", + "fcp": { + "file_descriptor": { + "file_descriptor_byte": { + "shareable": true, + "file_type": "working_ef", + "structure": "transparent" + }, + "record_len": null, + "num_of_rec": null + }, + "file_identifier": "6ffd", + "proprietary_information": { + "unknown_ber_tlv_ie_d0": { + "raw": "20" + }, + "toolkit_access_conditions": { + "rfm_create": true, + "rfm_delete_terminate": true, + "other_applet_create": true, + "other_applet_delete_terminate": true + } + }, + "life_cycle_status_integer": "operational_activated", + "security_attrib_referenced": { + "ef_arr_file_id": "6f06", + "ef_arr_record_nr": 6 + }, + "file_size": 128, + "short_file_identifier": null + }, + "body": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" + }, "MF/ADF.USIM/EF.MuDMiDConfigData": { "path": [ "MF",