]> git.ipfire.org Git - ipfire-3.x.git/blob - iputils/patches/iputils-s20071127-addrcache.patch
Change file layout of the makefiles.
[ipfire-3.x.git] / iputils / patches / iputils-s20071127-addrcache.patch
1 --- iputils/ping.c.addrcache 2002-09-20 17:08:11.000000000 +0200
2 +++ iputils/ping.c 2003-05-15 16:41:19.000000000 +0200
3 @@ -1124,6 +1124,12 @@
4 {
5 struct hostent *hp;
6 static char buf[4096];
7 + static __u32 addr_cache = 0;
8 +
9 + if ( addr == addr_cache )
10 + return buf;
11 +
12 + addr_cache = addr;
13
14 if ((options & F_NUMERIC) ||
15 !(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
16 --- iputils/ping6.c.addrcache 2002-09-20 17:08:11.000000000 +0200
17 +++ iputils/ping6.c 2003-05-15 16:41:19.000000000 +0200
18 @@ -893,7 +893,12 @@
19 */
20 char * pr_addr(struct in6_addr *addr)
21 {
22 - struct hostent *hp = NULL;
23 + static struct hostent *hp;
24 + static struct in6_addr addr_cache;
25 +
26 + if (memcmp(addr, &addr_cache, sizeof(addr_cache)) == 0)
27 + return hp ? hp->h_name : pr_addr_n(addr);
28 + memcpy(&addr_cache, addr, sizeof(addr_cache));
29
30 if (!(options&F_NUMERIC))
31 hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);