laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37137?usp=email )
Change subject: pySim.tlv: Correctly parse COMPREHENSION-TLV without comprehension bit
......................................................................
pySim.tlv: Correctly parse COMPREHENSION-TLV without comprehension bit
The uppermost bit of COMPREHENSION-TLV tags indicates whether the
recipient is required to "comprehend" that IE or not. So every IE
actually has two tag values: one with and one without that bit set.
As all our existing TLV definitions of COMPR_TLV_IE have that bit set,
let's assume this is the default, but use the same definition also for
the situation where that bit is not set.
Change-Id: I58d04ec13be0c12d9fb8cb3d5a0480d0defb6c95
---
M pySim/tlv.py
1 file changed, 33 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/37/37137/1
diff --git a/pySim/tlv.py b/pySim/tlv.py
index 8bf43c6..5835d33 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -224,12 +224,16 @@
val = self.to_bytes(context=context)
return self._encode_tag() + self._encode_len(val) + val
+ def is_tag_compatible(self, rawtag) -> bool:
+ """Is the given rawtag compatible with this class?"""
+ return rawtag == self._compute_tag()
+
def from_tlv(self, do: bytes, context: dict = {}):
if len(do) == 0:
return {}, b''
(rawtag, remainder) = self.__class__._parse_tag_raw(do)
if rawtag:
- if rawtag != self._compute_tag():
+ if not self.is_tag_compatible(rawtag):
raise ValueError("%s: Encountered tag %s doesn't match our supported tag %s" %
(self, rawtag, self.tag))
(length, remainder) = self.__class__._parse_len(remainder)
@@ -283,6 +287,15 @@
def _parse_len(cls, do: bytes) -> Tuple[int, bytes]:
return bertlv_parse_len(do)
+ def is_tag_compatible(self, rawtag: int) -> bool:
+ """Override is_tag_compatible as we need to mask out the
+ comprehension bit when doing compares."""
+ ctag = self._compute_tag()
+ if ctag > 0xff:
+ return ctag & 0x7fff == rawtag & 0x7fff
+ else:
+ return ctag & 0x7f == rawtag & 0x7f
+
def _encode_tag(self) -> bytes:
return comprehensiontlv_encode_tag(self._compute_tag())
@@ -367,6 +380,8 @@
tag, _r = first._parse_tag_raw(remainder)
if tag is None:
break
+ if issubclass(first, COMPR_TLV_IE):
+ tag = tag | 0x80 # HACK: always assume comprehension
if tag in self.members_by_tag:
cls = self.members_by_tag[tag]
# create an instance and parse accordingly
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37137?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I58d04ec13be0c12d9fb8cb3d5a0480d0defb6c95
Gerrit-Change-Number: 37137
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/37136?usp=email )
Change subject: pySim/cat: Fix "Decode the "Type of Comand" from numeric value to a string"
......................................................................
pySim/cat: Fix "Decode the "Type of Comand" from numeric value to a string"
This fixes a bug introduced in Change-Id: I833ec02bf281fe49de2be326018e91f521de52c0
Change-Id: I8b466c123173a5be335df3e1d77ef1c5f717a7d9
---
M pySim/cat.py
1 file changed, 12 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/36/37136/1
diff --git a/pySim/cat.py b/pySim/cat.py
index 875806c..bfd22b4 100644
--- a/pySim/cat.py
+++ b/pySim/cat.py
@@ -1191,7 +1191,7 @@
pcmd.from_tlv(binary)
cmd_details = pcmd.find_cmd_details()
# then do a second decode stage for the specific
- cmd_type = cmd_details.decoded['type_of_command']
+ cmd_type = TypeOfCommand.encmapping[cmd_details.decoded['type_of_command']]
if cmd_type in self.members_by_tag:
cls = self.members_by_tag[cmd_type]
inst = cls()
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37136?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I8b466c123173a5be335df3e1d77ef1c5f717a7d9
Gerrit-Change-Number: 37136
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
Attention is currently required from: osmith.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37010?usp=email )
Change subject: esim.saip: Add ProfileElementSequence.remove_naas_of_type
......................................................................
Patch Set 3:
(2 comments)
File pySim/esim/saip/__init__.py:
https://gerrit.osmocom.org/c/pysim/+/37010/comment/7d618235_a66276df
PS3, Line 562: def remove_naas_of_type(self, naa: Naa) -> None:
> maybe it would be useful if this function printed which instances of NAAs it removed?
I don't like printing by library functions in general, this kind of code might very well be executed in an environment without a console. In tems of returning: The questions is what should it return? The number of matching NAAs removed would be an idea, but then there are many different items removed at various different locations. Which one should count, and which not?
https://gerrit.osmocom.org/c/pysim/+/37010/comment/0cb7572d_08b6127d
PS3, Line 573: if template in hdr.decoded['eUICC-Mandatory-GFSTEList']:
: hdr.decoded['eUICC-Mandatory-GFSTEList'] = [x for x in hdr.decoded['eUICC-Mandatory-GFSTEList'] if not template.prefix_match(x)]
> just to be sure: it cannot be that `template.prefix_match() is True` for any element of `hdr. […]
I'm not following you here, sorry.
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37010?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I64438bf0be58bad7a561c3744b7e9b1338a7857c
Gerrit-Change-Number: 37010
Gerrit-PatchSet: 3
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Attention: osmith <osmith(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 09 Jun 2024 10:15:35 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: osmith <osmith(a)sysmocom.de>
Gerrit-MessageType: comment
Attention is currently required from: pespin.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/docker-playground/+/37125?usp=email )
Change subject: ttcn3-asterisk: Add extra IP addr in ttcn3 docker for IMS Core
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/docker-playground/+/37125?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: docker-playground
Gerrit-Branch: master
Gerrit-Change-Id: I6e5a261748ec61bb1cfa4aafee8c748d0f46aa9e
Gerrit-Change-Number: 37125
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 09 Jun 2024 08:02:38 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: falconia.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/37129?usp=email )
Change subject: add support for RTP extensions via TW-TS-003
......................................................................
Patch Set 1: Code-Review+1
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/37129?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I2a742afff160a9a8286633bf5ae0dd4a828c7a42
Gerrit-Change-Number: 37129
Gerrit-PatchSet: 1
Gerrit-Owner: falconia <falcon(a)freecalypso.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Attention: falconia <falcon(a)freecalypso.org>
Gerrit-Comment-Date: Sat, 08 Jun 2024 19:32:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/37135?usp=email )
Change subject: pySim/cat: Decode the "Type of Comand" from numeric value to a string
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37135?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I833ec02bf281fe49de2be326018e91f521de52c0
Gerrit-Change-Number: 37135
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Comment-Date: Sat, 08 Jun 2024 18:26:58 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/37133?usp=email )
Change subject: pySim.apdu.ts_102_221: Decode the ENVELOPE command body using pySim.cat TLV
......................................................................
pySim.apdu.ts_102_221: Decode the ENVELOPE command body using pySim.cat TLV
This will decode the ENVELOPE body in pySim-trace further.
Before:
00 ENVELOPE - 9000 {'p1': 0, 'p2': 0, 'cmd': 'd14682028381060291978b3c40048111227ff6407070611535002d02700000281516011212000001eae1bd578fa25791898128811b2206cc71639ca292ec2526da8aef4273d2fe2e', 'rsp': '027100001f0a00000100000001200000ab12800101230d08a0000001510000000f829000'}
After:
00 ENVELOPE - 9000 {'p1': 0, 'p2': 0, 'cmd': [{'smspp_download': [{'device_identities': {'source_dev_id': 'network', 'dest_dev_id': 'uicc'}}, {'address': {'ton_npi': 145, 'call_number': '79'}}, {'sms_tpdu': {'tpdu': '40048111227ff6407070611535002d02700000281516011212000001eae1bd578fa25791898128811b2206cc71639ca292ec2526da8aef4273d2fe2e'}}]}], 'rsp': '027100001f0a00000100000001200000ab12800101230d08a0000001510000000f829000'}
Change-Id: I5ecdbe0b5fa8856cb723569896b73cd49778ed5f
---
M pySim/apdu/ts_102_221.py
1 file changed, 22 insertions(+), 1 deletion(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/pySim/apdu/ts_102_221.py b/pySim/apdu/ts_102_221.py
index 52d88d2..5636da2 100644
--- a/pySim/apdu/ts_102_221.py
+++ b/pySim/apdu/ts_102_221.py
@@ -1,7 +1,7 @@
# coding=utf-8
"""APDU definitions/decoders of ETSI TS 102 221, the core UICC spec.
-(C) 2022 by Harald Welte <laforge(a)osmocom.org>
+(C) 2022-2024 by Harald Welte <laforge(a)osmocom.org>
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
@@ -27,6 +27,7 @@
from pySim.runtime import RuntimeLchan
from pySim.apdu import ApduCommand, ApduCommandSet
from pySim.utils import i2h
+from pySim import cat
logger = logging.getLogger(__name__)
@@ -458,6 +459,7 @@
# TS 102 221 Section 11.2.2 / TS 102 223
class Envelope(ApduCommand, n='ENVELOPE', ins=0xC2, cla=['80']):
_apdu_case = 4
+ _tlv = cat.EventCollection
# TS 102 221 Section 11.2.3 / TS 102 223
class Fetch(ApduCommand, n='FETCH', ins=0x12, cla=['80']):
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/37133?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I5ecdbe0b5fa8856cb723569896b73cd49778ed5f
Gerrit-Change-Number: 37133
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged