diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index f95f5d12..7ce10a89 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -1,6 +1,6 @@ /* ISO7816-3 state machine for the card side * - * (C) 2010-2017 by Harald Welte + * (C) 2010-2019 by Harald Welte * (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon * * This program is free software; you can redistribute it and/or modify @@ -233,6 +233,13 @@ struct card_handle { } stats; }; +/* reset all the 'dynamic' state of the card handle to the initial/default values */ +static void card_handle_reset(struct card_handle *ch) +{ + ch->pts.state = PTS_S_WAIT_REQ_PTSS; + ch->tpdu.state = TPDU_S_WAIT_CLA; +} + struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch) { return &ch->uart_tx_queue; @@ -1189,8 +1196,7 @@ struct card_handle *card_emu_init(uint8_t slot_num, uint8_t tc_chan, uint8_t uar ch->atr.len = sizeof(default_atr); memcpy(ch->atr.atr, default_atr, ch->atr.len); - ch->pts.state = PTS_S_WAIT_REQ_PTSS; - ch->tpdu.state = TPDU_S_WAIT_CLA; + card_handle_reset(ch); tc_etu_init(ch->tc_chan, ch);