Change in libosmocore[master]: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

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
Sun Jul 5 09:27:34 UTC 2020


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


Change subject: socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints
......................................................................

socket.h: introduce osmo_sockaddr to hold v4 and v6 endpoints

When dealing with IPv4 and IPv6 address, the struct sockaddr
allows to hold IPv4 and IPv6.
However even when struct sockaddr is being used, a cast to the
IPv4 or IPv6 family must happen. To work around this additional code,
use a union for the most common types.

Change-Id: If80172373735193401af872b18e1ff00c93880e7
---
M include/osmocom/core/socket.h
1 file changed, 9 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/19141/1

diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index 129612c..bc60dfc 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -22,6 +22,15 @@
 struct sockaddr;
 struct osmo_fd;
 
+struct osmo_sockaddr {
+	union {
+		struct sockaddr sa;
+		struct sockaddr_storage sas;
+		struct sockaddr_in sin;
+		struct sockaddr_in6 sin6;
+	} u;
+};
+
 /* flags for osmo_sock_init. */
 /*! connect the socket to a remote peer */
 #define OSMO_SOCK_F_CONNECT	(1 << 0)

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: If80172373735193401af872b18e1ff00c93880e7
Gerrit-Change-Number: 19141
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/20200705/0a4e49cb/attachment.htm>


More information about the gerrit-log mailing list