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
This commit is contained in:
Alexander Couzens 2020-10-11 19:52:36 +02:00 committed by laforge
parent 05e7f7dd99
commit 896fcd5c80
3 changed files with 12 additions and 4 deletions

View File

@ -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,

View File

@ -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);
}
}
/*! @} */

View File

@ -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;