SHA256
1
0
forked from pool/iputils
iputils/iputils-pingnamelookuponce.diff
Marcus Schaefer a2f67ab311 - fixed device broadcast setup (bnc #614389)
- upstream maintainer has changed. new maintainer is
  YOSHIFUJI Hideaki. Along with this change the versioning
  of the package also changed. Current version is: s20100418
  from 18-Apr-2010
- many patches upstream now, reduced patch set

OBS-URL: https://build.opensuse.org/package/show/network:utilities/iputils?expand=0&rev=11
2010-07-14 12:07:32 +00:00

62 lines
1.6 KiB
Diff

diff -ur iputils/ping.c iputils.new/ping.c
--- ping.c 2004-03-17 12:36:43.000000000 +0100
+++ 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
--- ping6.c 2004-03-17 12:36:43.000000000 +0100
+++ 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)