Change in libosmocore[master]: gprs_ns2_sns: Add some more OSMO_ASSERT about BSS role

laforge gerrit-no-reply at lists.osmocom.org
Fri Mar 19 12:38:53 UTC 2021


laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23406 )


Change subject: gprs_ns2_sns: Add some more OSMO_ASSERT about BSS role
......................................................................

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
---
M src/gb/gprs_ns2_sns.c
1 file changed, 17 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/06/23406/1

diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index 9be0909..564ffc7 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -713,15 +713,20 @@
 
 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 @@
 {
 	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_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 @@
 {
 	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 @@
 {
 	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 @@
 	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:

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/23406
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I20d1bd8df62e0bb84696e291756e2d96acf49246
Gerrit-Change-Number: 23406
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210319/9f1b6338/attachment.htm>


More information about the gerrit-log mailing list