aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2020-06-07 18:10:13 +0200
committerAlexander Couzens <lynxis@fe80.eu>2020-06-07 19:02:48 +0200
commitcbeaa05423a520152f1a2c5f39523f8dc20d494e (patch)
tree8b86545933b23678b1204eea4e66d1c240d6e6c6
parentfc93159437cc5eee4b0b90c019e93f08497ece6d (diff)
socket.h: introduce osmo_sockaddr to hold v4 and v6 endpointslynxis/ipv6
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
-rw-r--r--include/osmocom/core/socket.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/osmocom/core/socket.h b/include/osmocom/core/socket.h
index 129612c6..fd02eefd 100644
--- a/include/osmocom/core/socket.h
+++ b/include/osmocom/core/socket.h
@@ -22,6 +22,14 @@ struct sockaddr_in;
struct sockaddr;
struct osmo_fd;
+struct osmo_sockaddr {
+ union {
+ struct sockaddr sa;
+ 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)