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

August 2025

  • 1 participants
  • 1086 discussions
[S] Change in osmo-ci[master]: OBS: --version-append: never override version
by osmith 29 Aug '25

29 Aug '25
Attention is currently required from: fixeria, keith. osmith has posted comments on this change by osmith. ( https://gerrit.osmocom.org/c/osmo-ci/+/40965?usp=email ) Change subject: OBS: --version-append: never override version ...................................................................... Patch Set 1: (1 comment) Commit Message: https://gerrit.osmocom.org/c/osmo-ci/+/40965/comment/abb09878_3c9b55ab?usp=… : PS1, Line 25: While IMHO it is a bad idea to just amend the commit of the last release > Actually, looking at it again: In the case of osmo-sgsn, What I did was pick a bunch of commits, on […] I think it would still be useful to merge this, it prevents an unexpected outcome and gives a warning hinting at what is going on. @axilirator@gmail.com: maybe take a another look at it with this context? :) -- To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/40965?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ci Gerrit-Branch: master Gerrit-Change-Id: I589ceb08b9e1ff2ccdd54e94216b25e1e40f22fe Gerrit-Change-Number: 40965 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: keith <keith(a)rhizomatica.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Attention: keith <keith(a)rhizomatica.org> Gerrit-Comment-Date: Fri, 29 Aug 2025 06:09:41 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: osmith <osmith(a)sysmocom.de> Comment-In-Reply-To: fixeria <vyanitskiy(a)sysmocom.de> Comment-In-Reply-To: keith <keith(a)rhizomatica.org>
1 0
0 0
[XS] Change in osmo-ttcn3-hacks[master]: testenv: fix missing hasattr check
by osmith 29 Aug '25

29 Aug '25
osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40970?usp=email ) Change subject: testenv: fix missing hasattr check ...................................................................... testenv: fix missing hasattr check Fix that commands without a --distro argument ("./testenv.py init osmo-dev" and "./testenv.py clean") fail with: AttributeError: 'Namespace' object has no attribute 'distro' Fixes: 8d21add6 ("testenv: check for --distro without --podman") Change-Id: I138fda5f5807588428bba4eb1593b887fe7357c9 --- M _testenv/testenv/__init__.py 1 file changed, 1 insertion(+), 1 deletion(-) Approvals: pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/_testenv/testenv/__init__.py b/_testenv/testenv/__init__.py index 7a453a5..44e0e92 100644 --- a/_testenv/testenv/__init__.py +++ b/_testenv/testenv/__init__.py @@ -279,7 +279,7 @@ def set_args_defaults(): """Some defaults are set later, e.g. after verifying that --distro is not being used without --podman.""" - if args.distro is None: + if hasattr(args, "distro") and args.distro is None: args.distro = distro_default -- To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/40970?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-ttcn3-hacks Gerrit-Branch: master Gerrit-Change-Id: I138fda5f5807588428bba4eb1593b887fe7357c9 Gerrit-Change-Number: 40970 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-iuh[master]: ranap: Introduce ranap_new_msg_error_ind()
by pespin 28 Aug '25

