From f61a9150a90eec96cf47275fb43d3fad6bf772a2 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 2 Mar 2021 22:20:17 +0100 Subject: gprs_ns2_sns: Add some more OSMO_ASSERT about BSS role Some functions are only to be called when operating in BSS role, let's enforce that by sprinkling some OSMO_ASSERT() around. Related: OS#3373 Change-Id: I20d1bd8df62e0bb84696e291756e2d96acf49246 --- src/gb/gprs_ns2_sns.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c index c6e86429..51b3ea89 100644 --- a/src/gb/gprs_ns2_sns.c +++ b/src/gb/gprs_ns2_sns.c @@ -713,15 +713,20 @@ static int do_sns_add(struct osmo_fsm_inst *fi, static void ns2_sns_st_unconfigured(struct osmo_fsm_inst *fi, uint32_t event, void *data) { + struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); /* empty state - SNS Select will start by ns2_sns_st_all_action() */ } static void ns2_sns_st_size(struct osmo_fsm_inst *fi, uint32_t event, void *data) { + struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; struct gprs_ns2_nse *nse = nse_inst_from_fi(fi); struct gprs_ns2_inst *nsi = nse->nsi; struct tlv_parsed *tp = NULL; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); + switch (event) { case GPRS_SNS_EV_RX_SIZE_ACK: tp = data; @@ -849,6 +854,8 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state { struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); + /* on a generic failure, the timer callback will recover */ if (old_state != GPRS_SNS_ST_UNCONFIGURED) ns2_prim_status_ind(gss->nse, NULL, 0, GPRS_NS2_AFF_CAUSE_SNS_FAILURE); @@ -890,8 +897,11 @@ static void ns2_sns_st_size_onenter(struct osmo_fsm_inst *fi, uint32_t old_state static void ns2_sns_st_config_bss(struct osmo_fsm_inst *fi, uint32_t event, void *data) { - struct tlv_parsed *tp = NULL; + struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; struct gprs_ns2_nse *nse = nse_inst_from_fi(fi); + struct tlv_parsed *tp = NULL; + + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); switch (event) { case GPRS_SNS_EV_RX_CONFIG_ACK: @@ -913,6 +923,8 @@ static void ns2_sns_st_config_bss_onenter(struct osmo_fsm_inst *fi, uint32_t old { struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); + if (old_state != GPRS_SNS_ST_CONFIG_BSS) gss->N = 0; @@ -998,6 +1010,8 @@ static void ns2_sns_st_config_sgsn_onenter(struct osmo_fsm_inst *fi, uint32_t ol { struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); + if (old_state != GPRS_SNS_ST_CONFIG_SGSN) gss->N = 0; } @@ -1009,6 +1023,8 @@ static void ns2_sns_st_config_sgsn(struct osmo_fsm_inst *fi, uint32_t event, voi uint8_t cause; int rc; + OSMO_ASSERT(gss->role == GPRS_SNS_ROLE_BSS); + switch (event) { case GPRS_SNS_EV_RX_CONFIG_END: case GPRS_SNS_EV_RX_CONFIG: -- cgit v1.2.3