diff options
author | Alexander Couzens <lynxis@fe80.eu> | 2020-10-11 23:23:31 +0200 |
---|---|---|
committer | Alexander Couzens <lynxis@fe80.eu> | 2020-10-12 15:54:21 +0200 |
commit | 6cb5d5f2e03a70329ae60c405f46f993a1b520cf (patch) | |
tree | 5d11fed704697cfc5bb16ad8039a2d9c0d4ff0bb /src | |
parent | d33512b997143b2354566a0df88d33ba096ec84d (diff) |
gprs_ns2: add gprs_ns2_nse_foreach_nsvc()
Allow to loop over all NSVC within a NSE via a callback
Change-Id: I5a2bb95d05d06d909347e2fb084a446ead888cb3
Diffstat (limited to 'src')
-rw-r--r-- | src/gb/gprs_ns2.c | 22 | ||||
-rw-r--r-- | src/gb/libosmogb.map | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 002ea1d2..95736514 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -861,6 +861,28 @@ struct gprs_ns2_vc *gprs_ns2_nsvc_by_sockaddr_nse(struct gprs_ns2_nse *nse, return NULL; } +/*! + * Iterate over all nsvc of a NS Entity and call the callback. + * If the callback returns < 0 it aborts the loop and returns the callback return code. + * \param[in] nse NS Entity to iterate over all nsvcs + * \param[in] cb the callback to call + * \param[inout] cb_data the private data of the callback + * \return 0 if the loop completes. If a callback returns < 0 it will returns this value. + */ +int gprs_ns2_nse_foreach_nsvc(struct gprs_ns2_nse *nse, gprs_ns2_foreach_nsvc_cb cb, void *cb_data) +{ + struct gprs_ns2_vc *nsvc, *tmp; + int rc = 0; + llist_for_each_entry_safe(nsvc, tmp, &nse->nsvc, list) { + rc = cb(nsvc, cb_data); + if (rc < 0) + return rc; + } + + return 0; +} + + /*! Bottom-side entry-point for received NS PDU from the driver/bind * \param[in] nsvc NS-VC for which the message was received diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index e6557b7e..eea1285e 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -101,6 +101,7 @@ gprs_ns2_ll_str; gprs_ns2_ll_str_buf; gprs_ns2_ll_str_c; gprs_ns2_nse_by_nsei; +gprs_ns2_nse_foreach_nsvc; gprs_ns2_nse_nsei; gprs_ns2_nse_sns_remote; gprs_ns2_nsvc_by_nsvci; |