28 Aug '25
pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-iuh/+/40974?usp=email ) Change subject: ranap: Introduce ranap_new_msg_error_ind() ...................................................................... ranap: Introduce ranap_new_msg_error_ind() Change-Id: I58c75b3e0e0f33f48d077385ffac820a6b2be59e --- M TODO-RELEASE M include/osmocom/ranap/ranap_msg_factory.h M src/ranap_msg_factory.c 3 files changed, 62 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified lynxis lazus: Looks good to me, but someone else must approve diff --git a/TODO-RELEASE b/TODO-RELEASE index f825ac1..7af0fca 100644 --- a/TODO-RELEASE +++ b/TODO-RELEASE @@ -14,3 +14,4 @@ libosmo-ranap move declaration (backwards compatible): asn_debug, asn1_xer_print: use osmocom/iuh/common.h instead of iu_client.h libosmo-ranap move definition (backwards compatible): enum ranap_nsap_addr_enc: use osmocom/ranap/ranap_common.h instead of iu_client.h libosmo-ranap move declaration (backwards compatible): ranap_iu_vty_init, ranap_iu_vty_config_write: use osmocom/ranap/vty.h instead of iu_client.h +libosmo-ranap add API ranap_new_msg_error_ind() diff --git a/include/osmocom/ranap/ranap_msg_factory.h b/include/osmocom/ranap/ranap_msg_factory.h index 0a4bdf2..b1175b0 100644 --- a/include/osmocom/ranap/ranap_msg_factory.h +++ b/include/osmocom/ranap/ranap_msg_factory.h @@ -7,6 +7,7 @@ #include <osmocom/ranap/RANAP_GlobalRNC-ID.h> #include <osmocom/ranap/RANAP_ChosenIntegrityProtectionAlgorithm.h> #include <osmocom/ranap/RANAP_ChosenEncryptionAlgorithm.h> +#include <osmocom/ranap/RANAP_CriticalityDiagnostics.h> #include <osmocom/ranap/RANAP_KeyStatus.h> /*! \brief generate RANAP DIRECT TRANSFER message */ @@ -55,6 +56,12 @@ struct msgb *ranap_new_msg_reset_ack(RANAP_CN_DomainIndicator_t domain, const RANAP_GlobalRNC_ID_t *rnc_id); +/*! \brief generate RANAP ERROR INDICATION message */ +struct msgb *ranap_new_msg_error_ind(const RANAP_Cause_t *cause, + const RANAP_CriticalityDiagnostics_t *criticalityDiagnostics, + const RANAP_CN_DomainIndicator_t *domain, + const RANAP_GlobalRNC_ID_t *rnc_id); + /*! \brief generate RANAP INITIAL UE message */ struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps, diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c index 8f6a99a..794d82d 100644 --- a/src/ranap_msg_factory.c +++ b/src/ranap_msg_factory.c @@ -129,6 +129,60 @@ return msg; } +/*! \brief generate RANAP ERROR INDICATION message */ +struct msgb *ranap_new_msg_error_ind(const RANAP_Cause_t *cause, + const RANAP_CriticalityDiagnostics_t *criticalityDiagnostics, + const RANAP_CN_DomainIndicator_t *domain, + const RANAP_GlobalRNC_ID_t *rnc_id) +{ + RANAP_ErrorIndicationIEs_t ies; + RANAP_ErrorIndication_t out; + struct msgb *msg; + int rc; + + memset(&ies, 0, sizeof(ies)); + + if (cause) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CAUSE_PRESENT; + memcpy(&ies.cause, cause, sizeof(ies.cause)); + } + + if (criticalityDiagnostics) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CRITICALITYDIAGNOSTICS_PRESENT; + memcpy(&ies.criticalityDiagnostics, criticalityDiagnostics, sizeof(ies.criticalityDiagnostics)); + } + + if (domain) { + ies.presenceMask |= ERRORINDICATIONIES_RANAP_CN_DOMAININDICATOR_PRESENT; + ies.cN_DomainIndicator = *domain; + } + + if (rnc_id) { + ies.presenceMask = RESETACKNOWLEDGEIES_RANAP_GLOBALRNC_ID_PRESENT; + OCTET_STRING_noalloc(&ies.globalRNC_ID.pLMNidentity, + rnc_id->pLMNidentity.buf, + rnc_id->pLMNidentity.size); + ies.globalRNC_ID.rNC_ID = rnc_id->rNC_ID; + } + + memset(&out, 0, sizeof(out)); + rc = ranap_encode_errorindicationies(&out, &ies); + if (rc < 0) { + LOGP(DRANAP, LOGL_ERROR, "error encoding ErrorIndication IEs: %d\n", rc); + return NULL; + } + + msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_ErrorIndication, + RANAP_Criticality_ignore, + &asn_DEF_RANAP_ErrorIndication, + &out); + + /* release dynamic allocations attached to dt */ + ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_ErrorIndication, &out); + + return msg; +} + /*! \brief generate RANAP INITIAL UE message */ struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps, const RANAP_GlobalRNC_ID_t *rnc_id, -- To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/40974?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Change-Id: I58c75b3e0e0f33f48d077385ffac820a6b2be59e Gerrit-Change-Number: 40974 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in osmo-iuh[master]: ranap: Introduce ranap_new_msg_error_ind()
by pespin 28 Aug '25

28 Aug '25
Attention is currently required from: lynxis lazus. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-iuh/+/40974?usp=email ) Change subject: ranap: Introduce ranap_new_msg_error_ind() ...................................................................... Patch Set 2: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/osmo-iuh/+/40974?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-iuh Gerrit-Branch: master Gerrit-Change-Id: I58c75b3e0e0f33f48d077385ffac820a6b2be59e Gerrit-Change-Number: 40974 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Thu, 28 Aug 2025 21:56:43 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[S] Change in osmo-ci[master]: OBS: --version-append: never override version
by pespin 28 Aug '25

