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:
parent
c7995e7112
commit
ec628e964e
|
@ -43,6 +43,9 @@ struct rspro_server_conn {
|
||||||
/* remote component ID */
|
/* remote component ID */
|
||||||
struct app_comp_id peer_comp_id;
|
struct app_comp_id peer_comp_id;
|
||||||
|
|
||||||
|
/* client id and slot number */
|
||||||
|
ClientSlot_t *clslot;
|
||||||
|
|
||||||
/* configuration */
|
/* configuration */
|
||||||
char *server_host;
|
char *server_host;
|
||||||
uint16_t server_port;
|
uint16_t server_port;
|
||||||
|
@ -65,9 +68,6 @@ struct bankd_client {
|
||||||
uint16_t bankd_port;
|
uint16_t bankd_port;
|
||||||
struct ipa_client_conn *bankd_conn;
|
struct ipa_client_conn *bankd_conn;
|
||||||
struct osmo_fsm_inst *bankd_fi;
|
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);
|
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;
|
break;
|
||||||
case RsproPDUchoice_PR_configClientReq:
|
case RsproPDUchoice_PR_configClientReq:
|
||||||
/* store/set the clientID as instructed by the server */
|
/* store/set the clientID as instructed by the server */
|
||||||
if (!g_client->clslot)
|
if (!g_client->srv_conn.clslot)
|
||||||
g_client->clslot = talloc_zero(g_client, ClientSlot_t);
|
g_client->srv_conn.clslot = talloc_zero(g_client, ClientSlot_t);
|
||||||
*g_client->clslot = pdu->msg.choice.configClientReq.clientSlot;
|
*g_client->srv_conn.clslot = pdu->msg.choice.configClientReq.clientSlot;
|
||||||
/* store/set the bankd ip/port as instructed by the server */
|
/* store/set the bankd ip/port as instructed by the server */
|
||||||
osmo_talloc_replace_string(g_client, &g_client->bankd_host,
|
osmo_talloc_replace_string(g_client, &g_client->bankd_host,
|
||||||
rspro_IpAddr2str(&pdu->msg.choice.configClientReq.bankd.ip));
|
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;
|
RsproPDU_t *pdu;
|
||||||
|
|
||||||
/* FIXME: Send ClientConnReq */
|
/* 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);
|
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);
|
ipa_keepalive_fsm_start(srvc->keepalive_fi);
|
||||||
|
|
||||||
/* FIXME: Bankd in case of Bankd connection! */
|
pdu = rspro_gen_ConnectClientReq(&srvc->own_comp_id, srvc->clslot);
|
||||||
pdu = rspro_gen_ConnectClientReq(&srvc->own_comp_id, NULL);
|
|
||||||
ipa_client_conn_send_rspro(srvc->conn, pdu);
|
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
|
memcpy(apdu_command + sizeof(ac.hdr), ac.dc, ac.lc.tot); // copy APDU command data
|
||||||
}
|
}
|
||||||
// send APDU to card
|
// 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
|
ipa_client_conn_send_rspro(g_client->bankd_conn, pdu); // send RSPRO packet
|
||||||
// the response will come separately
|
// the response will come separately
|
||||||
free(apdu_command);
|
free(apdu_command);
|
||||||
|
@ -598,9 +598,9 @@ static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t *pdu)
|
||||||
break;
|
break;
|
||||||
case RsproPDUchoice_PR_configClientReq:
|
case RsproPDUchoice_PR_configClientReq:
|
||||||
/* store/set the clientID as instructed by the server */
|
/* store/set the clientID as instructed by the server */
|
||||||
if (!g_client->clslot)
|
if (!g_client->srv_conn.clslot)
|
||||||
g_client->clslot = talloc_zero(g_client, ClientSlot_t);
|
g_client->srv_conn.clslot = talloc_zero(g_client, ClientSlot_t);
|
||||||
*g_client->clslot = pdu->msg.choice.configClientReq.clientSlot;
|
*g_client->srv_conn.clslot = pdu->msg.choice.configClientReq.clientSlot;
|
||||||
/* store/set the bankd ip/port as instructed by the server */
|
/* store/set the bankd ip/port as instructed by the server */
|
||||||
osmo_talloc_replace_string(g_client, &g_client->bankd_host,
|
osmo_talloc_replace_string(g_client, &g_client->bankd_host,
|
||||||
rspro_IpAddr2str(&pdu->msg.choice.configClientReq.bankd.ip));
|
rspro_IpAddr2str(&pdu->msg.choice.configClientReq.bankd.ip));
|
||||||
|
|
Loading…
Reference in New Issue