dexter has submitted this change. (
https://gerrit.osmocom.org/c/pysim/+/33959 )
(
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
)Change subject: pySim-trace: add commandline option --show-raw-apdu
......................................................................
pySim-trace: add commandline option --show-raw-apdu
The trace log currently only shows the parsed APDU. However, depending
on the problem to investigate it may be required to see the raw APDU
string as well. Let's add an option for this.
Related: OS#6094
Change-Id: I1a3bc54c459e45ed3154479759ceecdc26db9d37
---
M pySim-trace.py
1 file changed, 24 insertions(+), 4 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
fixeria: Looks good to me, approved
Jenkins Builder: Verified
diff --git a/pySim-trace.py b/pySim-trace.py
index d457bf4..453ee43 100755
--- a/pySim-trace.py
+++ b/pySim-trace.py
@@ -83,10 +83,13 @@
# parameters
self.suppress_status = kwargs.get('suppress_status', True)
self.suppress_select = kwargs.get('suppress_select', True)
+ self.show_raw_apdu = kwargs.get('show_raw_apdu', False)
self.source = kwargs.get('source', None)
- def format_capdu(self, inst: ApduCommand):
+ def format_capdu(self, apdu: Apdu, inst: ApduCommand):
"""Output a single decoded + processed
ApduCommand."""
+ if self.show_raw_apdu:
+ print(apdu)
print("%02u %-16s %-35s %-8s %s %s" % (inst.lchan_nr, inst._name,
inst.path_str, inst.col_id, inst.col_sw, inst.processed))
print("===============================")
@@ -95,7 +98,6 @@
while True:
# obtain the next APDU from the source (blocking read)
apdu = self.source.read()
- #print(apdu)
if isinstance(apdu, CardReset):
self.rs.reset()
@@ -113,7 +115,7 @@
if self.suppress_status and isinstance(inst, UiccStatus):
continue
#print(inst)
- self.format_capdu(inst)
+ self.format_capdu(apdu, inst)
option_parser = argparse.ArgumentParser(description='Osmocom pySim high-level SIM
card trace decoder',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@@ -128,6 +130,9 @@
help="""
Don't suppress displaying STATUS APDUs. We normally suppress them as they
don't provide any
information that was not already received in resposne to the most recent
SEELCT.""")
+global_group.add_argument('--show-raw-apdu', action='store_true',
dest='show_raw_apdu',
+ help="""Show the raw APDU in addition to its
parsed form.""")
+
subparsers = option_parser.add_subparsers(help='APDU Source',
dest='source', required=True)
@@ -172,7 +177,8 @@
elif opts.source == 'gsmtap-pyshark-pcap':
s = PysharkGsmtapPcap(opts.pcap_file)
- tracer = Tracer(source=s, suppress_status=opts.suppress_status,
suppress_select=opts.suppress_select)
+ tracer = Tracer(source=s, suppress_status=opts.suppress_status,
suppress_select=opts.suppress_select,
+ show_raw_apdu=opts.show_raw_apdu)
logger.info('Entering main loop...')
tracer.main()
--
To view, visit
https://gerrit.osmocom.org/c/pysim/+/33959
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I1a3bc54c459e45ed3154479759ceecdc26db9d37
Gerrit-Change-Number: 33959
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged