summaryrefslogtreecommitdiffstats
path: root/lib/sockunion.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/sockunion.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/sockunion.h b/lib/sockunion.h
index e507255..1466512 100644
--- a/lib/sockunion.h
+++ b/lib/sockunion.h
@@ -7,10 +7,13 @@
#ifndef _ZEBRA_SOCKUNION_H
#define _ZEBRA_SOCKUNION_H
+#include "compiler.h"
+
#include "privs.h"
#include "if.h"
#include <sys/un.h>
#ifdef __OpenBSD__
+#include <net/route.h>
#include <netmpls/mpls.h>
#endif
@@ -27,8 +30,40 @@ union sockunion {
struct sockaddr_mpls smpls;
struct sockaddr_rtlabel rtlabel;
#endif
+
+ /* sockaddr_storage is guaranteed to be larger than the others */
+ struct sockaddr_storage sa_storage;
};
+/* clang-format off */
+/* for functions that want to accept any sockaddr pointer without casts */
+union sockaddrptr {
+ uniontype(sockaddrptr, union sockunion, su)
+ uniontype(sockaddrptr, struct sockaddr, sa)
+ uniontype(sockaddrptr, struct sockaddr_in, sin)
+ uniontype(sockaddrptr, struct sockaddr_in6, sin6)
+ uniontype(sockaddrptr, struct sockaddr_un, sun)
+#ifdef __OpenBSD__
+ uniontype(sockaddrptr, struct sockaddr_mpls, smpls)
+ uniontype(sockaddrptr, struct sockaddr_rtlabel, rtlabel)
+#endif
+ uniontype(sockaddrptr, struct sockaddr_storage, sa_storage)
+} TRANSPARENT_UNION;
+
+union sockaddrconstptr {
+ uniontype(sockaddrconstptr, const union sockunion, su)
+ uniontype(sockaddrconstptr, const struct sockaddr, sa)
+ uniontype(sockaddrconstptr, const struct sockaddr_in, sin)
+ uniontype(sockaddrconstptr, const struct sockaddr_in6, sin6)
+ uniontype(sockaddrconstptr, const struct sockaddr_un, sun)
+#ifdef __OpenBSD__
+ uniontype(sockaddrconstptr, const struct sockaddr_mpls, smpls)
+ uniontype(sockaddrconstptr, const struct sockaddr_rtlabel, rtlabel)
+#endif
+ uniontype(sockaddrconstptr, const struct sockaddr_storage, sa_storage)
+} TRANSPARENT_UNION;
+/* clang-format on */
+
enum connect_result { connect_error, connect_success, connect_in_progress };
/* Default address family. */