Change in pysim[master]: sysmo-usim-sjs1: update EF.AD with correct MNC length

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Thu Mar 21 15:24:18 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/13366


Change subject: sysmo-usim-sjs1: update EF.AD with correct MNC length
......................................................................

sysmo-usim-sjs1: update EF.AD with correct MNC length

At the moment EF.AD, which contains the length of the MNC is not
updated. For two digit MNC (the usual case) this is fine since the
length is set to 2 by default. However, when one wants to set an MNC
with 3 digit length the file must be updated, otherwise the third digit
of the MNC is recognized as part of the MSIN.

Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65
Related: OS#3850
---
M pySim-read.py
M pySim/cards.py
2 files changed, 19 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/66/13366/1

diff --git a/pySim-read.py b/pySim-read.py
index 4356453..bcdbca6 100755
--- a/pySim-read.py
+++ b/pySim-read.py
@@ -176,5 +176,12 @@
 	except Exception as e:
 		print "MSISDN: Can't read file -- " + str(e)
 
+	# EF.AD
+	(res, sw) = scc.read_binary(['3f00', '7f20', '6fad'])
+	if sw == '9000':
+		print("AD: %s" % (res,))
+	else:
+		print("AD: Can't read, response code = %s" % (sw,))
+
 	# Done for this card and maybe for everything ?
 	print "Done !\n"
diff --git a/pySim/cards.py b/pySim/cards.py
index 3a5caac..059c954 100644
--- a/pySim/cards.py
+++ b/pySim/cards.py
@@ -118,6 +118,13 @@
 		data, sw = self._scc.update_record(EF['SMSP'], 1, rpad(smsp, 84))
 		return sw
 
+	def update_ad(self, mnc):
+	        data = self._scc.read_binary(EF['AD'], length=None, offset=0)
+                size = len(data[0])/2
+                content = data[0][0:6] + "%02X" % len(str(mnc))
+		data, sw = self._scc.update_binary(EF['AD'], content)
+		return sw
+
 	def read_spn(self):
 		(spn, sw) = self._scc.read_binary(EF['SPN'])
 		if sw == '9000':
@@ -594,6 +601,11 @@
 			if sw != '9000':
 				print("Programming OPLMNwAcT failed with code %s"%sw)
 
+                # EF.AD
+                if p.get('mcc') and p.get('mnc'):
+			sw = self.update_ad(p['mnc'])
+			if sw != '9000':
+				print("Programming AD failed with code %s"%sw)
 
 		# EF.SMSP
 		r = self._scc.select_file(['3f00', '7f10'])

-- 
To view, visit https://gerrit.osmocom.org/13366
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I827092b2c7f7952f54b2d9f8dbda419a0dbfaf65
Gerrit-Change-Number: 13366
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190321/d60185e3/attachment.htm>


More information about the gerrit-log mailing list