diff options
author | Stef Walter <stef@memberwebs.com> | 2004-07-08 18:27:54 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-07-08 18:27:54 +0000 |
commit | c912dc0c7a6ab39c90200ed5614b181cd1397d5c (patch) | |
tree | a3b2df0f9a3a62ea9de95395d8e313bffddce203 /common/sock_any.h | |
parent | 0561cfd0ce346fce733dd1b25e5b2650e50bf7bf (diff) |
Initial import
Diffstat (limited to 'common/sock_any.h')
-rw-r--r-- | common/sock_any.h | 33 |
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__ */ |