28 Aug '25
Attention is currently required from: fixeria, osmith. pespin has posted comments on this change by osmith. ( https://gerrit.osmocom.org/c/osmo-ci/+/40965?usp=email ) Change subject: OBS: --version-append: never override version ...................................................................... Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/40965?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-ci Gerrit-Branch: master Gerrit-Change-Id: I589ceb08b9e1ff2ccdd54e94216b25e1e40f22fe Gerrit-Change-Number: 40965 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: keith <keith(a)rhizomatica.org> Gerrit-Attention: osmith <osmith(a)sysmocom.de> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Thu, 28 Aug 2025 21:55:32 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes
1 0
0 0
[XS] Change in osmo-sgsn[master]: ranap: Create iu_rnc upon rx RESET
by pespin 28 Aug '25

28 Aug '25
Attention is currently required from: lynxis lazus. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40976?usp=email ) Change subject: ranap: Create iu_rnc upon rx RESET ...................................................................... Patch Set 1: (1 comment) Patchset: PS1: > Not about this patch, but what should the RNC lifecycle be? […] I'm basically taking what osmo-msc does as a reference here, which has already a way better code logic and data domain tan osmo-sgsn. "iu_rnc" in osmo-sgsn is the equivalent to "ran_peer" in omso-msc. It makes sense to create an iu_rnc the first time a RANAP RESET is received (which should be in any case the first valid message). There's no need to free iu_rnc peers, we will simply mark them as unavailable when signalled by SCCP layer (this will happen once I introduce the iu_rnc_fsm in a follow-up patch, which will be the counterpart of "ran_peer_fsm" in osmo-msc). -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/40976?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: Iaf31271feb4d88881382ed8594d0d8e20e22b194 Gerrit-Change-Number: 40976 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Thu, 28 Aug 2025 21:51:52 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: lynxis lazus <lynxis(a)fe80.eu>
1 0
0 0
[M] Change in osmo-sgsn[master]: ranap: Improve error handling in Rx RESET
by pespin 28 Aug '25

28 Aug '25
Attention is currently required from: lynxis lazus. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40975?usp=email ) Change subject: ranap: Improve error handling in Rx RESET ...................................................................... Patch Set 1: (2 comments) Commit Message: https://gerrit.osmocom.org/c/osmo-sgsn/+/40975/comment/4423ac61_8c9344ea?us… : PS1, Line 8: > please describe a little bit more what fancy error handling you're doing. I'll update the commit description listing the changes plus explaining this also prepares for a follow-up patch adding rnc creation during rx RANAP RESET. File src/sgsn/gprs_ranap.c: https://gerrit.osmocom.org/c/osmo-sgsn/+/40975/comment/0a9a5161_4bf28bb5?us… : PS1, Line 332: /* Send CL RANAP message over SCCP: */ > CL means? Connectionless. The RANAP code is already full of "co" (connected oritentd) vs "cl" everywhere, so I assumed needs to furhter explanation here. -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/40975?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I2a53e10c3903992a42d081e3ec300fbdb9b3c34c Gerrit-Change-Number: 40975 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Thu, 28 Aug 2025 21:47:40 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: lynxis lazus <lynxis(a)fe80.eu>
1 0
0 0
[M] Change in osmo-sgsn[master]: ranap: Improve error handling in Rx RESET
by pespin 28 Aug '25

28 Aug '25
Attention is currently required from: lynxis lazus. pespin has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/40975?usp=email ) Change subject: ranap: Improve error handling in Rx RESET ...................................................................... Patch Set 1: (1 comment) File src/sgsn/gprs_ranap.c: https://gerrit.osmocom.org/c/osmo-sgsn/+/40975/comment/653d6af9_2c9269a9?us… : PS1, Line 679: if (ies->presenceMask & ERRORINDICATIONIES_RANAP_CN_DOMAININDICATOR_PRESENT) { > a reset without domain ie is valid and expect? According to specs the field is marked as "O" (optional), hence also why code from ASN1 files generates a PRESENT define for it. I didn't look for exact causes for missing the IE, but in the event it is forgotten I followed the "be permissive on Rx" here. -- To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/40975?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: osmo-sgsn Gerrit-Branch: master Gerrit-Change-Id: I2a53e10c3903992a42d081e3ec300fbdb9b3c34c Gerrit-Change-Number: 40975 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Attention: lynxis lazus <lynxis(a)fe80.eu> Gerrit-Comment-Date: Thu, 28 Aug 2025 21:45:18 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: No Comment-In-Reply-To: lynxis lazus <lynxis(a)fe80.eu>
1 0
0 0
[XS] Change in pysim[master]: Make sure to select MF before probing for files/Addons
by laforge 28 Aug '25

