Change in ...osmo-ccid-firmware[master]: ccid_slot_fsm: Convert from CCID msgb to TPDU msgb

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Oct 10 13:48:41 UTC 2019


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15755


Change subject: ccid_slot_fsm: Convert from CCID msgb to TPDU msgb
......................................................................

ccid_slot_fsm: Convert from CCID msgb to TPDU msgb

Change-Id: I67f684ec098c0fdf4bf75c20d8cdf91b6e6411c2
---
M ccid_common/ccid_slot_fsm.c
1 file changed, 18 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/55/15755/1

diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 90899bd..7b513a5 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -3,6 +3,7 @@
 
 #include <unistd.h>
 #include <errno.h>
+#include <string.h>
 
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/timer.h>
@@ -111,10 +112,25 @@
 				const struct ccid_pc_to_rdr_xfr_block *xfb)
 {
 	struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
+	struct msgb *tpdu;
 
-	LOGPCS(cs, LOGL_DEBUG, "scheduling TPDU transfer\n");
 	ss->seq = xfb->hdr.bSeq;
-	osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_XCEIVE_TPDU_CMD, msg);
+
+	/* must be '0' for TPDU level exchanges or for short APDU */
+	OSMO_ASSERT(xfb->wLevelParameter == 0x0000);
+	OSMO_ASSERT(msgb_length(msg) > xfb->hdr.dwLength);
+
+	/* 'msg' contains the raw CCID message as received from USB. We could create
+	 * a new message buffer for the ISO7816 side here or we could 'strip the CCID
+	 * header off the start of the message. Let's KISS and do a copy here */
+	tpdu = msgb_alloc(512, "TPDU");
+	OSMO_ASSERT(tpdu);
+	memcpy(msgb_data(tpdu), xfb->abData, xfb->hdr.dwLength);
+	msgb_put(tpdu, xfb->hdr.dwLength);
+	msgb_free(msg);
+
+	LOGPCS(cs, LOGL_DEBUG, "scheduling TPDU transfer: %s\n", msgb_hexdump(tpdu));
+	osmo_fsm_inst_dispatch(ss->fi, ISO7816_E_XCEIVE_TPDU_CMD, tpdu);
 	/* continues in iso_fsm_clot_user_cb once response/error/timeout is received */
 }
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/15755
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I67f684ec098c0fdf4bf75c20d8cdf91b6e6411c2
Gerrit-Change-Number: 15755
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191010/ab8ab4d4/attachment.htm>


More information about the gerrit-log mailing list