lists.osmocom.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

gerrit-log

Thread Start a new thread
Download
Threads by month
  • ----- 2026 -----
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2025 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
gerrit-log@lists.osmocom.org

December 2022

  • 1 participants
  • 1979 discussions
Change in pysim[master]: pySim-prog: add python docstring for read_params_csv
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30714 ) Change subject: pySim-prog: add python docstring for read_params_csv ...................................................................... pySim-prog: add python docstring for read_params_csv Change-Id: I098ff56ef38208f2f321194625ff4279ece2023c --- M pySim-prog.py 1 file changed, 6 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim-prog.py b/pySim-prog.py index f106018..b3919ee 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -584,6 +584,12 @@ def read_params_csv(opts, imsi=None, iccid=None): + """ + Read the card parameters from a CSV file. This function will generate the + same dictionary that gen_parameters would generate from parameters passed as + commandline arguments. + """ + row = find_row_in_csv_file(opts.read_csv, opts.num, iccid=iccid, imsi=imsi) if row is not None: row['mcc'] = row.get('mcc', mcc_from_imsi(row.get('imsi'))) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30714 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I098ff56ef38208f2f321194625ff4279ece2023c Gerrit-Change-Number: 30714 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: pySim-prog: add python docstring for read_params_csv
by laforge 23 Dec '22

