Change in libosmocore[master]: gprs_ns2: add gprs_ns2_ip_bind_by_sockaddr() to search for binds by s...

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 01:16:49 UTC 2020


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/20552 )


Change subject: gprs_ns2: add gprs_ns2_ip_bind_by_sockaddr() to search for binds by sockaddr
......................................................................

gprs_ns2: add gprs_ns2_ip_bind_by_sockaddr() to search for binds by sockaddr

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



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/52/20552/1

diff --git a/include/osmocom/gprs/gprs_ns2.h b/include/osmocom/gprs/gprs_ns2.h
index dc27c96..cbd6647 100644
--- a/include/osmocom/gprs/gprs_ns2.h
+++ b/include/osmocom/gprs/gprs_ns2.h
@@ -110,6 +110,8 @@
 		     const struct osmo_sockaddr *local,
 		     int dscp,
 		     struct gprs_ns2_vc_bind **result);
+struct gprs_ns2_vc_bind *gprs_ns2_ip_bind_by_sockaddr(struct gprs_ns2_inst *nsi,
+						      const struct osmo_sockaddr *sockaddr);
 void gprs_ns2_bind_set_mode(struct gprs_ns2_vc_bind *bind, enum gprs_ns2_vc_mode mode);
 
 /* create a VC connection */
diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c
index 815e516..a578160 100644
--- a/src/gb/gprs_ns2_udp.c
+++ b/src/gb/gprs_ns2_udp.c
@@ -265,6 +265,32 @@
 	return rc;
 }
 
+/*! Find NS bind for a given socket address
+ *  \param[in] nsi NS instance
+ *  \param[in] sockaddr socket address to search for
+ *  \return
+ */
+struct gprs_ns2_vc_bind *gprs_ns2_ip_bind_by_sockaddr(struct gprs_ns2_inst *nsi,
+						      const struct osmo_sockaddr *sockaddr)
+{
+	struct gprs_ns2_vc_bind *bind;
+	struct osmo_sockaddr *local;
+
+	OSMO_ASSERT(nsi);
+	OSMO_ASSERT(sockaddr);
+
+	llist_for_each_entry(bind, &nsi->binding, list) {
+		if (!gprs_ns2_is_ip_bind(bind))
+			continue;
+
+		local = gprs_ns2_ip_bind_sockaddr(bind);
+		if (!osmo_sockaddr_cmp(sockaddr, local))
+			return bind;
+	}
+
+	return NULL;
+}
+
 /*! Bind to an IPv4/IPv6 address
  *  \param[in] nsi NS Instance in which to create the NSVC
  *  \param[in] local the local address to bind to
diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map
index d08e85e..980b317 100644
--- a/src/gb/libosmogb.map
+++ b/src/gb/libosmogb.map
@@ -84,6 +84,7 @@
 gprs_ns2_frgre_bind;
 gprs_ns2_instantiate;
 gprs_ns2_ip_bind;
+gprs_ns2_ip_bind_by_sockaddr;
 gprs_ns2_ip_bind_set_dscp;
 gprs_ns2_ip_bind_sockaddr;
 gprs_ns2_ip_connect;

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I48c3f1a82574eee0a49e6941cf9e1365c2302d3b
Gerrit-Change-Number: 20552
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201012/37e8fe83/attachment.htm>


More information about the gerrit-log mailing list