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
This commit is contained in:
Harald Welte 2019-03-08 22:18:31 +01:00
parent c7995e7112
commit ec628e964e
4 changed files with 12 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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