23 Dec '22
Attention is currently required from: daniel, dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/30714 ) Change subject: pySim-prog: add python docstring for read_params_csv ...................................................................... Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30714 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I098ff56ef38208f2f321194625ff4279ece2023c Gerrit-Change-Number: 30714 Gerrit-PatchSet: 1 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 23 Dec 2022 11:15:45 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in pysim[master]: pySim-prog: make dry-run more realistic
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30636 ) Change subject: pySim-prog: make dry-run more realistic ...................................................................... pySim-prog: make dry-run more realistic The process_card function has a dry-run mode where one can test parameters without actually writing to the card. However, the dry-run feature also does not perform read operations and connects to the card reader at a different point in time. Lets be more accurate here and perform all operations a normal programming cycle would perform but without calling the card.program() method. Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c --- M pySim-prog.py 1 file changed, 14 insertions(+), 21 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved msuraev: Looks good to me, but someone else must approve diff --git a/pySim-prog.py b/pySim-prog.py index 1ea1425..dbf1148 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -718,22 +718,21 @@ def process_card(opts, first, ch): + # Connect transport + ch.get(first) + + # Get card + card = card_detect(opts.type, scc) + if card is None: + print("No card detected!") + return -1 + + # Probe only + if opts.probe: + return 0 + + # Erase if requested (not in dry run mode!) if opts.dry_run is False: - # Connect transport - ch.get(first) - - if opts.dry_run is False: - # Get card - card = card_detect(opts.type, scc) - if card is None: - print("No card detected!") - return -1 - - # Probe only - if opts.probe: - return 0 - - # Erase if requested if opts.erase: print("Formatting ...") card.erase() @@ -746,15 +745,9 @@ imsi = None iccid = None if opts.read_iccid: - if opts.dry_run: - # Connect transport - ch.get(False) (res, _) = scc.read_binary(['3f00', '2fe2'], length=10) iccid = dec_iccid(res) elif opts.read_imsi: - if opts.dry_run: - # Connect transport - ch.get(False) (res, _) = scc.read_binary(EF['IMSI']) imsi = swap_nibbles(res)[3:] else: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30636 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c Gerrit-Change-Number: 30636 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: pySim-prog: rename write_parameters function.
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30637 ) Change subject: pySim-prog: rename write_parameters function. ...................................................................... pySim-prog: rename write_parameters function. The function name "write_parameters" is very generic and since it is called during the programming cycle it should be made clear that it is not about writing parameters to the card. Change-Id: Idaba672987230d7d0dd500409f9fe0b94ba39370 --- M pySim-prog.py 1 file changed, 3 insertions(+), 3 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved msuraev: Looks good to me, but someone else must approve diff --git a/pySim-prog.py b/pySim-prog.py index dbf1148..f106018 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -669,7 +669,7 @@ conn.close() -def write_parameters(opts, params): +def write_parameters_to_csv_and_hlr(opts, params): write_params_csv(opts, params) write_params_hlr(opts, params) @@ -764,8 +764,8 @@ else: print("Dry Run: NOT PROGRAMMING!") - # Write parameters permanently - write_parameters(opts, cp) + # Write parameters to a specified CSV file or an HLR database (not the card) + write_parameters_to_csv_and_hlr(opts, cp) # Batch mode state update and save if opts.num is not None: -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30637 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Idaba672987230d7d0dd500409f9fe0b94ba39370 Gerrit-Change-Number: 30637 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: cards: check length of mnc more restrictively
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30635 ) Change subject: cards: check length of mnc more restrictively ...................................................................... cards: check length of mnc more restrictively Since we now ensure that mnc always has a valid length lets make the check in cards.py more strict. Related: OS#5830 Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd --- M pySim/cards.py 1 file changed, 5 insertions(+), 4 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index 55965d7..4eff38c 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -205,11 +205,12 @@ # perform updates if mnc and abstract_data['extensions']: + # Note: Since we derive the length of the MNC by the string length + # of the mnc parameter, the caller must ensure that mnc has the + # correct length and is padded with zeros (if necessary). mnclen = len(str(mnc)) - if mnclen == 1: - mnclen = 2 - if mnclen > 3: - raise RuntimeError('invalid length of mnc "{}"'.format(mnc)) + if mnclen > 3 or mnclen < 2: + raise RuntimeError('invalid length of mnc "{}", expecting 2 or 3 digits'.format(mnc)) abstract_data['extensions']['mnc_len'] = mnclen if opmode: opmode_num = int(opmode, 16) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30635 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd Gerrit-Change-Number: 30635 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: msuraev <msuraev(a)sysmocom.de> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: pySim-prog: fix handling of mnclen parameter.
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30634 ) Change subject: pySim-prog: fix handling of mnclen parameter. ...................................................................... pySim-prog: fix handling of mnclen parameter. The handling of the mnclen parameter does not work. Lets fix it so that it can be used again with CSV and normal card programming. Lets ensure that depending on the parameter and the defaults it is always ensured that the mnc string has the correct length so that lower layers can deduct the length of the mnc properly by the string length of the mnc. Change-Id: I48a109296efcd7a3f37c183ff53c5fc9544e3cfc Related: OS#5830 --- M pySim-prog.py 1 file changed, 30 insertions(+), 5 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim-prog.py b/pySim-prog.py index 2981ada..1ea1425 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -114,8 +114,8 @@ ) parser.add_option("--mnclen", dest="mnclen", type="choice", help="Length of Mobile Network Code [default: %default]", - default=2, - choices=[2, 3], + default="auto", + choices=["2", "3", "auto"], ) parser.add_option("-m", "--smsc", dest="smsc", help="SMSC number (Start with + for international no.) [default: '00 + country code + 5555']", @@ -319,8 +319,15 @@ # MCC always has 3 digits mcc = lpad(mcc, 3, "0") - # MNC must be at least 2 digits - mnc = lpad(mnc, 2, "0") + + # The MNC must be at least 2 digits long. This is also the most common case. + # The user may specify an explicit length using the --mnclen option. + if opts.mnclen != "auto": + if len(mnc) > int(opts.mnclen): + raise ValueError('mcc is longer than specified in option --mnclen') + mnc = lpad(mnc, int(opts.mnclen), "0") + else: + mnc = lpad(mnc, 2, "0") # Digitize country code (2 or 3 digits) cc_digits = _cc_digits(opts.country) @@ -580,7 +587,25 @@ row = find_row_in_csv_file(opts.read_csv, opts.num, iccid=iccid, imsi=imsi) if row is not None: row['mcc'] = row.get('mcc', mcc_from_imsi(row.get('imsi'))) - row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'))) + + # We cannot determine the MNC length (2 or 3 digits?) from the IMSI + # alone. In cases where the user has specified an mnclen via the + # commandline options we can use that info, otherwise we guess that + # the length is 2, which is also the most common case. + if opts.mnclen != "auto": + if opts.mnclen is "2": + row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'), False)) + elif opts.mnclen is "3": + row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'), True)) + else: + raise ValueError("invalid parameter --mnclen, must be 2 or 3 or auto") + else: + row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'), False)) + + # NOTE: We might concider to specify a new CSV field "mnclen" in our + # CSV files for a better automatization. However, this only makes sense + # when the tools and databases we export our files from will also add + # such a field. pin_adm = None # We need to escape the pin_adm we get from the csv -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30634 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I48a109296efcd7a3f37c183ff53c5fc9544e3cfc Gerrit-Change-Number: 30634 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: pySim-prog: clean up csv file reader function
by laforge 23 Dec '22

