tags 109709 patch
thanks
Attached is a simple patch which implements this functionality for
ping and ping6 programs.
Index: ping6.c
===================================================================
--- ping6.c (revision 185)
+++ ping6.c (working copy)
@@ -1536,9 +1536,9 @@
*/
char * pr_addr(struct in6_addr *addr)
{
- struct hostent *hp = NULL;
+ static struct hostent *hp = NULL;
- if (!(options&F_NUMERIC))
+ if (!hp && !(options&F_NUMERIC))
hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6);
return hp ? hp->h_name : pr_addr_n(addr);
Index: ping.c
===================================================================
--- ping.c (revision 185)
+++ ping.c (working copy)
@@ -1158,8 +1158,11 @@
pr_addr(__u32 addr)
{
struct hostent *hp;
- static char buf[4096];
+ static char buf[4096] = "";
+ if (*buf)
+ return(buf);
+
if ((options & F_NUMERIC) ||
!(hp = gethostbyaddr((char *)&addr, 4, AF_INET)))
sprintf(buf, "%s", inet_ntoa(*(struct in_addr *)&addr));