Change in pysim[master]: Add option to keep cards' ICCID when programming

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/.

Max gerrit-no-reply at lists.osmocom.org
Thu Jan 3 09:25:54 UTC 2019


Max has uploaded this change for review. ( https://gerrit.osmocom.org/12460


Change subject: Add option to keep cards' ICCID when programming
......................................................................

Add option to keep cards' ICCID when programming

This makes it easier to change only the network-related parameters while
keeping SIM-specific data (used for inventory or DB for example) intact.

Change-Id: I7a9c2fdd6af081fe478f1007bc322f3d7cb8d350
---
M pySim-prog.py
1 file changed, 12 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/60/12460/1

diff --git a/pySim-prog.py b/pySim-prog.py
index d6d7ad5..0c1e634 100755
--- a/pySim-prog.py
+++ b/pySim-prog.py
@@ -128,6 +128,9 @@
 	parser.add_option("--read-imsi", dest="read_imsi", action="store_true",
 			help="Read the IMSI from the CARD", default=False
 		)
+	parser.add_option("--keep-iccid", dest="keep_iccid", action="store_true",
+			help="Use ICCID of the card as is", default=False
+		)
 	parser.add_option("-z", "--secret", dest="secret", metavar="STR",
 			help="Secret used for ICCID/IMSI autogen",
 		)
@@ -173,8 +176,8 @@
 		if options.read_csv is None:
 			parser.error("CSV mode requires a CSV input file")
 	elif options.source == 'cmdline':
-		if ((options.imsi is None) or (options.iccid is None)) and (options.num is None):
-			parser.error("If either IMSI or ICCID isn't specified, num is required")
+		if ((options.imsi is None) or (options.iccid is None)) and (options.num is None) and (options.keep_iccid is False):
+			parser.error("If either IMSI or ICCID isn't specified, num or keep-iccid is required")
 	else:
 		parser.error("Only `cmdline' and `csv' sources supported")
 
@@ -267,7 +270,9 @@
 		iccid = opts.iccid
 		if not _isnum(iccid, 19) and not _isnum(iccid, 20):
 			raise ValueError('ICCID must be 19 or 20 digits !');
-
+        elif opts.keep_iccid is True:
+                # will be filled by the caller
+                iccid = 0
 	else:
 		if opts.num is None:
 			raise ValueError('Neither ICCID nor card number specified !')
@@ -620,7 +625,10 @@
 
 		# Generate parameters
 		if opts.source == 'cmdline':
-			cp = gen_parameters(opts)
+                        cp = gen_parameters(opts)
+                        if opts.keep_iccid is True:
+                                (res, _) = scc.read_binary(EF['ICCID'])
+                                cp['iccid'] = dec_iccid(res)
 		elif opts.source == 'csv':
 			if opts.read_imsi:
 				if opts.dry_run:

-- 
To view, visit https://gerrit.osmocom.org/12460
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: I7a9c2fdd6af081fe478f1007bc322f3d7cb8d350
Gerrit-Change-Number: 12460
Gerrit-PatchSet: 1
Gerrit-Owner: Max <msuraev at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190103/488f3cd7/attachment.htm>


More information about the gerrit-log mailing list