diff options
author | Stef Walter <stef@memberwebs.com> | 2004-06-09 17:19:45 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-06-09 17:19:45 +0000 |
commit | 5995e2afd8f026de8f5eb9a392b59542a98bf7e5 (patch) | |
tree | 1bd4e661665c49fa62ea7813b793a18718d4d47b /common/sock_any.c | |
parent | 88bdaea8c3ef28680a83ee6c82e77e97c6116fb4 (diff) |
- Added peer name logging
- Reformatted connection logging
Diffstat (limited to 'common/sock_any.c')
-rw-r--r-- | common/sock_any.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/common/sock_any.c b/common/sock_any.c index 7a128f2..acac8ee 100644 --- a/common/sock_any.c +++ b/common/sock_any.c @@ -237,3 +237,39 @@ int sock_any_pton(const char* addr, struct sockaddr_any* any, int defport) return -1; } +int sock_any_ntop(struct sockaddr_any* any, char* addr, size_t addrlen) +{ + int len = 0; + + switch(any->s.a.sa_family) + { + case AF_UNIX: + len = strlen(any->s.un.sun_path); + if(addrlen < len + 1) + { + errno = ENOSPC; + return -1; + } + + strcpy(addr, any->s.un.sun_path); + break; + + case AF_INET: + if(inet_ntop(any->s.a.sa_family, &(any->s.in.sin_addr), addr, addrlen) == NULL) + return -1; + break; + +#ifdef HAVE_INET6 + case AF_INET6: + if(inet_ntop(any->s.a.sa_family, &(any->s.in6.sin6_addr), addr, addrlen) == NULL) + return -1; + break; +#endif + + default: + errno = EAFNOSUPPORT; + return -1; + } + + return 0; +} |