diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:46:04 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 22:46:04 +0000 |
commit | 5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6 (patch) | |
tree | 5ef5305297b2b964500873bed682f31b12d1479e | |
parent | 9adc6ced4fcab4d8a068874c55d5f563ce9e62f9 (diff) | |
download | busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.tar.gz busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.tar.bz2 busybox-w32-5de9e9ce0bcc5aacb53ec45e36b3fa6b5c7ab5f6.zip |
clean up commented out old code
-rw-r--r-- | include/libbb.h | 6 | ||||
-rw-r--r-- | networking/Config.in | 8 | ||||
-rw-r--r-- | networking/Kbuild | 1 | ||||
-rw-r--r-- | networking/fakeidentd.c | 378 | ||||
-rw-r--r-- | networking/nslookup.c | 55 | ||||
-rw-r--r-- | networking/ping6.c | 19 | ||||
-rw-r--r-- | scripts/defconfig | 1 |
7 files changed, 16 insertions, 452 deletions
diff --git a/include/libbb.h b/include/libbb.h index 1a5ce24ad..8cd4bc377 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -336,12 +336,10 @@ char* xmalloc_sockaddr2hostonly_noport(const struct sockaddr *sa, socklen_t sale | |||
336 | char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); | 336 | char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); |
337 | char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen); | 337 | char* xmalloc_sockaddr2dotted_noport(const struct sockaddr *sa, socklen_t salen); |
338 | // "old" (ipv4 only) API | 338 | // "old" (ipv4 only) API |
339 | //void bb_lookup_host(struct sockaddr_in *s_in, const char *host); | ||
340 | //int xconnect_tcp_v4(struct sockaddr_in *s_addr); | ||
341 | // users: traceroute.c hostname.c ifconfig.c ping.c | 339 | // users: traceroute.c hostname.c ifconfig.c ping.c |
342 | struct hostent *xgethostbyname(const char *name); | 340 | struct hostent *xgethostbyname(const char *name); |
343 | //// ping6 is the only user - convert to new API | 341 | //TODO: eliminate gethostbyname2 in arping (the only remaining place), |
344 | //struct hostent *xgethostbyname2(const char *name, int af); | 342 | //use host_and_af2sockaddr instead. |
345 | 343 | ||
346 | 344 | ||
347 | extern char *xstrdup(const char *s); | 345 | extern char *xstrdup(const char *s); |
diff --git a/networking/Config.in b/networking/Config.in index 3b00f03ef..6bb2d3b83 100644 --- a/networking/Config.in +++ b/networking/Config.in | |||
@@ -12,6 +12,14 @@ config FEATURE_IPV6 | |||
12 | Enable IPv6 support in busybox. | 12 | Enable IPv6 support in busybox. |
13 | This adds IPv6 support in the networking applets. | 13 | This adds IPv6 support in the networking applets. |
14 | 14 | ||
15 | config VERBOSE_RESOLUTION_ERRORS | ||
16 | bool "Verbose resolution errors" | ||
17 | default n | ||
18 | help | ||
19 | Enable if you are not satisfied with simplistic | ||
20 | "can't resolve 'hostname.com'" and want to know more. | ||
21 | This may increase size of your executable a bit. | ||
22 | |||
15 | config ARP | 23 | config ARP |
16 | bool "arp" | 24 | bool "arp" |
17 | default n | 25 | default n |
diff --git a/networking/Kbuild b/networking/Kbuild index bb024c9b7..65ecfbf5f 100644 --- a/networking/Kbuild +++ b/networking/Kbuild | |||
@@ -9,7 +9,6 @@ lib-$(CONFIG_ARP) += arp.o interface.o | |||
9 | lib-$(CONFIG_ARPING) += arping.o | 9 | lib-$(CONFIG_ARPING) += arping.o |
10 | lib-$(CONFIG_DNSD) += dnsd.o | 10 | lib-$(CONFIG_DNSD) += dnsd.o |
11 | lib-$(CONFIG_ETHER_WAKE) += ether-wake.o | 11 | lib-$(CONFIG_ETHER_WAKE) += ether-wake.o |
12 | #lib-$(CONFIG_FAKEIDENTD) += fakeidentd.o | ||
13 | lib-$(CONFIG_FAKEIDENTD) += isrv_identd.o isrv.o | 12 | lib-$(CONFIG_FAKEIDENTD) += isrv_identd.o isrv.o |
14 | lib-$(CONFIG_FTPGET) += ftpgetput.o | 13 | lib-$(CONFIG_FTPGET) += ftpgetput.o |
15 | lib-$(CONFIG_FTPPUT) += ftpgetput.o | 14 | lib-$(CONFIG_FTPPUT) += ftpgetput.o |
diff --git a/networking/fakeidentd.c b/networking/fakeidentd.c index 6f766a827..7af2f75fb 100644 --- a/networking/fakeidentd.c +++ b/networking/fakeidentd.c | |||
@@ -1,377 +1 @@ | |||
1 | /* NB: this file is to be removed soon. See isrv_identd.c */ | /* TO DELETE */ | |
2 | |||
3 | /* vi: set sw=4 ts=4: */ | ||
4 | /* | ||
5 | * A fake identd server | ||
6 | * | ||
7 | * Adapted to busybox by Thomas Lundquist <thomasez@zelow.no> | ||
8 | * Original Author: Tomi Ollila <too@iki.fi> | ||
9 | * http://www.guru-group.fi/~too/sw/ | ||
10 | * | ||
11 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | ||
12 | */ | ||
13 | |||
14 | /* Ident crash course | ||
15 | * | ||
16 | * Incoming requests are of form "6191, 23\r\n" - peer asks us | ||
17 | * "which user connected from your port 6191 to my port 23?" | ||
18 | * We should answer: | ||
19 | * "6193, 23 : USERID : UNIX : username\r\n" | ||
20 | * and close the connection. | ||
21 | * We can also reply: | ||
22 | * "6195, 23 : USERID : OTHER[,US-ASCII] : username\r\n" | ||
23 | * "6195, 23 : ERROR : INVALID-PORT/NO-USER/HIDDEN-USER/UNKNOWN-ERROR\r\n" | ||
24 | * but we probably will never want that. | ||
25 | */ | ||
26 | |||
27 | #include "busybox.h" | ||
28 | |||
29 | #define SANE_INETD_ONLY_VERSION | ||
30 | |||
31 | #ifdef SANE_INETD_ONLY_VERSION | ||
32 | |||
33 | int fakeidentd_main(int argc, char **argv) | ||
34 | { | ||
35 | char buf[64]; | ||
36 | const char *bogouser = "nobody"; | ||
37 | char *cur = buf; | ||
38 | int rem = sizeof(buf)-1; | ||
39 | |||
40 | if (argv[1]) | ||
41 | bogouser = argv[1]; | ||
42 | |||
43 | alarm(30); | ||
44 | while (1) { | ||
45 | char *p; | ||
46 | int sz = safe_read(0, cur, rem); | ||
47 | if (sz < 0) return 1; | ||
48 | cur[sz] = '\0'; | ||
49 | p = strpbrk(cur, "\r\n"); | ||
50 | if (p) { | ||
51 | *p = '\0'; | ||
52 | break; | ||
53 | } | ||
54 | cur += sz; | ||
55 | rem -= sz; | ||
56 | if (!rem || !sz) | ||
57 | break; | ||
58 | } | ||
59 | printf("%s : USERID : UNIX : %s\r\n", buf, bogouser); | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | #else | ||
64 | |||
65 | /* Welcome to the bloaty horrors */ | ||
66 | |||
67 | #include <sys/syslog.h> | ||
68 | #include <sys/uio.h> | ||
69 | |||
70 | #define MAXCONNS 20 | ||
71 | #define MAXIDLETIME 45 | ||
72 | |||
73 | static const char ident_substr[] = " : USERID : UNIX : "; | ||
74 | enum { ident_substr_len = sizeof(ident_substr) - 1 }; | ||
75 | #define PIDFILE "/var/run/identd.pid" | ||
76 | |||
77 | /* | ||
78 | * We have to track the 'first connection socket' so that we | ||
79 | * don't go around closing file descriptors for non-clients. | ||
80 | * | ||
81 | * descriptor setup normally | ||
82 | * 0 = server socket | ||
83 | * 1 = syslog fd (hopefully -- otherwise this won't work) | ||
84 | * 2 = connection socket after detached from tty. standard error before that | ||
85 | * 3 - 2 + MAXCONNS = rest connection sockets | ||
86 | * | ||
87 | * To try to make sure that syslog fd is what is "requested", the that fd | ||
88 | * is closed before openlog() call. It can only severely fail if fd 0 | ||
89 | * is initially closed. | ||
90 | */ | ||
91 | #define FCS 2 | ||
92 | |||
93 | /* | ||
94 | * FD of the connection is always the index of the connection structure | ||
95 | * in `conns' array + FCS | ||
96 | */ | ||
97 | static struct { | ||
98 | time_t lasttime; | ||
99 | int len; | ||
100 | char buf[20]; | ||
101 | } conns[MAXCONNS]; | ||
102 | |||
103 | /* When using global variables, bind those at least to a structure. */ | ||
104 | static struct { | ||
105 | const char *identuser; | ||
106 | fd_set readfds; | ||
107 | int conncnt; | ||
108 | } G; | ||
109 | |||
110 | static char *bind_ip_address; | ||
111 | |||
112 | static int chmatch(char c, char *chars) | ||
113 | { | ||
114 | for (; *chars; chars++) | ||
115 | if (c == *chars) | ||
116 | return 1; | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static int skipchars(char **p, char *chars) | ||
121 | { | ||
122 | while (chmatch(**p, chars)) | ||
123 | (*p)++; | ||
124 | if (**p == '\r' || **p == '\n') | ||
125 | return 0; | ||
126 | return 1; | ||
127 | } | ||
128 | |||
129 | static int parseAddrs(char *ptr, char **myaddr, char **heraddr) | ||
130 | { | ||
131 | /* parse <port-on-server> , <port-on-client> */ | ||
132 | |||
133 | if (!skipchars(&ptr, " \t")) | ||
134 | return -1; | ||
135 | |||
136 | *myaddr = ptr; | ||
137 | |||
138 | if (!skipchars(&ptr, "1234567890")) | ||
139 | return -1; | ||
140 | |||
141 | if (!chmatch(*ptr, " \t,")) | ||
142 | return -1; | ||
143 | |||
144 | *ptr++ = '\0'; | ||
145 | |||
146 | if (!skipchars(&ptr, " \t,") ) | ||
147 | return -1; | ||
148 | |||
149 | *heraddr = ptr; | ||
150 | |||
151 | skipchars(&ptr, "1234567890"); | ||
152 | |||
153 | if (!chmatch(*ptr, " \n\r")) | ||
154 | return -1; | ||
155 | |||
156 | *ptr = '\0'; | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static void replyError(int s, char *buf) | ||
162 | { | ||
163 | struct iovec iv[3]; | ||
164 | iv[0].iov_base = "0, 0 : ERROR : "; iv[0].iov_len = 15; | ||
165 | iv[1].iov_base = buf; iv[1].iov_len = strlen(buf); | ||
166 | iv[2].iov_base = "\r\n"; iv[2].iov_len = 2; | ||
167 | writev(s, iv, 3); | ||
168 | } | ||
169 | |||
170 | static void reply(int s, char *buf) | ||
171 | { | ||
172 | char *myaddr, *heraddr; | ||
173 | |||
174 | myaddr = heraddr = NULL; | ||
175 | |||
176 | if (parseAddrs(buf, &myaddr, &heraddr)) | ||
177 | replyError(s, "X-INVALID-REQUEST"); | ||
178 | else { | ||
179 | struct iovec iv[6]; | ||
180 | iv[0].iov_base = myaddr; iv[0].iov_len = strlen(myaddr); | ||
181 | iv[1].iov_base = ", "; iv[1].iov_len = 2; | ||
182 | iv[2].iov_base = heraddr; iv[2].iov_len = strlen(heraddr); | ||
183 | iv[3].iov_base = (void *)ident_substr; iv[3].iov_len = ident_substr_len; | ||
184 | iv[4].iov_base = (void *)G.identuser; iv[4].iov_len = strlen(G.identuser); | ||
185 | iv[5].iov_base = "\r\n"; iv[5].iov_len = 2; | ||
186 | writev(s, iv, 6); | ||
187 | } | ||
188 | } | ||
189 | |||
190 | static void movefd(int from, int to) | ||
191 | { | ||
192 | if (from != to) { | ||
193 | dup2(from, to); | ||
194 | close(from); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | static void deleteConn(int s) | ||
199 | { | ||
200 | int i = s - FCS; | ||
201 | |||
202 | close(s); | ||
203 | |||
204 | G.conncnt--; | ||
205 | |||
206 | /* | ||
207 | * Most of the time there is 0 connections. Most often that there | ||
208 | * is connections, there is just one connection. When this one connection | ||
209 | * closes, i == G.conncnt = 0 -> no copying. | ||
210 | * When there is more than one connection, the oldest connections closes | ||
211 | * earlier on average. When this happens, the code below starts copying | ||
212 | * the connection structure w/ highest index to the place which which is | ||
213 | * just deleted. This means that the connection structures are no longer | ||
214 | * in chronological order. I'd quess this means that when there is more | ||
215 | * than 1 connection, on average every other connection structure needs | ||
216 | * to be copied over the time all these connections are deleted. | ||
217 | */ | ||
218 | if (i != G.conncnt) { | ||
219 | memcpy(&conns[i], &conns[G.conncnt], sizeof(conns[0])); | ||
220 | movefd(G.conncnt + FCS, s); | ||
221 | } | ||
222 | |||
223 | FD_CLR(G.conncnt + FCS, &G.readfds); | ||
224 | } | ||
225 | |||
226 | static int closeOldest(void) | ||
227 | { | ||
228 | time_t min = conns[0].lasttime; | ||
229 | int idx = 0; | ||
230 | int i; | ||
231 | |||
232 | for (i = 1; i < MAXCONNS; i++) | ||
233 | if (conns[i].lasttime < min) | ||
234 | idx = i; | ||
235 | |||
236 | replyError(idx + FCS, "X-SERVER-TOO-BUSY"); | ||
237 | close(idx + FCS); | ||
238 | |||
239 | return idx; | ||
240 | } | ||
241 | |||
242 | static int checkInput(char *buf, int len, int l) | ||
243 | { | ||
244 | int i; | ||
245 | for (i = len; i < len + l; ++i) | ||
246 | if (buf[i] == '\n') | ||
247 | return 1; | ||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | /* May succeed. If not, won't care. */ | ||
252 | static const char *to_unlink; | ||
253 | static void writepid(void) | ||
254 | { | ||
255 | int fd = open(PIDFILE, O_WRONLY|O_CREAT|O_TRUNC, 0664); | ||
256 | if (fd < 0) | ||
257 | return; | ||
258 | to_unlink = PIDFILE; | ||
259 | fdprintf(fd, "%d\n", getpid()); | ||
260 | close(fd); | ||
261 | } | ||
262 | |||
263 | static void handlexitsigs(int signum) | ||
264 | { | ||
265 | if (to_unlink) | ||
266 | if (unlink(to_unlink) < 0) | ||
267 | close(open(to_unlink, O_WRONLY|O_CREAT|O_TRUNC, 0644)); | ||
268 | exit(0); | ||
269 | } | ||
270 | |||
271 | int fakeidentd_main(int argc, char **argv) | ||
272 | { | ||
273 | int fd; | ||
274 | pid_t pid; | ||
275 | |||
276 | /* FD_ZERO(&G.readfds); - in bss, already zeroed */ | ||
277 | FD_SET(0, &G.readfds); | ||
278 | |||
279 | /* handle -b <ip> parameter */ | ||
280 | getopt32(argc, argv, "b:", &bind_ip_address); | ||
281 | /* handle optional REPLY STRING */ | ||
282 | if (optind < argc) | ||
283 | G.identuser = argv[optind]; | ||
284 | else | ||
285 | G.identuser = "nobody"; | ||
286 | |||
287 | writepid(); | ||
288 | signal(SIGTERM, handlexitsigs); | ||
289 | signal(SIGINT, handlexitsigs); | ||
290 | signal(SIGQUIT, handlexitsigs); | ||
291 | signal(SIGHUP, SIG_IGN); | ||
292 | signal(SIGPIPE, SIG_IGN); /* ignore closed connections when writing */ | ||
293 | |||
294 | fd = create_and_bind_stream_or_die(bind_ip_address, bb_lookup_port("identd", "tcp", 113)); | ||
295 | xlisten(fd, 5); | ||
296 | |||
297 | pid = fork(); | ||
298 | if (pid < 0) | ||
299 | bb_perror_msg_and_die("fork"); | ||
300 | if (pid != 0) /* parent */ | ||
301 | exit(0); | ||
302 | /* child */ | ||
303 | setsid(); | ||
304 | movefd(fd, 0); | ||
305 | while (fd) | ||
306 | close(fd--); | ||
307 | openlog(applet_name, 0, LOG_DAEMON); | ||
308 | logmode = LOGMODE_SYSLOG; | ||
309 | |||
310 | /* main loop where we process all events and never exit */ | ||
311 | while (1) { | ||
312 | fd_set rfds = G.readfds; | ||
313 | struct timeval tv = { 15, 0 }; | ||
314 | int i; | ||
315 | int tim = time(NULL); | ||
316 | |||
317 | select(G.conncnt + FCS, &rfds, NULL, NULL, G.conncnt? &tv: NULL); | ||
318 | |||
319 | for (i = G.conncnt - 1; i >= 0; i--) { | ||
320 | int s = i + FCS; | ||
321 | |||
322 | if (FD_ISSET(s, &rfds)) { | ||
323 | char *buf = conns[i].buf; | ||
324 | unsigned len = conns[i].len; | ||
325 | unsigned l; | ||
326 | |||
327 | l = read(s, buf + len, sizeof(conns[0].buf) - len); | ||
328 | if (l > 0) { | ||
329 | if (checkInput(buf, len, l)) { | ||
330 | reply(s, buf); | ||
331 | goto deleteconn; | ||
332 | } else if (len + l >= sizeof(conns[0].buf)) { | ||
333 | replyError(s, "X-INVALID-REQUEST"); | ||
334 | goto deleteconn; | ||
335 | } else { | ||
336 | conns[i].len += l; | ||
337 | } | ||
338 | } else { | ||
339 | goto deleteconn; | ||
340 | } | ||
341 | conns[i].lasttime = tim; | ||
342 | continue; | ||
343 | deleteconn: | ||
344 | deleteConn(s); | ||
345 | } else { | ||
346 | /* implement as time_after() in linux kernel sources ... */ | ||
347 | if (conns[i].lasttime + MAXIDLETIME <= tim) { | ||
348 | replyError(s, "X-TIMEOUT"); | ||
349 | deleteConn(s); | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | |||
354 | if (FD_ISSET(0, &rfds)) { | ||
355 | int s = accept(0, NULL, 0); | ||
356 | |||
357 | if (s < 0) { | ||
358 | if (errno != EINTR) | ||
359 | bb_perror_msg("accept"); | ||
360 | } else { | ||
361 | if (G.conncnt == MAXCONNS) | ||
362 | i = closeOldest(); | ||
363 | else | ||
364 | i = G.conncnt++; | ||
365 | |||
366 | movefd(s, i + FCS); /* move if not already there */ | ||
367 | FD_SET(i + FCS, &G.readfds); | ||
368 | conns[i].len = 0; | ||
369 | conns[i].lasttime = time(NULL); | ||
370 | } | ||
371 | } | ||
372 | } /* end of while (1) */ | ||
373 | |||
374 | return 0; | ||
375 | } | ||
376 | |||
377 | #endif /* !SANE_INETD_ONLY_VERSION */ | ||
diff --git a/networking/nslookup.c b/networking/nslookup.c index af0816215..914f3f5ee 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -47,57 +47,8 @@ | |||
47 | * ns3.kernel.org internet address = 204.152.191.36 | 47 | * ns3.kernel.org internet address = 204.152.191.36 |
48 | */ | 48 | */ |
49 | 49 | ||
50 | /*static int sockaddr_to_dotted(struct sockaddr *saddr, char *buf, int buflen) | ||
51 | { | ||
52 | if (buflen <= 0) return -1; | ||
53 | buf[0] = '\0'; | ||
54 | if (saddr->sa_family == AF_INET) { | ||
55 | inet_ntop(AF_INET, &((struct sockaddr_in*)saddr)->sin_addr, buf, buflen); | ||
56 | return 0; | ||
57 | } | ||
58 | if (saddr->sa_family == AF_INET6) { | ||
59 | inet_ntop(AF_INET6, &((struct sockaddr_in6*)saddr)->sin6_addr, buf, buflen); | ||
60 | return 0; | ||
61 | } | ||
62 | return -1; | ||
63 | } | ||
64 | */ | ||
65 | |||
66 | static int print_host(const char *hostname, const char *header) | 50 | static int print_host(const char *hostname, const char *header) |
67 | { | 51 | { |
68 | #if 0 | ||
69 | char str[128]; /* IPv6 address will fit, hostnames hopefully too */ | ||
70 | struct addrinfo *result = NULL; | ||
71 | int rc; | ||
72 | struct addrinfo hint; | ||
73 | |||
74 | memset(&hint, 0 , sizeof(hint)); | ||
75 | /* hint.ai_family = AF_UNSPEC; - zero anyway */ | ||
76 | /* Needed. Or else we will get each address thrice (or more) | ||
77 | * for each possible socket type (tcp,udp,raw...): */ | ||
78 | hint.ai_socktype = SOCK_STREAM; | ||
79 | // hint.ai_flags = AI_CANONNAME; | ||
80 | rc = getaddrinfo(hostname, NULL /*service*/, &hint, &result); | ||
81 | |||
82 | if (!rc) { | ||
83 | struct addrinfo *cur = result; | ||
84 | // printf("%s\n", cur->ai_canonname); ? | ||
85 | while (cur) { | ||
86 | sockaddr_to_dotted(cur->ai_addr, str, sizeof(str)); | ||
87 | printf("%s %s\nAddress: %s", header, hostname, str); | ||
88 | str[0] = ' '; | ||
89 | if (getnameinfo(cur->ai_addr, cur->ai_addrlen, str+1, sizeof(str)-1, NULL, 0, NI_NAMEREQD)) | ||
90 | str[0] = '\0'; | ||
91 | puts(str); | ||
92 | cur = cur->ai_next; | ||
93 | } | ||
94 | } else { | ||
95 | bb_error_msg("getaddrinfo('%s') failed: %s", hostname, gai_strerror(rc)); | ||
96 | } | ||
97 | freeaddrinfo(result); | ||
98 | return (rc != 0); | ||
99 | |||
100 | #else | ||
101 | /* We can't use host2sockaddr() - we want to get ALL addresses, | 52 | /* We can't use host2sockaddr() - we want to get ALL addresses, |
102 | * not just one */ | 53 | * not just one */ |
103 | 54 | ||
@@ -136,7 +87,7 @@ static int print_host(const char *hostname, const char *header) | |||
136 | } | 87 | } |
137 | } else { | 88 | } else { |
138 | #if ENABLE_VERBOSE_RESOLUTION_ERRORS | 89 | #if ENABLE_VERBOSE_RESOLUTION_ERRORS |
139 | bb_error_msg("getaddrinfo('%s') failed: %s", hostname, gai_strerror(rc)); | 90 | bb_error_msg("can't resolve '%s': %s", hostname, gai_strerror(rc)); |
140 | #else | 91 | #else |
141 | bb_error_msg("can't resolve '%s'", hostname); | 92 | bb_error_msg("can't resolve '%s'", hostname); |
142 | #endif | 93 | #endif |
@@ -144,10 +95,8 @@ static int print_host(const char *hostname, const char *header) | |||
144 | if (ENABLE_FEATURE_CLEAN_UP) | 95 | if (ENABLE_FEATURE_CLEAN_UP) |
145 | freeaddrinfo(result); | 96 | freeaddrinfo(result); |
146 | return (rc != 0); | 97 | return (rc != 0); |
147 | #endif | ||
148 | } | 98 | } |
149 | 99 | ||
150 | |||
151 | /* lookup the default nameserver and display it */ | 100 | /* lookup the default nameserver and display it */ |
152 | static void server_print(void) | 101 | static void server_print(void) |
153 | { | 102 | { |
@@ -167,7 +116,6 @@ static void server_print(void) | |||
167 | puts(""); | 116 | puts(""); |
168 | } | 117 | } |
169 | 118 | ||
170 | |||
171 | /* alter the global _res nameserver structure to use | 119 | /* alter the global _res nameserver structure to use |
172 | an explicit dns server instead of what is in /etc/resolv.h */ | 120 | an explicit dns server instead of what is in /etc/resolv.h */ |
173 | static void set_default_dns(char *server) | 121 | static void set_default_dns(char *server) |
@@ -180,7 +128,6 @@ static void set_default_dns(char *server) | |||
180 | } | 128 | } |
181 | } | 129 | } |
182 | 130 | ||
183 | |||
184 | int nslookup_main(int argc, char **argv) | 131 | int nslookup_main(int argc, char **argv) |
185 | { | 132 | { |
186 | /* We allow 1 or 2 arguments. | 133 | /* We allow 1 or 2 arguments. |
diff --git a/networking/ping6.c b/networking/ping6.c index ccb19b2b5..b95e098ad 100644 --- a/networking/ping6.c +++ b/networking/ping6.c | |||
@@ -48,8 +48,6 @@ static void ping(const char *host); | |||
48 | 48 | ||
49 | /* simple version */ | 49 | /* simple version */ |
50 | 50 | ||
51 | //static struct hostent *h; | ||
52 | |||
53 | static void noresp(int ign) | 51 | static void noresp(int ign) |
54 | { | 52 | { |
55 | printf("No response from %s\n", h->h_name); | 53 | printf("No response from %s\n", h->h_name); |
@@ -58,7 +56,7 @@ static void noresp(int ign) | |||
58 | 56 | ||
59 | static void ping(const char *host) | 57 | static void ping(const char *host) |
60 | { | 58 | { |
61 | len_and_sockaddr *lsa;// | 59 | len_and_sockaddr *lsa; |
62 | struct sockaddr_in6 pingaddr; | 60 | struct sockaddr_in6 pingaddr; |
63 | struct icmp6_hdr *pkt; | 61 | struct icmp6_hdr *pkt; |
64 | int pingsock, c; | 62 | int pingsock, c; |
@@ -67,10 +65,6 @@ static void ping(const char *host) | |||
67 | 65 | ||
68 | pingsock = create_icmp6_socket(); | 66 | pingsock = create_icmp6_socket(); |
69 | 67 | ||
70 | //memset(&pingaddr, 0, sizeof(pingaddr)); | ||
71 | //pingaddr.sin6_family = AF_INET6; | ||
72 | //h = xgethostbyname2(host, AF_INET6); | ||
73 | //memcpy(&pingaddr.sin6_addr, h->h_addr, sizeof(pingaddr.sin6_addr)); | ||
74 | lsa = host_and_af2sockaddr(host, 0, AF_INET6); | 68 | lsa = host_and_af2sockaddr(host, 0, AF_INET6); |
75 | pingaddr = lsa->sin6; | 69 | pingaddr = lsa->sin6; |
76 | 70 | ||
@@ -144,8 +138,7 @@ static int myid; | |||
144 | static unsigned long tmin = ULONG_MAX, tmax, tsum; | 138 | static unsigned long tmin = ULONG_MAX, tmax, tsum; |
145 | static char rcvd_tbl[MAX_DUP_CHK / 8]; | 139 | static char rcvd_tbl[MAX_DUP_CHK / 8]; |
146 | 140 | ||
147 | //static struct hostent *hostent; | 141 | static char *hostname; |
148 | char *hostname; | ||
149 | 142 | ||
150 | static void sendping(int); | 143 | static void sendping(int); |
151 | static void pingstats(int); | 144 | static void pingstats(int); |
@@ -318,7 +311,7 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit | |||
318 | extern int BUG_bad_offsetof_icmp6_cksum(void); | 311 | extern int BUG_bad_offsetof_icmp6_cksum(void); |
319 | static void ping(const char *host) | 312 | static void ping(const char *host) |
320 | { | 313 | { |
321 | len_and_sockaddr *lsa;// | 314 | len_and_sockaddr *lsa; |
322 | char packet[datalen + MAXIPLEN + MAXICMPLEN]; | 315 | char packet[datalen + MAXIPLEN + MAXICMPLEN]; |
323 | char buf[INET6_ADDRSTRLEN]; | 316 | char buf[INET6_ADDRSTRLEN]; |
324 | int sockopt; | 317 | int sockopt; |
@@ -329,12 +322,6 @@ static void ping(const char *host) | |||
329 | 322 | ||
330 | pingsock = create_icmp6_socket(); | 323 | pingsock = create_icmp6_socket(); |
331 | 324 | ||
332 | //memset(&pingaddr, 0, sizeof(pingaddr)); | ||
333 | //pingaddr.sin6_family = AF_INET6; | ||
334 | //hostent = xgethostbyname2(host, AF_INET6); | ||
335 | //if (hostent->h_addrtype != AF_INET6) | ||
336 | // 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)); | ||
338 | lsa = host_and_af2sockaddr(host, 0, AF_INET6); | 325 | lsa = host_and_af2sockaddr(host, 0, AF_INET6); |
339 | hostname = xmalloc_sockaddr2host_noport(&lsa->sa, lsa->len); | 326 | hostname = xmalloc_sockaddr2host_noport(&lsa->sa, lsa->len); |
340 | pingaddr = lsa->sin6; | 327 | pingaddr = lsa->sin6; |
diff --git a/scripts/defconfig b/scripts/defconfig index 8f15481de..6a1c57bc8 100644 --- a/scripts/defconfig +++ b/scripts/defconfig | |||
@@ -501,6 +501,7 @@ CONFIG_WATCHDOG=y | |||
501 | # Networking Utilities | 501 | # Networking Utilities |
502 | # | 502 | # |
503 | CONFIG_FEATURE_IPV6=y | 503 | CONFIG_FEATURE_IPV6=y |
504 | # CONFIG_VERBOSE_RESOLUTION_ERRORS is not set | ||
504 | CONFIG_ARP=y | 505 | CONFIG_ARP=y |
505 | CONFIG_ARPING=y | 506 | CONFIG_ARPING=y |
506 | CONFIG_DNSD=y | 507 | CONFIG_DNSD=y |