Attention is currently required from: pespin.
osmith has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/30777 )
Change subject: mslookup: use apn functions from libosmocore
......................................................................
Patch Set 1:
(2 comments)
File src/mslookup/mdns_rfc.c:
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/c55ea0f8_a9087fc5
PS1, Line 80: if (osmo_apn_from_str(buf, buf_len, qst->domain) < 0)
> so in here you are assuming that encoding the string into the msg will take always exactly strlen(qs […]
Yes. Each part of the domain is encoded with a label that consists of the size and the string. There's always one more label length than the amount of dots. For example:
"osmocom.org" -> len 11
0x07, 'o', 's', 'm', 'o', 'c', 'o', 'm', 0x03, 'o', 'r', 'g' -> len 12
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/94ad6489_69bf7e46
PS1, Line 105: ret->domain = talloc_size(ret, qname_len - 1);
> I'd expect the string to be longer than the buffer due to \0? Is this correct?
qname_len is the size of the encoded domain name + 0x00 at the end, e.g.
0x07, 'o', 's', 'm', 'o', 'c', 'o', 'm', 0x03, 'o', 'r', 'g', 0x00 -> len 13
Therefore "osmocom.org" with 0x00 at the end needs one char less, so it's correct as written there.
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/30777
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I09d3c617fd6eb4075084ee106d3f3c5803861d2f
Gerrit-Change-Number: 30777
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 13:11:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: osmith.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/30775 )
Change subject: osmo_mdns_rfc_record_decode: check ret of talloc
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/30775
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: Icd0f54a8eb80ca50976f248e017f6e5c727385f3
Gerrit-Change-Number: 30775
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 13:01:01 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: osmith.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-hlr/+/30777 )
Change subject: mslookup: use apn functions from libosmocore
......................................................................
Patch Set 1:
(2 comments)
File src/mslookup/mdns_rfc.c:
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/d0fa1040_a41f19aa
PS1, Line 80: if (osmo_apn_from_str(buf, buf_len, qst->domain) < 0)
so in here you are assuming that encoding the string into the msg will take always exactly strlen(qst->domain) + 1.
Is that correct to assume?
https://gerrit.osmocom.org/c/osmo-hlr/+/30777/comment/d2f0bea4_e217b591
PS1, Line 105: ret->domain = talloc_size(ret, qname_len - 1);
I'd expect the string to be longer than the buffer due to \0? Is this correct?
--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/30777
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I09d3c617fd6eb4075084ee106d3f3c5803861d2f
Gerrit-Change-Number: 30777
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-CC: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 13:00:41 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: Hoernchen, fixeria, pespin.
Hello Jenkins Builder, laforge, fixeria, pespin,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/osmo-trx/+/30416
to look at the new patch set (#32).
Change subject: ms-trx support
......................................................................
ms-trx support
This is basically a trxcon that includes a transceiver, and can just
be used with existing and future apps supporting the trxcon interface,
i.e. mobile or ccch_scan.
Supports bladerf and uhd.
Currently using hardcoded sched/prios aimed at a setup with working,
reliable usb and reserved cores, for example a raspi 4 (ONLY 4, not 3,
not 2, not any other version)
Additionally builds test tools used for development: osmo-trx-syncthing*
see https://osmocom.org/projects/baseband/wiki/MS-side_GPRS for the
project description and details
Change-Id: I36c65a8c725c4da76dc70006cd96b0a2b6878e84
---
M .gitignore
M Makefile.am
M Transceiver52M/Makefile.am
M Transceiver52M/grgsm_vitac/grgsm_vitac.cpp
M Transceiver52M/grgsm_vitac/grgsm_vitac.h
A Transceiver52M/ms/bladerf_specific.h
A Transceiver52M/ms/itrq.h
A Transceiver52M/ms/l1ctl_server.c
A Transceiver52M/ms/l1ctl_server_cb.cpp
A Transceiver52M/ms/logging.c
A Transceiver52M/ms/ms.cpp
A Transceiver52M/ms/ms.h
A Transceiver52M/ms/ms_rx_burst.h
A Transceiver52M/ms/ms_rx_burst_test.cpp
A Transceiver52M/ms/ms_rx_lower.cpp
A Transceiver52M/ms/ms_upper.cpp
A Transceiver52M/ms/ms_upper.h
A Transceiver52M/ms/sch.c
A Transceiver52M/ms/sch.h
A Transceiver52M/ms/uhd_specific.h
M configure.ac
M contrib/jenkins.sh
22 files changed, 3,538 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/16/30416/32
--
To view, visit https://gerrit.osmocom.org/c/osmo-trx/+/30416
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-Change-Id: I36c65a8c725c4da76dc70006cd96b0a2b6878e84
Gerrit-Change-Number: 30416
Gerrit-PatchSet: 32
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: Hoernchen <ewild(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: laforge, dexter.
pespin has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-abis/+/29999 )
Change subject: trau_sync: support more than 40 bytes sync pattern.
......................................................................
Patch Set 5: Code-Review+1
(1 comment)
Patchset:
PS5:
> probably needs an update to TODO-RELEASE as it breaks ABI?
why do you say it breaks ABI? I see only changes in a C file of a struct not allocated outside it.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/29999
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I5be127ed5e39cb154e949b16fb08c26a1d816357
Gerrit-Change-Number: 29999
Gerrit-PatchSet: 5
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 12:35:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: comment
Attention is currently required from: fixeria.
Hello Jenkins Builder, fixeria,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/30773
to look at the new patch set (#2).
Change subject: llc: Initialize gprs_cipher
......................................................................
llc: Initialize gprs_cipher
Change-Id: Ifac6239a3695b69f694eb55574de64a62b0787ed
---
M include/osmocom/gprs/llc/llc.h
M src/llc/llc.c
M tests/llc/llc_prim_test.c
3 files changed, 8 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/73/30773/2
--
To view, visit https://gerrit.osmocom.org/c/libosmo-gprs/+/30773
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Ifac6239a3695b69f694eb55574de64a62b0787ed
Gerrit-Change-Number: 30773
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newpatchset
Attention is currently required from: arehbein.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmocore/+/30703 )
Change subject: libosmocore: Transition to use of 'telnet_init_default'
......................................................................
Patch Set 4: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/30703
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Ibd05d3bc2736256aa45e9e7ec15a98bd14a10454
Gerrit-Change-Number: 30703
Gerrit-PatchSet: 4
Gerrit-Owner: arehbein <arehbein(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: arehbein <arehbein(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 11:16:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
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
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
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
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
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
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
Attention is currently required from: dexter.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/30632 )
Change subject: pySim-prog: clean up csv file reader function
......................................................................
Patch Set 3: Code-Review+2
--
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-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 23 Dec 2022 11:14:29 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment