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_udp.c b/src/gb/gprs_ns2_udp.c
index d93b66d..1037b19 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -63,6 +63,8 @@
if (!bind)
return;
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+
priv = bind->priv;
osmo_fd_close(&priv->fd);
@@ -74,6 +76,7 @@
if (!nsvc->priv)
return;
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(nsvc->bind));
talloc_free(nsvc->priv);
nsvc->priv = NULL;
}
@@ -116,6 +119,8 @@
struct gprs_ns2_vc *nsvc;
struct priv_vc *vcpriv;
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+
llist_for_each_entry(nsvc, &bind->nsvc, blist) {
vcpriv = nsvc->priv;
if (vcpriv->remote.u.sa.sa_family != saddr->u.sa.sa_family)
@@ -397,6 +402,8 @@
char *sockaddr_str;
char idbuf[64];
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
+
vc_mode = gprs_ns2_dialect_to_vc_mode(nse->dialect);
if ((int) vc_mode == -1) {
LOGP(DLNS, LOGL_ERROR, "Can not derive vc mode from dialect %d. Maybe libosmocore is too old.\n",
@@ -492,6 +499,7 @@
const struct osmo_sockaddr *gprs_ns2_ip_bind_sockaddr(struct gprs_ns2_vc_bind *bind)
{
struct priv_bind *priv;
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
priv = bind->priv;
return &priv->addr;
@@ -509,6 +517,7 @@
struct priv_bind *priv;
int rc = 0;
+ OSMO_ASSERT(gprs_ns2_is_ip_bind(bind));
priv = bind->priv;
if (dscp != priv->dscp) {