rspro_client_fsm: Disconnect if Connect{Client,Bank}Res != ok

Change-Id: Id199f9c4cb4c86fd0dba8939334ac69878f4a3f5
changes/97/13497/1
Harald Welte 4 years ago
parent ce638d8fd7
commit 4e7a285427
  1. 15
      src/rspro_client_fsm.c
  2. 22
      src/rspro_util.c
  3. 2
      src/rspro_util.h

@ -223,14 +223,25 @@ static void srvc_st_established_onenter(struct osmo_fsm_inst *fi, uint32_t prev_
static void srvc_st_established(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv;
RsproPDU_t *pdu = NULL;
e_ResultCode res;
switch (event) {
case SRVC_E_TCP_DOWN:
case SRVC_E_KA_TIMEOUT:
osmo_fsm_inst_state_chg(fi, SRVC_ST_REESTABLISH, T2_RECONNECT, 2);
break;
case SRVC_E_CLIENT_CONN_RES:
/* somehow notify the main code? */
osmo_fsm_inst_state_chg(fi, SRVC_ST_CONNECTED, 0, 0);
pdu = data;
res = rspro_get_result(pdu);
if (res != ResultCode_ok) {
ipa_client_conn_close(srvc->conn);
osmo_fsm_inst_dispatch(fi, SRVC_E_TCP_DOWN, NULL);
} else {
/* somehow notify the main code? */
osmo_fsm_inst_state_chg(fi, SRVC_ST_CONNECTED, 0, 0);
}
break;
default:
OSMO_ASSERT(0);

@ -376,6 +376,28 @@ RsproPDU_t *rspro_gen_TpduCard2Modem(const BankSlot_t *bank, const ClientSlot_t
return pdu;
}
e_ResultCode rspro_get_result(const RsproPDU_t *pdu)
{
switch (pdu->msg.present) {
case RsproPDUchoice_PR_connectBankRes:
return pdu->msg.choice.connectBankRes.result;
case RsproPDUchoice_PR_connectClientRes:
return pdu->msg.choice.connectClientRes.result;
case RsproPDUchoice_PR_createMappingRes:
return pdu->msg.choice.createMappingRes.result;
case RsproPDUchoice_PR_removeMappingRes:
return pdu->msg.choice.removeMappingRes.result;
case RsproPDUchoice_PR_configClientIdRes:
return pdu->msg.choice.configClientIdRes.result;
case RsproPDUchoice_PR_configClientBankRes:
return pdu->msg.choice.configClientBankRes.result;
case RsproPDUchoice_PR_setAtrRes:
return pdu->msg.choice.setAtrRes.result;
default:
OSMO_ASSERT(0);
}
}
void rspro2bank_slot(struct bank_slot *out, const BankSlot_t *in)
{
out->bank_id = in->bankId;

@ -42,6 +42,8 @@ RsproPDU_t *rspro_gen_TpduModem2Card(const ClientSlot_t *client, const BankSlot_
RsproPDU_t *rspro_gen_TpduCard2Modem(const BankSlot_t *bank, const ClientSlot_t *client,
const uint8_t *tpdu, unsigned int tpdu_len);
e_ResultCode rspro_get_result(const RsproPDU_t *pdu);
void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);
const char *rspro_IpAddr2str(const IpAddress_t *in);

Loading…
Cancel
Save