laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/41786?usp=email )
Change subject: Print SMSC in pySim-read.py ......................................................................
Print SMSC in pySim-read.py
Change-Id: I17067b68086316d51fd71ba77049874605594e3f --- M pySim-read.py M tests/pySim-prog_test/Fairwaves-SIM.ok M tests/pySim-prog_test/Wavemobile-SIM.ok M tests/pySim-prog_test/fakemagicsim.ok M tests/pySim-prog_test/sysmoISIM-SJA2.ok M tests/pySim-prog_test/sysmoISIM-SJA5.ok M tests/pySim-prog_test/sysmoUSIM-SJS1.ok M tests/pySim-prog_test/sysmosim-gr1.ok 8 files changed, 17 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified dexter: Looks good to me, but someone else must approve; Verified
diff --git a/pySim-read.py b/pySim-read.py index 9829a15..481e9da 100755 --- a/pySim-read.py +++ b/pySim-read.py @@ -44,6 +44,7 @@ from pySim.legacy.cards import card_detect, SimCard, UsimCard, IsimCard from pySim.utils import dec_imsi, dec_iccid from pySim.legacy.utils import format_xplmn_w_act, dec_st, dec_msisdn +from pySim.ts_51_011 import EF_SMSP
option_parser = argparse.ArgumentParser(description='Legacy tool for reading some parts of a SIM card', formatter_class=argparse.ArgumentDefaultsHelpFormatter) @@ -141,6 +142,15 @@ (res, sw) = card.read_record('SMSP', 1) if sw == '9000': print("SMSP: %s" % (res,)) + ef_smsp = EF_SMSP() + smsc_a = ef_smsp.decode_record_bin(h2b(res), 1).get('tp_sc_addr', {}) + smsc_n = smsc_a.get('call_number', None) + if smsc_a.get('ton_npi', {}).get('type_of_number', None) == 'international' and smsc_n is not None: + smsc = '+' + smsc_n + else: + smsc = smsc_n + if smsc is not None: + print("SMSC: %s" % (smsc,)) else: print("SMSP: Can't read, response code = %s" % (sw,))
diff --git a/tests/pySim-prog_test/Fairwaves-SIM.ok b/tests/pySim-prog_test/Fairwaves-SIM.ok index 3751c57..303e8ae 100644 --- a/tests/pySim-prog_test/Fairwaves-SIM.ok +++ b/tests/pySim-prog_test/Fairwaves-SIM.ok @@ -6,6 +6,7 @@ GID1: ffffffffffffffff GID2: ffffffffffffffff SMSP: e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000ffffffffffffffffffffffffffff +SMSC: 0015555 SPN: Fairwaves Show in HPLMN: False Hide in OPLMN: False diff --git a/tests/pySim-prog_test/Wavemobile-SIM.ok b/tests/pySim-prog_test/Wavemobile-SIM.ok index 7a0ecec..3c1e62d 100644 --- a/tests/pySim-prog_test/Wavemobile-SIM.ok +++ b/tests/pySim-prog_test/Wavemobile-SIM.ok @@ -6,6 +6,7 @@ GID1: Can't read file -- SW match failed! Expected 9000 and got 6a82. GID2: Can't read file -- SW match failed! Expected 9000 and got 6a82. SMSP: e1ffffffffffffffffffffffff0581005155f5ffffffffffff000000ffffffffffffffffffffffffffff +SMSC: 0015555 SPN: wavemobile Show in HPLMN: False Hide in OPLMN: False diff --git a/tests/pySim-prog_test/fakemagicsim.ok b/tests/pySim-prog_test/fakemagicsim.ok index 4c366f9..306cef9 100644 --- a/tests/pySim-prog_test/fakemagicsim.ok +++ b/tests/pySim-prog_test/fakemagicsim.ok @@ -6,6 +6,7 @@ GID1: Can't read file -- SW match failed! Expected 9000 and got 9404. GID2: Can't read file -- SW match failed! Expected 9000 and got 9404. SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 +SMSC: 0015555 SPN: Magic Show in HPLMN: True Hide in OPLMN: False diff --git a/tests/pySim-prog_test/sysmoISIM-SJA2.ok b/tests/pySim-prog_test/sysmoISIM-SJA2.ok index 5640171..5e2b45f 100644 --- a/tests/pySim-prog_test/sysmoISIM-SJA2.ok +++ b/tests/pySim-prog_test/sysmoISIM-SJA2.ok @@ -6,6 +6,7 @@ GID1: ffffffffffffffffffff GID2: ffffffffffffffffffff SMSP: ffffffffffffffffffffffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 +SMSC: 0015555 SPN: Magic Show in HPLMN: True Hide in OPLMN: True diff --git a/tests/pySim-prog_test/sysmoISIM-SJA5.ok b/tests/pySim-prog_test/sysmoISIM-SJA5.ok index 28b2875..b6d7862 100644 --- a/tests/pySim-prog_test/sysmoISIM-SJA5.ok +++ b/tests/pySim-prog_test/sysmoISIM-SJA5.ok @@ -6,6 +6,7 @@ GID1: ffffffffffffffffffff GID2: ffffffffffffffffffff SMSP: ffffffffffffffffffffffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 +SMSC: 0015555 SPN: Magic Show in HPLMN: True Hide in OPLMN: True diff --git a/tests/pySim-prog_test/sysmoUSIM-SJS1.ok b/tests/pySim-prog_test/sysmoUSIM-SJS1.ok index 2f48c2c..c669353 100644 --- a/tests/pySim-prog_test/sysmoUSIM-SJS1.ok +++ b/tests/pySim-prog_test/sysmoUSIM-SJS1.ok @@ -6,6 +6,7 @@ GID1: ffffffffffffffffffff GID2: ffffffffffffffffffff SMSP: ffffffffffffffffffffffffffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 +SMSC: 0015555 SPN: Magic Show in HPLMN: True Hide in OPLMN: True diff --git a/tests/pySim-prog_test/sysmosim-gr1.ok b/tests/pySim-prog_test/sysmosim-gr1.ok index 03b6a17..3d926e2 100644 --- a/tests/pySim-prog_test/sysmosim-gr1.ok +++ b/tests/pySim-prog_test/sysmosim-gr1.ok @@ -6,6 +6,7 @@ GID1: Can't read file -- SW match failed! Expected 9000 and got 9404. GID2: Can't read file -- SW match failed! Expected 9000 and got 9404. SMSP: ffffffffffffffffffffffffe1ffffffffffffffffffffffff0581005155f5ffffffffffff000000 +SMSC: 0015555 SPN: Not available Show in HPLMN: False Hide in OPLMN: False