28 Aug '25
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/40913?usp=email ) Change subject: Make sure to select MF before probing for files/Addons ...................................................................... Make sure to select MF before probing for files/Addons Change-Id: I685367c282f57a8856668a3172a9391a5bbcf2e2 --- M pySim/cards.py M pySim/runtime.py 2 files changed, 5 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, approved diff --git a/pySim/cards.py b/pySim/cards.py index dedb2d6..58e8503 100644 --- a/pySim/cards.py +++ b/pySim/cards.py @@ -112,6 +112,8 @@ def probe(self) -> bool: # EF.DIR is a mandatory EF on all ICCIDs; however it *may* also exist on a TS 51.011 SIM ef_dir = EF_DIR() + # select MF first + self.file_exists("3f00") return self.file_exists(ef_dir.fid) def read_aids(self) -> List[Hexstr]: diff --git a/pySim/runtime.py b/pySim/runtime.py index ec19cb4..2205957 100644 --- a/pySim/runtime.py +++ b/pySim/runtime.py @@ -60,6 +60,9 @@ self.card.set_apdu_parameter( cla=self.profile.cla, sel_ctrl=self.profile.sel_ctrl) + # make sure MF is selected before probing for Addons + self.lchan[0].select('MF') + for addon_cls in self.profile.addons: addon = addon_cls() if addon.probe(self.card): -- To view, visit https://gerrit.osmocom.org/c/pysim/+/40913?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: I685367c282f57a8856668a3172a9391a5bbcf2e2 Gerrit-Change-Number: 40913 Gerrit-PatchSet: 2 Gerrit-Owner: bjoern <bjoern.c3(a)nixda.biz> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: dexter <pmaier(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
[M] Change in pysim[master]: Identify cards by Historical bytes of ATR
by laforge 28 Aug '25

