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.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/common/sock_any.h b/common/sock_any.h
new file mode 100644
index 0000000..693bd2a
--- /dev/null
+++ b/common/sock_any.h
@@ -0,0 +1,33 @@
+
+#ifndef __SOCK_ANY_H__
+#define __SOCK_ANY_H__
+
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+
+struct sockaddr_any
+{
+ 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;
+ size_t namelen;
+};
+
+#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);
+int sock_any_ntop(struct sockaddr_any* any, char* addr, size_t addrlen);
+
+#endif /* __SOCK_ANY_H__ */