summaryrefslogtreecommitdiff
path: root/common/sock_any.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/sock_any.h')
-rw-r--r--common/sock_any.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/common/sock_any.h b/common/sock_any.h
new file mode 100644
index 0000000..f281020
--- /dev/null
+++ b/common/sock_any.h
@@ -0,0 +1,32 @@
+
+#ifndef __SOCK_ANY_H__
+#define __SOCK_ANY_H__
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+
+struct sockaddr_any
+{
+ size_t namelen;
+ union _sockaddr_any
+ {
+ /* The header */
+ struct sockaddr a;
+
+ /* The different types */
+ struct sockaddr_un un;
+ struct sockaddr_in in;
+#ifdef HAVE_INET6
+ struct sockaddr_in6 in6;
+#endif
+ } s;
+};
+
+#define SANY_ADDR(any) (&((any).s.a))
+#define SANY_LEN(any) ((any).namelen)
+#define SANY_TYPE(any) ((any).s.a.sa_family)
+
+int sock_any_pton(const char* addr, struct sockaddr_any* any, int defport);
+
+#endif /* __SOCK_ANY_H__ */