aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorherlesupreeth <herlesupreeth@gmail.com>2020-09-29 10:11:36 +0200
committerlaforge <laforge@osmocom.org>2020-10-03 07:37:06 +0000
commit4a3580b4c17e286f0613febf9d8d3594734ed6a0 (patch)
treee4912f42640330490fa81414461cde74acbc5a0e
parentf8232db3276ddb5a94233bc43afdf176611fd3b1 (diff)
Move reading of USIM service table to generic USIM class
-rwxr-xr-xpySim-read.py20
-rw-r--r--pySim/cards.py12
2 files changed, 23 insertions, 9 deletions
diff --git a/pySim-read.py b/pySim-read.py
index a4f15f8..3e19a02 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -256,14 +256,20 @@ if __name__ == '__main__':
print("EHPLMN:\n%s" % (res))
else:
print("EHPLMN: Can't read, response code = %s" % (sw,))
+
# EF.UST
- (res, sw) = card.read_binary(EF_USIM_ADF_map['UST'])
- if sw == '9000':
- print("USIM Service Table: %s" % res)
- # Print those which are available
- print("%s" % dec_st(res, table="usim"))
- else:
- print("USIM Service Table: Can't read, response code = %s" % (sw,))
+ try:
+ if card.file_exists(EF_USIM_ADF_map['UST']):
+ # res[0] - EF content of UST
+ # res[1] - Human readable format of services marked available in UST
+ (res, sw) = card.read_ust()
+ if sw == '9000':
+ print("USIM Service Table: %s" % res[0])
+ print("%s" % res[1])
+ else:
+ print("USIM Service Table: Can't read, response code = %s" % (sw,))
+ except Exception as e:
+ print("USIM Service Table: Can't read file -- " + str(e))
#EF.ePDGId - Home ePDG Identifier
try:
diff --git a/pySim/cards.py b/pySim/cards.py
index f2f79e4..a67540f 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -277,6 +277,14 @@ class UsimCard(Card):
EF_USIM_ADF_map['ePDGId'], epdgid_tlv)
return sw
+ def read_ust(self):
+ (res, sw) = self._scc.read_binary(EF_USIM_ADF_map['UST'])
+ if sw == '9000':
+ # Print those which are available
+ return ([res, dec_st(res, table="usim")], sw)
+ else:
+ return ([None, None], sw)
+
class _MagicSimBase(Card):
"""
@@ -772,7 +780,7 @@ class SysmoUSIMSJS1(UsimCard):
data, sw = self._scc.update_record('6F40', 1, data, force_len=True)
-class FairwavesSIM(Card):
+class FairwavesSIM(UsimCard):
"""
FairwavesSIM
@@ -961,7 +969,7 @@ class OpenCellsSim(Card):
# write EF.IMSI
data, sw = self._scc.update_binary('6f07', enc_imsi(p['imsi']))
-class WavemobileSim(Card):
+class WavemobileSim(UsimCard):
"""
WavemobileSim