From 896fcd5c80962767dd2ed413fb348d4e178262d5 Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Sun, 11 Oct 2020 19:52:36 +0200 Subject: gprs_ns2: add gprs_ns2_free_binds() to free all binds Allow users to clean up all binds (e.g. the PCU). Change-Id: Ic8f6f8aca10da23a18fab8870be7806065a34b47 --- include/osmocom/gprs/gprs_ns2.h | 1 + src/gb/gprs_ns2.c | 14 ++++++++++---- src/gb/libosmogb.map | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h index d798ac49..2c58723a 100644 --- a/include/osmocom/gprs/gprs_ns2.h +++ b/include/osmocom/gprs/gprs_ns2.h @@ -131,6 +131,7 @@ struct gprs_ns2_vc *gprs_ns2_ip_connect_inactive(struct gprs_ns2_vc_bind *bind, uint16_t nsvci); void gprs_ns2_free_bind(struct gprs_ns2_vc_bind *bind); +void gprs_ns2_free_binds(struct gprs_ns2_inst *nsi); /* create a VC SNS connection */ int gprs_ns2_ip_connect_sns(struct gprs_ns2_vc_bind *bind, diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 58304cdf..e3fc0786 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -997,7 +997,6 @@ struct gprs_ns2_inst *gprs_ns2_instantiate(void *ctx, osmo_prim_cb cb, void *cb_ * \param[in] nsi NS instance to destroy */ void gprs_ns2_free(struct gprs_ns2_inst *nsi) { - struct gprs_ns2_vc_bind *bind, *tbind; struct gprs_ns2_nse *nse, *ntmp; if (!nsi) @@ -1007,9 +1006,7 @@ void gprs_ns2_free(struct gprs_ns2_inst *nsi) gprs_ns2_free_nse(nse); } - llist_for_each_entry_safe(bind, tbind, &nsi->binding, list) { - gprs_ns2_free_bind(bind); - } + gprs_ns2_free_binds(nsi); talloc_free(nsi); } @@ -1067,4 +1064,13 @@ void gprs_ns2_free_bind(struct gprs_ns2_vc_bind *bind) llist_del(&bind->list); talloc_free(bind); } + +void gprs_ns2_free_binds(struct gprs_ns2_inst *nsi) +{ + struct gprs_ns2_vc_bind *bind, *tbind; + + llist_for_each_entry_safe(bind, tbind, &nsi->binding, list) { + gprs_ns2_free_bind(bind); + } +} /*! @} */ diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index 3d1d5d68..d23d263b 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -79,6 +79,7 @@ gprs_ns2_dynamic_create_nse; gprs_ns2_find_vc_by_sockaddr; gprs_ns2_free; gprs_ns2_free_bind; +gprs_ns2_free_binds; gprs_ns2_free_nse; gprs_ns2_free_nsvc; gprs_ns2_frgre_bind; -- cgit v1.2.3