diff options
author | stbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2015-09-18 15:15:18 +0000 |
---|---|---|
committer | stbuehler <stbuehler@152afb58-edef-0310-8abb-c4023f1b3aa9> | 2015-09-18 15:15:18 +0000 |
commit | 8b2630a82fbecfd57fa38aebb397a755936690e5 (patch) | |
tree | a9cfcd7bb5bea87d63fc8ef81c8456a130a249bc /src/inet_ntop_cache.c | |
parent | e57c8295ebe92b58ca3e68fa8ea8f70d4b0b4cee (diff) | |
download | lighttpd-master.tar.gz |
git-svn-id: svn://svn.lighttpd.net/lighttpd/trunk@3041 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/inet_ntop_cache.c')
-rw-r--r-- | src/inet_ntop_cache.c | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/inet_ntop_cache.c b/src/inet_ntop_cache.c deleted file mode 100644 index 51755df3..00000000 --- a/src/inet_ntop_cache.c +++ /dev/null @@ -1,53 +0,0 @@ -#include <sys/types.h> - -#include <string.h> - - -#include "base.h" -#include "inet_ntop_cache.h" -#include "sys-socket.h" - -const char * inet_ntop_cache_get_ip(server *srv, sock_addr *addr) { -#ifdef HAVE_IPV6 - size_t ndx = 0, i; - for (i = 0; i < INET_NTOP_CACHE_MAX; i++) { - if (srv->inet_ntop_cache[i].ts != 0 && srv->inet_ntop_cache[i].family == addr->plain.sa_family) { - if (srv->inet_ntop_cache[i].family == AF_INET6 && - 0 == memcmp(srv->inet_ntop_cache[i].addr.ipv6.s6_addr, addr->ipv6.sin6_addr.s6_addr, 16)) { - /* IPv6 found in cache */ - break; - } else if (srv->inet_ntop_cache[i].family == AF_INET && - srv->inet_ntop_cache[i].addr.ipv4.s_addr == addr->ipv4.sin_addr.s_addr) { - /* IPv4 found in cache */ - break; - - } - } - } - - if (i == INET_NTOP_CACHE_MAX) { - /* not found in cache */ - - i = ndx; - inet_ntop(addr->plain.sa_family, - addr->plain.sa_family == AF_INET6 ? - (const void *) &(addr->ipv6.sin6_addr) : - (const void *) &(addr->ipv4.sin_addr), - srv->inet_ntop_cache[i].b2, INET6_ADDRSTRLEN); - - srv->inet_ntop_cache[i].ts = srv->cur_ts; - srv->inet_ntop_cache[i].family = addr->plain.sa_family; - - if (srv->inet_ntop_cache[i].family == AF_INET) { - srv->inet_ntop_cache[i].addr.ipv4.s_addr = addr->ipv4.sin_addr.s_addr; - } else if (srv->inet_ntop_cache[i].family == AF_INET6) { - memcpy(srv->inet_ntop_cache[i].addr.ipv6.s6_addr, addr->ipv6.sin6_addr.s6_addr, 16); - } - } - - return srv->inet_ntop_cache[i].b2; -#else - UNUSED(srv); - return inet_ntoa(addr->ipv4.sin_addr); -#endif -} |