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