Attention is currently required from: dexter.
laforge has posted comments on this change by dexter. ( https://gerrit.osmocom.org/c/pysim/+/41479?usp=email )
Change subject: pySim-shell: use log level INFO by default
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41479?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I89315f830ce1cc2d573887de4f4cf4e19d17543b
Gerrit-Change-Number: 41479
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-CC: Jenkins Builder
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 21 Nov 2025 11:35:02 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41479?usp=email )
Change subject: pySim-shell: use log level INFO by default
......................................................................
pySim-shell: use log level INFO by default
The default log level of the PySimLogger is DEBUG by default. This is
to ensure that all messages are printed in an unconfigured setup.
However in pySim-Shell we care about configuring the logger, so let's
set the debug log level to INFO in startup. This will allow us to
turn debug messages on and off using the verbose switch.
Change-Id: I89315f830ce1cc2d573887de4f4cf4e19d17543b
Related: SYS#7725
---
M pySim-shell.py
1 file changed, 4 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/79/41479/1
diff --git a/pySim-shell.py b/pySim-shell.py
index 8b0b58e..c629656 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -229,7 +229,7 @@
if new == True:
PySimLogger.set_level(logging.DEBUG)
else:
- PySimLogger.set_level()
+ PySimLogger.set_level(logging.INFO)
class Cmd2ApduTracer(ApduTracer):
def __init__(self, cmd2_app):
@@ -1144,6 +1144,9 @@
if (opts.verbose):
PySimLogger.set_verbose(True)
PySimLogger.set_level(logging.DEBUG)
+ else:
+ PySimLogger.set_verbose(False)
+ PySimLogger.set_level(logging.INFO)
# Register csv-file as card data provider, either from specified CSV
# or from CSV file in home directory
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41479?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I89315f830ce1cc2d573887de4f4cf4e19d17543b
Gerrit-Change-Number: 41479
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41481?usp=email )
Change subject: card_key_provider: refactor code and optimize out get_field method
......................................................................
card_key_provider: refactor code and optimize out get_field method
The method get_field in the base class can be optimized out. This
also allows us to remove code dup in the card_key_provider_get_field
function.
Let's also fix the return code behavior. A get method in a
CardKeyProvider implementation should always return None in case
nothing is found. Also it should not crash in that case. This will
allow the card_key_provider_get function to move on to the next
CardKeyProvider. In case no CardKeyProvider yields any results, an
exception is appropriate since it is pointless to continue execution
with "None" as key material.
To make the debugging of problems easier, let's also print some debug
messages that inform the user what key/value pair and which
CardKeyProvider was queried. This will make it easier to investigate
in case an expected result was not found.
Related: SYS#7725
Change-Id: I4d6367b8eb057e7b2c06c8625094d8a1e4c8eef9
---
M pySim/card_key_provider.py
1 file changed, 25 insertions(+), 24 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/81/41481/1
diff --git a/pySim/card_key_provider.py b/pySim/card_key_provider.py
index cdd871f..b8578fa 100644
--- a/pySim/card_key_provider.py
+++ b/pySim/card_key_provider.py
@@ -132,24 +132,24 @@
class CardKeyProvider(abc.ABC):
"""Base class, not containing any concrete implementation."""
- def get_field(self, field: str, key: str = 'ICCID', value: str = "") -> Optional[str]:
- """get a single field from CSV file using a specified key/value pair"""
- fields = [field]
- result = self.get(fields, key, value)
- return result.get(field)
-
@abc.abstractmethod
def get(self, fields: List[str], key: str, value: str) -> Dict[str, str]:
- """Get multiple card-individual fields for identified card.
+ """
+ Get multiple card-individual fields for identified card. This method should not fail with an exception in
+ case the entry, columns or even the key column itsself is not found.
Args:
fields : list of valid field names such as 'ADM1', 'PIN1', ... which are to be obtained
key : look-up key to identify card data, such as 'ICCID'
value : value for look-up key to identify card data
Returns:
- dictionary of {field, value} strings for each requested field from 'fields'
+ dictionary of {field : value, ...} strings for each requested field from 'fields'. In case nothing is
+ fond None shall be returned.
"""
+ def __str__(self):
+ return type(self).__name__
+
class CardKeyProviderCsv(CardKeyProvider):
"""Card key provider implementation that allows to query against a specified CSV file."""
@@ -172,15 +172,20 @@
raise RuntimeError("Could not open DictReader for CSV-File '%s'" % self.csv_filename)
cr.fieldnames = [field.upper() for field in cr.fieldnames]
- rc = {}
+ if key not in cr.fieldnames:
+ return None
+ return_dict = {}
for row in cr:
if row[key] == value:
for f in fields:
if f in row:
- rc.update({f: self.crypt.decrypt_field(f, row[f])})
+ return_dict.update({f: self.crypt.decrypt_field(f, row[f])})
else:
raise RuntimeError("CSV-File '%s' lacks column '%s'" % (self.csv_filename, f))
- return rc
+ if return_dict == {}:
+ return None
+ return return_dict
+
def card_key_provider_register(provider: CardKeyProvider, provider_list=card_key_providers):
@@ -210,12 +215,14 @@
fields = [f.upper() for f in fields]
for p in provider_list:
if not isinstance(p, CardKeyProvider):
- raise ValueError(
- "provider list contains element which is not a card data provider")
+ raise ValueError("Provider list contains element which is not a card data provider")
+ log.debug("Searching for card key data (key=%s, value=%s, provider=%s)" % (key, value, str(p)))
result = p.get(fields, key, value)
if result:
+ log.debug("Found card data: %s" % (str(result)))
return result
- return {}
+
+ raise ValueError("Unable to find card key data (key=%s, value=%s, fields=%s)" % (key, value, str(fields)))
def card_key_provider_get_field(field: str, key: str, value: str, provider_list=card_key_providers) -> Optional[str]:
@@ -229,13 +236,7 @@
Returns:
dictionary of {field, value} strings for the requested field
"""
- key = key.upper()
- field = field.upper()
- for p in provider_list:
- if not isinstance(p, CardKeyProvider):
- raise ValueError(
- "provider list contains element which is not a card data provider")
- result = p.get_field(field, key, value)
- if result:
- return result
- return None
+
+ fields = [field]
+ result = card_key_provider_get(fields, key, value, card_key_providers)
+ return result.get(field.upper())
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41481?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4d6367b8eb057e7b2c06c8625094d8a1e4c8eef9
Gerrit-Change-Number: 41481
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
dexter has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/41480?usp=email )
Change subject: card_key_provider: remove method _verify_get_data from base class
......................................................................
card_key_provider: remove method _verify_get_data from base class
The method _verify_get_data was intended to be used to verify the
user input before it further processed but ended up to be a simple
check that only checks the name of the key column very basically.
Unfortunately it is difficult to generalize the check code as the
concrete implementation of those checks is highly format dependent.
With the advent of eUICCs, we now have two data formats with
different lookup keys, so a static list with valid lookup keys is
also no longer up to the task.
After all it makes not much sense to keep this method, so let's
remove it.
(From the technical perspective, the key column is not limitied to
any specif field. In theory it would even be possible to use the KI
as lookup key as well, even though it would not make sense in
practice)
Related: SYS#7725
Change-Id: Ibf5745fb8a4f927397adff33900731524715d6a9
---
M pySim/card_key_provider.py
1 file changed, 0 insertions(+), 22 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/80/41480/1
diff --git a/pySim/card_key_provider.py b/pySim/card_key_provider.py
index 0827b70..cdd871f 100644
--- a/pySim/card_key_provider.py
+++ b/pySim/card_key_provider.py
@@ -132,26 +132,6 @@
class CardKeyProvider(abc.ABC):
"""Base class, not containing any concrete implementation."""
- VALID_KEY_FIELD_NAMES = ['ICCID', 'EID', 'IMSI' ]
-
- # check input parameters, but do nothing concrete yet
- def _verify_get_data(self, fields: List[str] = [], key: str = 'ICCID', value: str = "") -> Dict[str, str]:
- """Verify multiple fields for identified card.
-
- Args:
- fields : list of valid field names such as 'ADM1', 'PIN1', ... which are to be obtained
- key : look-up key to identify card data, such as 'ICCID'
- value : value for look-up key to identify card data
- Returns:
- dictionary of {field, value} strings for each requested field from 'fields'
- """
-
- if key not in self.VALID_KEY_FIELD_NAMES:
- raise ValueError("Key field name '%s' is not a valid field name, valid field names are: %s" %
- (key, str(self.VALID_KEY_FIELD_NAMES)))
-
- return {}
-
def get_field(self, field: str, key: str = 'ICCID', value: str = "") -> Optional[str]:
"""get a single field from CSV file using a specified key/value pair"""
fields = [field]
@@ -186,8 +166,6 @@
self.crypt = CardKeyFieldCryptor(transport_keys)
def get(self, fields: List[str], key: str, value: str) -> Dict[str, str]:
- super()._verify_get_data(fields, key, value)
-
self.csv_file.seek(0)
cr = csv.DictReader(self.csv_file)
if not cr:
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/41480?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ibf5745fb8a4f927397adff33900731524715d6a9
Gerrit-Change-Number: 41480
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Attention is currently required from: daniel, laforge, pespin.
fixeria has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bsc/+/41449?usp=email )
Change subject: sccplite: rx mgcp: Make sure payload string is null-terminated
......................................................................
Patch Set 2: Code-Review+2
(1 comment)
File src/osmo-bsc/osmo_bsc_mgcp.c:
https://gerrit.osmocom.org/c/osmo-bsc/+/41449/comment/acd89f7c_760931b0?usp… :
PS2, Line 174: *msg->tail = '\0';
> Yes it's intentional, since the \0 is not part of the message, it's just to allow parsing it using r […]
Acknowledged
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/41449?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iac3ea7dd5d89eb9ffb6d5123700e9dc9cdfc2ea2
Gerrit-Change-Number: 41449
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 21 Nov 2025 10:52:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: pespin <pespin(a)sysmocom.de>
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>
Attention is currently required from: daniel, fixeria, laforge.
pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-bsc/+/41449?usp=email )
Change subject: sccplite: rx mgcp: Make sure payload string is null-terminated
......................................................................
Patch Set 2:
(1 comment)
File src/osmo-bsc/osmo_bsc_mgcp.c:
https://gerrit.osmocom.org/c/osmo-bsc/+/41449/comment/194003de_5a86cf09?usp… :
PS2, Line 174: *msg->tail = '\0';
> Note that `msgb->len` remains unchanged here. […]
Yes it's intentional, since the \0 is not part of the message, it's just to allow parsing it using regular string functions safely.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/41449?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Iac3ea7dd5d89eb9ffb6d5123700e9dc9cdfc2ea2
Gerrit-Change-Number: 41449
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: laforge <laforge(a)osmocom.org>
Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: daniel <dwillmann(a)sysmocom.de>
Gerrit-Comment-Date: Fri, 21 Nov 2025 10:50:01 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de>