28 Aug '25
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/40914?usp=email ) Change subject: Identify cards by Historical bytes of ATR ...................................................................... Identify cards by Historical bytes of ATR - try to identify the CardModel by just comparing the Historical Bytes if matching by Whole ATR failed - add decompose ATR code from pyscard-contrib Related: OS#6837 Change-Id: Id7555e42290d232a0e0efc47e7d97575007d846f --- M pySim/filesystem.py M pySim/utils.py 2 files changed, 137 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/pySim/filesystem.py b/pySim/filesystem.py index 6712755..1d71e08 100644 --- a/pySim/filesystem.py +++ b/pySim/filesystem.py @@ -39,7 +39,7 @@ from osmocom.tlv import bertlv_parse_one from osmocom.construct import filter_dict, parse_construct, build_construct -from pySim.utils import sw_match +from pySim.utils import sw_match, decomposeATR from pySim.jsonpath import js_path_modify from pySim.commands import SimCardCommands from pySim.exceptions import SwMatchError @@ -1545,6 +1545,13 @@ if atr == card_atr: print("Detected CardModel:", cls.__name__) return True + # if nothing found try to just compare the Historical Bytes of the ATR + card_atr_hb = decomposeATR(card_atr)['hb'] + for atr in cls._atrs: + atr_hb = decomposeATR(atr)['hb'] + if atr_hb == card_atr_hb: + print("Detected CardModel:", cls.__name__) + return True return False @staticmethod diff --git a/pySim/utils.py b/pySim/utils.py index 48a9998..b0443c8 100644 --- a/pySim/utils.py +++ b/pySim/utils.py @@ -15,6 +15,7 @@ # Copyright (C) 2009-2010 Sylvain Munaut <tnt(a)246tNt.com> # Copyright (C) 2021 Harald Welte <laforge(a)osmocom.org> +# Copyright (C) 2009-2022 Ludovic Rousseau # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -585,6 +586,134 @@ raise ValueError('invalid APDU (%s), too short!' % b2h(apdu)) +# ATR handling code under GPL from parseATR: https://github.com/LudovicRousseau/pyscard-contrib +def normalizeATR(atr): + """Transform an ATR in list of integers. + valid input formats are + "3B A7 00 40 18 80 65 A2 08 01 01 52" + "3B:A7:00:40:18:80:65:A2:08:01:01:52" + + Args: + atr: string + Returns: + list of bytes + + >>> normalize("3B:A7:00:40:18:80:65:A2:08:01:01:52") + [59, 167, 0, 64, 24, 128, 101, 162, 8, 1, 1, 82] + """ + atr = atr.replace(":", "") + atr = atr.replace(" ", "") + + res = [] + while len(atr) >= 2: + byte, atr = atr[:2], atr[2:] + res.append(byte) + if len(atr) > 0: + raise ValueError("warning: odd string, remainder: %r" % atr) + + atr = [int(x, 16) for x in res] + return atr + + +# ATR handling code under GPL from parseATR: https://github.com/LudovicRousseau/pyscard-contrib +def decomposeATR(atr_txt): + """Decompose the ATR in elementary fields + + Args: + atr_txt: ATR as a hex bytes string + Returns: + dictionary of field and values + + >>> decomposeATR("3B A7 00 40 18 80 65 A2 08 01 01 52") + { 'T0': {'value': 167}, + 'TB': {1: {'value': 0}}, + 'TC': {2: {'value': 24}}, + 'TD': {1: {'value': 64}}, + 'TS': {'value': 59}, + 'atr': [59, 167, 0, 64, 24, 128, 101, 162, 8, 1, 1, 82], + 'hb': {'value': [128, 101, 162, 8, 1, 1, 82]}, + 'hbn': 7} + """ + ATR_PROTOCOL_TYPE_T0 = 0 + atr_txt = normalizeATR(atr_txt) + atr = {} + + # the ATR itself as a list of integers + atr["atr"] = atr_txt + + # store TS and T0 + atr["TS"] = {"value": atr_txt[0]} + TDi = atr_txt[1] + atr["T0"] = {"value": TDi} + hb_length = TDi & 15 + pointer = 1 + # protocol number + pn = 1 + + # store number of historical bytes + atr["hbn"] = TDi & 0xF + + while pointer < len(atr_txt): + # Check TAi is present + if (TDi | 0xEF) == 0xFF: + pointer += 1 + if "TA" not in atr: + atr["TA"] = {} + atr["TA"][pn] = {"value": atr_txt[pointer]} + + # Check TBi is present + if (TDi | 0xDF) == 0xFF: + pointer += 1 + if "TB" not in atr: + atr["TB"] = {} + atr["TB"][pn] = {"value": atr_txt[pointer]} + + # Check TCi is present + if (TDi | 0xBF) == 0xFF: + pointer += 1 + if "TC" not in atr: + atr["TC"] = {} + atr["TC"][pn] = {"value": atr_txt[pointer]} + + # Check TDi is present + if (TDi | 0x7F) == 0xFF: + pointer += 1 + if "TD" not in atr: + atr["TD"] = {} + TDi = atr_txt[pointer] + atr["TD"][pn] = {"value": TDi} + if (TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0: + atr["TCK"] = True + pn += 1 + else: + break + + # Store historical bytes + atr["hb"] = {"value": atr_txt[pointer + 1 : pointer + 1 + hb_length]} + + # Store TCK + last = pointer + 1 + hb_length + if "TCK" in atr: + try: + atr["TCK"] = {"value": atr_txt[last]} + except IndexError: + atr["TCK"] = {"value": -1} + last += 1 + + if len(atr_txt) > last: + atr["extra"] = atr_txt[last:] + + if len(atr["hb"]["value"]) < hb_length: + missing = hb_length - len(atr["hb"]["value"]) + if missing > 1: + (t1, t2) = ("s", "are") + else: + (t1, t2) = ("", "is") + atr["warning"] = "ATR is truncated: %d byte%s %s missing" % (missing, t1, t2) + + return atr + + class DataObject(abc.ABC): """A DataObject (DO) in the sense of ISO 7816-4. Contrary to 'normal' TLVs where one simply has any number of different TLVs that may occur in any order at any point, ISO 7816 -- To view, visit https://gerrit.osmocom.org/c/pysim/+/40914?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pysim Gerrit-Branch: master Gerrit-Change-Id: Id7555e42290d232a0e0efc47e7d97575007d846f Gerrit-Change-Number: 40914 Gerrit-PatchSet: 3 Gerrit-Owner: bjoern <bjoern.c3(a)nixda.biz> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: dexter <pmaier(a)sysmocom.de> Gerrit-CC: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-CC: pespin <pespin(a)sysmocom.de>
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • ...
  • 109
  • Older →

HyperKitty Powered by HyperKitty version 1.3.12.