laforge has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/pysim/+/28963 )
Change subject: pySim.transport: Add mechanism for handling for CAT/USAT proactive cmds
......................................................................
pySim.transport: Add mechanism for handling for CAT/USAT proactive cmds
This introduces an optional argument to the LinkBase class constructor,
where the application can pass an instance of a ProactiveHandler derived
class in order to handle the proactive commands that the LinkBase is
automatically fetching whenever the card indicates so.
Change-Id: I844504e2fc1b27ce4fc7ede20b2307e698baa0f6
---
M pySim/transport/__init__.py
1 file changed, 23 insertions(+), 5 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/28963/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28963
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I844504e2fc1b27ce4fc7ede20b2307e698baa0f6
Gerrit-Change-Number: 28963
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset
laforge has uploaded a new patch set (#2). ( https://gerrit.osmocom.org/c/pysim/+/28965 )
Change subject: pySim-shell: Use pySim.cat definitions to print decoded proactive cmds
......................................................................
pySim-shell: Use pySim.cat definitions to print decoded proactive cmds
Register a ProactiveHandler with pySim.transport and call the decoder
from pySim.cat to print a decoded version:
Example usage (exact data only works on my specific card due to the
encrpyted payload):
pySIM-shell (MF/ADF.USIM)> envelope_sms 400881214365877ff6227052000000000302700000201506393535b000118dd46f4ad6b015922f62292350d60af4af191adcbbc35cf4
FETCH: d0378103011300820281838b2c410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c
SendShortMessage(CommandDetails({'command_number': 1, 'type_of_command': 19, 'command_qualifier': 0}),DeviceIdentities({'source_dev_id': 'uicc', 'dest_dev_id': 'network'}),SMS_TPDU({'tpdu': '410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c'}))
SW: 9000, data: d0378103011300820281838b2c410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c
Change-Id: Ia4cdf06a44f46184d0da318bdf67077bc8ac9a1a
---
M pySim-shell.py
1 file changed, 14 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/65/28965/2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28965
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia4cdf06a44f46184d0da318bdf67077bc8ac9a1a
Gerrit-Change-Number: 28965
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-CC: Jenkins Builder
Gerrit-MessageType: newpatchset
laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/pysim/+/28965 )
Change subject: pySim-shell: Use pySim.cat definitions to print decoded proactive cmds
......................................................................
pySim-shell: Use pySim.cat definitions to print decoded proactive cmds
Register a ProactiveHandler with pySim.transport and call the decoder
from pySim.cat to print a decoded version:
Example usage (exact data only works on my specific card due to the
encrpyted payload):
pySIM-shell (MF/ADF.USIM)> envelope_sms 400881214365877ff6227052000000000302700000201506393535b000118dd46f4ad6b015922f62292350d60af4af191adcbbc35cf4
FETCH: d0378103011300820281838b2c410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c
SendShortMessage(CommandDetails({'command_number': 1, 'type_of_command': 19, 'command_qualifier': 0}),DeviceIdentities({'source_dev_id': 'uicc', 'dest_dev_id': 'network'}),SMS_TPDU({'tpdu': '410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c'}))
SW: 9000, data: d0378103011300820281838b2c410008812143658700f621027100001c12b000119660ebdb81be189b5e4389e9e7ab2bc0954f963ad869ed7c
Change-Id: Ia4cdf06a44f46184d0da318bdf67077bc8ac9a1a
---
M pySim-shell.py
1 file changed, 17 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/65/28965/1
diff --git a/pySim-shell.py b/pySim-shell.py
index ce6efb8..41f6685 100755
--- a/pySim-shell.py
+++ b/pySim-shell.py
@@ -2,7 +2,7 @@
# Interactive shell for working with SIM / UICC / USIM / ISIM cards
#
-# (C) 2021 by Harald Welte <laforge(a)osmocom.org>
+# (C) 2021-2022 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
@@ -32,12 +32,14 @@
from pathlib import Path
from io import StringIO
+from pprint import pprint as pp
+
from pySim.exceptions import *
from pySim.commands import SimCardCommands
-from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args
+from pySim.transport import init_reader, ApduTracer, argparse_add_reader_args, ProactiveHandler
from pySim.cards import card_detect, SimCard
from pySim.utils import h2b, swap_nibbles, rpad, b2h, JsonEncoder, bertlv_parse_one, sw_match
-from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str
+from pySim.utils import sanitize_pin_adm, tabulate_str_list, boxed_heading_str, Hexstr
from pySim.card_handler import CardHandler, CardHandlerAuto
from pySim.filesystem import RuntimeState, CardDF, CardADF, CardModel
@@ -49,6 +51,7 @@
from pySim.ara_m import CardApplicationARAM
from pySim.global_platform import CardApplicationISD
from pySim.gsm_r import DF_EIRENE
+from pySim.cat import ProactiveCommand
# we need to import this module so that the SysmocomSJA2 sub-class of
# CardModel is created, which will add the ATR-based matching and
@@ -902,6 +905,16 @@
self._cmd.poutput(
'Negotiated Duration: %u secs, Token: %s, SW: %s' % (duration, token, sw))
+class Proact(ProactiveHandler):
+ def receive_fetch(self, payload: Hexstr):
+ # parse the proactive command
+ pcmd = ProactiveCommand()
+ parsed = pcmd.from_tlv(h2b(payload))
+ # print its parsed representation
+ print(parsed)
+ # TODO: implement the basics, such as SMS Sending, ...
+
+
option_parser = argparse.ArgumentParser(prog='pySim-shell', description='interactive SIM card shell',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@@ -942,7 +955,7 @@
card_key_provider_register(CardKeyProviderCsv(csv_default))
# Init card reader driver
- sl = init_reader(opts)
+ sl = init_reader(opts, proactive_handler = Proact())
if sl is None:
exit(1)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28965
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: Ia4cdf06a44f46184d0da318bdf67077bc8ac9a1a
Gerrit-Change-Number: 28965
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/+/28962 )
Change subject: tlv: Use self._compute_tag() method rather than direct self.tag
......................................................................
tlv: Use self._compute_tag() method rather than direct self.tag
The TLV_IE.from_tlv() method is part of a base class that is inherited
by more specific classes. The official way to obtain the tag is the
inherited-class-provided self._compute_tag() method, and *not* a direct
reference to the self.tag member.
This allows for some more obscure TLV parsers, such as the upcoming one
for Proactive Commands in the CAT/OTA context.
Change-Id: I0cd70e31567edc5a0584336efcb5e4282734f6dd
---
M pySim/tlv.py
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/62/28962/1
diff --git a/pySim/tlv.py b/pySim/tlv.py
index 5acc781..a5baa23 100644
--- a/pySim/tlv.py
+++ b/pySim/tlv.py
@@ -236,7 +236,7 @@
return {}, b''
(rawtag, remainder) = self.__class__._parse_tag_raw(do)
if rawtag:
- if rawtag != self.tag:
+ if rawtag != self._compute_tag():
raise ValueError("%s: Encountered tag %s doesn't match our supported tag %s" %
(self, rawtag, self.tag))
(length, remainder) = self.__class__._parse_len(remainder)
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28962
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I0cd70e31567edc5a0584336efcb5e4282734f6dd
Gerrit-Change-Number: 28962
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/+/28963 )
Change subject: pySim.transport: Add mechanism for handling for CAT/USAT proactive cmds
......................................................................
pySim.transport: Add mechanism for handling for CAT/USAT proactive cmds
This introduces an optional argument to the LinkBase class constructor,
where the application can pass an instance of a ProactiveHandler derived
class in order to handle the proactive commands that the LinkBase is
automatically fetching whenever the card indicates so.
Change-Id: I844504e2fc1b27ce4fc7ede20b2307e698baa0f6
---
M pySim/transport/__init__.py
1 file changed, 15 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/pysim refs/changes/63/28963/1
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 9364b07..bc18b5a 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -9,11 +9,11 @@
from pySim.exceptions import *
from pySim.construct import filter_dict
-from pySim.utils import sw_match, b2h, h2b, i2h
+from pySim.utils import sw_match, b2h, h2b, i2h, Hexstr
#
# Copyright (C) 2009-2010 Sylvain Munaut <tnt(a)246tNt.com>
-# Copyright (C) 2021 Harald Welte <laforge(a)osmocom.org>
+# Copyright (C) 2021-2022 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
@@ -37,13 +37,22 @@
def trace_response(self, cmd, sw, resp):
pass
+class ProactiveHandler(abc.ABC):
+ """Abstract base class representing the interface of some code that handles
+ the proactive commands, as returned by the card in responses to the FETCH
+ command."""
+ @abc.abstractmethod
+ def receive_fetch(payload: Hexstr):
+ pass
class LinkBase(abc.ABC):
"""Base class for link/transport to card."""
- def __init__(self, sw_interpreter=None, apdu_tracer=None):
+ def __init__(self, sw_interpreter=None, apdu_tracer=None,
+ proactive_handler: Optional[ProactiveHandler]=None):
self.sw_interpreter = sw_interpreter
self.apdu_tracer = apdu_tracer
+ self.proactive_handler = proactive_handler
@abc.abstractmethod
def _send_apdu_raw(self, pdu: str) -> Tuple[str, str]:
@@ -137,10 +146,12 @@
"""
rv = self.send_apdu(pdu)
- if sw == '9000' and sw_match(rv[1], '91xx'):
+ while sw == '9000' and sw_match(rv[1], '91xx'):
# proactive sim as per TS 102 221 Setion 7.4.2
rv = self.send_apdu_checksw('80120000' + rv[1][2:], sw)
print("FETCH: %s", rv[0])
+ if self.proactive_handler:
+ self.proactive_handler.receive_fetch(rv[0])
if not sw_match(rv[1], sw):
raise SwMatchError(rv[1], sw.lower(), self.sw_interpreter)
return rv
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/28963
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I844504e2fc1b27ce4fc7ede20b2307e698baa0f6
Gerrit-Change-Number: 28963
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/28961 )
Change subject: contrib/libosmo-pfcp.spec.in: do not disable LTO
......................................................................
contrib/libosmo-pfcp.spec.in: do not disable LTO
AFAICT, everything compiles just fine with -flto=auto.
Change-Id: I632cfd8deaaaa50f0ffba04aca4d422b7b51034e
---
M contrib/libosmo-pfcp.spec.in
1 file changed, 0 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/61/28961/1
diff --git a/contrib/libosmo-pfcp.spec.in b/contrib/libosmo-pfcp.spec.in
index 95dad82..d3cf821 100644
--- a/contrib/libosmo-pfcp.spec.in
+++ b/contrib/libosmo-pfcp.spec.in
@@ -1,7 +1,3 @@
-## Disable LTO for now since it breaks compilation of the tests
-## https://osmocom.org/issues/4113
-%define _lto_cflags %{nil}
-
Name: libosmo-pfcp
Version: @VERSION@
Release: 0
--
To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/28961
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-pfcp
Gerrit-Branch: master
Gerrit-Change-Id: I632cfd8deaaaa50f0ffba04aca4d422b7b51034e
Gerrit-Change-Number: 28961
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-pfcp/+/28960 )
Change subject: contrib/libosmo-pfcp.spec.in: do not depend on systemd
......................................................................
contrib/libosmo-pfcp.spec.in: do not depend on systemd
There is no need to do so, this project has nothing to do with systemd.
Change-Id: I57d6c46a6b9aab161f7ccfa663c26ea2e7f05e7b
---
M contrib/libosmo-pfcp.spec.in
1 file changed, 0 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-pfcp refs/changes/60/28960/1
diff --git a/contrib/libosmo-pfcp.spec.in b/contrib/libosmo-pfcp.spec.in
index 6af8319..95dad82 100644
--- a/contrib/libosmo-pfcp.spec.in
+++ b/contrib/libosmo-pfcp.spec.in
@@ -15,14 +15,10 @@
BuildRequires: libtool >= 2
BuildRequires: lksctp-tools-devel
BuildRequires: pkgconfig >= 0.20
-%if 0%{?suse_version}
-BuildRequires: systemd-rpm-macros
-%endif
BuildRequires: pkgconfig(libosmocore) >= 1.6.0
BuildRequires: pkgconfig(libosmoctrl) >= 1.6.0
BuildRequires: pkgconfig(libosmovty) >= 1.6.0
BuildRequires: pkgconfig(talloc)
-%{?systemd_requires}
%description
libosmo-pfcp: PFCP protocol encoding and decoding, and generic PFCP endpoint implementation
--
To view, visit https://gerrit.osmocom.org/c/libosmo-pfcp/+/28960
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-pfcp
Gerrit-Branch: master
Gerrit-Change-Id: I57d6c46a6b9aab161f7ccfa663c26ea2e7f05e7b
Gerrit-Change-Number: 28960
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange