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
diff --git a/src/rspro_client_fsm.c b/src/rspro_client_fsm.c
index 2c1c029..e55892c 100644
--- a/src/rspro_client_fsm.c
+++ b/src/rspro_client_fsm.c
@@ -244,6 +244,14 @@
}
}
+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_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 @@
.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",
diff --git a/src/rspro_client_fsm.h b/src/rspro_client_fsm.h
index c1ae764..029fcd9 100644
--- a/src/rspro_client_fsm.h
+++ b/src/rspro_client_fsm.h
@@ -41,6 +41,10 @@
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;