laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/29067 )
Change subject: proactive: Send a Terminal Response automatically after a Fetch
......................................................................
proactive: Send a Terminal Response automatically after a Fetch
Change-Id: I43bc994e7517b5907fb40a98d84797c54056c47d
---
M pySim/transport/__init__.py
1 file changed, 43 insertions(+), 7 deletions(-)
Approvals:
Jenkins Builder: Verified
laforge: Looks good to me, approved
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index fb04209..09752ac 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -10,7 +10,7 @@
from pySim.exceptions import *
from pySim.construct import filter_dict
from pySim.utils import sw_match, b2h, h2b, i2h, Hexstr
-from pySim.cat import ProactiveCommand
+from pySim.cat import ProactiveCommand, CommandDetails, DeviceIdentities, Result
#
# Copyright (C) 2009-2010 Sylvain Munaut <tnt(a)246tNt.com>
@@ -42,10 +42,7 @@
"""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."""
- def receive_fetch_raw(self, payload: Hexstr):
- # parse the proactive command
- pcmd = ProactiveCommand()
- parsed = pcmd.from_tlv(h2b(payload))
+ def receive_fetch_raw(self, pcmd: ProactiveCommand, parsed: Hexstr):
# try to find a generic handler like handle_SendShortMessage
handle_name = 'handle_%s' % type(parsed).__name__
if hasattr(self, handle_name):
@@ -167,11 +164,50 @@
# need not concern the caller.
rv = (rv[0], '9000')
# proactive sim as per TS 102 221 Setion 7.4.2
+ # TODO: Check SW manually to avoid recursing on the stack (provided this piece of code stays in this place)
fetch_rv = self.send_apdu_checksw('80120000' + last_sw[2:], sw)
+ # Setting this in case we later decide not to send a terminal
+ # response immediately unconditionally -- the card may still have
+ # something pending even though the last command was not processed
+ # yet.
last_sw = fetch_rv[1]
- print("FETCH: %s" % fetch_rv[0])
+ # parse the proactive command
+ pcmd = ProactiveCommand()
+ parsed = pcmd.from_tlv(h2b(fetch_rv[0]))
+ print("FETCH: %s (%s)" % (fetch_rv[0], type(parsed).__name__))
+ result = Result()
if self.proactive_handler:
- self.proactive_handler.receive_fetch_raw(fetch_rv[0])
+ # Extension point: If this does return a list of TLV objects,
+ # they could be appended after the Result; if the first is a
+ # Result, that cuold replace the one built here.
+ self.proactive_handler.receive_fetch_raw(pcmd, parsed)
+ result.from_dict({'general_result': 'performed_successfully', 'additional_information': ''})
+ else:
+ result.from_dict({'general_result': 'command_beyond_terminal_capability', 'additional_information': ''})
+
+ # Send response immediately, thus also flushing out any further
+ # proactive commands that the card already wants to send
+ #
+ # Structure as per TS 102 223 V4.4.0 Section 6.8
+
+ # The Command Details are echoed from the command that has been processed.
+ (command_details,) = [c for c in pcmd.decoded.children if isinstance(c, CommandDetails)]
+ # The Device Identities are fixed. (TS 102 223 V4.0.0 Section 6.8.2)
+ device_identities = DeviceIdentities()
+ device_identities.from_dict({'source_dev_id': 'terminal', 'dest_dev_id': 'uicc'})
+
+ # Testing hint: The value of tail does not influence the behavior
+ # of an SJA2 that sent ans SMS, so this is implemented only
+ # following TS 102 223, and not fully tested.
+ tail = command_details.to_tlv() + device_identities.to_tlv() + result.to_tlv()
+ # Testing hint: In contrast to the above, this part is positively
+ # essential to get the SJA2 to provide the later parts of a
+ # multipart SMS in response to an OTA RFM command.
+ terminal_response = '80140000' + b2h(len(tail).to_bytes(1, 'big') + tail)
+
+ terminal_response_rv = self.send_apdu(terminal_response)
+ last_sw = terminal_response_rv[1]
+
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/+/29067
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I43bc994e7517b5907fb40a98d84797c54056c47d
Gerrit-Change-Number: 29067
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
laforge has submitted this change. ( https://gerrit.osmocom.org/c/pysim/+/29066 )
Change subject: proactive: Avoid clobbering the output of the command that triggered the FETCH
......................................................................
proactive: Avoid clobbering the output of the command that triggered the FETCH
Change-Id: I2b794a5c5bc808b9703b4bc679c119341a0ed41c
---
M pySim/transport/__init__.py
1 file changed, 9 insertions(+), 4 deletions(-)
Approvals:
Jenkins Builder: Verified
fixeria: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
diff --git a/pySim/transport/__init__.py b/pySim/transport/__init__.py
index 04e6b22..fb04209 100644
--- a/pySim/transport/__init__.py
+++ b/pySim/transport/__init__.py
@@ -160,13 +160,18 @@
sw : string (in hex) of status word (ex. "9000")
"""
rv = self.send_apdu(pdu)
+ last_sw = rv[1]
- while sw == '9000' and sw_match(rv[1], '91xx'):
+ while sw == '9000' and sw_match(last_sw, '91xx'):
+ # It *was* successful after all -- the extra pieces FETCH handled
+ # need not concern the caller.
+ rv = (rv[0], '9000')
# 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])
+ fetch_rv = self.send_apdu_checksw('80120000' + last_sw[2:], sw)
+ last_sw = fetch_rv[1]
+ print("FETCH: %s" % fetch_rv[0])
if self.proactive_handler:
- self.proactive_handler.receive_fetch_raw(rv[0])
+ self.proactive_handler.receive_fetch_raw(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/+/29066
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2b794a5c5bc808b9703b4bc679c119341a0ed41c
Gerrit-Change-Number: 29066
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged
Attention is currently required from: Christian Amsüss.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/29067 )
Change subject: proactive: Send a Terminal Response automatically after a Fetch
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/29067
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I43bc994e7517b5907fb40a98d84797c54056c47d
Gerrit-Change-Number: 29067
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Comment-Date: Sun, 21 Aug 2022 13:16:20 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: Christian Amsüss.
laforge has posted comments on this change. ( https://gerrit.osmocom.org/c/pysim/+/29066 )
Change subject: proactive: Avoid clobbering the output of the command that triggered the FETCH
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit https://gerrit.osmocom.org/c/pysim/+/29066
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I2b794a5c5bc808b9703b4bc679c119341a0ed41c
Gerrit-Change-Number: 29066
Gerrit-PatchSet: 2
Gerrit-Owner: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Attention: Christian Amsüss <chrysn(a)fsfe.org>
Gerrit-Comment-Date: Sun, 21 Aug 2022 13:16:18 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: msuraev.
fixeria has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/29082 )
Change subject: Log more details in osmo_stream_srv_write()
......................................................................
Patch Set 2:
(1 comment)
File src/stream.c:
https://gerrit.osmocom.org/c/libosmo-netif/+/29082/comment/5a3b30ff_195c87a7
PS2, Line 1334: ret
Somehow I missed this. According to man: "Upon successful completion, send() shall return the number of bytes sent. Otherwise, -1 shall be returned and errno set to indicate the error." So here you should do strerror(errno) instead.
--
To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/29082
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: I580c00f3b5ade05ecb20a92ce4ece2854334a41f
Gerrit-Change-Number: 29082
Gerrit-PatchSet: 2
Gerrit-Owner: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: msuraev <msuraev(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 21 Aug 2022 13:13:36 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
Attention is currently required from: neels, pespin, dexter.
msuraev has posted comments on this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/28892 )
Change subject: BSSMAP: add assert to reset resending
......................................................................
Patch Set 3:
(1 comment)
Patchset:
PS3:
> Either I am doing something wrong or... […]
Indeed - see the related ticket: in the absense of config and core files the best guess I have is that smth else has caused the stack corruption which resulted in this crash.
--
To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/28892
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I235bdd42ea82e7b5a1a40f437ca34c49ad239c48
Gerrit-Change-Number: 28892
Gerrit-PatchSet: 3
Gerrit-Owner: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: dexter <pmaier(a)sysmocom.de>
Gerrit-CC: laforge <laforge(a)osmocom.org>
Gerrit-Attention: neels <nhofmeyr(a)sysmocom.de>
Gerrit-Attention: pespin <pespin(a)sysmocom.de>
Gerrit-Attention: dexter <pmaier(a)sysmocom.de>
Gerrit-Comment-Date: Sun, 21 Aug 2022 13:07:50 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: dexter <pmaier(a)sysmocom.de>
Gerrit-MessageType: comment
msuraev has posted comments on this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/29169 )
Change subject: Add basic readme for example code
......................................................................
Set Ready For Review
--
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/29169
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I4c76a48a76ca9afc960ea2f08229bacc79b6fe77
Gerrit-Change-Number: 29169
Gerrit-PatchSet: 1
Gerrit-Owner: msuraev <msuraev(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Comment-Date: Sun, 21 Aug 2022 13:04:42 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
Gerrit-MessageType: comment