Change in libosmocore[master]: gprs_ns2: add gprs_ns2_nse_foreach_nsvc()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Oct 12 14:13:45 UTC 2020


lynxis lazus has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20562 )

Change subject: gprs_ns2: add gprs_ns2_nse_foreach_nsvc()
......................................................................

gprs_ns2: add gprs_ns2_nse_foreach_nsvc()

Allow to loop over all NSVC within a NSE via a callback

Change-Id: I5a2bb95d05d06d909347e2fb084a446ead888cb3
---
M include/osmocom/gprs/gprs_ns2.h
M src/gb/gprs_ns2.c
M src/gb/libosmogb.map
3 files changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  daniel: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index efdc8f3..6f33f79 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -97,6 +97,11 @@
 /* Entrypoint for primitives from the NS USER */
 int gprs_ns2_recv_prim(struct gprs_ns2_inst *nsi, struct osmo_prim_hdr *oph);
 
+/*! a callback to iterate over all NSVC */
+typedef int (*gprs_ns2_foreach_nsvc_cb)(struct gprs_ns2_vc *nsvc, void *ctx);
+
+int gprs_ns2_nse_foreach_nsvc(struct gprs_ns2_nse *nse,
+			      gprs_ns2_foreach_nsvc_cb cb, void *cb_data);
 struct gprs_ns2_nse *gprs_ns2_nse_by_nsei(struct gprs_ns2_inst *nsi, uint16_t nsei);
 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);
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c
index 002ea1d..9573651 100644
--- a/src/gb/gprs_ns2.c
+++ b/src/gb/gprs_ns2.c
@@ -861,6 +861,28 @@
 	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 e6557b7..eea1285 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -101,6 +101,7 @@
 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;

-- 
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20562
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I5a2bb95d05d06d909347e2fb084a446ead888cb3
Gerrit-Change-Number: 20562
Gerrit-PatchSet: 2
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201012/7d21b79b/attachment.htm>


More information about the gerrit-log mailing list