Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2
iputils
iputils-ss021109-pingnamelookuponce.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File iputils-ss021109-pingnamelookuponce.diff of Package iputils
diff -ur iputils/ping.c iputils.new/ping.c --- iputils/ping.c 2004-03-17 12:36:43.000000000 +0100 +++ iputils.new/ping.c 2004-03-17 12:35:49.000000000 +0100 @@ -1141,15 +1141,24 @@ char * pr_addr(__u32 addr) { - struct hostent *hp; + struct hostent *hp = NULL; + static __u32 last_addr; static char buf[4096]; - if ((options & F_NUMERIC) || - !(hp = gethostbyaddr((char *)&addr, 4, AF_INET))) - sprintf(buf, "%s", inet_ntoa(*(struct in_addr *)&addr)); - else + if (!(options & F_NUMERIC)) { + if (buf[0] && addr == last_addr) + return buf; + hp = gethostbyaddr((char *)&addr, 4, AF_INET); + } + + if (hp) { snprintf(buf, sizeof(buf), "%s (%s)", hp->h_name, inet_ntoa(*(struct in_addr *)&addr)); + } else { + sprintf(buf, "%s", inet_ntoa(*(struct in_addr *)&addr)); + } + + last_addr = addr; return(buf); } diff -ur iputils/ping6.c iputils.new/ping6.c --- iputils/ping6.c 2004-03-17 12:36:43.000000000 +0100 +++ iputils.new/ping6.c 2004-03-17 12:36:29.000000000 +0100 @@ -898,11 +898,22 @@ char * pr_addr(struct in6_addr *addr) { struct hostent *hp = NULL; + static struct in6_addr last_addr; + static char buf[1024]; - if (!(options&F_NUMERIC)) + if (!(options&F_NUMERIC)) { + if (buf[0] && !memcmp(&last_addr, addr, sizeof(*addr))) + return buf; hp = gethostbyaddr((__u8*)addr, sizeof(struct in6_addr), AF_INET6); + } - return hp ? hp->h_name : pr_addr_n(addr); + if (hp && strlen(hp->h_name) < sizeof(buf)) { + strcpy(buf, hp->h_name); + } else { + inet_ntop(AF_INET6, addr, buf, sizeof(buf)); + } + last_addr = *addr; + return buf; } char * pr_addr_n(struct in6_addr *addr)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor