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/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/pysim/+/15313 ) Change subject: pySim-prog: Use CSV format with headers ...................................................................... pySim-prog: Use CSV format with headers This way we can have optional fields like pin_adm in the file Also require iccid as identifier for the SIM card Set defaults for optional card parameters. Change-Id: I0d317ea51d0cf582b82157eec6cdec074001a236 --- A csv-format M pySim-prog.py 2 files changed, 44 insertions(+), 15 deletions(-) Approvals: Jenkins Builder: Verified dexter: Looks good to me, but someone else must approve; Verified laforge: Looks good to me, approved diff --git a/csv-format b/csv-format new file mode 100644 index 0000000..808003a --- /dev/null +++ b/csv-format @@ -0,0 +1,16 @@ +This file aims to describe the format of the CSV file pySim uses. + +The first line contains the fieldnames which will be used by pySim. This +avoids having a specific order. + +The field names are the following: + +iccid: ICCID of the card. Used to identify the cards (with --read-iccid) +imsi: IMSI of the card +mcc: Mobile Country Code (optional) +mnc: Mobile Network Code (optional) +smsp: MSISDN of the SMSC (optional) +ki: Ki +opc: OPc +acc: Access class of the SIM (optional) +pin_adm: Admin PIN of the SIM. Needed to reprogram various files diff --git a/pySim-prog.py b/pySim-prog.py index 7edadd7..e00c2d0 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -405,17 +405,20 @@ def print_parameters(params): - print """Generated card parameters : - > Name : %(name)s - > SMSP : %(smsp)s - > ICCID : %(iccid)s - > MCC/MNC : %(mcc)d/%(mnc)d - > IMSI : %(imsi)s - > Ki : %(ki)s - > OPC : %(opc)s - > ACC : %(acc)s - > ADM1(hex): %(pin_adm)s -""" % params + s = ["Generated card parameters :"] + if 'name' in params: + s.append(" > Name : %(name)s") + if 'smsp' in params: + s.append(" > SMSP : %(smsp)s") + s.append(" > ICCID : %(iccid)s") + s.append(" > MCC/MNC : %(mcc)d/%(mnc)d") + s.append(" > IMSI : %(imsi)s") + s.append(" > Ki : %(ki)s") + s.append(" > OPC : %(opc)s") + if 'acc' in params: + s.append(" > ACC : %(acc)s") + s.append(" > ADM1(hex): %(pin_adm)s") + print("\n".join(s) % params) def write_params_csv(opts, params): @@ -430,10 +433,11 @@ def _read_params_csv(opts, imsi): import csv - row = ['name', 'iccid', 'mcc', 'mnc', 'imsi', 'smsp', 'ki', 'opc'] f = open(opts.read_csv, 'r') - cr = csv.DictReader(f, row) + cr = csv.DictReader(f) i = 0 + if not 'iccid' in cr.fieldnames: + raise Exception("CSV file in wrong format!") for row in cr: if opts.num is not None and opts.read_imsi is False: if opts.num == i: @@ -450,8 +454,17 @@ def read_params_csv(opts, imsi): row = _read_params_csv(opts, imsi) if row is not None: - row['mcc'] = int(row['mcc']) - row['mnc'] = int(row['mnc']) + row['mcc'] = int(row.get('mcc', row['imsi'][0:3])) + row['mnc'] = int(row.get('mnc', row['imsi'][3:5])) + pin_adm = None + # We need to escape the pin_adm we get from the csv + if 'pin_adm' in row: + pin_adm = ''.join(['%02x'%(ord(x)) for x in row['pin_adm']]) + # Stay compatible to the odoo csv format + elif 'adm1' in row: + pin_adm = ''.join(['%02x'%(ord(x)) for x in row['adm1']]) + if pin_adm: + row['pin_adm'] = rpad(pin_adm, 16) return row -- To view, visit https://gerrit.osmocom.org/c/pysim/+/15313 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I0d317ea51d0cf582b82157eec6cdec074001a236 Gerrit-Change-Number: 15313 Gerrit-PatchSet: 3 Gerrit-Owner: laforge <laforge at gnumonks.org> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: laforge <laforge at gnumonks.org> Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu> Gerrit-CC: daniel <dwillmann at sysmocom.de> Gerrit-CC: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190904/cd5e4057/attachment.htm>