Check RSPRO component type; print error if type doesn't match

If one component connects to another component, verify that the
remote component type (bank/server/client) matches our expectation.

This is important in order to detect a misconfiguration of port numbers,
for example.

Closes: OS#5548
Change-Id: I89a4fc4331e8a0622f8f146c7fc235d34d990497
changes/29/27929/2
Harald Welte 8 months ago
parent 55f12b8e38
commit 5ae0f31c31
  1. 7
      src/bankd/bankd_main.c
  2. 14
      src/client/remsim_client.c

@ -174,6 +174,13 @@ static int bankd_srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t
switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectBankRes:
if (pdu->msg.choice.connectBankRes.identity.type != ComponentType_remsimServer) {
LOGPFSML(srvc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimServer? "
"Check your IP/Port configuration\n",
pdu->msg.choice.connectBankRes.identity.type);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_DISCONNECT, NULL);
return -1;
}
/* Store 'identity' of server in srvc->peer_comp_id */
rspro_comp_id_retrieve(&srvc->peer_comp_id, &pdu->msg.choice.connectBankRes.identity);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);

@ -67,6 +67,13 @@ static int bankd_handle_rx(struct rspro_server_conn *bankdc, const RsproPDU_t *p
switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectClientRes:
if (pdu->msg.choice.connectClientRes.identity.type != ComponentType_remsimBankd) {
LOGPFSML(bankdc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimBankd? "
"Check your IP/Port configuration\n",
pdu->msg.choice.connectClientRes.identity.type);
osmo_fsm_inst_dispatch(bankdc->fi, SRVC_E_DISCONNECT, NULL);
return -1;
}
/* Store 'identity' of bankd to in peer_comp_id */
rspro_comp_id_retrieve(&bankdc->peer_comp_id, &pdu->msg.choice.connectClientRes.identity);
osmo_fsm_inst_dispatch(bankdc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);
@ -94,6 +101,13 @@ static int srvc_handle_rx(struct rspro_server_conn *srvc, const RsproPDU_t *pdu)
switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectClientRes:
if (pdu->msg.choice.connectClientRes.identity.type != ComponentType_remsimServer) {
LOGPFSML(srvc->fi, LOGL_ERROR, "Server connection to a ComponentType(%ld) != RemsimServer? "
"Check your IP/Port configuration\n",
pdu->msg.choice.connectClientRes.identity.type);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_DISCONNECT, NULL);
return -1;
}
/* Store 'identity' of server in srvc->peer_comp_id */
rspro_comp_id_retrieve(&srvc->peer_comp_id, &pdu->msg.choice.connectClientRes.identity);
osmo_fsm_inst_dispatch(srvc->fi, SRVC_E_CLIENT_CONN_RES, (void *) pdu);

Loading…
Cancel
Save