aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-10-11 20:15:25 +0200
committerlaforge <laforge@osmocom.org>2020-10-12 13:08:42 +0000
commit4b6c8afcb2e0c7c366bf0a98138d659055860af3 (patch)
treefc080fe66c93fa694cd968234e9208212681a4cb
parent896fcd5c80962767dd2ed413fb348d4e178262d5 (diff)
gprs_ns2: add gprs_ns2_free_nses() to free all NS-E
Allow users to clean up most of the state (e.g. the PCU). Change-Id: Ia00753a64b7622a0864341f51ea49b6963543755
-rw-r--r--include/osmocom/gprs/gprs_ns2.h1
-rw-r--r--src/gb/gprs_ns2.c16
-rw-r--r--src/gb/libosmogb.map1
3 files changed, 12 insertions, 6 deletions
diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index 2c58723a..75315308 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -101,6 +101,7 @@ struct gprs_ns2_nse *gprs_ns2_nse_by_nsei(struct gprs_ns2_inst *nsi, uint16_t ns
struct gprs_ns2_nse *gprs_ns2_create_nse(struct gprs_ns2_inst *nsi, uint16_t nsei);
uint16_t gprs_ns2_nse_nsei(struct gprs_ns2_nse *nse);
void gprs_ns2_free_nse(struct gprs_ns2_nse *nse);
+void gprs_ns2_free_nses(struct gprs_ns2_inst *nsi);
/* create vc */
void gprs_ns2_free_nsvc(struct gprs_ns2_vc *nsvc);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index e3fc0786..50acf99a 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -598,6 +598,15 @@ void gprs_ns2_free_nse(struct gprs_ns2_nse *nse)
talloc_free(nse);
}
+void gprs_ns2_free_nses(struct gprs_ns2_inst *nsi)
+{
+ struct gprs_ns2_nse *nse, *ntmp;
+
+ llist_for_each_entry_safe(nse, ntmp, &nsi->nse, list) {
+ gprs_ns2_free_nse(nse);
+ }
+}
+
static inline int ns2_tlv_parse(struct tlv_parsed *dec,
const uint8_t *buf, int buf_len, uint8_t lv_tag,
uint8_t lv_tag2)
@@ -997,15 +1006,10 @@ 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_nse *nse, *ntmp;
-
if (!nsi)
return;
- llist_for_each_entry_safe(nse, ntmp, &nsi->nse, list) {
- gprs_ns2_free_nse(nse);
- }
-
+ gprs_ns2_free_nses(nsi);
gprs_ns2_free_binds(nsi);
talloc_free(nsi);
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index d23d263b..a1854709 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -81,6 +81,7 @@ gprs_ns2_free;
gprs_ns2_free_bind;
gprs_ns2_free_binds;
gprs_ns2_free_nse;
+gprs_ns2_free_nses;
gprs_ns2_free_nsvc;
gprs_ns2_frgre_bind;
gprs_ns2_instantiate;