From aa66d91edae4c122286b48b30412d4fe09e4d424 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 25 May 2020 23:05:31 +0200 Subject: [PATCH] user_shell: Dispatch all events via main_fsm.c ... avoid calling server_conn_send_rspro() directly from user code. Change-Id: I7f589ea1b1610e6d716ed0d9f4078b185bc6401d --- src/client/user_shell.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/client/user_shell.c b/src/client/user_shell.c index 9c804c6..c8f1b5f 100644 --- a/src/client/user_shell.c +++ b/src/client/user_shell.c @@ -74,21 +74,30 @@ struct stdin_state { static void handle_stdin_command(struct stdin_state *ss, char *cmd) { struct bankd_client *bc = ss->bc; - RsproPDU_t *pdu; - BankSlot_t bslot; - uint8_t buf[1024]; int rc; - bank_slot2rspro(&bslot, &bc->bankd_slot); - OSMO_ASSERT(ss->rx_msg); if (!strcasecmp(cmd, "RESET")) { /* reset the [remote] card */ - pdu = rspro_gen_ClientSlotStatusInd(bc->srv_conn.clslot, &bslot, - true, false, false, true); - server_conn_send_rspro(&bc->bankd_conn, pdu); + struct frontend_phys_status pstatus = { + .flags = { + .reset_active = true, + .vcc_present = false, + .clk_active = false, + .card_present = true, + }, + .voltage_mv = 0, + .fi = 0, + .di = 0, + .wi = 0, + .waiting_time = 0, + }; + osmo_fsm_inst_dispatch(bc->main_fi, MF_E_MDM_STATUS_IND, &pstatus); } else { + struct frontend_tpdu ftpdu; + uint8_t buf[1024]; + /* we assume the user has entered a C-APDU as hex string. parse + send */ rc = osmo_hexparse(cmd, buf, sizeof(buf)); if (rc < 0) { @@ -101,8 +110,9 @@ static void handle_stdin_command(struct stdin_state *ss, char *cmd) } /* Send CMD APDU to [remote] card */ - pdu = rspro_gen_TpduModem2Card(bc->srv_conn.clslot, &bslot, buf, rc); - server_conn_send_rspro(&bc->bankd_conn, pdu); + ftpdu.buf = buf; + ftpdu.len = rc; + osmo_fsm_inst_dispatch(bc->main_fi, MF_E_MDM_TPDU, &ftpdu); } }