card_emu: Only transmit NULL byte from the right state

The reader cannot accept a waiting time extension at any time. Rather,
it can only accept it if it is currently  waiting for a procedure byte.
This commit is contained in:
Harald Welte
2016-03-02 10:29:55 +01:00
parent f1697e2dd9
commit dda7355306

View File

@@ -876,7 +876,21 @@ void tc_etu_wtime_half_expired(void *handle)
{
struct card_handle *ch = handle;
/* transmit NULL procedure byte well before waiting time expires */
card_emu_uart_tx(ch->uart_chan, ISO7816_3_PB_NULL);
switch (ch->state) {
case ISO_S_IN_TPDU:
switch (ch->tpdu.state) {
case TPDU_S_WAIT_PB:
case TPDU_S_WAIT_TX:
putchar('N');
card_emu_uart_tx(ch->uart_chan, ISO7816_3_PB_NULL);
break;
default:
break;
}
break;
default:
break;
}
}
/* hardware driver informs us that one (more) ETU has expired */