rspro_client_fsm: Add optional notifiation of parent on connect/disconnect

This will be useful once we introduce a 'main' client FSM that is a
parent to the rspro_client_fsms.

Change-Id: Ifddb8e0b5c991e5348392c9e44612669ce207bc4
This commit is contained in:
Harald Welte 2020-02-22 20:53:19 +01:00
parent 8da220911d
commit b266d508be
2 changed files with 22 additions and 0 deletions

View File

@ -244,6 +244,14 @@ static void srvc_st_established(struct osmo_fsm_inst *fi, uint32_t event, void *
}
}
static void srvc_st_connected_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv;
if (fi->proc.parent)
osmo_fsm_inst_dispatch(fi->proc.parent, srvc->parent_conn_evt, NULL);
}
static void srvc_st_connected(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv;
@ -263,6 +271,14 @@ static void srvc_st_connected(struct osmo_fsm_inst *fi, uint32_t event, void *da
}
}
static void srvc_st_connected_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
{
struct rspro_server_conn *srvc = (struct rspro_server_conn *) fi->priv;
if (fi->proc.parent)
osmo_fsm_inst_dispatch(fi->proc.parent, srvc->parent_disc_evt, NULL);
}
static int ipa_kaepalive_timeout_cb(struct osmo_fsm_inst *ka_fi, void *conn)
{
struct osmo_fsm_inst *fi = ka_fi->proc.parent;
@ -396,6 +412,8 @@ static const struct osmo_fsm_state server_conn_fsm_states[] = {
.in_event_mask = S(SRVC_E_TCP_DOWN) | S(SRVC_E_KA_TIMEOUT) | S(SRVC_E_RSPRO_TX),
.out_state_mask = S(SRVC_ST_REESTABLISH) | S(SRVC_ST_INIT),
.action = srvc_st_connected,
.onenter = srvc_st_connected_onenter,
.onleave = srvc_st_connected_onleave,
},
[SRVC_ST_REESTABLISH] = {
.name = "REESTABLISH",

View File

@ -41,6 +41,10 @@ struct rspro_server_conn {
char *server_host;
uint16_t server_port;
/* FSM events we are to sent to the parent FSM on connect / disconnect */
uint32_t parent_conn_evt;
uint32_t parent_disc_evt;
/* only in case we are representing a bankd client */
struct {
uint16_t bank_id;