gprs_ns2: add assert on most bind calls

Add a OSMO_ASSERT to all bind calls which doesn't
check if the bind is from the expected type.
The only exception is rx and tx functions (hot path).

Change-Id: Ia4f8932263c60618c7f0dfc32d50ba5a8d57602b
diff --git a/src/gb/gprs_ns2_fr.c b/src/gb/gprs_ns2_fr.c
index c1bed6c..7b9450c 100644
--- a/src/gb/gprs_ns2_fr.c
+++ b/src/gb/gprs_ns2_fr.c
@@ -106,6 +106,7 @@
 	if (!nsvc->priv)
 		return;
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(nsvc->bind));
 	talloc_free(nsvc->priv);
 	nsvc->priv = NULL;
 }
@@ -137,6 +138,7 @@
 {
 	struct priv_bind *priv;
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
 	if (!bind)
 		return;
 
@@ -158,6 +160,7 @@
 	if (!priv)
 		return NULL;
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
 	nsvc->priv = priv;
 	priv->dlci = dlci;
 	priv->dlc = osmo_fr_dlc_alloc(privb->link, dlci);
@@ -180,6 +183,7 @@
 	struct gprs_ns2_vc *nsvc;
 	struct priv_vc *vcpriv;
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
 	if (!result)
 		return -EINVAL;
 
@@ -740,6 +744,7 @@
 	struct priv_bind *bpriv = bind->priv;
 	char idbuf[64];
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
 	nsvc = gprs_ns2_fr_nsvc_by_dlci(bind, dlci);
 	if (nsvc) {
 		goto err;
@@ -780,7 +785,10 @@
 {
 	bool created_nse = false;
 	struct gprs_ns2_vc *nsvc = NULL;
-	struct gprs_ns2_nse *nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei);
+	struct gprs_ns2_nse *nse;
+
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
+	nse = gprs_ns2_nse_by_nsei(bind->nsi, nsei);
 	if (!nse) {
 		nse = gprs_ns2_create_nse(bind->nsi, nsei, GPRS_NS2_LL_FR, NS2_DIALECT_STATIC_RESETBLOCK);
 		if (!nse)
@@ -812,6 +820,7 @@
 	struct gprs_ns2_vc *nsvc;
 	struct priv_vc *vcpriv;
 
+	OSMO_ASSERT(gprs_ns2_is_fr_bind(bind));
 	llist_for_each_entry(nsvc, &bind->nsvc, blist) {
 		vcpriv = nsvc->priv;