diff options
author | Sebastian Viviani <guilly@gmail.com> | 2020-06-03 08:57:00 +0100 |
---|---|---|
committer | Sebastian Viviani <guilly@gmail.com> | 2020-06-09 10:10:28 +0100 |
commit | e61170c0eb85daa8ac5deabc8a62e00c9b33d800 (patch) | |
tree | 2892f7c3bbbaa5f98de1401d728656c90e8f6d18 | |
parent | 0e9f93fdd613ec53b9123335bc6f1ed71b8a06b6 (diff) |
utils.py add LOCI EFs decode functions
The LOCI, PSLOCI and EPSLOCI contain some info,
including the PLMN, added helper functions to
decode it
Change-Id: Ibb513ff7d1dc6d33b354ae26cbd9c390ea3c8efc
-rw-r--r-- | pySim/ts_31_102.py | 6 | ||||
-rw-r--r-- | pySim/utils.py | 30 |
2 files changed, 36 insertions, 0 deletions
diff --git a/pySim/ts_31_102.py b/pySim/ts_31_102.py index 473e595..215ed4c 100644 --- a/pySim/ts_31_102.py +++ b/pySim/ts_31_102.py @@ -137,6 +137,12 @@ EF_UST_map = { 111: 'ePDG configuration Information for Emergency Service configured', } +LOCI_STATUS_map = { + 0: 'updated', + 1: 'not updated', + 2: 'plmn not allowed', + 3: 'locatation area not allowed' +} EF_USIM_ADF_map = { 'LI': '6F05', 'ARR': '6F06', diff --git a/pySim/utils.py b/pySim/utils.py index 496b918..2ca6165 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -183,6 +183,36 @@ def format_xplmn_w_act(hexstr): s += "\t%s # %s\n" % (rec_data, rec_str) return s +def dec_loci(hexstr): + res = {'tmsi': '', 'mcc': 0, 'mnc': 0, 'lac': '', 'status': 0} + res['tmsi'] = hexstr[:8] + res['mcc'] = dec_mcc_from_plmn(hexstr[8:14]) + res['mnc'] = dec_mnc_from_plmn(hexstr[8:14]) + res['lac'] = hexstr[14:18] + res['status'] = h2i(hexstr[20:22]) + return res + +def dec_psloci(hexstr): + res = {'p-tmsi': '', 'p-tmsi-sig': '', 'mcc': 0, 'mnc': 0, 'lac': '', 'rac': '', 'status': 0} + res['p-tmsi'] = hexstr[:8] + res['p-tmsi-sig'] = hexstr[8:14] + res['mcc'] = dec_mcc_from_plmn(hexstr[14:20]) + res['mnc'] = dec_mnc_from_plmn(hexstr[14:20]) + res['lac'] = hexstr[20:24] + res['rac'] = hexstr[24:26] + res['status'] = h2i(hexstr[26:28]) + return res + +def dec_epsloci(hexstr): + res = {'guti': '', 'mcc': 0, 'mnc': 0, 'tac': '', 'status': 0} + res['guti'] = hexstr[:24] + res['tai'] = hexstr[24:34] + res['mcc'] = dec_mcc_from_plmn(hexstr[24:30]) + res['mnc'] = dec_mnc_from_plmn(hexstr[24:30]) + res['tac'] = hexstr[30:34] + res['status'] = h2i(hexstr[34:36]) + return res + def derive_milenage_opc(ki_hex, op_hex): """ Run the milenage algorithm to calculate OPC from Ki and OP |