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
changes/97/13497/1
Harald Welte 4 years ago
parent c7995e7112
commit ec628e964e
  1. 6
      src/client.h
  2. 6
      src/remsim_client.c
  3. 5
      src/remsim_client_fsm.c
  4. 8
      src/simtrace2-remsim_client.c

@ -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);

@ -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));

@ -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);
}

@ -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));

Loading…
Cancel
Save