23 Dec '22
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/30632 ) Change subject: pySim-prog: clean up csv file reader function ...................................................................... pySim-prog: clean up csv file reader function The function that goes through the CSV file and searches for either IMSI or ICCID or picks a specific line by number is very hard to read and understand. Lets clean it up and add useful error messages Change-Id: I7ae995aa3297e77b983e59c75e1c3ef17e1d7cd4 Related: OS#5830 --- M pySim-prog.py 1 file changed, 31 insertions(+), 9 deletions(-) Approvals: Jenkins Builder: Verified daniel: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/pySim-prog.py b/pySim-prog.py index ade213b..2981ada 100755 --- a/pySim-prog.py +++ b/pySim-prog.py @@ -32,6 +32,7 @@ import sys import traceback import json +import csv from pySim.commands import SimCardCommands from pySim.transport import init_reader @@ -524,37 +525,59 @@ f.close() -def _read_params_csv(opts, iccid=None, imsi=None): - import csv - f = open(opts.read_csv, 'r') +def find_row_in_csv_file(csv_file_name:str, num=None, iccid=None, imsi=None): + """ + Pick a matching row in a CSV file by row number or ICCID or IMSI. When num + is not None, the search parameters iccid and imsi are ignored. When + searching for a specific ICCID or IMSI the caller must set num to None. It + is possible to search for an ICCID or an IMSI at the same time. The first + line that either contains a matching ICCID or IMSI is returned. Unused + search parameters must be set to None. + """ + + f = open(csv_file_name, 'r') cr = csv.DictReader(f) + # Make sure the CSV file contains at least the fields we are searching for + if not 'iccid' in cr.fieldnames: + raise Exception("wrong CSV file format - no field \"iccid\" or missing header!") + if not 'imsi' in cr.fieldnames: + raise Exception("wrong CSV file format - no field \"imsi\" or missing header!") + + # Enforce at least one search parameter + if not num and not iccid and not imsi: + raise Exception("no CSV file search parameters!") + # Lower-case fieldnames cr.fieldnames = [field.lower() for field in cr.fieldnames] 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_iccid is False and opts.read_imsi is False: + # Pick a specific row by line number (num) + if num is not None and iccid is None and imsi is None: if opts.num == i: f.close() return row - i += 1 + + # Pick the first row that contains the specified ICCID if row['iccid'] == iccid: f.close() return row + # Pick the first row that contains the specified IMSI if row['imsi'] == imsi: f.close() return row + i += 1 + f.close() + print("Could not read card parameters from CSV file, no matching entry found.") return None def read_params_csv(opts, imsi=None, iccid=None): - row = _read_params_csv(opts, iccid=iccid, imsi=imsi) + row = find_row_in_csv_file(opts.read_csv, opts.num, iccid=iccid, imsi=imsi) if row is not None: row['mcc'] = row.get('mcc', mcc_from_imsi(row.get('imsi'))) row['mnc'] = row.get('mnc', mnc_from_imsi(row.get('imsi'))) @@ -713,7 +736,6 @@ imsi = opts.imsi cp = read_params_csv(opts, imsi=imsi, iccid=iccid) if cp is None: - print("Error reading parameters from CSV file!\n") return 2 print_parameters(cp) -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30632 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I7ae995aa3297e77b983e59c75e1c3ef17e1d7cd4 Gerrit-Change-Number: 30632 Gerrit-PatchSet: 3 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-MessageType: merged
1 0
0 0
Change in pysim[master]: pySim-prog: rename write_parameters function.
by laforge 23 Dec '22

23 Dec '22
Attention is currently required from: daniel, dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/30637 ) Change subject: pySim-prog: rename write_parameters function. ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30637 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Idaba672987230d7d0dd500409f9fe0b94ba39370 Gerrit-Change-Number: 30637 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 23 Dec 2022 11:15:29 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in pysim[master]: pySim-prog: make dry-run more realistic
by laforge 23 Dec '22

23 Dec '22
Attention is currently required from: daniel, dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/30636 ) Change subject: pySim-prog: make dry-run more realistic ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30636 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I3653bada1ad26bcf75109a935105273ee9d1525c Gerrit-Change-Number: 30636 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 23 Dec 2022 11:15:21 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
Change in pysim[master]: cards: check length of mnc more restrictively
by laforge 23 Dec '22

23 Dec '22
Attention is currently required from: daniel, msuraev, dexter. laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/30635 ) Change subject: cards: check length of mnc more restrictively ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/30635 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Iee8f25416e0cc3be96dff025affb1dc11d919fcd Gerrit-Change-Number: 30635 Gerrit-PatchSet: 2 Gerrit-Owner: dexter <pmaier(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: daniel <dwillmann(a)sysmocom.de> Gerrit-Attention: msuraev <msuraev(a)sysmocom.de> Gerrit-Attention: dexter <pmaier(a)sysmocom.de> Gerrit-Comment-Date: Fri, 23 Dec 2022 11:15:10 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 0
0 0
  • ← Newer
  • 1
  • ...
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • ...
  • 198
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.