From ec628e964e0fb1b13f176943a7275887e8008612 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Fri, 8 Mar 2019 22:18:31 +0100 Subject: [PATCH] client: move ClientSlot from bankd_conn to srv_conn If the client uses a locally-configured (static) ClientId, then the bankd_client_fsm.c code needs access to this information at time of the connect to the server, not just when connecting to the bankd. Change-Id: I8238b4c56c723f9edcf1042f8a7793208c42f15c --- src/client.h | 6 +++--- src/remsim_client.c | 6 +++--- src/remsim_client_fsm.c | 5 ++--- src/simtrace2-remsim_client.c | 8 ++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/client.h b/src/client.h index b2b885c..6f1e959 100644 --- a/src/client.h +++ b/src/client.h @@ -43,6 +43,9 @@ struct rspro_server_conn { /* remote component ID */ struct app_comp_id peer_comp_id; + /* client id and slot number */ + ClientSlot_t *clslot; + /* configuration */ char *server_host; uint16_t server_port; @@ -65,9 +68,6 @@ struct bankd_client { uint16_t bankd_port; struct ipa_client_conn *bankd_conn; struct osmo_fsm_inst *bankd_fi; - - /* client id and slot number */ - ClientSlot_t *clslot; }; void ipa_client_conn_send_rspro(struct ipa_client_conn *ipa, RsproPDU_t *rspro); diff --git a/src/remsim_client.c b/src/remsim_client.c index aa58032..ccf1d22 100644 --- a/src/remsim_client.c +++ b/src/remsim_client.c @@ -105,9 +105,9 @@ static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t *pdu) break; case RsproPDUchoice_PR_configClientReq: /* store/set the clientID as instructed by the server */ - if (!g_client->clslot) - g_client->clslot = talloc_zero(g_client, ClientSlot_t); - *g_client->clslot = pdu->msg.choice.configClientReq.clientSlot; + if (!g_client->srv_conn.clslot) + g_client->srv_conn.clslot = talloc_zero(g_client, ClientSlot_t); + *g_client->srv_conn.clslot = pdu->msg.choice.configClientReq.clientSlot; /* store/set the bankd ip/port as instructed by the server */ osmo_talloc_replace_string(g_client, &g_client->bankd_host, rspro_IpAddr2str(&pdu->msg.choice.configClientReq.bankd.ip)); diff --git a/src/remsim_client_fsm.c b/src/remsim_client_fsm.c index a76a24d..f1af705 100644 --- a/src/remsim_client_fsm.c +++ b/src/remsim_client_fsm.c @@ -85,7 +85,7 @@ static void bdc_st_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_s RsproPDU_t *pdu; /* FIXME: Send ClientConnReq */ - pdu = rspro_gen_ConnectClientReq(&bc->srv_conn.own_comp_id, bc->clslot); + pdu = rspro_gen_ConnectClientReq(&bc->srv_conn.own_comp_id, bc->srv_conn.clslot); ipa_client_conn_send_rspro(bc->bankd_conn, pdu); } @@ -387,8 +387,7 @@ static void srvc_st_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_ ipa_keepalive_fsm_start(srvc->keepalive_fi); - /* FIXME: Bankd in case of Bankd connection! */ - pdu = rspro_gen_ConnectClientReq(&srvc->own_comp_id, NULL); + pdu = rspro_gen_ConnectClientReq(&srvc->own_comp_id, srvc->clslot); ipa_client_conn_send_rspro(srvc->conn, pdu); } diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c index 0832300..ec37379 100644 --- a/src/simtrace2-remsim_client.c +++ b/src/simtrace2-remsim_client.c @@ -404,7 +404,7 @@ static int process_do_rx_da(struct cardem_inst *ci, uint8_t *buf, int len) memcpy(apdu_command + sizeof(ac.hdr), ac.dc, ac.lc.tot); // copy APDU command data } // send APDU to card - RsproPDU_t *pdu = rspro_gen_TpduModem2Card(g_client->clslot, &(BankSlot_t){ .bankId = 0, .slotNr = 0}, apdu_command, sizeof(ac.hdr) + ac.lc.tot); // create RSPRO packet + RsproPDU_t *pdu = rspro_gen_TpduModem2Card(g_client->srv_conn.clslot, &(BankSlot_t){ .bankId = 0, .slotNr = 0}, apdu_command, sizeof(ac.hdr) + ac.lc.tot); // create RSPRO packet ipa_client_conn_send_rspro(g_client->bankd_conn, pdu); // send RSPRO packet // the response will come separately free(apdu_command); @@ -598,9 +598,9 @@ static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t *pdu) break; case RsproPDUchoice_PR_configClientReq: /* store/set the clientID as instructed by the server */ - if (!g_client->clslot) - g_client->clslot = talloc_zero(g_client, ClientSlot_t); - *g_client->clslot = pdu->msg.choice.configClientReq.clientSlot; + if (!g_client->srv_conn.clslot) + g_client->srv_conn.clslot = talloc_zero(g_client, ClientSlot_t); + *g_client->srv_conn.clslot = pdu->msg.choice.configClientReq.clientSlot; /* store/set the bankd ip/port as instructed by the server */ osmo_talloc_replace_string(g_client, &g_client->bankd_host, rspro_IpAddr2str(&pdu->msg.choice.configClientReq.bankd.ip));