diff options
author | Harald Welte <laforge@osmocom.org> | 2021-03-02 22:20:17 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-03-23 11:57:16 +0100 |
commit | f61a9150a90eec96cf47275fb43d3fad6bf772a2 (patch) | |
tree | aff1f9246674f5d5c913caaa4de2bc26936e2cdb | |
parent | gprs_ns2_sns: Support for SGSN-side IP-SNS (diff) | |
download | libosmocore-f61a9150a90eec96cf47275fb43d3fad6bf772a2.tar.xz libosmocore-f61a9150a90eec96cf47275fb43d3fad6bf772a2.zip |
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
-rw-r--r-- | src/gb/gprs_ns2_sns.c | 18 |
1 files changed, 17 insertions, 1 deletions
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: |