diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:56:15 +0700 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2011-01-04 19:56:15 +0700 |
commit | 5f6f2162512106adf120d4b528bb125e93e34429 (patch) | |
tree | 7d7449f755633c263be7125ad58d21cc3ca5b8a7 /networking | |
parent | 9db69882bee2d528d706d61d34ef7741122330be (diff) | |
parent | a116552869db5e7793ae10968eb3c962c69b3d8c (diff) | |
download | busybox-w32-5f6f2162512106adf120d4b528bb125e93e34429.tar.gz busybox-w32-5f6f2162512106adf120d4b528bb125e93e34429.tar.bz2 busybox-w32-5f6f2162512106adf120d4b528bb125e93e34429.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'networking')
39 files changed, 414 insertions, 357 deletions
diff --git a/networking/Config.src b/networking/Config.src index 6dd7df754..274fcae3a 100644 --- a/networking/Config.src +++ b/networking/Config.src | |||
@@ -684,29 +684,6 @@ config FEATURE_NTPD_SERVER | |||
684 | Make ntpd usable as a NTP server. If you disable this option | 684 | Make ntpd usable as a NTP server. If you disable this option |
685 | ntpd will be usable only as a NTP client. | 685 | ntpd will be usable only as a NTP client. |
686 | 686 | ||
687 | config PING | ||
688 | bool "ping" | ||
689 | default y | ||
690 | depends on PLATFORM_LINUX | ||
691 | help | ||
692 | ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to | ||
693 | elicit an ICMP ECHO_RESPONSE from a host or gateway. | ||
694 | |||
695 | config PING6 | ||
696 | bool "ping6" | ||
697 | default y | ||
698 | depends on FEATURE_IPV6 && PING | ||
699 | help | ||
700 | This will give you a ping that can talk IPv6. | ||
701 | |||
702 | config FEATURE_FANCY_PING | ||
703 | bool "Enable fancy ping output" | ||
704 | default y | ||
705 | depends on PING | ||
706 | help | ||
707 | Make the output from the ping applet include statistics, and at the | ||
708 | same time provide full support for ICMP packets. | ||
709 | |||
710 | config PSCAN | 687 | config PSCAN |
711 | bool "pscan" | 688 | bool "pscan" |
712 | default y | 689 | default y |
diff --git a/networking/Kbuild.src b/networking/Kbuild.src index f41a2df70..944f27be1 100644 --- a/networking/Kbuild.src +++ b/networking/Kbuild.src | |||
@@ -30,8 +30,6 @@ lib-$(CONFIG_NC) += nc.o | |||
30 | lib-$(CONFIG_NETSTAT) += netstat.o | 30 | lib-$(CONFIG_NETSTAT) += netstat.o |
31 | lib-$(CONFIG_NSLOOKUP) += nslookup.o | 31 | lib-$(CONFIG_NSLOOKUP) += nslookup.o |
32 | lib-$(CONFIG_NTPD) += ntpd.o | 32 | lib-$(CONFIG_NTPD) += ntpd.o |
33 | lib-$(CONFIG_PING) += ping.o | ||
34 | lib-$(CONFIG_PING6) += ping.o | ||
35 | lib-$(CONFIG_PSCAN) += pscan.o | 33 | lib-$(CONFIG_PSCAN) += pscan.o |
36 | lib-$(CONFIG_ROUTE) += route.o | 34 | lib-$(CONFIG_ROUTE) += route.o |
37 | lib-$(CONFIG_SLATTACH) += slattach.o | 35 | lib-$(CONFIG_SLATTACH) += slattach.o |
diff --git a/networking/arping.c b/networking/arping.c index f2b12ed04..6f6b59cfb 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -1,10 +1,8 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * arping.c - Ping hosts by ARP requests/replies | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Author: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> | 5 | * Author: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> |
8 | * Busybox port: Nick Fedchik <nick@fedchik.org.ua> | 6 | * Busybox port: Nick Fedchik <nick@fedchik.org.ua> |
9 | */ | 7 | */ |
10 | 8 | ||
diff --git a/networking/dnsd.c b/networking/dnsd.c index 92d4867aa..8ed31cea2 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -388,7 +388,7 @@ static int process_packet(struct dns_entry *conf_data, | |||
388 | query_len = strlen(query_string) + 1; | 388 | query_len = strlen(query_string) + 1; |
389 | /* may be unaligned! */ | 389 | /* may be unaligned! */ |
390 | unaligned_type_class = (void *)(query_string + query_len); | 390 | unaligned_type_class = (void *)(query_string + query_len); |
391 | query_len += sizeof(unaligned_type_class); | 391 | query_len += sizeof(*unaligned_type_class); |
392 | /* where to append answer block */ | 392 | /* where to append answer block */ |
393 | answb = (void *)(unaligned_type_class + 1); | 393 | answb = (void *)(unaligned_type_class + 1); |
394 | 394 | ||
diff --git a/networking/httpd.c b/networking/httpd.c index c174958e2..fa42d9850 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -231,7 +231,7 @@ struct globals { | |||
231 | int verbose; /* must be int (used by getopt32) */ | 231 | int verbose; /* must be int (used by getopt32) */ |
232 | smallint flg_deny_all; | 232 | smallint flg_deny_all; |
233 | 233 | ||
234 | unsigned rmt_ip; /* used for IP-based allow/deny rules */ | 234 | unsigned rmt_ip; /* used for IP-based allow/deny rules */ |
235 | time_t last_mod; | 235 | time_t last_mod; |
236 | char *rmt_ip_str; /* for $REMOTE_ADDR and $REMOTE_PORT */ | 236 | char *rmt_ip_str; /* for $REMOTE_ADDR and $REMOTE_PORT */ |
237 | const char *bind_addr_or_port; | 237 | const char *bind_addr_or_port; |
@@ -267,7 +267,7 @@ struct globals { | |||
267 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR | 267 | #if ENABLE_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR |
268 | Htaccess *script_i; /* config script interpreters */ | 268 | Htaccess *script_i; /* config script interpreters */ |
269 | #endif | 269 | #endif |
270 | char *iobuf; /* [IOBUF_SIZE] */ | 270 | char *iobuf; /* [IOBUF_SIZE] */ |
271 | #define hdr_buf bb_common_bufsiz1 | 271 | #define hdr_buf bb_common_bufsiz1 |
272 | char *hdr_ptr; | 272 | char *hdr_ptr; |
273 | int hdr_cnt; | 273 | int hdr_cnt; |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 3cb1ec858..59df4e80f 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -164,7 +164,7 @@ static char *get_var(const char *id, size_t idlen, struct interface_defn_t *ifd) | |||
164 | return NULL; | 164 | return NULL; |
165 | } | 165 | } |
166 | 166 | ||
167 | #if ENABLE_FEATURE_IFUPDOWN_IP | 167 | # if ENABLE_FEATURE_IFUPDOWN_IP |
168 | static int count_netmask_bits(const char *dotted_quad) | 168 | static int count_netmask_bits(const char *dotted_quad) |
169 | { | 169 | { |
170 | // int result; | 170 | // int result; |
@@ -195,7 +195,7 @@ static int count_netmask_bits(const char *dotted_quad) | |||
195 | } | 195 | } |
196 | return result; | 196 | return result; |
197 | } | 197 | } |
198 | #endif | 198 | # endif |
199 | 199 | ||
200 | static char *parse(const char *command, struct interface_defn_t *ifd) | 200 | static char *parse(const char *command, struct interface_defn_t *ifd) |
201 | { | 201 | { |
@@ -258,17 +258,17 @@ static char *parse(const char *command, struct interface_defn_t *ifd) | |||
258 | varvalue = get_var(command, nextpercent - command, ifd); | 258 | varvalue = get_var(command, nextpercent - command, ifd); |
259 | 259 | ||
260 | if (varvalue) { | 260 | if (varvalue) { |
261 | #if ENABLE_FEATURE_IFUPDOWN_IP | 261 | # if ENABLE_FEATURE_IFUPDOWN_IP |
262 | /* "hwaddress <class> <address>": | 262 | /* "hwaddress <class> <address>": |
263 | * unlike ifconfig, ip doesnt want <class> | 263 | * unlike ifconfig, ip doesnt want <class> |
264 | * (usually "ether" keyword). Skip it. */ | 264 | * (usually "ether" keyword). Skip it. */ |
265 | if (strncmp(command, "hwaddress", 9) == 0) { | 265 | if (strncmp(command, "hwaddress", 9) == 0) { |
266 | varvalue = skip_whitespace(skip_non_whitespace(varvalue)); | 266 | varvalue = skip_whitespace(skip_non_whitespace(varvalue)); |
267 | } | 267 | } |
268 | #endif | 268 | # endif |
269 | addstr(&result, varvalue, strlen(varvalue)); | 269 | addstr(&result, varvalue, strlen(varvalue)); |
270 | } else { | 270 | } else { |
271 | #if ENABLE_FEATURE_IFUPDOWN_IP | 271 | # if ENABLE_FEATURE_IFUPDOWN_IP |
272 | /* Sigh... Add a special case for 'ip' to convert from | 272 | /* Sigh... Add a special case for 'ip' to convert from |
273 | * dotted quad to bit count style netmasks. */ | 273 | * dotted quad to bit count style netmasks. */ |
274 | if (strncmp(command, "bnmask", 6) == 0) { | 274 | if (strncmp(command, "bnmask", 6) == 0) { |
@@ -284,7 +284,7 @@ static char *parse(const char *command, struct interface_defn_t *ifd) | |||
284 | } | 284 | } |
285 | } | 285 | } |
286 | } | 286 | } |
287 | #endif | 287 | # endif |
288 | okay[opt_depth - 1] = 0; | 288 | okay[opt_depth - 1] = 0; |
289 | } | 289 | } |
290 | 290 | ||
@@ -329,56 +329,64 @@ static int execute(const char *command, struct interface_defn_t *ifd, execfn *ex | |||
329 | } | 329 | } |
330 | return 1; | 330 | return 1; |
331 | } | 331 | } |
332 | #endif | 332 | |
333 | #endif /* FEATURE_IFUPDOWN_IPV4 || FEATURE_IFUPDOWN_IPV6 */ | ||
334 | |||
333 | 335 | ||
334 | #if ENABLE_FEATURE_IFUPDOWN_IPV6 | 336 | #if ENABLE_FEATURE_IFUPDOWN_IPV6 |
337 | |||
335 | static int FAST_FUNC loopback_up6(struct interface_defn_t *ifd, execfn *exec) | 338 | static int FAST_FUNC loopback_up6(struct interface_defn_t *ifd, execfn *exec) |
336 | { | 339 | { |
337 | #if ENABLE_FEATURE_IFUPDOWN_IP | 340 | # if ENABLE_FEATURE_IFUPDOWN_IP |
338 | int result; | 341 | int result; |
339 | result = execute("ip addr add ::1 dev %iface%", ifd, exec); | 342 | result = execute("ip addr add ::1 dev %iface%", ifd, exec); |
340 | result += execute("ip link set %iface% up", ifd, exec); | 343 | result += execute("ip link set %iface% up", ifd, exec); |
341 | return ((result == 2) ? 2 : 0); | 344 | return ((result == 2) ? 2 : 0); |
342 | #else | 345 | # else |
343 | return execute("ifconfig %iface% add ::1", ifd, exec); | 346 | return execute("ifconfig %iface% add ::1", ifd, exec); |
344 | #endif | 347 | # endif |
345 | } | 348 | } |
346 | 349 | ||
347 | static int FAST_FUNC loopback_down6(struct interface_defn_t *ifd, execfn *exec) | 350 | static int FAST_FUNC loopback_down6(struct interface_defn_t *ifd, execfn *exec) |
348 | { | 351 | { |
349 | #if ENABLE_FEATURE_IFUPDOWN_IP | 352 | # if ENABLE_FEATURE_IFUPDOWN_IP |
350 | return execute("ip link set %iface% down", ifd, exec); | 353 | return execute("ip link set %iface% down", ifd, exec); |
351 | #else | 354 | # else |
352 | return execute("ifconfig %iface% del ::1", ifd, exec); | 355 | return execute("ifconfig %iface% del ::1", ifd, exec); |
353 | #endif | 356 | # endif |
357 | } | ||
358 | |||
359 | static int FAST_FUNC manual_up_down6(struct interface_defn_t *ifd UNUSED_PARAM, execfn *exec UNUSED_PARAM) | ||
360 | { | ||
361 | return 1; | ||
354 | } | 362 | } |
355 | 363 | ||
356 | static int FAST_FUNC static_up6(struct interface_defn_t *ifd, execfn *exec) | 364 | static int FAST_FUNC static_up6(struct interface_defn_t *ifd, execfn *exec) |
357 | { | 365 | { |
358 | int result; | 366 | int result; |
359 | #if ENABLE_FEATURE_IFUPDOWN_IP | 367 | # if ENABLE_FEATURE_IFUPDOWN_IP |
360 | result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); | 368 | result = execute("ip addr add %address%/%netmask% dev %iface%[[ label %label%]]", ifd, exec); |
361 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); | 369 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); |
362 | /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ | 370 | /* Was: "[[ ip ....%gateway% ]]". Removed extra spaces w/o checking */ |
363 | result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); | 371 | result += execute("[[ip route add ::/0 via %gateway%]]", ifd, exec); |
364 | #else | 372 | # else |
365 | result = execute("ifconfig %iface%[[ media %media%]][[ hw %hwaddress%]][[ mtu %mtu%]] up", ifd, exec); | 373 | result = execute("ifconfig %iface%[[ media %media%]][[ hw %hwaddress%]][[ mtu %mtu%]] up", ifd, exec); |
366 | result += execute("ifconfig %iface% add %address%/%netmask%", ifd, exec); | 374 | result += execute("ifconfig %iface% add %address%/%netmask%", ifd, exec); |
367 | result += execute("[[route -A inet6 add ::/0 gw %gateway%]]", ifd, exec); | 375 | result += execute("[[route -A inet6 add ::/0 gw %gateway%]]", ifd, exec); |
368 | #endif | 376 | # endif |
369 | return ((result == 3) ? 3 : 0); | 377 | return ((result == 3) ? 3 : 0); |
370 | } | 378 | } |
371 | 379 | ||
372 | static int FAST_FUNC static_down6(struct interface_defn_t *ifd, execfn *exec) | 380 | static int FAST_FUNC static_down6(struct interface_defn_t *ifd, execfn *exec) |
373 | { | 381 | { |
374 | #if ENABLE_FEATURE_IFUPDOWN_IP | 382 | # if ENABLE_FEATURE_IFUPDOWN_IP |
375 | return execute("ip link set %iface% down", ifd, exec); | 383 | return execute("ip link set %iface% down", ifd, exec); |
376 | #else | 384 | # else |
377 | return execute("ifconfig %iface% down", ifd, exec); | 385 | return execute("ifconfig %iface% down", ifd, exec); |
378 | #endif | 386 | # endif |
379 | } | 387 | } |
380 | 388 | ||
381 | #if ENABLE_FEATURE_IFUPDOWN_IP | 389 | # if ENABLE_FEATURE_IFUPDOWN_IP |
382 | static int FAST_FUNC v4tunnel_up(struct interface_defn_t *ifd, execfn *exec) | 390 | static int FAST_FUNC v4tunnel_up(struct interface_defn_t *ifd, execfn *exec) |
383 | { | 391 | { |
384 | int result; | 392 | int result; |
@@ -394,14 +402,15 @@ static int FAST_FUNC v4tunnel_down(struct interface_defn_t * ifd, execfn * exec) | |||
394 | { | 402 | { |
395 | return execute("ip tunnel del %iface%", ifd, exec); | 403 | return execute("ip tunnel del %iface%", ifd, exec); |
396 | } | 404 | } |
397 | #endif | 405 | # endif |
398 | 406 | ||
399 | static const struct method_t methods6[] = { | 407 | static const struct method_t methods6[] = { |
400 | #if ENABLE_FEATURE_IFUPDOWN_IP | 408 | # if ENABLE_FEATURE_IFUPDOWN_IP |
401 | { "v4tunnel", v4tunnel_up, v4tunnel_down, }, | 409 | { "v4tunnel" , v4tunnel_up , v4tunnel_down , }, |
402 | #endif | 410 | # endif |
403 | { "static", static_up6, static_down6, }, | 411 | { "static" , static_up6 , static_down6 , }, |
404 | { "loopback", loopback_up6, loopback_down6, }, | 412 | { "manual" , manual_up_down6 , manual_up_down6 , }, |
413 | { "loopback" , loopback_up6 , loopback_down6 , }, | ||
405 | }; | 414 | }; |
406 | 415 | ||
407 | static const struct address_family_t addr_inet6 = { | 416 | static const struct address_family_t addr_inet6 = { |
@@ -409,43 +418,46 @@ static const struct address_family_t addr_inet6 = { | |||
409 | ARRAY_SIZE(methods6), | 418 | ARRAY_SIZE(methods6), |
410 | methods6 | 419 | methods6 |
411 | }; | 420 | }; |
421 | |||
412 | #endif /* FEATURE_IFUPDOWN_IPV6 */ | 422 | #endif /* FEATURE_IFUPDOWN_IPV6 */ |
413 | 423 | ||
424 | |||
414 | #if ENABLE_FEATURE_IFUPDOWN_IPV4 | 425 | #if ENABLE_FEATURE_IFUPDOWN_IPV4 |
426 | |||
415 | static int FAST_FUNC loopback_up(struct interface_defn_t *ifd, execfn *exec) | 427 | static int FAST_FUNC loopback_up(struct interface_defn_t *ifd, execfn *exec) |
416 | { | 428 | { |
417 | #if ENABLE_FEATURE_IFUPDOWN_IP | 429 | # if ENABLE_FEATURE_IFUPDOWN_IP |
418 | int result; | 430 | int result; |
419 | result = execute("ip addr add 127.0.0.1/8 dev %iface%", ifd, exec); | 431 | result = execute("ip addr add 127.0.0.1/8 dev %iface%", ifd, exec); |
420 | result += execute("ip link set %iface% up", ifd, exec); | 432 | result += execute("ip link set %iface% up", ifd, exec); |
421 | return ((result == 2) ? 2 : 0); | 433 | return ((result == 2) ? 2 : 0); |
422 | #else | 434 | # else |
423 | return execute("ifconfig %iface% 127.0.0.1 up", ifd, exec); | 435 | return execute("ifconfig %iface% 127.0.0.1 up", ifd, exec); |
424 | #endif | 436 | # endif |
425 | } | 437 | } |
426 | 438 | ||
427 | static int FAST_FUNC loopback_down(struct interface_defn_t *ifd, execfn *exec) | 439 | static int FAST_FUNC loopback_down(struct interface_defn_t *ifd, execfn *exec) |
428 | { | 440 | { |
429 | #if ENABLE_FEATURE_IFUPDOWN_IP | 441 | # if ENABLE_FEATURE_IFUPDOWN_IP |
430 | int result; | 442 | int result; |
431 | result = execute("ip addr flush dev %iface%", ifd, exec); | 443 | result = execute("ip addr flush dev %iface%", ifd, exec); |
432 | result += execute("ip link set %iface% down", ifd, exec); | 444 | result += execute("ip link set %iface% down", ifd, exec); |
433 | return ((result == 2) ? 2 : 0); | 445 | return ((result == 2) ? 2 : 0); |
434 | #else | 446 | # else |
435 | return execute("ifconfig %iface% 127.0.0.1 down", ifd, exec); | 447 | return execute("ifconfig %iface% 127.0.0.1 down", ifd, exec); |
436 | #endif | 448 | # endif |
437 | } | 449 | } |
438 | 450 | ||
439 | static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) | 451 | static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) |
440 | { | 452 | { |
441 | int result; | 453 | int result; |
442 | #if ENABLE_FEATURE_IFUPDOWN_IP | 454 | # if ENABLE_FEATURE_IFUPDOWN_IP |
443 | result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " | 455 | result = execute("ip addr add %address%/%bnmask%[[ broadcast %broadcast%]] " |
444 | "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); | 456 | "dev %iface%[[ peer %pointopoint%]][[ label %label%]]", ifd, exec); |
445 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); | 457 | result += execute("ip link set[[ mtu %mtu%]][[ addr %hwaddress%]] %iface% up", ifd, exec); |
446 | result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); | 458 | result += execute("[[ip route add default via %gateway% dev %iface%]]", ifd, exec); |
447 | return ((result == 3) ? 3 : 0); | 459 | return ((result == 3) ? 3 : 0); |
448 | #else | 460 | # else |
449 | /* ifconfig said to set iface up before it processes hw %hwaddress%, | 461 | /* ifconfig said to set iface up before it processes hw %hwaddress%, |
450 | * which then of course fails. Thus we run two separate ifconfig */ | 462 | * which then of course fails. Thus we run two separate ifconfig */ |
451 | result = execute("ifconfig %iface%[[ hw %hwaddress%]][[ media %media%]][[ mtu %mtu%]] up", | 463 | result = execute("ifconfig %iface%[[ hw %hwaddress%]][[ media %media%]][[ mtu %mtu%]] up", |
@@ -455,26 +467,26 @@ static int FAST_FUNC static_up(struct interface_defn_t *ifd, execfn *exec) | |||
455 | ifd, exec); | 467 | ifd, exec); |
456 | result += execute("[[route add default gw %gateway% %iface%]]", ifd, exec); | 468 | result += execute("[[route add default gw %gateway% %iface%]]", ifd, exec); |
457 | return ((result == 3) ? 3 : 0); | 469 | return ((result == 3) ? 3 : 0); |
458 | #endif | 470 | # endif |
459 | } | 471 | } |
460 | 472 | ||
461 | static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec) | 473 | static int FAST_FUNC static_down(struct interface_defn_t *ifd, execfn *exec) |
462 | { | 474 | { |
463 | int result; | 475 | int result; |
464 | #if ENABLE_FEATURE_IFUPDOWN_IP | 476 | # if ENABLE_FEATURE_IFUPDOWN_IP |
465 | result = execute("ip addr flush dev %iface%", ifd, exec); | 477 | result = execute("ip addr flush dev %iface%", ifd, exec); |
466 | result += execute("ip link set %iface% down", ifd, exec); | 478 | result += execute("ip link set %iface% down", ifd, exec); |
467 | #else | 479 | # else |
468 | /* result = execute("[[route del default gw %gateway% %iface%]]", ifd, exec); */ | 480 | /* result = execute("[[route del default gw %gateway% %iface%]]", ifd, exec); */ |
469 | /* Bringing the interface down deletes the routes in itself. | 481 | /* Bringing the interface down deletes the routes in itself. |
470 | Otherwise this fails if we reference 'gateway' when using this from dhcp_down */ | 482 | Otherwise this fails if we reference 'gateway' when using this from dhcp_down */ |
471 | result = 1; | 483 | result = 1; |
472 | result += execute("ifconfig %iface% down", ifd, exec); | 484 | result += execute("ifconfig %iface% down", ifd, exec); |
473 | #endif | 485 | # endif |
474 | return ((result == 2) ? 2 : 0); | 486 | return ((result == 2) ? 2 : 0); |
475 | } | 487 | } |
476 | 488 | ||
477 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP | 489 | # if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP |
478 | struct dhcp_client_t { | 490 | struct dhcp_client_t { |
479 | const char *name; | 491 | const char *name; |
480 | const char *startcmd; | 492 | const char *startcmd; |
@@ -500,21 +512,21 @@ static const struct dhcp_client_t ext_dhcp_clients[] = { | |||
500 | "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", | 512 | "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", |
501 | }, | 513 | }, |
502 | }; | 514 | }; |
503 | #endif /* ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCPC */ | 515 | # endif /* FEATURE_IFUPDOWN_EXTERNAL_DHCPC */ |
504 | 516 | ||
505 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP | 517 | # if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP |
506 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec) | 518 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec) |
507 | { | 519 | { |
508 | unsigned i; | 520 | unsigned i; |
509 | #if ENABLE_FEATURE_IFUPDOWN_IP | 521 | # if ENABLE_FEATURE_IFUPDOWN_IP |
510 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ | 522 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ |
511 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) | 523 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) |
512 | return 0; | 524 | return 0; |
513 | #else | 525 | # else |
514 | /* needed if we have hwaddress on dhcp iface */ | 526 | /* needed if we have hwaddress on dhcp iface */ |
515 | if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec)) | 527 | if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec)) |
516 | return 0; | 528 | return 0; |
517 | #endif | 529 | # endif |
518 | for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { | 530 | for (i = 0; i < ARRAY_SIZE(ext_dhcp_clients); i++) { |
519 | if (exists_execable(ext_dhcp_clients[i].name)) | 531 | if (exists_execable(ext_dhcp_clients[i].name)) |
520 | return execute(ext_dhcp_clients[i].startcmd, ifd, exec); | 532 | return execute(ext_dhcp_clients[i].startcmd, ifd, exec); |
@@ -522,31 +534,31 @@ static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec) | |||
522 | bb_error_msg("no dhcp clients found"); | 534 | bb_error_msg("no dhcp clients found"); |
523 | return 0; | 535 | return 0; |
524 | } | 536 | } |
525 | #elif ENABLE_UDHCPC | 537 | # elif ENABLE_UDHCPC |
526 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec) | 538 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd, execfn *exec) |
527 | { | 539 | { |
528 | #if ENABLE_FEATURE_IFUPDOWN_IP | 540 | # if ENABLE_FEATURE_IFUPDOWN_IP |
529 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ | 541 | /* ip doesn't up iface when it configures it (unlike ifconfig) */ |
530 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) | 542 | if (!execute("ip link set[[ addr %hwaddress%]] %iface% up", ifd, exec)) |
531 | return 0; | 543 | return 0; |
532 | #else | 544 | # else |
533 | /* needed if we have hwaddress on dhcp iface */ | 545 | /* needed if we have hwaddress on dhcp iface */ |
534 | if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec)) | 546 | if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec)) |
535 | return 0; | 547 | return 0; |
536 | #endif | 548 | # endif |
537 | return execute("udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid " | 549 | return execute("udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid " |
538 | "-i %iface%[[ -H %hostname%]][[ -c %client%]][[ -s %script%]][[ %udhcpc_opts%]]", | 550 | "-i %iface%[[ -H %hostname%]][[ -c %client%]][[ -s %script%]][[ %udhcpc_opts%]]", |
539 | ifd, exec); | 551 | ifd, exec); |
540 | } | 552 | } |
541 | #else | 553 | # else |
542 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd UNUSED_PARAM, | 554 | static int FAST_FUNC dhcp_up(struct interface_defn_t *ifd UNUSED_PARAM, |
543 | execfn *exec UNUSED_PARAM) | 555 | execfn *exec UNUSED_PARAM) |
544 | { | 556 | { |
545 | return 0; /* no dhcp support */ | 557 | return 0; /* no dhcp support */ |
546 | } | 558 | } |
547 | #endif | 559 | # endif |
548 | 560 | ||
549 | #if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP | 561 | # if ENABLE_FEATURE_IFUPDOWN_EXTERNAL_DHCP |
550 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) | 562 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) |
551 | { | 563 | { |
552 | int result = 0; | 564 | int result = 0; |
@@ -569,7 +581,7 @@ static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) | |||
569 | result += static_down(ifd, exec); | 581 | result += static_down(ifd, exec); |
570 | return ((result == 3) ? 3 : 0); | 582 | return ((result == 3) ? 3 : 0); |
571 | } | 583 | } |
572 | #elif ENABLE_UDHCPC | 584 | # elif ENABLE_UDHCPC |
573 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) | 585 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) |
574 | { | 586 | { |
575 | int result; | 587 | int result; |
@@ -586,13 +598,13 @@ static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec) | |||
586 | result += static_down(ifd, exec); | 598 | result += static_down(ifd, exec); |
587 | return ((result == 3) ? 3 : 0); | 599 | return ((result == 3) ? 3 : 0); |
588 | } | 600 | } |
589 | #else | 601 | # else |
590 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd UNUSED_PARAM, | 602 | static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd UNUSED_PARAM, |
591 | execfn *exec UNUSED_PARAM) | 603 | execfn *exec UNUSED_PARAM) |
592 | { | 604 | { |
593 | return 0; /* no dhcp support */ | 605 | return 0; /* no dhcp support */ |
594 | } | 606 | } |
595 | #endif | 607 | # endif |
596 | 608 | ||
597 | static int FAST_FUNC manual_up_down(struct interface_defn_t *ifd UNUSED_PARAM, execfn *exec UNUSED_PARAM) | 609 | static int FAST_FUNC manual_up_down(struct interface_defn_t *ifd UNUSED_PARAM, execfn *exec UNUSED_PARAM) |
598 | { | 610 | { |
@@ -644,7 +656,8 @@ static const struct address_family_t addr_inet = { | |||
644 | methods | 656 | methods |
645 | }; | 657 | }; |
646 | 658 | ||
647 | #endif /* if ENABLE_FEATURE_IFUPDOWN_IPV4 */ | 659 | #endif /* FEATURE_IFUPDOWN_IPV4 */ |
660 | |||
648 | 661 | ||
649 | /* Returns pointer to the next word, or NULL. | 662 | /* Returns pointer to the next word, or NULL. |
650 | * In 1st case, advances *buf to the word after this one. | 663 | * In 1st case, advances *buf to the word after this one. |
diff --git a/networking/inetd.c b/networking/inetd.c index 7030062b6..fb00c6cd7 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -295,7 +295,7 @@ struct globals { | |||
295 | struct rlimit rlim_ofile; | 295 | struct rlimit rlim_ofile; |
296 | servtab_t *serv_list; | 296 | servtab_t *serv_list; |
297 | int global_queuelen; | 297 | int global_queuelen; |
298 | int maxsock; /* max fd# in allsock, -1: unknown */ | 298 | int maxsock; /* max fd# in allsock, -1: unknown */ |
299 | /* whenever maxsock grows, prev_maxsock is set to new maxsock, | 299 | /* whenever maxsock grows, prev_maxsock is set to new maxsock, |
300 | * but if maxsock is set to -1, prev_maxsock is not changed */ | 300 | * but if maxsock is set to -1, prev_maxsock is not changed */ |
301 | int prev_maxsock; | 301 | int prev_maxsock; |
@@ -778,6 +778,12 @@ static servtab_t *parse_one_line(void) | |||
778 | argc = 0; | 778 | argc = 0; |
779 | while ((arg = token[6+argc]) != NULL && argc < MAXARGV) | 779 | while ((arg = token[6+argc]) != NULL && argc < MAXARGV) |
780 | sep->se_argv[argc++] = xstrdup(arg); | 780 | sep->se_argv[argc++] = xstrdup(arg); |
781 | /* Some inetd.conf files have no argv's, not even argv[0]. | ||
782 | * Fix them up. | ||
783 | * (Technically, programs can be execed with argv[0] = NULL, | ||
784 | * but many programs do not like that at all) */ | ||
785 | if (argc == 0) | ||
786 | sep->se_argv[0] = xstrdup(sep->se_program); | ||
781 | 787 | ||
782 | /* catch mixups. "<service> stream udp ..." == wtf */ | 788 | /* catch mixups. "<service> stream udp ..." == wtf */ |
783 | if (sep->se_socktype == SOCK_STREAM) { | 789 | if (sep->se_socktype == SOCK_STREAM) { |
diff --git a/networking/ip.c b/networking/ip.c index 7b1e2eb6a..350656cef 100644 --- a/networking/ip.c +++ b/networking/ip.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * "ip" utility frontend. | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
8 | * | 6 | * |
9 | * Changes: | 7 | * Changes: |
10 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 8 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
11 | * Bernhard Reutner-Fischer rewrote to use index_in_substr_array | 9 | * Bernhard Reutner-Fischer rewrote to use index_in_substr_array |
12 | */ | 10 | */ |
13 | 11 | ||
diff --git a/networking/ipcalc.c b/networking/ipcalc.c index d4aa885c6..acbaa4ac5 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c | |||
@@ -15,9 +15,9 @@ | |||
15 | /* After libbb.h, because on some systems it needs other includes */ | 15 | /* After libbb.h, because on some systems it needs other includes */ |
16 | #include <arpa/inet.h> | 16 | #include <arpa/inet.h> |
17 | 17 | ||
18 | #define CLASS_A_NETMASK ntohl(0xFF000000) | 18 | #define CLASS_A_NETMASK ntohl(0xFF000000) |
19 | #define CLASS_B_NETMASK ntohl(0xFFFF0000) | 19 | #define CLASS_B_NETMASK ntohl(0xFFFF0000) |
20 | #define CLASS_C_NETMASK ntohl(0xFFFFFF00) | 20 | #define CLASS_C_NETMASK ntohl(0xFFFFFF00) |
21 | 21 | ||
22 | static unsigned long get_netmask(unsigned long ipaddr) | 22 | static unsigned long get_netmask(unsigned long ipaddr) |
23 | { | 23 | { |
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index bf01528c4..59c759b23 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c | |||
@@ -1,18 +1,15 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ip.c "ip" utility frontend. | 3 | * This program is free software; you can redistribute it and/or |
4 | * | 4 | * modify it under the terms of the GNU General Public License |
5 | * This program is free software; you can redistribute it and/or | 5 | * as published by the Free Software Foundation; either version |
6 | * modify it under the terms of the GNU General Public License | 6 | * 2 of the License, or (at your option) any later version. |
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
12 | * | 9 | * |
13 | * Changes: | 10 | * Changes: |
14 | * | 11 | * |
15 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
16 | */ | 13 | */ |
17 | 14 | ||
18 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 15 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 1be03a6c3..397a8ee34 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ipaddress.c "ip address". | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
8 | * | 6 | * |
9 | * Changes: | 7 | * Changes: |
10 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated | 8 | * Laszlo Valko <valko@linux.karinthy.hu> 990223: address label must be zero terminated |
11 | */ | 9 | */ |
12 | 10 | ||
13 | #include <fnmatch.h> | 11 | #include <fnmatch.h> |
@@ -20,7 +18,7 @@ | |||
20 | 18 | ||
21 | #ifndef IFF_LOWER_UP | 19 | #ifndef IFF_LOWER_UP |
22 | /* from linux/if.h */ | 20 | /* from linux/if.h */ |
23 | #define IFF_LOWER_UP 0x10000 /* driver signals L1 up*/ | 21 | #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */ |
24 | #endif | 22 | #endif |
25 | 23 | ||
26 | struct filter_t { | 24 | struct filter_t { |
@@ -365,7 +363,7 @@ static int FAST_FUNC print_addrinfo(const struct sockaddr_nl *who UNUSED_PARAM, | |||
365 | 363 | ||
366 | struct nlmsg_list { | 364 | struct nlmsg_list { |
367 | struct nlmsg_list *next; | 365 | struct nlmsg_list *next; |
368 | struct nlmsghdr h; | 366 | struct nlmsghdr h; |
369 | }; | 367 | }; |
370 | 368 | ||
371 | static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo) | 369 | static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo) |
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index c5ba294aa..82ab979a5 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c | |||
@@ -1,7 +1,5 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * iplink.c "ip link". | ||
4 | * | ||
5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 3 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
6 | * | 4 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
@@ -296,9 +294,9 @@ static int do_change(char **argv, const unsigned rtm) | |||
296 | }; | 294 | }; |
297 | struct rtnl_handle rth; | 295 | struct rtnl_handle rth; |
298 | struct { | 296 | struct { |
299 | struct nlmsghdr n; | 297 | struct nlmsghdr n; |
300 | struct ifinfomsg i; | 298 | struct ifinfomsg i; |
301 | char buf[1024]; | 299 | char buf[1024]; |
302 | } req; | 300 | } req; |
303 | smalluint arg; | 301 | smalluint arg; |
304 | char *name_str = NULL, *link_str = NULL, *type_str = NULL, *dev_str = NULL; | 302 | char *name_str = NULL, *link_str = NULL, *type_str = NULL, *dev_str = NULL; |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 1696e6a34..f6071b463 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -1,19 +1,16 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * iproute.c "ip route". | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
8 | * | ||
9 | * | 6 | * |
10 | * Changes: | 7 | * Changes: |
11 | * | 8 | * |
12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
13 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized | 10 | * Kunihiro Ishiguro <kunihiro@zebra.org> 001102: rtnh_ifindex was not initialized |
14 | */ | 11 | */ |
15 | 12 | ||
16 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 13 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
17 | #include "rt_names.h" | 14 | #include "rt_names.h" |
18 | #include "utils.h" | 15 | #include "utils.h" |
19 | 16 | ||
@@ -327,9 +324,9 @@ IF_FEATURE_IP_RULE(ARG_table,) | |||
327 | }; | 324 | }; |
328 | struct rtnl_handle rth; | 325 | struct rtnl_handle rth; |
329 | struct { | 326 | struct { |
330 | struct nlmsghdr n; | 327 | struct nlmsghdr n; |
331 | struct rtmsg r; | 328 | struct rtmsg r; |
332 | char buf[1024]; | 329 | char buf[1024]; |
333 | } req; | 330 | } req; |
334 | char mxbuf[256]; | 331 | char mxbuf[256]; |
335 | struct rtattr * mxrta = (void*)mxbuf; | 332 | struct rtattr * mxrta = (void*)mxbuf; |
@@ -791,8 +788,8 @@ static int iproute_get(char **argv) | |||
791 | } | 788 | } |
792 | req.r.rtm_dst_len = addr.bitlen; | 789 | req.r.rtm_dst_len = addr.bitlen; |
793 | } | 790 | } |
794 | argv++; | ||
795 | } | 791 | } |
792 | argv++; | ||
796 | } | 793 | } |
797 | 794 | ||
798 | if (req.r.rtm_dst_len == 0) { | 795 | if (req.r.rtm_dst_len == 0) { |
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c index 3af6a83a8..dd3265c7c 100644 --- a/networking/libiproute/iprule.c +++ b/networking/libiproute/iprule.c | |||
@@ -1,18 +1,15 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * iprule.c "ip rule". | 3 | * This program is free software; you can redistribute it and/or |
4 | * | 4 | * modify it under the terms of the GNU General Public License |
5 | * This program is free software; you can redistribute it and/or | 5 | * as published by the Free Software Foundation; either version |
6 | * modify it under the terms of the GNU General Public License | 6 | * 2 of the License, or (at your option) any later version. |
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
12 | * | 9 | * |
13 | * Changes: | 10 | * Changes: |
14 | * | 11 | * |
15 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 12 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
16 | * initially integrated into busybox by Bernhard Reutner-Fischer | 13 | * initially integrated into busybox by Bernhard Reutner-Fischer |
17 | */ | 14 | */ |
18 | 15 | ||
@@ -191,9 +188,9 @@ static int iprule_modify(int cmd, char **argv) | |||
191 | bool table_ok = 0; | 188 | bool table_ok = 0; |
192 | struct rtnl_handle rth; | 189 | struct rtnl_handle rth; |
193 | struct { | 190 | struct { |
194 | struct nlmsghdr n; | 191 | struct nlmsghdr n; |
195 | struct rtmsg r; | 192 | struct rtmsg r; |
196 | char buf[1024]; | 193 | char buf[1024]; |
197 | } req; | 194 | } req; |
198 | smalluint key; | 195 | smalluint key; |
199 | 196 | ||
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index bce373d05..5942feafc 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c | |||
@@ -1,16 +1,14 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * iptunnel.c "ip tunnel" | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
8 | * | 6 | * |
9 | * Changes: | 7 | * Changes: |
10 | * | 8 | * |
11 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
12 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit | 10 | * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit |
13 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag | 11 | * Phil Karn <karn@ka9q.ampr.org> 990408: "pmtudisc" flag |
14 | */ | 12 | */ |
15 | 13 | ||
16 | #include <netinet/ip.h> | 14 | #include <netinet/ip.h> |
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 8da80b2fc..7291ee2f1 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -1,7 +1,5 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * RTnetlink service routines. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | 3 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 4 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version | 5 | * as published by the Free Software Foundation; either version |
@@ -74,8 +72,8 @@ int FAST_FUNC rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, in | |||
74 | struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } }; | 72 | struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } }; |
75 | struct msghdr msg = { | 73 | struct msghdr msg = { |
76 | (void*)&nladdr, sizeof(nladdr), | 74 | (void*)&nladdr, sizeof(nladdr), |
77 | iov, 2, | 75 | iov, 2, |
78 | NULL, 0, | 76 | NULL, 0, |
79 | 0 | 77 | 0 |
80 | }; | 78 | }; |
81 | 79 | ||
@@ -108,8 +106,8 @@ static int rtnl_dump_filter(struct rtnl_handle *rth, | |||
108 | 106 | ||
109 | struct msghdr msg = { | 107 | struct msghdr msg = { |
110 | (void*)&nladdr, sizeof(nladdr), | 108 | (void*)&nladdr, sizeof(nladdr), |
111 | &iov, 1, | 109 | &iov, 1, |
112 | NULL, 0, | 110 | NULL, 0, |
113 | 0 | 111 | 0 |
114 | }; | 112 | }; |
115 | 113 | ||
@@ -214,8 +212,8 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, | |||
214 | char *buf = xmalloc(8*1024); /* avoid big stack buffer */ | 212 | char *buf = xmalloc(8*1024); /* avoid big stack buffer */ |
215 | struct msghdr msg = { | 213 | struct msghdr msg = { |
216 | (void*)&nladdr, sizeof(nladdr), | 214 | (void*)&nladdr, sizeof(nladdr), |
217 | &iov, 1, | 215 | &iov, 1, |
218 | NULL, 0, | 216 | NULL, 0, |
219 | 0 | 217 | 0 |
220 | }; | 218 | }; |
221 | 219 | ||
diff --git a/networking/libiproute/libnetlink.h b/networking/libiproute/libnetlink.h index 4e4d5b7b9..51bee2d67 100644 --- a/networking/libiproute/libnetlink.h +++ b/networking/libiproute/libnetlink.h | |||
@@ -11,11 +11,11 @@ | |||
11 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN | 11 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
12 | 12 | ||
13 | struct rtnl_handle { | 13 | struct rtnl_handle { |
14 | int fd; | 14 | int fd; |
15 | struct sockaddr_nl local; | 15 | struct sockaddr_nl local; |
16 | struct sockaddr_nl peer; | 16 | struct sockaddr_nl peer; |
17 | uint32_t seq; | 17 | uint32_t seq; |
18 | uint32_t dump; | 18 | uint32_t dump; |
19 | }; | 19 | }; |
20 | 20 | ||
21 | extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC; | 21 | extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC; |
diff --git a/networking/libiproute/ll_addr.c b/networking/libiproute/ll_addr.c index c2c01305d..33a54ea6c 100644 --- a/networking/libiproute/ll_addr.c +++ b/networking/libiproute/ll_addr.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ll_addr.c | 3 | * This program is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU General Public License | ||
5 | * as published by the Free Software Foundation; either version | ||
6 | * 2 of the License, or (at your option) any later version. | ||
4 | * | 7 | * |
5 | * This program is free software; you can redistribute it and/or | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | */ | 9 | */ |
12 | 10 | ||
13 | #include <net/if_arp.h> | 11 | #include <net/if_arp.h> |
diff --git a/networking/libiproute/ll_map.c b/networking/libiproute/ll_map.c index 246b9e33a..27cd90f34 100644 --- a/networking/libiproute/ll_map.c +++ b/networking/libiproute/ll_map.c | |||
@@ -1,17 +1,14 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ll_map.c | 3 | * This program is free software; you can redistribute it and/or |
4 | * | 4 | * modify it under the terms of the GNU General Public License |
5 | * This program is free software; you can redistribute it and/or | 5 | * as published by the Free Software Foundation; either version |
6 | * modify it under the terms of the GNU General Public License | 6 | * 2 of the License, or (at your option) any later version. |
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include <net/if.h> /* struct ifreq and co. */ | 11 | #include <net/if.h> /* struct ifreq and co. */ |
15 | 12 | ||
16 | #include "libbb.h" | 13 | #include "libbb.h" |
17 | #include "libnetlink.h" | 14 | #include "libnetlink.h" |
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 1cd576f1d..04925ecf6 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ll_proto.c | 3 | * This program is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU General Public License | ||
5 | * as published by the Free Software Foundation; either version | ||
6 | * 2 of the License, or (at your option) any later version. | ||
4 | * | 7 | * |
5 | * This program is free software; you can redistribute it and/or | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | */ | 9 | */ |
12 | 10 | ||
13 | #include "libbb.h" | 11 | #include "libbb.h" |
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c index 3861c2870..38b6c0516 100644 --- a/networking/libiproute/ll_types.c +++ b/networking/libiproute/ll_types.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * ll_types.c | 3 | * This program is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU General Public License | ||
5 | * as published by the Free Software Foundation; either version | ||
6 | * 2 of the License, or (at your option) any later version. | ||
4 | * | 7 | * |
5 | * This program is free software; you can redistribute it and/or | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | */ | 9 | */ |
12 | #include <arpa/inet.h> | 10 | #include <arpa/inet.h> |
13 | #include <linux/if_arp.h> | 11 | #include <linux/if_arp.h> |
diff --git a/networking/libiproute/rt_names.c b/networking/libiproute/rt_names.c index 8dd16e3d3..c474ab903 100644 --- a/networking/libiproute/rt_names.c +++ b/networking/libiproute/rt_names.c | |||
@@ -1,13 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * rt_names.c rtnetlink names DB. | 3 | * This program is free software; you can redistribute it and/or |
4 | * modify it under the terms of the GNU General Public License | ||
5 | * as published by the Free Software Foundation; either version | ||
6 | * 2 of the License, or (at your option) any later version. | ||
4 | * | 7 | * |
5 | * This program is free software; you can redistribute it and/or | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | */ | 9 | */ |
12 | #include "libbb.h" | 10 | #include "libbb.h" |
13 | #include "rt_names.h" | 11 | #include "rt_names.h" |
diff --git a/networking/libiproute/rtm_map.c b/networking/libiproute/rtm_map.c index 5e358e105..3bab53baf 100644 --- a/networking/libiproute/rtm_map.c +++ b/networking/libiproute/rtm_map.c | |||
@@ -1,14 +1,11 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * rtm_map.c | 3 | * This program is free software; you can redistribute it and/or |
4 | * | 4 | * modify it under the terms of the GNU General Public License |
5 | * This program is free software; you can redistribute it and/or | 5 | * as published by the Free Software Foundation; either version |
6 | * modify it under the terms of the GNU General Public License | 6 | * 2 of the License, or (at your option) any later version. |
7 | * as published by the Free Software Foundation; either version | ||
8 | * 2 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
11 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | ||
12 | */ | 9 | */ |
13 | 10 | ||
14 | #include "libbb.h" | 11 | #include "libbb.h" |
diff --git a/networking/libiproute/utils.c b/networking/libiproute/utils.c index 2b646f0ea..d32db8de5 100644 --- a/networking/libiproute/utils.c +++ b/networking/libiproute/utils.c | |||
@@ -1,14 +1,12 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * utils.c | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
8 | * | 6 | * |
9 | * Changes: | 7 | * Changes: |
10 | * | 8 | * |
11 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses | 9 | * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses |
12 | */ | 10 | */ |
13 | 11 | ||
14 | #include "libbb.h" | 12 | #include "libbb.h" |
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h index ed03e785a..93c9d25d6 100644 --- a/networking/libiproute/utils.h +++ b/networking/libiproute/utils.h | |||
@@ -17,14 +17,14 @@ extern smallint oneline; | |||
17 | extern char _SL_; | 17 | extern char _SL_; |
18 | 18 | ||
19 | #ifndef IPPROTO_ESP | 19 | #ifndef IPPROTO_ESP |
20 | #define IPPROTO_ESP 50 | 20 | #define IPPROTO_ESP 50 |
21 | #endif | 21 | #endif |
22 | #ifndef IPPROTO_AH | 22 | #ifndef IPPROTO_AH |
23 | #define IPPROTO_AH 51 | 23 | #define IPPROTO_AH 51 |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | #define SPRINT_BSIZE 64 | 26 | #define SPRINT_BSIZE 64 |
27 | #define SPRINT_BUF(x) char x[SPRINT_BSIZE] | 27 | #define SPRINT_BUF(x) char x[SPRINT_BSIZE] |
28 | 28 | ||
29 | extern void incomplete_command(void) NORETURN; | 29 | extern void incomplete_command(void) NORETURN; |
30 | 30 | ||
diff --git a/networking/nameif.c b/networking/nameif.c index 45a3229f4..d02c2c11b 100644 --- a/networking/nameif.c +++ b/networking/nameif.c | |||
@@ -21,10 +21,10 @@ | |||
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | /* Taken from linux/sockios.h */ | 23 | /* Taken from linux/sockios.h */ |
24 | #define SIOCSIFNAME 0x8923 /* set interface name */ | 24 | #define SIOCSIFNAME 0x8923 /* set interface name */ |
25 | 25 | ||
26 | /* Octets in one Ethernet addr, from <linux/if_ether.h> */ | 26 | /* Octets in one Ethernet addr, from <linux/if_ether.h> */ |
27 | #define ETH_ALEN 6 | 27 | #define ETH_ALEN 6 |
28 | 28 | ||
29 | #ifndef ifr_newname | 29 | #ifndef ifr_newname |
30 | #define ifr_newname ifr_ifru.ifru_slave | 30 | #define ifr_newname ifr_ifru.ifru_slave |
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index 8594a67a6..e98a5dd5b 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -268,8 +268,7 @@ static int doexec(char **proggie) | |||
268 | dup2(0, 1); | 268 | dup2(0, 1); |
269 | /* dup2(0, 2); - do we *really* want this? NO! | 269 | /* dup2(0, 2); - do we *really* want this? NO! |
270 | * exec'ed prog can do it yourself, if needed */ | 270 | * exec'ed prog can do it yourself, if needed */ |
271 | execvp(proggie[0], proggie); | 271 | BB_EXECVP_or_die(proggie); |
272 | bb_perror_msg_and_die("can't execute '%s'", proggie[0]); | ||
273 | } | 272 | } |
274 | 273 | ||
275 | /* connect_w_timeout: | 274 | /* connect_w_timeout: |
@@ -766,7 +765,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv) | |||
766 | getopt32(argv, "hnp:s:uvw:" IF_NC_SERVER("l") | 765 | getopt32(argv, "hnp:s:uvw:" IF_NC_SERVER("l") |
767 | IF_NC_EXTRA("i:o:z"), | 766 | IF_NC_EXTRA("i:o:z"), |
768 | &str_p, &str_s, &o_wait | 767 | &str_p, &str_s, &o_wait |
769 | IF_NC_EXTRA(, &str_i, &str_o, &o_verbose)); | 768 | IF_NC_EXTRA(, &str_i, &str_o), &o_verbose); |
770 | argv += optind; | 769 | argv += optind; |
771 | #if ENABLE_NC_EXTRA | 770 | #if ENABLE_NC_EXTRA |
772 | if (option_mask32 & OPT_i) /* line-interval time */ | 771 | if (option_mask32 & OPT_i) /* line-interval time */ |
diff --git a/networking/netstat.c b/networking/netstat.c index 2a83af3ac..356fb53cb 100644 --- a/networking/netstat.c +++ b/networking/netstat.c | |||
@@ -699,7 +699,7 @@ int netstat_main(int argc UNUSED_PARAM, char **argv) | |||
699 | flags |= opt; | 699 | flags |= opt; |
700 | } | 700 | } |
701 | if (flags & (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW)) { | 701 | if (flags & (NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW)) { |
702 | printf("Active Internet connections "); /* xxx */ | 702 | printf("Active Internet connections "); /* xxx */ |
703 | 703 | ||
704 | if ((flags & (NETSTAT_LISTENING|NETSTAT_CONNECTED)) == (NETSTAT_LISTENING|NETSTAT_CONNECTED)) | 704 | if ((flags & (NETSTAT_LISTENING|NETSTAT_CONNECTED)) == (NETSTAT_LISTENING|NETSTAT_CONNECTED)) |
705 | printf("(servers and established)"); | 705 | printf("(servers and established)"); |
diff --git a/networking/ntpd.c b/networking/ntpd.c index b7bd239b5..8fe529edb 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -89,7 +89,7 @@ | |||
89 | //UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */ | 89 | //UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */ |
90 | 90 | ||
91 | #define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */ | 91 | #define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */ |
92 | #define BURSTPOLL 0 /* initial poll */ | 92 | #define BURSTPOLL 0 /* initial poll */ |
93 | #define MINPOLL 5 /* minimum poll interval. std ntpd uses 6 (6: 64 sec) */ | 93 | #define MINPOLL 5 /* minimum poll interval. std ntpd uses 6 (6: 64 sec) */ |
94 | #define BIGPOLL 10 /* drop to lower poll at any trouble (10: 17 min) */ | 94 | #define BIGPOLL 10 /* drop to lower poll at any trouble (10: 17 min) */ |
95 | #define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */ | 95 | #define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */ |
@@ -865,7 +865,7 @@ fit(peer_t *p, double rd) | |||
865 | VERB3 bb_error_msg("peer %s unfit for selection: unreachable", p->p_dotted); | 865 | VERB3 bb_error_msg("peer %s unfit for selection: unreachable", p->p_dotted); |
866 | return 0; | 866 | return 0; |
867 | } | 867 | } |
868 | #if 0 /* we filter out such packets earlier */ | 868 | #if 0 /* we filter out such packets earlier */ |
869 | if ((p->lastpkt_status & LI_ALARM) == LI_ALARM | 869 | if ((p->lastpkt_status & LI_ALARM) == LI_ALARM |
870 | || p->lastpkt_stratum >= MAXSTRAT | 870 | || p->lastpkt_stratum >= MAXSTRAT |
871 | ) { | 871 | ) { |
@@ -2110,7 +2110,7 @@ direct_freq(double fp_offset) | |||
2110 | } | 2110 | } |
2111 | 2111 | ||
2112 | static void | 2112 | static void |
2113 | set_freq(double freq) /* frequency update */ | 2113 | set_freq(double freq) /* frequency update */ |
2114 | { | 2114 | { |
2115 | char tbuf[80]; | 2115 | char tbuf[80]; |
2116 | 2116 | ||
diff --git a/networking/ntpd_simple.c b/networking/ntpd_simple.c index 5905e54e9..4ad44e4f3 100644 --- a/networking/ntpd_simple.c +++ b/networking/ntpd_simple.c | |||
@@ -870,7 +870,7 @@ static NOINLINE void ntp_init(char **argv) | |||
870 | int prec = 0; | 870 | int prec = 0; |
871 | int b; | 871 | int b; |
872 | # if 0 | 872 | # if 0 |
873 | struct timespec tp; | 873 | struct timespec tp; |
874 | /* We can use sys_clock_getres but assuming 10ms tick should be fine */ | 874 | /* We can use sys_clock_getres but assuming 10ms tick should be fine */ |
875 | clock_getres(CLOCK_REALTIME, &tp); | 875 | clock_getres(CLOCK_REALTIME, &tp); |
876 | tp.tv_sec = 0; | 876 | tp.tv_sec = 0; |
diff --git a/networking/ping.c b/networking/ping.c index 3aba4906e..366a98668 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -29,6 +29,93 @@ | |||
29 | #include <netinet/ip_icmp.h> | 29 | #include <netinet/ip_icmp.h> |
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | 31 | ||
32 | //config:config PING | ||
33 | //config: bool "ping" | ||
34 | //config: default y | ||
35 | //config: depends on PLATFORM_LINUX | ||
36 | //config: help | ||
37 | //config: ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to | ||
38 | //config: elicit an ICMP ECHO_RESPONSE from a host or gateway. | ||
39 | //config: | ||
40 | //config:config PING6 | ||
41 | //config: bool "ping6" | ||
42 | //config: default y | ||
43 | //config: depends on FEATURE_IPV6 && PING | ||
44 | //config: help | ||
45 | //config: This will give you a ping that can talk IPv6. | ||
46 | //config: | ||
47 | //config:config FEATURE_FANCY_PING | ||
48 | //config: bool "Enable fancy ping output" | ||
49 | //config: default y | ||
50 | //config: depends on PING | ||
51 | //config: help | ||
52 | //config: Make the output from the ping applet include statistics, and at the | ||
53 | //config: same time provide full support for ICMP packets. | ||
54 | |||
55 | /* Needs socket(AF_INET, SOCK_RAW, IPPROTO_ICMP), therefore _BB_SUID_MAYBE: */ | ||
56 | //applet:IF_PING(APPLET(ping, _BB_DIR_BIN, _BB_SUID_MAYBE)) | ||
57 | //applet:IF_PING6(APPLET(ping6, _BB_DIR_BIN, _BB_SUID_MAYBE)) | ||
58 | |||
59 | //kbuild:lib-$(CONFIG_PING) += ping.o | ||
60 | //kbuild:lib-$(CONFIG_PING6) += ping.o | ||
61 | |||
62 | //usage:#if !ENABLE_FEATURE_FANCY_PING | ||
63 | //usage:# define ping_trivial_usage | ||
64 | //usage: "HOST" | ||
65 | //usage:# define ping_full_usage "\n\n" | ||
66 | //usage: "Send ICMP ECHO_REQUEST packets to network hosts" | ||
67 | //usage:# define ping6_trivial_usage | ||
68 | //usage: "HOST" | ||
69 | //usage:# define ping6_full_usage "\n\n" | ||
70 | //usage: "Send ICMP ECHO_REQUEST packets to network hosts" | ||
71 | //usage:#else | ||
72 | //usage:# define ping_trivial_usage | ||
73 | //usage: "[OPTIONS] HOST" | ||
74 | //usage:# define ping_full_usage "\n\n" | ||
75 | //usage: "Send ICMP ECHO_REQUEST packets to network hosts\n" | ||
76 | //usage: "\nOptions:" | ||
77 | //usage: "\n -4,-6 Force IP or IPv6 name resolution" | ||
78 | //usage: "\n -c CNT Send only CNT pings" | ||
79 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default:56)" | ||
80 | //usage: "\n -t TTL Set TTL" | ||
81 | //usage: "\n -I IFACE/IP Use interface or IP address as source" | ||
82 | //usage: "\n -W SEC Seconds to wait for the first response (default:10)" | ||
83 | //usage: "\n (after all -c CNT packets are sent)" | ||
84 | //usage: "\n -w SEC Seconds until ping exits (default:infinite)" | ||
85 | //usage: "\n (can exit earlier with -c CNT)" | ||
86 | //usage: "\n -q Quiet, only displays output at start" | ||
87 | //usage: "\n and when finished" | ||
88 | //usage: | ||
89 | //usage:# define ping6_trivial_usage | ||
90 | //usage: "[OPTIONS] HOST" | ||
91 | //usage:# define ping6_full_usage "\n\n" | ||
92 | //usage: "Send ICMP ECHO_REQUEST packets to network hosts\n" | ||
93 | //usage: "\nOptions:" | ||
94 | //usage: "\n -c CNT Send only CNT pings" | ||
95 | //usage: "\n -s SIZE Send SIZE data bytes in packets (default:56)" | ||
96 | //usage: "\n -I IFACE/IP Use interface or IP address as source" | ||
97 | //usage: "\n -q Quiet, only displays output at start" | ||
98 | //usage: "\n and when finished" | ||
99 | //usage: | ||
100 | //usage:#endif | ||
101 | //usage: | ||
102 | //usage:#define ping_example_usage | ||
103 | //usage: "$ ping localhost\n" | ||
104 | //usage: "PING slag (127.0.0.1): 56 data bytes\n" | ||
105 | //usage: "64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=20.1 ms\n" | ||
106 | //usage: "\n" | ||
107 | //usage: "--- debian ping statistics ---\n" | ||
108 | //usage: "1 packets transmitted, 1 packets received, 0% packet loss\n" | ||
109 | //usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" | ||
110 | //usage:#define ping6_example_usage | ||
111 | //usage: "$ ping6 ip6-localhost\n" | ||
112 | //usage: "PING ip6-localhost (::1): 56 data bytes\n" | ||
113 | //usage: "64 bytes from ::1: icmp6_seq=0 ttl=64 time=20.1 ms\n" | ||
114 | //usage: "\n" | ||
115 | //usage: "--- ip6-localhost ping statistics ---\n" | ||
116 | //usage: "1 packets transmitted, 1 packets received, 0% packet loss\n" | ||
117 | //usage: "round-trip min/avg/max = 20.1/20.1/20.1 ms\n" | ||
118 | |||
32 | #if ENABLE_PING6 | 119 | #if ENABLE_PING6 |
33 | # include <netinet/icmp6.h> | 120 | # include <netinet/icmp6.h> |
34 | /* I see RENUMBERED constants in bits/in.h - !!? | 121 | /* I see RENUMBERED constants in bits/in.h - !!? |
@@ -223,17 +310,18 @@ static int common_ping_main(sa_family_t af, char **argv) | |||
223 | 310 | ||
224 | /* Full(er) version */ | 311 | /* Full(er) version */ |
225 | 312 | ||
226 | #define OPT_STRING ("qvc:s:w:W:I:4" IF_PING6("6")) | 313 | #define OPT_STRING ("qvc:s:t:w:W:I:4" IF_PING6("6")) |
227 | enum { | 314 | enum { |
228 | OPT_QUIET = 1 << 0, | 315 | OPT_QUIET = 1 << 0, |
229 | OPT_VERBOSE = 1 << 1, | 316 | OPT_VERBOSE = 1 << 1, |
230 | OPT_c = 1 << 2, | 317 | OPT_c = 1 << 2, |
231 | OPT_s = 1 << 3, | 318 | OPT_s = 1 << 3, |
232 | OPT_w = 1 << 4, | 319 | OPT_t = 1 << 4, |
233 | OPT_W = 1 << 5, | 320 | OPT_w = 1 << 5, |
234 | OPT_I = 1 << 6, | 321 | OPT_W = 1 << 6, |
235 | OPT_IPV4 = 1 << 7, | 322 | OPT_I = 1 << 7, |
236 | OPT_IPV6 = (1 << 8) * ENABLE_PING6, | 323 | OPT_IPV4 = 1 << 8, |
324 | OPT_IPV6 = (1 << 9) * ENABLE_PING6, | ||
237 | }; | 325 | }; |
238 | 326 | ||
239 | 327 | ||
@@ -244,6 +332,7 @@ struct globals { | |||
244 | len_and_sockaddr *source_lsa; | 332 | len_and_sockaddr *source_lsa; |
245 | unsigned datalen; | 333 | unsigned datalen; |
246 | unsigned pingcount; /* must be int-sized */ | 334 | unsigned pingcount; /* must be int-sized */ |
335 | unsigned opt_ttl; | ||
247 | unsigned long ntransmitted, nreceived, nrepeats; | 336 | unsigned long ntransmitted, nreceived, nrepeats; |
248 | uint16_t myid; | 337 | uint16_t myid; |
249 | unsigned tmin, tmax; /* in us */ | 338 | unsigned tmin, tmax; /* in us */ |
@@ -275,6 +364,7 @@ struct globals { | |||
275 | #define nreceived (G.nreceived ) | 364 | #define nreceived (G.nreceived ) |
276 | #define nrepeats (G.nrepeats ) | 365 | #define nrepeats (G.nrepeats ) |
277 | #define pingcount (G.pingcount ) | 366 | #define pingcount (G.pingcount ) |
367 | #define opt_ttl (G.opt_ttl ) | ||
278 | #define myid (G.myid ) | 368 | #define myid (G.myid ) |
279 | #define tmin (G.tmin ) | 369 | #define tmin (G.tmin ) |
280 | #define tmax (G.tmax ) | 370 | #define tmax (G.tmax ) |
@@ -586,6 +676,12 @@ static void ping4(len_and_sockaddr *lsa) | |||
586 | sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */ | 676 | sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */ |
587 | setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt)); | 677 | setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt)); |
588 | 678 | ||
679 | if (opt_ttl != 0) { | ||
680 | setsockopt(pingsock, IPPROTO_IP, IP_TTL, &opt_ttl, sizeof(opt_ttl)); | ||
681 | /* above doesnt affect packets sent to bcast IP, so... */ | ||
682 | setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_TTL, &opt_ttl, sizeof(opt_ttl)); | ||
683 | } | ||
684 | |||
589 | signal(SIGINT, print_stats_and_exit); | 685 | signal(SIGINT, print_stats_and_exit); |
590 | 686 | ||
591 | /* start the ping's going ... */ | 687 | /* start the ping's going ... */ |
@@ -735,9 +831,9 @@ static int common_ping_main(int opt, char **argv) | |||
735 | 831 | ||
736 | INIT_G(); | 832 | INIT_G(); |
737 | 833 | ||
738 | /* exactly one argument needed; -v and -q don't mix; -c NUM, -w NUM, -W NUM */ | 834 | /* exactly one argument needed; -v and -q don't mix; -c NUM, -t NUM, -w NUM, -W NUM */ |
739 | opt_complementary = "=1:q--v:v--q:c+:w+:W+"; | 835 | opt_complementary = "=1:q--v:v--q:c+:t+:w+:W+"; |
740 | opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &deadline, &timeout, &str_I); | 836 | opt |= getopt32(argv, OPT_STRING, &pingcount, &str_s, &opt_ttl, &deadline, &timeout, &str_I); |
741 | if (opt & OPT_s) | 837 | if (opt & OPT_s) |
742 | datalen = xatou16(str_s); // -s | 838 | datalen = xatou16(str_s); // -s |
743 | if (opt & OPT_I) { // -I | 839 | if (opt & OPT_I) { // -I |
diff --git a/networking/slattach.c b/networking/slattach.c index 921ec552d..71edd2f27 100644 --- a/networking/slattach.c +++ b/networking/slattach.c | |||
@@ -134,9 +134,9 @@ int slattach_main(int argc UNUSED_PARAM, char **argv) | |||
134 | int i, encap, opt; | 134 | int i, encap, opt; |
135 | struct termios state; | 135 | struct termios state; |
136 | const char *proto = "cslip"; | 136 | const char *proto = "cslip"; |
137 | const char *extcmd; /* Command to execute after hangup */ | 137 | const char *extcmd; /* Command to execute after hangup */ |
138 | const char *baud_str; | 138 | const char *baud_str; |
139 | int baud_code = -1; /* Line baud rate (system code) */ | 139 | int baud_code = -1; /* Line baud rate (system code) */ |
140 | 140 | ||
141 | enum { | 141 | enum { |
142 | OPT_p_proto = 1 << 0, | 142 | OPT_p_proto = 1 << 0, |
diff --git a/networking/tc.c b/networking/tc.c index 9242741e4..2e2473a70 100644 --- a/networking/tc.c +++ b/networking/tc.c | |||
@@ -1,7 +1,5 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | 1 | /* vi: set sw=4 ts=4: */ |
2 | /* | 2 | /* |
3 | * "tc" utility frontend. | ||
4 | * | ||
5 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 3 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
6 | * | 4 | * |
7 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 5 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
diff --git a/networking/telnet.c b/networking/telnet.c index 12d1970fa..f6fad684c 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -42,11 +42,13 @@ enum { | |||
42 | UF_ECHO = 0x01, | 42 | UF_ECHO = 0x01, |
43 | UF_SGA = 0x02, | 43 | UF_SGA = 0x02, |
44 | 44 | ||
45 | TS_0 = 1, | 45 | TS_NORMAL = 0, |
46 | TS_COPY = 1, | ||
46 | TS_IAC = 2, | 47 | TS_IAC = 2, |
47 | TS_OPT = 3, | 48 | TS_OPT = 3, |
48 | TS_SUB1 = 4, | 49 | TS_SUB1 = 4, |
49 | TS_SUB2 = 5, | 50 | TS_SUB2 = 5, |
51 | TS_CR = 6, | ||
50 | }; | 52 | }; |
51 | 53 | ||
52 | typedef unsigned char byte; | 54 | typedef unsigned char byte; |
@@ -83,13 +85,13 @@ struct globals { | |||
83 | }; \ | 85 | }; \ |
84 | } while (0) | 86 | } while (0) |
85 | 87 | ||
86 | /* Function prototypes */ | 88 | |
87 | static void rawmode(void); | 89 | static void rawmode(void); |
88 | static void cookmode(void); | 90 | static void cookmode(void); |
89 | static void do_linemode(void); | 91 | static void do_linemode(void); |
90 | static void will_charmode(void); | 92 | static void will_charmode(void); |
91 | static void telopt(byte c); | 93 | static void telopt(byte c); |
92 | static int subneg(byte c); | 94 | static void subneg(byte c); |
93 | 95 | ||
94 | static void iac_flush(void) | 96 | static void iac_flush(void) |
95 | { | 97 | { |
@@ -170,24 +172,24 @@ static void handle_net_output(int len) | |||
170 | * So I implemented it. It's really useful for me. I hope that | 172 | * So I implemented it. It's really useful for me. I hope that |
171 | * other people will find it interesting too. | 173 | * other people will find it interesting too. |
172 | */ | 174 | */ |
173 | 175 | byte outbuf[2 * DATABUFSIZE]; | |
174 | int i, j; | ||
175 | byte *p = (byte*)G.buf; | 176 | byte *p = (byte*)G.buf; |
176 | byte outbuf[4*DATABUFSIZE]; | 177 | int j = 0; |
177 | 178 | ||
178 | for (i = len, j = 0; i > 0; i--, p++) { | 179 | for (; len > 0; len--, p++) { |
179 | if (*p == 0x1d) { | 180 | byte c = *p; |
181 | if (c == 0x1d) { | ||
180 | con_escape(); | 182 | con_escape(); |
181 | return; | 183 | return; |
182 | } | 184 | } |
183 | outbuf[j++] = *p; | 185 | outbuf[j++] = c; |
184 | if (*p == 0xff) | 186 | if (c == IAC) |
185 | outbuf[j++] = 0xff; | 187 | outbuf[j++] = c; /* IAC -> IAC IAC */ |
186 | else if (*p == 0x0d) | 188 | else if (c == '\r') |
187 | outbuf[j++] = 0x00; | 189 | outbuf[j++] = '\0'; /* CR -> CR NUL */ |
188 | } | 190 | } |
189 | if (j > 0) | 191 | if (j > 0) |
190 | write(netfd, outbuf, j); | 192 | full_write(netfd, outbuf, j); |
191 | } | 193 | } |
192 | 194 | ||
193 | static void handle_net_input(int len) | 195 | static void handle_net_input(int len) |
@@ -198,25 +200,44 @@ static void handle_net_input(int len) | |||
198 | for (i = 0; i < len; i++) { | 200 | for (i = 0; i < len; i++) { |
199 | byte c = G.buf[i]; | 201 | byte c = G.buf[i]; |
200 | 202 | ||
201 | if (G.telstate == 0) { /* most of the time state == 0 */ | 203 | if (G.telstate == TS_NORMAL) { /* most typical state */ |
202 | if (c == IAC) { | 204 | if (c == IAC) { |
203 | cstart = i; | 205 | cstart = i; |
204 | G.telstate = TS_IAC; | 206 | G.telstate = TS_IAC; |
205 | } | 207 | } |
208 | else if (c == '\r') { | ||
209 | cstart = i + 1; | ||
210 | G.telstate = TS_CR; | ||
211 | } | ||
212 | /* No IACs were seen so far, no need to copy | ||
213 | * bytes within G.buf: */ | ||
206 | continue; | 214 | continue; |
207 | } | 215 | } |
216 | |||
208 | switch (G.telstate) { | 217 | switch (G.telstate) { |
209 | case TS_0: | 218 | case TS_CR: |
219 | /* Prev char was CR. If cur one is NUL, ignore it. | ||
220 | * See RFC 1123 section 3.3.1 for discussion of telnet EOL handling. | ||
221 | */ | ||
222 | G.telstate = TS_COPY; | ||
223 | if (c == '\0') | ||
224 | break; | ||
225 | /* else: fall through - need to handle CR IAC ... properly */ | ||
226 | |||
227 | case TS_COPY: /* Prev char was ordinary */ | ||
228 | /* Similar to NORMAL, but in TS_COPY we need to copy bytes */ | ||
210 | if (c == IAC) | 229 | if (c == IAC) |
211 | G.telstate = TS_IAC; | 230 | G.telstate = TS_IAC; |
212 | else | 231 | else |
213 | G.buf[cstart++] = c; | 232 | G.buf[cstart++] = c; |
233 | if (c == '\r') | ||
234 | G.telstate = TS_CR; | ||
214 | break; | 235 | break; |
215 | 236 | ||
216 | case TS_IAC: | 237 | case TS_IAC: /* Prev char was IAC */ |
217 | if (c == IAC) { /* IAC IAC -> 0xFF */ | 238 | if (c == IAC) { /* IAC IAC -> one IAC */ |
218 | G.buf[cstart++] = c; | 239 | G.buf[cstart++] = c; |
219 | G.telstate = TS_0; | 240 | G.telstate = TS_COPY; |
220 | break; | 241 | break; |
221 | } | 242 | } |
222 | /* else */ | 243 | /* else */ |
@@ -228,34 +249,38 @@ static void handle_net_input(int len) | |||
228 | case DONT: | 249 | case DONT: |
229 | case WILL: | 250 | case WILL: |
230 | case WONT: | 251 | case WONT: |
231 | G.telwish = c; | 252 | G.telwish = c; |
232 | G.telstate = TS_OPT; | 253 | G.telstate = TS_OPT; |
233 | break; | 254 | break; |
255 | /* DATA MARK must be added later */ | ||
234 | default: | 256 | default: |
235 | G.telstate = TS_0; /* DATA MARK must be added later */ | 257 | G.telstate = TS_COPY; |
236 | } | 258 | } |
237 | break; | 259 | break; |
238 | case TS_OPT: /* WILL, WONT, DO, DONT */ | 260 | |
261 | case TS_OPT: /* Prev chars were IAC WILL/WONT/DO/DONT */ | ||
239 | telopt(c); | 262 | telopt(c); |
240 | G.telstate = TS_0; | 263 | G.telstate = TS_COPY; |
241 | break; | 264 | break; |
265 | |||
242 | case TS_SUB1: /* Subnegotiation */ | 266 | case TS_SUB1: /* Subnegotiation */ |
243 | case TS_SUB2: /* Subnegotiation */ | 267 | case TS_SUB2: /* Subnegotiation */ |
244 | if (subneg(c)) | 268 | subneg(c); /* can change G.telstate */ |
245 | G.telstate = TS_0; | ||
246 | break; | 269 | break; |
247 | } | 270 | } |
248 | } | 271 | } |
249 | if (G.telstate) { | 272 | |
273 | if (G.telstate != TS_NORMAL) { | ||
274 | /* We had some IACs, or CR */ | ||
250 | if (G.iaclen) | 275 | if (G.iaclen) |
251 | iac_flush(); | 276 | iac_flush(); |
252 | if (G.telstate == TS_0) | 277 | if (G.telstate == TS_COPY) /* we aren't in the middle of IAC */ |
253 | G.telstate = 0; | 278 | G.telstate = TS_NORMAL; |
254 | len = cstart; | 279 | len = cstart; |
255 | } | 280 | } |
256 | 281 | ||
257 | if (len) | 282 | if (len) |
258 | write(STDOUT_FILENO, G.buf, len); | 283 | full_write(STDOUT_FILENO, G.buf, len); |
259 | } | 284 | } |
260 | 285 | ||
261 | static void put_iac(int c) | 286 | static void put_iac(int c) |
@@ -495,7 +520,7 @@ static void telopt(byte c) | |||
495 | } | 520 | } |
496 | 521 | ||
497 | /* subnegotiation -- ignore all (except TTYPE,NAWS) */ | 522 | /* subnegotiation -- ignore all (except TTYPE,NAWS) */ |
498 | static int subneg(byte c) | 523 | static void subneg(byte c) |
499 | { | 524 | { |
500 | switch (G.telstate) { | 525 | switch (G.telstate) { |
501 | case TS_SUB1: | 526 | case TS_SUB1: |
@@ -513,12 +538,13 @@ static int subneg(byte c) | |||
513 | #endif | 538 | #endif |
514 | break; | 539 | break; |
515 | case TS_SUB2: | 540 | case TS_SUB2: |
516 | if (c == SE) | 541 | if (c == SE) { |
517 | return TRUE; | 542 | G.telstate = TS_COPY; |
543 | return; | ||
544 | } | ||
518 | G.telstate = TS_SUB1; | 545 | G.telstate = TS_SUB1; |
519 | /* break; */ | 546 | break; |
520 | } | 547 | } |
521 | return FALSE; | ||
522 | } | 548 | } |
523 | 549 | ||
524 | static void rawmode(void) | 550 | static void rawmode(void) |
@@ -533,21 +559,13 @@ static void cookmode(void) | |||
533 | tcsetattr(0, TCSADRAIN, &G.termios_def); | 559 | tcsetattr(0, TCSADRAIN, &G.termios_def); |
534 | } | 560 | } |
535 | 561 | ||
536 | /* poll gives smaller (-70 bytes) code */ | ||
537 | #define USE_POLL 1 | ||
538 | |||
539 | int telnet_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 562 | int telnet_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
540 | int telnet_main(int argc UNUSED_PARAM, char **argv) | 563 | int telnet_main(int argc UNUSED_PARAM, char **argv) |
541 | { | 564 | { |
542 | char *host; | 565 | char *host; |
543 | int port; | 566 | int port; |
544 | int len; | 567 | int len; |
545 | #ifdef USE_POLL | ||
546 | struct pollfd ufds[2]; | 568 | struct pollfd ufds[2]; |
547 | #else | ||
548 | fd_set readfds; | ||
549 | int maxfd; | ||
550 | #endif | ||
551 | 569 | ||
552 | INIT_G(); | 570 | INIT_G(); |
553 | 571 | ||
@@ -585,63 +603,39 @@ int telnet_main(int argc UNUSED_PARAM, char **argv) | |||
585 | 603 | ||
586 | signal(SIGINT, record_signo); | 604 | signal(SIGINT, record_signo); |
587 | 605 | ||
588 | #ifdef USE_POLL | 606 | ufds[0].fd = STDIN_FILENO; |
589 | ufds[0].fd = 0; ufds[1].fd = netfd; | 607 | ufds[0].events = POLLIN; |
590 | ufds[0].events = ufds[1].events = POLLIN; | 608 | ufds[1].fd = netfd; |
591 | #else | 609 | ufds[1].events = POLLIN; |
592 | FD_ZERO(&readfds); | ||
593 | FD_SET(STDIN_FILENO, &readfds); | ||
594 | FD_SET(netfd, &readfds); | ||
595 | maxfd = netfd + 1; | ||
596 | #endif | ||
597 | 610 | ||
598 | while (1) { | 611 | while (1) { |
599 | #ifndef USE_POLL | 612 | if (poll(ufds, 2, -1) < 0) { |
600 | fd_set rfds = readfds; | ||
601 | |||
602 | switch (select(maxfd, &rfds, NULL, NULL, NULL)) | ||
603 | #else | ||
604 | switch (poll(ufds, 2, -1)) | ||
605 | #endif | ||
606 | { | ||
607 | case 0: | ||
608 | /* timeout */ | ||
609 | case -1: | ||
610 | /* error, ignore and/or log something, bay go to loop */ | 613 | /* error, ignore and/or log something, bay go to loop */ |
611 | if (bb_got_signal) | 614 | if (bb_got_signal) |
612 | con_escape(); | 615 | con_escape(); |
613 | else | 616 | else |
614 | sleep(1); | 617 | sleep(1); |
615 | break; | 618 | continue; |
616 | default: | 619 | } |
617 | 620 | ||
618 | #ifdef USE_POLL | 621 | // FIXME: reads can block. Need full bidirectional buffering. |
619 | if (ufds[0].revents) | ||
620 | #else | ||
621 | if (FD_ISSET(STDIN_FILENO, &rfds)) | ||
622 | #endif | ||
623 | { | ||
624 | len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE); | ||
625 | if (len <= 0) | ||
626 | doexit(EXIT_SUCCESS); | ||
627 | TRACE(0, ("Read con: %d\n", len)); | ||
628 | handle_net_output(len); | ||
629 | } | ||
630 | 622 | ||
631 | #ifdef USE_POLL | 623 | if (ufds[0].revents) { |
632 | if (ufds[1].revents) | 624 | len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE); |
633 | #else | 625 | if (len <= 0) |
634 | if (FD_ISSET(netfd, &rfds)) | 626 | doexit(EXIT_SUCCESS); |
635 | #endif | 627 | TRACE(0, ("Read con: %d\n", len)); |
636 | { | 628 | handle_net_output(len); |
637 | len = safe_read(netfd, G.buf, DATABUFSIZE); | 629 | } |
638 | if (len <= 0) { | 630 | |
639 | full_write1_str("Connection closed by foreign host\r\n"); | 631 | if (ufds[1].revents) { |
640 | doexit(EXIT_FAILURE); | 632 | len = safe_read(netfd, G.buf, DATABUFSIZE); |
641 | } | 633 | if (len <= 0) { |
642 | TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); | 634 | full_write1_str("Connection closed by foreign host\r\n"); |
643 | handle_net_input(len); | 635 | doexit(EXIT_FAILURE); |
644 | } | 636 | } |
637 | TRACE(0, ("Read netfd (%d): %d\n", netfd, len)); | ||
638 | handle_net_input(len); | ||
645 | } | 639 | } |
646 | } /* while (1) */ | 640 | } /* while (1) */ |
647 | } | 641 | } |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 5c011e15d..07c6a6a73 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -141,7 +141,7 @@ remove_iacs(struct tsession *ts, int *pnum_totty) | |||
141 | if (ptr[1] == SB && ptr[2] == TELOPT_NAWS) { | 141 | if (ptr[1] == SB && ptr[2] == TELOPT_NAWS) { |
142 | struct winsize ws; | 142 | struct winsize ws; |
143 | if ((ptr+8) >= end) | 143 | if ((ptr+8) >= end) |
144 | break; /* incomplete, can't process */ | 144 | break; /* incomplete, can't process */ |
145 | ws.ws_col = (ptr[3] << 8) | ptr[4]; | 145 | ws.ws_col = (ptr[3] << 8) | ptr[4]; |
146 | ws.ws_row = (ptr[5] << 8) | ptr[6]; | 146 | ws.ws_row = (ptr[5] << 8) | ptr[6]; |
147 | ioctl(ts->ptyfd, TIOCSWINSZ, (char *)&ws); | 147 | ioctl(ts->ptyfd, TIOCSWINSZ, (char *)&ws); |
@@ -273,8 +273,8 @@ make_new_session( | |||
273 | static const char iacs_to_send[] ALIGN1 = { | 273 | static const char iacs_to_send[] ALIGN1 = { |
274 | IAC, DO, TELOPT_ECHO, | 274 | IAC, DO, TELOPT_ECHO, |
275 | IAC, DO, TELOPT_NAWS, | 275 | IAC, DO, TELOPT_NAWS, |
276 | /* This requires telnetd.ctrlSQ.patch (incomplete) */ | 276 | /* This requires telnetd.ctrlSQ.patch (incomplete) */ |
277 | /* IAC, DO, TELOPT_LFLOW, */ | 277 | /*IAC, DO, TELOPT_LFLOW,*/ |
278 | IAC, WILL, TELOPT_ECHO, | 278 | IAC, WILL, TELOPT_ECHO, |
279 | IAC, WILL, TELOPT_SGA | 279 | IAC, WILL, TELOPT_SGA |
280 | }; | 280 | }; |
@@ -314,6 +314,8 @@ make_new_session( | |||
314 | /* Restore default signal handling ASAP */ | 314 | /* Restore default signal handling ASAP */ |
315 | bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL); | 315 | bb_signals((1 << SIGCHLD) + (1 << SIGPIPE), SIG_DFL); |
316 | 316 | ||
317 | pid = getpid(); | ||
318 | |||
317 | if (ENABLE_FEATURE_UTMP) { | 319 | if (ENABLE_FEATURE_UTMP) { |
318 | len_and_sockaddr *lsa = get_peer_lsa(sock); | 320 | len_and_sockaddr *lsa = get_peer_lsa(sock); |
319 | char *hostname = NULL; | 321 | char *hostname = NULL; |
@@ -335,7 +337,6 @@ make_new_session( | |||
335 | xopen(tty_name, O_RDWR); /* becomes our ctty */ | 337 | xopen(tty_name, O_RDWR); /* becomes our ctty */ |
336 | xdup2(0, 1); | 338 | xdup2(0, 1); |
337 | xdup2(0, 2); | 339 | xdup2(0, 2); |
338 | pid = getpid(); | ||
339 | tcsetpgrp(0, pid); /* switch this tty's process group to us */ | 340 | tcsetpgrp(0, pid); /* switch this tty's process group to us */ |
340 | 341 | ||
341 | /* The pseudo-terminal allocated to the client is configured to operate | 342 | /* The pseudo-terminal allocated to the client is configured to operate |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 78aabedf2..7e5ab61fd 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -926,6 +926,10 @@ static void client_background(void) | |||
926 | //usage: "\n -v Verbose" | 926 | //usage: "\n -v Verbose" |
927 | //usage: ) | 927 | //usage: ) |
928 | //usage: ) | 928 | //usage: ) |
929 | //usage: "\nSignals:" | ||
930 | //usage: "\n USR1 Renew current lease" | ||
931 | //usage: "\n USR2 Release current lease" | ||
932 | |||
929 | 933 | ||
930 | int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 934 | int udhcpc_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
931 | int udhcpc_main(int argc UNUSED_PARAM, char **argv) | 935 | int udhcpc_main(int argc UNUSED_PARAM, char **argv) |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index a015cf038..6fb48a19a 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -133,7 +133,10 @@ static uint32_t select_lease_time(struct dhcp_packet *packet) | |||
133 | 133 | ||
134 | /* We got a DHCP DISCOVER. Send an OFFER. */ | 134 | /* We got a DHCP DISCOVER. Send an OFFER. */ |
135 | /* NOINLINE: limit stack usage in caller */ | 135 | /* NOINLINE: limit stack usage in caller */ |
136 | static NOINLINE void send_offer(struct dhcp_packet *oldpacket, uint32_t static_lease_nip, struct dyn_lease *lease) | 136 | static NOINLINE void send_offer(struct dhcp_packet *oldpacket, |
137 | uint32_t static_lease_nip, | ||
138 | struct dyn_lease *lease, | ||
139 | uint8_t *requested_ip_opt) | ||
137 | { | 140 | { |
138 | struct dhcp_packet packet; | 141 | struct dhcp_packet packet; |
139 | uint32_t lease_time_sec; | 142 | uint32_t lease_time_sec; |
@@ -147,7 +150,6 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket, uint32_t static_l | |||
147 | if (!static_lease_nip) { | 150 | if (!static_lease_nip) { |
148 | /* We have no static lease for client's chaddr */ | 151 | /* We have no static lease for client's chaddr */ |
149 | uint32_t req_nip; | 152 | uint32_t req_nip; |
150 | uint8_t *req_ip_opt; | ||
151 | const char *p_host_name; | 153 | const char *p_host_name; |
152 | 154 | ||
153 | if (lease) { | 155 | if (lease) { |
@@ -158,9 +160,9 @@ static NOINLINE void send_offer(struct dhcp_packet *oldpacket, uint32_t static_l | |||
158 | packet.yiaddr = lease->lease_nip; | 160 | packet.yiaddr = lease->lease_nip; |
159 | } | 161 | } |
160 | /* Or: if client has requested an IP */ | 162 | /* Or: if client has requested an IP */ |
161 | else if ((req_ip_opt = udhcp_get_option(oldpacket, DHCP_REQUESTED_IP)) != NULL | 163 | else if (requested_ip_opt != NULL |
162 | /* (read IP) */ | 164 | /* (read IP) */ |
163 | && (move_from_unaligned32(req_nip, req_ip_opt), 1) | 165 | && (move_from_unaligned32(req_nip, requested_ip_opt), 1) |
164 | /* and the IP is in the lease range */ | 166 | /* and the IP is in the lease range */ |
165 | && ntohl(req_nip) >= server_config.start_ip | 167 | && ntohl(req_nip) >= server_config.start_ip |
166 | && ntohl(req_nip) <= server_config.end_ip | 168 | && ntohl(req_nip) <= server_config.end_ip |
@@ -283,16 +285,12 @@ struct dyn_lease *g_leases; | |||
283 | int udhcpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 285 | int udhcpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
284 | int udhcpd_main(int argc UNUSED_PARAM, char **argv) | 286 | int udhcpd_main(int argc UNUSED_PARAM, char **argv) |
285 | { | 287 | { |
286 | fd_set rfds; | ||
287 | int server_socket = -1, retval, max_sock; | 288 | int server_socket = -1, retval, max_sock; |
288 | struct dhcp_packet packet; | ||
289 | uint8_t *state; | 289 | uint8_t *state; |
290 | uint32_t static_lease_nip; | ||
291 | unsigned timeout_end; | 290 | unsigned timeout_end; |
292 | unsigned num_ips; | 291 | unsigned num_ips; |
293 | unsigned opt; | 292 | unsigned opt; |
294 | struct option_set *option; | 293 | struct option_set *option; |
295 | struct dyn_lease *lease, fake_lease; | ||
296 | IF_FEATURE_UDHCP_PORT(char *str_P;) | 294 | IF_FEATURE_UDHCP_PORT(char *str_P;) |
297 | 295 | ||
298 | #if ENABLE_FEATURE_UDHCP_PORT | 296 | #if ENABLE_FEATURE_UDHCP_PORT |
@@ -372,11 +370,15 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
372 | 370 | ||
373 | timeout_end = monotonic_sec() + server_config.auto_time; | 371 | timeout_end = monotonic_sec() + server_config.auto_time; |
374 | while (1) { /* loop until universe collapses */ | 372 | while (1) { /* loop until universe collapses */ |
373 | fd_set rfds; | ||
374 | struct dhcp_packet packet; | ||
375 | int bytes; | 375 | int bytes; |
376 | struct timeval tv; | 376 | struct timeval tv; |
377 | uint8_t *server_id_opt; | 377 | uint8_t *server_id_opt; |
378 | uint8_t *requested_opt; | 378 | uint8_t *requested_ip_opt; |
379 | uint32_t requested_nip = requested_nip; /* for compiler */ | 379 | uint32_t requested_nip = requested_nip; /* for compiler */ |
380 | uint32_t static_lease_nip; | ||
381 | struct dyn_lease *lease, fake_lease; | ||
380 | 382 | ||
381 | if (server_socket < 0) { | 383 | if (server_socket < 0) { |
382 | server_socket = udhcp_listen_socket(/*INADDR_ANY,*/ SERVER_PORT, | 384 | server_socket = udhcp_listen_socket(/*INADDR_ANY,*/ SERVER_PORT, |
@@ -443,6 +445,18 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
443 | continue; | 445 | continue; |
444 | } | 446 | } |
445 | 447 | ||
448 | /* Get SERVER_ID if present */ | ||
449 | server_id_opt = udhcp_get_option(&packet, DHCP_SERVER_ID); | ||
450 | if (server_id_opt) { | ||
451 | uint32_t server_id_network_order; | ||
452 | move_from_unaligned32(server_id_network_order, server_id_opt); | ||
453 | if (server_id_network_order != server_config.server_nip) { | ||
454 | /* client talks to somebody else */ | ||
455 | log1("server ID doesn't match, ignoring"); | ||
456 | continue; | ||
457 | } | ||
458 | } | ||
459 | |||
446 | /* Look for a static/dynamic lease */ | 460 | /* Look for a static/dynamic lease */ |
447 | static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr); | 461 | static_lease_nip = get_static_nip_by_mac(server_config.static_leases, &packet.chaddr); |
448 | if (static_lease_nip) { | 462 | if (static_lease_nip) { |
@@ -455,20 +469,10 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
455 | lease = find_lease_by_mac(packet.chaddr); | 469 | lease = find_lease_by_mac(packet.chaddr); |
456 | } | 470 | } |
457 | 471 | ||
458 | /* Get REQUESTED_IP and SERVER_ID if present */ | 472 | /* Get REQUESTED_IP if present */ |
459 | server_id_opt = udhcp_get_option(&packet, DHCP_SERVER_ID); | 473 | requested_ip_opt = udhcp_get_option(&packet, DHCP_REQUESTED_IP); |
460 | if (server_id_opt) { | 474 | if (requested_ip_opt) { |
461 | uint32_t server_id_net; | 475 | move_from_unaligned32(requested_nip, requested_ip_opt); |
462 | move_from_unaligned32(server_id_net, server_id_opt); | ||
463 | if (server_id_net != server_config.server_nip) { | ||
464 | /* client talks to somebody else */ | ||
465 | log1("server ID doesn't match, ignoring"); | ||
466 | continue; | ||
467 | } | ||
468 | } | ||
469 | requested_opt = udhcp_get_option(&packet, DHCP_REQUESTED_IP); | ||
470 | if (requested_opt) { | ||
471 | move_from_unaligned32(requested_nip, requested_opt); | ||
472 | } | 476 | } |
473 | 477 | ||
474 | switch (state[0]) { | 478 | switch (state[0]) { |
@@ -476,7 +480,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
476 | case DHCPDISCOVER: | 480 | case DHCPDISCOVER: |
477 | log1("Received DISCOVER"); | 481 | log1("Received DISCOVER"); |
478 | 482 | ||
479 | send_offer(&packet, static_lease_nip, lease); | 483 | send_offer(&packet, static_lease_nip, lease, requested_ip_opt); |
480 | break; | 484 | break; |
481 | 485 | ||
482 | case DHCPREQUEST: | 486 | case DHCPREQUEST: |
@@ -567,7 +571,7 @@ o DHCPREQUEST generated during REBINDING state: | |||
567 | A DHCP server MAY extend a client's lease only if it has local | 571 | A DHCP server MAY extend a client's lease only if it has local |
568 | administrative authority to do so. | 572 | administrative authority to do so. |
569 | */ | 573 | */ |
570 | if (!requested_opt) { | 574 | if (!requested_ip_opt) { |
571 | requested_nip = packet.ciaddr; | 575 | requested_nip = packet.ciaddr; |
572 | if (requested_nip == 0) { | 576 | if (requested_nip == 0) { |
573 | log1("no requested IP and no ciaddr, ignoring"); | 577 | log1("no requested IP and no ciaddr, ignoring"); |
@@ -580,11 +584,15 @@ o DHCPREQUEST generated during REBINDING state: | |||
580 | send_ACK(&packet, lease->lease_nip); | 584 | send_ACK(&packet, lease->lease_nip); |
581 | break; | 585 | break; |
582 | } | 586 | } |
583 | if (server_id_opt) { | 587 | /* No lease for this MAC, or lease IP != requested IP */ |
584 | /* client was talking specifically to us. | 588 | |
585 | * "No, we don't have this IP for you". */ | 589 | if (server_id_opt /* client is in SELECTING state */ |
590 | || requested_ip_opt /* client is in INIT-REBOOT state */ | ||
591 | ) { | ||
592 | /* "No, we don't have this IP for you" */ | ||
586 | send_NAK(&packet); | 593 | send_NAK(&packet); |
587 | } | 594 | } /* else: client is in RENEWING or REBINDING, do not answer */ |
595 | |||
588 | break; | 596 | break; |
589 | 597 | ||
590 | case DHCPDECLINE: | 598 | case DHCPDECLINE: |
@@ -603,7 +611,7 @@ o DHCPREQUEST generated during REBINDING state: | |||
603 | */ | 611 | */ |
604 | log1("Received DECLINE"); | 612 | log1("Received DECLINE"); |
605 | if (server_id_opt | 613 | if (server_id_opt |
606 | && requested_opt | 614 | && requested_ip_opt |
607 | && lease /* chaddr matches this lease */ | 615 | && lease /* chaddr matches this lease */ |
608 | && requested_nip == lease->lease_nip | 616 | && requested_nip == lease->lease_nip |
609 | ) { | 617 | ) { |
diff --git a/networking/vconfig.c b/networking/vconfig.c index 1f574d2ad..13c65ad78 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -47,8 +47,8 @@ struct vlan_ioctl_args { | |||
47 | short vlan_qos; | 47 | short vlan_qos; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | #define VLAN_GROUP_ARRAY_LEN 4096 | 50 | #define VLAN_GROUP_ARRAY_LEN 4096 |
51 | #define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */ | 51 | #define SIOCSIFVLAN 0x8983 /* Set 802.1Q VLAN options */ |
52 | 52 | ||
53 | /* On entry, table points to the length of the current string | 53 | /* On entry, table points to the length of the current string |
54 | * plus NUL terminator plus data length for the subsequent entry. | 54 | * plus NUL terminator plus data length for the subsequent entry. |
diff --git a/networking/wget.c b/networking/wget.c index 5b0907e11..16594c9bf 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * Licensed under GPLv2, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2, see file LICENSE in this source tree. |
7 | * | 7 | * |
8 | * Copyright (C) 2010 Bradley M. Kuhn <bkuhn@ebb.org> | 8 | * Copyright (C) 2010 Bradley M. Kuhn <bkuhn@ebb.org> |
9 | * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2. | 9 | * Kuhn's copyrights are licensed GPLv2-or-later. File as a whole remains GPLv2. |
10 | */ | 10 | */ |
11 | #include "libbb.h" | 11 | #include "libbb.h" |
12 | 12 | ||
@@ -48,7 +48,7 @@ struct BUG_G_too_big { | |||
48 | /* Must match option string! */ | 48 | /* Must match option string! */ |
49 | enum { | 49 | enum { |
50 | WGET_OPT_CONTINUE = (1 << 0), | 50 | WGET_OPT_CONTINUE = (1 << 0), |
51 | WGET_OPT_SPIDER = (1 << 1), | 51 | WGET_OPT_SPIDER = (1 << 1), |
52 | WGET_OPT_QUIET = (1 << 2), | 52 | WGET_OPT_QUIET = (1 << 2), |
53 | WGET_OPT_OUTNAME = (1 << 3), | 53 | WGET_OPT_OUTNAME = (1 << 3), |
54 | WGET_OPT_PREFIX = (1 << 4), | 54 | WGET_OPT_PREFIX = (1 << 4), |
@@ -786,7 +786,7 @@ However, in real world it was observed that some web servers | |||
786 | */ | 786 | */ |
787 | case 204: | 787 | case 204: |
788 | break; | 788 | break; |
789 | case 300: /* redirection */ | 789 | case 300: /* redirection */ |
790 | case 301: | 790 | case 301: |
791 | case 302: | 791 | case 302: |
792 | case 303: | 792 | case 303: |