aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-22 22:45:27 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-01-22 22:45:27 +0000
commitcb06cc8dd6d8c973fd8ca661d56498353185f6dd (patch)
tree586266ceaeff8f26c8f08b24b2ad0df1630097e6 /networking
parenta78f04d49051a5d5742ef605fb5d3670e9938c57 (diff)
downloadbusybox-w32-cb06cc8dd6d8c973fd8ca661d56498353185f6dd.tar.gz
busybox-w32-cb06cc8dd6d8c973fd8ca661d56498353185f6dd.tar.bz2
busybox-w32-cb06cc8dd6d8c973fd8ca661d56498353185f6dd.zip
ping6: stop using xgethostbyname2, remove it from libbb.
git-svn-id: svn://busybox.net/trunk/busybox@17478 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r--networking/ping.c5
-rw-r--r--networking/ping6.c44
2 files changed, 28 insertions, 21 deletions
diff --git a/networking/ping.c b/networking/ping.c
index 91708d282..fc2de456a 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -97,7 +97,7 @@ static void ping(const char *host)
97 } 97 }
98 98
99 signal(SIGALRM, noresp); 99 signal(SIGALRM, noresp);
100 alarm(5); /* give the host 5000ms to respond */ 100 alarm(5); /* give the host 5000ms to respond */
101 /* listen for replies */ 101 /* listen for replies */
102 while (1) { 102 while (1) {
103 struct sockaddr_in from; 103 struct sockaddr_in from;
@@ -118,7 +118,8 @@ static void ping(const char *host)
118 break; 118 break;
119 } 119 }
120 } 120 }
121 if (ENABLE_FEATURE_CLEAN_UP) close(pingsock); 121 if (ENABLE_FEATURE_CLEAN_UP)
122 close(pingsock);
122 printf("%s is alive!\n", hostname); 123 printf("%s is alive!\n", hostname);
123} 124}
124 125
diff --git a/networking/ping6.c b/networking/ping6.c
index a92387e79..ccb19b2b5 100644
--- a/networking/ping6.c
+++ b/networking/ping6.c
@@ -48,7 +48,7 @@ static void ping(const char *host);
48 48
49/* simple version */ 49/* simple version */
50 50
51static struct hostent *h; 51//static struct hostent *h;
52 52
53static void noresp(int ign) 53static void noresp(int ign)
54{ 54{
@@ -58,6 +58,7 @@ static void noresp(int ign)
58 58
59static void ping(const char *host) 59static void ping(const char *host)
60{ 60{
61 len_and_sockaddr *lsa;//
61 struct sockaddr_in6 pingaddr; 62 struct sockaddr_in6 pingaddr;
62 struct icmp6_hdr *pkt; 63 struct icmp6_hdr *pkt;
63 int pingsock, c; 64 int pingsock, c;
@@ -66,11 +67,12 @@ static void ping(const char *host)
66 67
67 pingsock = create_icmp6_socket(); 68 pingsock = create_icmp6_socket();
68 69
69 memset(&pingaddr, 0, sizeof(pingaddr)); 70 //memset(&pingaddr, 0, sizeof(pingaddr));
70 71 //pingaddr.sin6_family = AF_INET6;
71 pingaddr.sin6_family = AF_INET6; 72 //h = xgethostbyname2(host, AF_INET6);
72 h = xgethostbyname2(host, AF_INET6); 73 //memcpy(&pingaddr.sin6_addr, h->h_addr, sizeof(pingaddr.sin6_addr));
73 memcpy(&pingaddr.sin6_addr, h->h_addr, sizeof(pingaddr.sin6_addr)); 74 lsa = host_and_af2sockaddr(host, 0, AF_INET6);
75 pingaddr = lsa->sin6;
74 76
75 pkt = (struct icmp6_hdr *) packet; 77 pkt = (struct icmp6_hdr *) packet;
76 memset(pkt, 0, sizeof(packet)); 78 memset(pkt, 0, sizeof(packet));
@@ -88,7 +90,7 @@ static void ping(const char *host)
88 } 90 }
89 91
90 signal(SIGALRM, noresp); 92 signal(SIGALRM, noresp);
91 alarm(5); /* give the host 5000ms to respond */ 93 alarm(5); /* give the host 5000ms to respond */
92 /* listen for replies */ 94 /* listen for replies */
93 while (1) { 95 while (1) {
94 struct sockaddr_in6 from; 96 struct sockaddr_in6 from;
@@ -107,7 +109,8 @@ static void ping(const char *host)
107 break; 109 break;
108 } 110 }
109 } 111 }
110 if (ENABLE_FEATURE_CLEAN_UP) close(pingsock); 112 if (ENABLE_FEATURE_CLEAN_UP)
113 close(pingsock);
111 printf("%s is alive!\n", h->h_name); 114 printf("%s is alive!\n", h->h_name);
112} 115}
113 116
@@ -141,7 +144,8 @@ static int myid;
141static unsigned long tmin = ULONG_MAX, tmax, tsum; 144static unsigned long tmin = ULONG_MAX, tmax, tsum;
142static char rcvd_tbl[MAX_DUP_CHK / 8]; 145static char rcvd_tbl[MAX_DUP_CHK / 8];
143 146
144static struct hostent *hostent; 147//static struct hostent *hostent;
148char *hostname;
145 149
146static void sendping(int); 150static void sendping(int);
147static void pingstats(int); 151static void pingstats(int);
@@ -161,7 +165,7 @@ static void pingstats(int junk)
161 165
162 signal(SIGINT, SIG_IGN); 166 signal(SIGINT, SIG_IGN);
163 167
164 printf("\n--- %s ping statistics ---\n", hostent->h_name); 168 printf("\n--- %s ping statistics ---\n", hostname);
165 printf("%lu packets transmitted, ", ntransmitted); 169 printf("%lu packets transmitted, ", ntransmitted);
166 printf("%lu packets received, ", nreceived); 170 printf("%lu packets received, ", nreceived);
167 if (nrepeats) 171 if (nrepeats)
@@ -314,6 +318,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit
314extern int BUG_bad_offsetof_icmp6_cksum(void); 318extern int BUG_bad_offsetof_icmp6_cksum(void);
315static void ping(const char *host) 319static void ping(const char *host)
316{ 320{
321 len_and_sockaddr *lsa;//
317 char packet[datalen + MAXIPLEN + MAXICMPLEN]; 322 char packet[datalen + MAXIPLEN + MAXICMPLEN];
318 char buf[INET6_ADDRSTRLEN]; 323 char buf[INET6_ADDRSTRLEN];
319 int sockopt; 324 int sockopt;
@@ -324,14 +329,15 @@ static void ping(const char *host)
324 329
325 pingsock = create_icmp6_socket(); 330 pingsock = create_icmp6_socket();
326 331
327 memset(&pingaddr, 0, sizeof(pingaddr)); 332 //memset(&pingaddr, 0, sizeof(pingaddr));
328 333 //pingaddr.sin6_family = AF_INET6;
329 pingaddr.sin6_family = AF_INET6; 334 //hostent = xgethostbyname2(host, AF_INET6);
330 hostent = xgethostbyname2(host, AF_INET6); 335 //if (hostent->h_addrtype != AF_INET6)
331 if (hostent->h_addrtype != AF_INET6) 336 // bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported");
332 bb_error_msg_and_die("unknown address type; only AF_INET6 is currently supported"); 337 //memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr));
333 338 lsa = host_and_af2sockaddr(host, 0, AF_INET6);
334 memcpy(&pingaddr.sin6_addr, hostent->h_addr, sizeof(pingaddr.sin6_addr)); 339 hostname = xmalloc_sockaddr2host_noport(&lsa->sa, lsa->len);
340 pingaddr = lsa->sin6;
335 341
336#ifdef ICMP6_FILTER 342#ifdef ICMP6_FILTER
337 { 343 {
@@ -367,7 +373,7 @@ static void ping(const char *host)
367 pingaddr.sin6_scope_id = if_index; 373 pingaddr.sin6_scope_id = if_index;
368 374
369 printf("PING %s (%s): %d data bytes\n", 375 printf("PING %s (%s): %d data bytes\n",
370 hostent->h_name, 376 hostname,
371 inet_ntop(AF_INET6, &pingaddr.sin6_addr, 377 inet_ntop(AF_INET6, &pingaddr.sin6_addr,
372 buf, sizeof(buf)), 378 buf, sizeof(buf)),
373 datalen); 379 datalen);