mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-23 00:38:33 +03:00
card_emu: Properly handle end of a procedure-byte carrying REQ_CTX
how we proceed changes depending on whether we should continue to receive or transmit...
This commit is contained in:
@@ -540,14 +540,21 @@ static int get_byte_tpdu(struct card_handle *ch, uint8_t *byte)
|
|||||||
/* check if the buffer has now been fully transmitted */
|
/* check if the buffer has now been fully transmitted */
|
||||||
if ((rctx->idx >= td->hdr.data_len) ||
|
if ((rctx->idx >= td->hdr.data_len) ||
|
||||||
(rctx->idx + sizeof(*td) - sizeof(td->hdr) >= rctx->tot_len)) {
|
(rctx->idx + sizeof(*td) - sizeof(td->hdr) >= rctx->tot_len)) {
|
||||||
if (td->flags & CEMU_DATA_F_FINAL) {
|
if (td->flags & CEMU_DATA_F_PB_AND_RX) {
|
||||||
/* this was the final part of the APDU, go
|
/* we have just sent the procedure byte and now
|
||||||
* back to state one*/
|
* need to continue receiving */
|
||||||
card_set_state(ch, ISO_S_WAIT_TPDU);
|
set_tpdu_state(ch, TPDU_S_WAIT_RX);
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: call into USB code to chec if we need
|
/* we have transmitted all bytes */
|
||||||
* to submit a free buffer to accept furthe data
|
if (td->flags & CEMU_DATA_F_FINAL) {
|
||||||
* on bulk out endpoint */
|
/* this was the final part of the APDU, go
|
||||||
|
* back to state one*/
|
||||||
|
card_set_state(ch, ISO_S_WAIT_TPDU);
|
||||||
|
} else {
|
||||||
|
/* FIXME: call into USB code to chec if we need
|
||||||
|
* to submit a free buffer to accept
|
||||||
|
* further data on bulk out endpoint */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
req_ctx_set_state(rctx, RCTX_S_FREE);
|
req_ctx_set_state(rctx, RCTX_S_FREE);
|
||||||
ch->uart_tx_ctx = NULL;
|
ch->uart_tx_ctx = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user