diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 14:11:12 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 14:11:12 +0000 |
commit | 67758035a4fe040c6ac69b39d61bcd6bddd7b827 (patch) | |
tree | a4a1db7f54c16d12fabe2626b8f1e235cd694e9e /networking | |
parent | 811c449748d5bd0505f8510e5582892f94ac0cda (diff) | |
parent | b83c9704128dd106071184e4b00335a3b8486857 (diff) | |
download | busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.gz busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.tar.bz2 busybox-w32-67758035a4fe040c6ac69b39d61bcd6bddd7b827.zip |
Merge commit 'b83c9704128dd106071184e4b00335a3b8486857' into merge
Diffstat (limited to 'networking')
38 files changed, 769 insertions, 65 deletions
diff --git a/networking/arp.c b/networking/arp.c index 0ef267a35..3f68f5cf7 100644 --- a/networking/arp.c +++ b/networking/arp.c | |||
@@ -13,6 +13,25 @@ | |||
13 | * modified for getopt32 by Arne Bernin <arne [at] alamut.de> | 13 | * modified for getopt32 by Arne Bernin <arne [at] alamut.de> |
14 | */ | 14 | */ |
15 | 15 | ||
16 | //usage:#define arp_trivial_usage | ||
17 | //usage: "\n[-vn] [-H HWTYPE] [-i IF] -a [HOSTNAME]" | ||
18 | //usage: "\n[-v] [-i IF] -d HOSTNAME [pub]" | ||
19 | //usage: "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [temp]" | ||
20 | //usage: "\n[-v] [-H HWTYPE] [-i IF] -s HOSTNAME HWADDR [netmask MASK] pub" | ||
21 | //usage: "\n[-v] [-H HWTYPE] [-i IF] -Ds HOSTNAME IFACE [netmask MASK] pub" | ||
22 | //usage:#define arp_full_usage "\n\n" | ||
23 | //usage: "Manipulate ARP cache\n" | ||
24 | //usage: "\nOptions:" | ||
25 | //usage: "\n -a Display (all) hosts" | ||
26 | //usage: "\n -s Set new ARP entry" | ||
27 | //usage: "\n -d Delete a specified entry" | ||
28 | //usage: "\n -v Verbose" | ||
29 | //usage: "\n -n Don't resolve names" | ||
30 | //usage: "\n -i IF Network interface" | ||
31 | //usage: "\n -D Read <hwaddr> from given device" | ||
32 | //usage: "\n -A,-p AF Protocol family" | ||
33 | //usage: "\n -H HWTYPE Hardware address type" | ||
34 | |||
16 | #include "libbb.h" | 35 | #include "libbb.h" |
17 | #include "inet_common.h" | 36 | #include "inet_common.h" |
18 | 37 | ||
diff --git a/networking/arping.c b/networking/arping.c index 6f6b59cfb..357dcaaf0 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -6,6 +6,23 @@ | |||
6 | * Busybox port: Nick Fedchik <nick@fedchik.org.ua> | 6 | * Busybox port: Nick Fedchik <nick@fedchik.org.ua> |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //usage:#define arping_trivial_usage | ||
10 | //usage: "[-fqbDUA] [-c CNT] [-w TIMEOUT] [-I IFACE] [-s SRC_IP] DST_IP" | ||
11 | //usage:#define arping_full_usage "\n\n" | ||
12 | //usage: "Send ARP requests/replies\n" | ||
13 | //usage: "\nOptions:" | ||
14 | //usage: "\n -f Quit on first ARP reply" | ||
15 | //usage: "\n -q Quiet" | ||
16 | //usage: "\n -b Keep broadcasting, don't go unicast" | ||
17 | //usage: "\n -D Duplicated address detection mode" | ||
18 | //usage: "\n -U Unsolicited ARP mode, update your neighbors" | ||
19 | //usage: "\n -A ARP answer mode, update your neighbors" | ||
20 | //usage: "\n -c N Stop after sending N ARP requests" | ||
21 | //usage: "\n -w TIMEOUT Time to wait for ARP reply, seconds" | ||
22 | //usage: "\n -I IFACE Interface to use (default eth0)" | ||
23 | //usage: "\n -s SRC_IP Sender IP address" | ||
24 | //usage: "\n DST_IP Target IP address" | ||
25 | |||
9 | #include <arpa/inet.h> | 26 | #include <arpa/inet.h> |
10 | #include <net/if.h> | 27 | #include <net/if.h> |
11 | #include <netinet/ether.h> | 28 | #include <netinet/ether.h> |
diff --git a/networking/brctl.c b/networking/brctl.c index c0b094eba..19f474fce 100644 --- a/networking/brctl.c +++ b/networking/brctl.c | |||
@@ -12,6 +12,30 @@ | |||
12 | /* This applet currently uses only the ioctl interface and no sysfs at all. | 12 | /* This applet currently uses only the ioctl interface and no sysfs at all. |
13 | * At the time of this writing this was considered a feature. | 13 | * At the time of this writing this was considered a feature. |
14 | */ | 14 | */ |
15 | |||
16 | //usage:#define brctl_trivial_usage | ||
17 | //usage: "COMMAND [BRIDGE [INTERFACE]]" | ||
18 | //usage:#define brctl_full_usage "\n\n" | ||
19 | //usage: "Manage ethernet bridges\n" | ||
20 | //usage: "\nCommands:" | ||
21 | //usage: IF_FEATURE_BRCTL_SHOW( | ||
22 | //usage: "\n show Show a list of bridges" | ||
23 | //usage: ) | ||
24 | //usage: "\n addbr BRIDGE Create BRIDGE" | ||
25 | //usage: "\n delbr BRIDGE Delete BRIDGE" | ||
26 | //usage: "\n addif BRIDGE IFACE Add IFACE to BRIDGE" | ||
27 | //usage: "\n delif BRIDGE IFACE Delete IFACE from BRIDGE" | ||
28 | //usage: IF_FEATURE_BRCTL_FANCY( | ||
29 | //usage: "\n setageing BRIDGE TIME Set ageing time" | ||
30 | //usage: "\n setfd BRIDGE TIME Set bridge forward delay" | ||
31 | //usage: "\n sethello BRIDGE TIME Set hello time" | ||
32 | //usage: "\n setmaxage BRIDGE TIME Set max message age" | ||
33 | //usage: "\n setpathcost BRIDGE COST Set path cost" | ||
34 | //usage: "\n setportprio BRIDGE PRIO Set port priority" | ||
35 | //usage: "\n setbridgeprio BRIDGE PRIO Set bridge priority" | ||
36 | //usage: "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off" | ||
37 | //usage: ) | ||
38 | |||
15 | #include "libbb.h" | 39 | #include "libbb.h" |
16 | #include <linux/sockios.h> | 40 | #include <linux/sockios.h> |
17 | #include <net/if.h> | 41 | #include <net/if.h> |
diff --git a/networking/dnsd.c b/networking/dnsd.c index 8ed31cea2..65eae9670 100644 --- a/networking/dnsd.c +++ b/networking/dnsd.c | |||
@@ -17,6 +17,22 @@ | |||
17 | * the first porting of oao' scdns to busybox also. | 17 | * the first porting of oao' scdns to busybox also. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | //usage:#define dnsd_trivial_usage | ||
21 | //usage: "[-dvs] [-c CONFFILE] [-t TTL_SEC] [-p PORT] [-i ADDR]" | ||
22 | //usage:#define dnsd_full_usage "\n\n" | ||
23 | //usage: "Small static DNS server daemon\n" | ||
24 | //usage: "\nOptions:" | ||
25 | //usage: "\n -c FILE Config file" | ||
26 | //usage: "\n -t SEC TTL" | ||
27 | //usage: "\n -p PORT Listen on PORT" | ||
28 | //usage: "\n -i ADDR Listen on ADDR" | ||
29 | //usage: "\n -d Daemonize" | ||
30 | //usage: "\n -v Verbose" | ||
31 | //usage: "\n -s Send successful replies only. Use this if you want" | ||
32 | //usage: "\n to use /etc/resolv.conf with two nameserver lines:" | ||
33 | //usage: "\n nameserver DNSD_SERVER" | ||
34 | //usage: "\n nameserver NORNAL_DNS_SERVER" | ||
35 | |||
20 | #include "libbb.h" | 36 | #include "libbb.h" |
21 | #include <syslog.h> | 37 | #include <syslog.h> |
22 | 38 | ||
diff --git a/networking/ether-wake.c b/networking/ether-wake.c index 8f1479c02..7bb9aa5a7 100644 --- a/networking/ether-wake.c +++ b/networking/ether-wake.c | |||
@@ -64,6 +64,16 @@ | |||
64 | * filter. That configuration consumes more power. | 64 | * filter. That configuration consumes more power. |
65 | */ | 65 | */ |
66 | 66 | ||
67 | //usage:#define ether_wake_trivial_usage | ||
68 | //usage: "[-b] [-i iface] [-p aa:bb:cc:dd[:ee:ff]] MAC" | ||
69 | //usage:#define ether_wake_full_usage "\n\n" | ||
70 | //usage: "Send a magic packet to wake up sleeping machines.\n" | ||
71 | //usage: "MAC must be a station address (00:11:22:33:44:55) or\n" | ||
72 | //usage: "a hostname with a known 'ethers' entry.\n" | ||
73 | //usage: "\nOptions:" | ||
74 | //usage: "\n -b Send wake-up packet to the broadcast address" | ||
75 | //usage: "\n -i iface Interface to use (default eth0)" | ||
76 | //usage: "\n -p pass Append four or six byte password PW to the packet" | ||
67 | 77 | ||
68 | #include <netpacket/packet.h> | 78 | #include <netpacket/packet.h> |
69 | #include <net/ethernet.h> | 79 | #include <net/ethernet.h> |
diff --git a/networking/ftpd.c b/networking/ftpd.c index b59135667..fae634ec4 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c | |||
@@ -433,7 +433,7 @@ bind_for_passive_mode(void) | |||
433 | G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0); | 433 | G.pasv_listen_fd = fd = xsocket(G.local_addr->u.sa.sa_family, SOCK_STREAM, 0); |
434 | setsockopt_reuseaddr(fd); | 434 | setsockopt_reuseaddr(fd); |
435 | 435 | ||
436 | set_nport(G.local_addr, 0); | 436 | set_nport(&G.local_addr->u.sa, 0); |
437 | xbind(fd, &G.local_addr->u.sa, G.local_addr->len); | 437 | xbind(fd, &G.local_addr->u.sa, G.local_addr->len); |
438 | xlisten(fd, 1); | 438 | xlisten(fd, 1); |
439 | getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len); | 439 | getsockname(fd, &G.local_addr->u.sa, &G.local_addr->len); |
@@ -542,7 +542,7 @@ handle_port(void) | |||
542 | G.port_addr = xdotted2sockaddr(raw, port); | 542 | G.port_addr = xdotted2sockaddr(raw, port); |
543 | #else | 543 | #else |
544 | G.port_addr = get_peer_lsa(STDIN_FILENO); | 544 | G.port_addr = get_peer_lsa(STDIN_FILENO); |
545 | set_nport(G.port_addr, htons(port)); | 545 | set_nport(&G.port_addr->u.sa, htons(port)); |
546 | #endif | 546 | #endif |
547 | WRITE_OK(FTP_PORTOK); | 547 | WRITE_OK(FTP_PORTOK); |
548 | } | 548 | } |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index c68d0ace2..66316e21f 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -13,6 +13,44 @@ | |||
13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 13 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | //usage:#define ftpget_trivial_usage | ||
17 | //usage: "[OPTIONS] HOST [LOCAL_FILE] REMOTE_FILE" | ||
18 | //usage:#define ftpget_full_usage "\n\n" | ||
19 | //usage: "Retrieve a remote file via FTP\n" | ||
20 | //usage: "\nOptions:" | ||
21 | //usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
22 | //usage: "\n -c,--continue Continue previous transfer" | ||
23 | //usage: "\n -v,--verbose Verbose" | ||
24 | //usage: "\n -u,--username Username" | ||
25 | //usage: "\n -p,--password Password" | ||
26 | //usage: "\n -P,--port Port number" | ||
27 | //usage: ) | ||
28 | //usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
29 | //usage: "\n -c Continue previous transfer" | ||
30 | //usage: "\n -v Verbose" | ||
31 | //usage: "\n -u Username" | ||
32 | //usage: "\n -p Password" | ||
33 | //usage: "\n -P Port number" | ||
34 | //usage: ) | ||
35 | //usage: | ||
36 | //usage:#define ftpput_trivial_usage | ||
37 | //usage: "[OPTIONS] HOST [REMOTE_FILE] LOCAL_FILE" | ||
38 | //usage:#define ftpput_full_usage "\n\n" | ||
39 | //usage: "Store a local file on a remote machine via FTP\n" | ||
40 | //usage: "\nOptions:" | ||
41 | //usage: IF_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
42 | //usage: "\n -v,--verbose Verbose" | ||
43 | //usage: "\n -u,--username Username" | ||
44 | //usage: "\n -p,--password Password" | ||
45 | //usage: "\n -P,--port Port number" | ||
46 | //usage: ) | ||
47 | //usage: IF_NOT_FEATURE_FTPGETPUT_LONG_OPTIONS( | ||
48 | //usage: "\n -v Verbose" | ||
49 | //usage: "\n -u Username" | ||
50 | //usage: "\n -p Password" | ||
51 | //usage: "\n -P Port number" | ||
52 | //usage: ) | ||
53 | |||
16 | #include "libbb.h" | 54 | #include "libbb.h" |
17 | 55 | ||
18 | struct globals { | 56 | struct globals { |
@@ -151,7 +189,7 @@ TODO2: need to stop ignoring IP address in PASV response. | |||
151 | *buf_ptr = '\0'; | 189 | *buf_ptr = '\0'; |
152 | port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; | 190 | port_num += xatoul_range(buf_ptr + 1, 0, 255) * 256; |
153 | 191 | ||
154 | set_nport(lsa, htons(port_num)); | 192 | set_nport(&lsa->u.sa, htons(port_num)); |
155 | return xconnect_stream(lsa); | 193 | return xconnect_stream(lsa); |
156 | } | 194 | } |
157 | 195 | ||
diff --git a/networking/hostname.c b/networking/hostname.c index 66b52dd90..49a3e89bb 100644 --- a/networking/hostname.c +++ b/networking/hostname.c | |||
@@ -9,6 +9,25 @@ | |||
9 | * | 9 | * |
10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
11 | */ | 11 | */ |
12 | |||
13 | //usage:#define hostname_trivial_usage | ||
14 | //usage: "[OPTIONS] [HOSTNAME | -F FILE]" | ||
15 | //usage:#define hostname_full_usage "\n\n" | ||
16 | //usage: "Get or set hostname or DNS domain name\n" | ||
17 | //usage: "\nOptions:" | ||
18 | //usage: "\n -s Short" | ||
19 | //usage: "\n -i Addresses for the hostname" | ||
20 | //usage: "\n -d DNS domain name" | ||
21 | //usage: "\n -f Fully qualified domain name" | ||
22 | //usage: "\n -F FILE Use FILE's content as hostname" | ||
23 | //usage: | ||
24 | //usage:#define hostname_example_usage | ||
25 | //usage: "$ hostname\n" | ||
26 | //usage: "sage\n" | ||
27 | //usage: | ||
28 | //usage:#define dnsdomainname_trivial_usage NOUSAGE_STR | ||
29 | //usage:#define dnsdomainname_full_usage "" | ||
30 | |||
12 | #include "libbb.h" | 31 | #include "libbb.h" |
13 | 32 | ||
14 | static void do_sethostname(char *s, int isfile) | 33 | static void do_sethostname(char *s, int isfile) |
diff --git a/networking/httpd.c b/networking/httpd.c index b8113a843..d6157aca2 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -21,6 +21,10 @@ | |||
21 | * The server changes directory to the location of the script and executes it | 21 | * The server changes directory to the location of the script and executes it |
22 | * after setting QUERY_STRING and other environment variables. | 22 | * after setting QUERY_STRING and other environment variables. |
23 | * | 23 | * |
24 | * If directory URL is given, no index.html is found and CGI support is enabled, | ||
25 | * cgi-bin/index.cgi will be run. Directory to list is ../$QUERY_STRING. | ||
26 | * See httpd_indexcgi.c for an example GCI code. | ||
27 | * | ||
24 | * Doc: | 28 | * Doc: |
25 | * "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html | 29 | * "CGI Environment Variables": http://hoohoo.ncsa.uiuc.edu/cgi/env.html |
26 | * | 30 | * |
@@ -71,7 +75,7 @@ | |||
71 | * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255 | 75 | * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255 |
72 | * A:* # (optional line added for clarity) | 76 | * A:* # (optional line added for clarity) |
73 | * | 77 | * |
74 | * If a sub directory contains a config file it is parsed and merged with | 78 | * If a sub directory contains config file, it is parsed and merged with |
75 | * any existing settings as if it was appended to the original configuration. | 79 | * any existing settings as if it was appended to the original configuration. |
76 | * | 80 | * |
77 | * subdir paths are relative to the containing subdir and thus cannot | 81 | * subdir paths are relative to the containing subdir and thus cannot |
@@ -93,6 +97,32 @@ | |||
93 | */ | 97 | */ |
94 | /* TODO: use TCP_CORK, parse_config() */ | 98 | /* TODO: use TCP_CORK, parse_config() */ |
95 | 99 | ||
100 | //usage:#define httpd_trivial_usage | ||
101 | //usage: "[-ifv[v]]" | ||
102 | //usage: " [-c CONFFILE]" | ||
103 | //usage: " [-p [IP:]PORT]" | ||
104 | //usage: IF_FEATURE_HTTPD_SETUID(" [-u USER[:GRP]]") | ||
105 | //usage: IF_FEATURE_HTTPD_BASIC_AUTH(" [-r REALM]") | ||
106 | //usage: " [-h HOME]\n" | ||
107 | //usage: "or httpd -d/-e" IF_FEATURE_HTTPD_AUTH_MD5("/-m") " STRING" | ||
108 | //usage:#define httpd_full_usage "\n\n" | ||
109 | //usage: "Listen for incoming HTTP requests\n" | ||
110 | //usage: "\nOptions:" | ||
111 | //usage: "\n -i Inetd mode" | ||
112 | //usage: "\n -f Don't daemonize" | ||
113 | //usage: "\n -v[v] Verbose" | ||
114 | //usage: "\n -p [IP:]PORT Bind to IP:PORT (default *:80)" | ||
115 | //usage: IF_FEATURE_HTTPD_SETUID( | ||
116 | //usage: "\n -u USER[:GRP] Set uid/gid after binding to port") | ||
117 | //usage: IF_FEATURE_HTTPD_BASIC_AUTH( | ||
118 | //usage: "\n -r REALM Authentication Realm for Basic Authentication") | ||
119 | //usage: "\n -h HOME Home directory (default .)" | ||
120 | //usage: "\n -c FILE Configuration file (default {/etc,HOME}/httpd.conf)" | ||
121 | //usage: IF_FEATURE_HTTPD_AUTH_MD5( | ||
122 | //usage: "\n -m STRING MD5 crypt STRING") | ||
123 | //usage: "\n -e STRING HTML encode STRING" | ||
124 | //usage: "\n -d STRING URL decode STRING" | ||
125 | |||
96 | #include "libbb.h" | 126 | #include "libbb.h" |
97 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE | 127 | #if ENABLE_FEATURE_HTTPD_USE_SENDFILE |
98 | # include <sys/sendfile.h> | 128 | # include <sys/sendfile.h> |
@@ -1065,6 +1095,7 @@ static void send_headers(int responseNum) | |||
1065 | static void send_headers_and_exit(int responseNum) NORETURN; | 1095 | static void send_headers_and_exit(int responseNum) NORETURN; |
1066 | static void send_headers_and_exit(int responseNum) | 1096 | static void send_headers_and_exit(int responseNum) |
1067 | { | 1097 | { |
1098 | IF_FEATURE_HTTPD_GZIP(content_gzip = 0;) | ||
1068 | send_headers(responseNum); | 1099 | send_headers(responseNum); |
1069 | log_and_exit(); | 1100 | log_and_exit(); |
1070 | } | 1101 | } |
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index da2635ce0..220b02126 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -26,6 +26,27 @@ | |||
26 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> | 26 | * IPV6 support added by Bart Visscher <magick@linux-fan.com> |
27 | */ | 27 | */ |
28 | 28 | ||
29 | //usage:#define ifconfig_trivial_usage | ||
30 | //usage: IF_FEATURE_IFCONFIG_STATUS("[-a]") " interface [address]" | ||
31 | //usage:#define ifconfig_full_usage "\n\n" | ||
32 | //usage: "Configure a network interface\n" | ||
33 | //usage: "\nOptions:" | ||
34 | //usage: "\n" | ||
35 | //usage: IF_FEATURE_IPV6( | ||
36 | //usage: " [add ADDRESS[/PREFIXLEN]]\n") | ||
37 | //usage: IF_FEATURE_IPV6( | ||
38 | //usage: " [del ADDRESS[/PREFIXLEN]]\n") | ||
39 | //usage: " [[-]broadcast [ADDRESS]] [[-]pointopoint [ADDRESS]]\n" | ||
40 | //usage: " [netmask ADDRESS] [dstaddr ADDRESS]\n" | ||
41 | //usage: IF_FEATURE_IFCONFIG_SLIP( | ||
42 | //usage: " [outfill NN] [keepalive NN]\n") | ||
43 | //usage: " " IF_FEATURE_IFCONFIG_HW("[hw ether" IF_FEATURE_HWIB("|infiniband")" ADDRESS] ") "[metric NN] [mtu NN]\n" | ||
44 | //usage: " [[-]trailers] [[-]arp] [[-]allmulti]\n" | ||
45 | //usage: " [multicast] [[-]promisc] [txqueuelen NN] [[-]dynamic]\n" | ||
46 | //usage: IF_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ( | ||
47 | //usage: " [mem_start NN] [io_addr NN] [irq NN]\n") | ||
48 | //usage: " [up|down] ..." | ||
49 | |||
29 | #include <net/if.h> | 50 | #include <net/if.h> |
30 | #include <net/if_arp.h> | 51 | #include <net/if_arp.h> |
31 | #include <netinet/in.h> | 52 | #include <netinet/in.h> |
diff --git a/networking/ifenslave.c b/networking/ifenslave.c index 0b3ebf72a..208623e7d 100644 --- a/networking/ifenslave.c +++ b/networking/ifenslave.c | |||
@@ -98,6 +98,33 @@ | |||
98 | * set version to 1.1.0 | 98 | * set version to 1.1.0 |
99 | */ | 99 | */ |
100 | 100 | ||
101 | //usage:#define ifenslave_trivial_usage | ||
102 | //usage: "[-cdf] MASTER_IFACE SLAVE_IFACE..." | ||
103 | //usage:#define ifenslave_full_usage "\n\n" | ||
104 | //usage: "Configure network interfaces for parallel routing\n" | ||
105 | //usage: "\nOptions:" | ||
106 | //usage: "\n -c,--change-active Change active slave" | ||
107 | //usage: "\n -d,--detach Remove slave interface from bonding device" | ||
108 | //usage: "\n -f,--force Force, even if interface is not Ethernet" | ||
109 | /* //usage: "\n -r,--receive-slave Create a receive-only slave" */ | ||
110 | //usage: | ||
111 | //usage:#define ifenslave_example_usage | ||
112 | //usage: "To create a bond device, simply follow these three steps:\n" | ||
113 | //usage: "- ensure that the required drivers are properly loaded:\n" | ||
114 | //usage: " # modprobe bonding ; modprobe <3c59x|eepro100|pcnet32|tulip|...>\n" | ||
115 | //usage: "- assign an IP address to the bond device:\n" | ||
116 | //usage: " # ifconfig bond0 <addr> netmask <mask> broadcast <bcast>\n" | ||
117 | //usage: "- attach all the interfaces you need to the bond device:\n" | ||
118 | //usage: " # ifenslave bond0 eth0 eth1 eth2\n" | ||
119 | //usage: " If bond0 didn't have a MAC address, it will take eth0's. Then, all\n" | ||
120 | //usage: " interfaces attached AFTER this assignment will get the same MAC addr.\n\n" | ||
121 | //usage: " To detach a dead interface without setting the bond device down:\n" | ||
122 | //usage: " # ifenslave -d bond0 eth1\n\n" | ||
123 | //usage: " To set the bond device down and automatically release all the slaves:\n" | ||
124 | //usage: " # ifconfig bond0 down\n\n" | ||
125 | //usage: " To change active slave:\n" | ||
126 | //usage: " # ifenslave -c bond0 eth0\n" | ||
127 | |||
101 | #include "libbb.h" | 128 | #include "libbb.h" |
102 | 129 | ||
103 | /* #include <net/if.h> - no. linux/if_bonding.h pulls in linux/if.h */ | 130 | /* #include <net/if.h> - no. linux/if_bonding.h pulls in linux/if.h */ |
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index 8dd0a5bd8..421611aae 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c | |||
@@ -6,6 +6,32 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | |||
10 | //usage:#define ifplugd_trivial_usage | ||
11 | //usage: "[OPTIONS]" | ||
12 | //usage:#define ifplugd_full_usage "\n\n" | ||
13 | //usage: "Network interface plug detection daemon\n" | ||
14 | //usage: "\nOptions:" | ||
15 | //usage: "\n -n Don't daemonize" | ||
16 | //usage: "\n -s Don't log to syslog" | ||
17 | //usage: "\n -i IFACE Interface" | ||
18 | //usage: "\n -f/-F Treat link detection error as link down/link up" | ||
19 | //usage: "\n (otherwise exit on error)" | ||
20 | //usage: "\n -a Don't up interface at each link probe" | ||
21 | //usage: "\n -M Monitor creation/destruction of interface" | ||
22 | //usage: "\n (otherwise it must exist)" | ||
23 | //usage: "\n -r PROG Script to run" | ||
24 | //usage: "\n -x ARG Extra argument for script" | ||
25 | //usage: "\n -I Don't exit on nonzero exit code from script" | ||
26 | //usage: "\n -p Don't run script on daemon startup" | ||
27 | //usage: "\n -q Don't run script on daemon quit" | ||
28 | //usage: "\n -l Run script on startup even if no cable is detected" | ||
29 | //usage: "\n -t SECS Poll time in seconds" | ||
30 | //usage: "\n -u SECS Delay before running script after link up" | ||
31 | //usage: "\n -d SECS Delay after link down" | ||
32 | //usage: "\n -m MODE API mode (mii, priv, ethtool, wlan, iff, auto)" | ||
33 | //usage: "\n -k Kill running daemon" | ||
34 | |||
9 | #include "libbb.h" | 35 | #include "libbb.h" |
10 | 36 | ||
11 | #include "fix_u32.h" | 37 | #include "fix_u32.h" |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 7706a84b7..b48abb7dc 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -17,6 +17,34 @@ | |||
17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | //usage:#define ifup_trivial_usage | ||
21 | //usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." | ||
22 | //usage:#define ifup_full_usage "\n\n" | ||
23 | //usage: "Options:" | ||
24 | //usage: "\n -a De/configure all interfaces automatically" | ||
25 | //usage: "\n -i FILE Use FILE for interface definitions" | ||
26 | //usage: "\n -n Print out what would happen, but don't do it" | ||
27 | //usage: IF_FEATURE_IFUPDOWN_MAPPING( | ||
28 | //usage: "\n (note: doesn't disable mappings)" | ||
29 | //usage: "\n -m Don't run any mappings" | ||
30 | //usage: ) | ||
31 | //usage: "\n -v Print out what would happen before doing it" | ||
32 | //usage: "\n -f Force de/configuration" | ||
33 | //usage: | ||
34 | //usage:#define ifdown_trivial_usage | ||
35 | //usage: "[-an"IF_FEATURE_IFUPDOWN_MAPPING("m")"vf] [-i FILE] IFACE..." | ||
36 | //usage:#define ifdown_full_usage "\n\n" | ||
37 | //usage: "Options:" | ||
38 | //usage: "\n -a De/configure all interfaces automatically" | ||
39 | //usage: "\n -i FILE Use FILE for interface definitions" | ||
40 | //usage: "\n -n Print out what would happen, but don't do it" | ||
41 | //usage: IF_FEATURE_IFUPDOWN_MAPPING( | ||
42 | //usage: "\n (note: doesn't disable mappings)" | ||
43 | //usage: "\n -m Don't run any mappings" | ||
44 | //usage: ) | ||
45 | //usage: "\n -v Print out what would happen before doing it" | ||
46 | //usage: "\n -f Force de/configuration" | ||
47 | |||
20 | #include "libbb.h" | 48 | #include "libbb.h" |
21 | /* After libbb.h, since it needs sys/types.h on some systems */ | 49 | /* After libbb.h, since it needs sys/types.h on some systems */ |
22 | #include <sys/utsname.h> | 50 | #include <sys/utsname.h> |
diff --git a/networking/inetd.c b/networking/inetd.c index fb00c6cd7..226a6491c 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -154,6 +154,17 @@ | |||
154 | * setuid() | 154 | * setuid() |
155 | */ | 155 | */ |
156 | 156 | ||
157 | //usage:#define inetd_trivial_usage | ||
158 | //usage: "[-fe] [-q N] [-R N] [CONFFILE]" | ||
159 | //usage:#define inetd_full_usage "\n\n" | ||
160 | //usage: "Listen for network connections and launch programs\n" | ||
161 | //usage: "\nOptions:" | ||
162 | //usage: "\n -f Run in foreground" | ||
163 | //usage: "\n -e Log to stderr" | ||
164 | //usage: "\n -q N Socket listen queue (default: 128)" | ||
165 | //usage: "\n -R N Pause services after N connects/min" | ||
166 | //usage: "\n (default: 0 - disabled)" | ||
167 | |||
157 | #include <syslog.h> | 168 | #include <syslog.h> |
158 | #include <sys/un.h> | 169 | #include <sys/un.h> |
159 | 170 | ||
@@ -501,7 +512,7 @@ static void prepare_socket_fd(servtab_t *sep) | |||
501 | 512 | ||
502 | /* zero out the port for all RPC services; let bind() | 513 | /* zero out the port for all RPC services; let bind() |
503 | * find one. */ | 514 | * find one. */ |
504 | set_nport(sep->se_lsa, 0); | 515 | set_nport(&sep->se_lsa->u.sa, 0); |
505 | 516 | ||
506 | /* for RPC services, attempt to use a reserved port | 517 | /* for RPC services, attempt to use a reserved port |
507 | * if they are going to be running as root. */ | 518 | * if they are going to be running as root. */ |
@@ -959,7 +970,7 @@ static void reread_config_file(int sig UNUSED_PARAM) | |||
959 | } | 970 | } |
960 | if (LONE_CHAR(sep->se_local_hostname, '*')) { | 971 | if (LONE_CHAR(sep->se_local_hostname, '*')) { |
961 | lsa = xzalloc_lsa(sep->se_family); | 972 | lsa = xzalloc_lsa(sep->se_family); |
962 | set_nport(lsa, port); | 973 | set_nport(&lsa->u.sa, port); |
963 | } else { | 974 | } else { |
964 | lsa = host_and_af2sockaddr(sep->se_local_hostname, | 975 | lsa = host_and_af2sockaddr(sep->se_local_hostname, |
965 | ntohs(port), sep->se_family); | 976 | ntohs(port), sep->se_family); |
diff --git a/networking/interface.c b/networking/interface.c index 83af62b7c..bea54c180 100644 --- a/networking/interface.c +++ b/networking/interface.c | |||
@@ -32,7 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | #include <net/if.h> | 33 | #include <net/if.h> |
34 | #include <net/if_arp.h> | 34 | #include <net/if_arp.h> |
35 | #if (defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1) || defined(_NEWLIB_VERSION) | 35 | #ifndef __UCLIBC__ |
36 | # include <net/ethernet.h> | 36 | # include <net/ethernet.h> |
37 | #else | 37 | #else |
38 | # include <linux/if_ether.h> | 38 | # include <linux/if_ether.h> |
diff --git a/networking/ip.c b/networking/ip.c index 350656cef..98d583325 100644 --- a/networking/ip.c +++ b/networking/ip.c | |||
@@ -9,6 +9,79 @@ | |||
9 | * Bernhard Reutner-Fischer rewrote to use index_in_substr_array | 9 | * Bernhard Reutner-Fischer rewrote to use index_in_substr_array |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /* would need to make the " | " optional depending on more than one selected: */ | ||
13 | //usage:#define ip_trivial_usage | ||
14 | //usage: "[OPTIONS] {" | ||
15 | //usage: IF_FEATURE_IP_ADDRESS("address | ") | ||
16 | //usage: IF_FEATURE_IP_ROUTE("route | ") | ||
17 | //usage: IF_FEATURE_IP_LINK("link | ") | ||
18 | //usage: IF_FEATURE_IP_TUNNEL("tunnel | ") | ||
19 | //usage: IF_FEATURE_IP_RULE("rule") | ||
20 | //usage: "} {COMMAND}" | ||
21 | //usage:#define ip_full_usage "\n\n" | ||
22 | //usage: "ip [OPTIONS] OBJECT {COMMAND}\n" | ||
23 | //usage: "where OBJECT := {" | ||
24 | //usage: IF_FEATURE_IP_ADDRESS("address | ") | ||
25 | //usage: IF_FEATURE_IP_ROUTE("route | ") | ||
26 | //usage: IF_FEATURE_IP_LINK("link | ") | ||
27 | //usage: IF_FEATURE_IP_TUNNEL("tunnel | ") | ||
28 | //usage: IF_FEATURE_IP_RULE("rule") | ||
29 | //usage: "}\n" | ||
30 | //usage: "OPTIONS := { -f[amily] { inet | inet6 | link } | -o[neline] }" | ||
31 | //usage: | ||
32 | //usage:#define ipaddr_trivial_usage | ||
33 | //usage: "{ {add|del} IFADDR dev STRING | {show|flush}\n" | ||
34 | //usage: " [dev STRING] [to PREFIX] }" | ||
35 | //usage:#define ipaddr_full_usage "\n\n" | ||
36 | //usage: "ipaddr {add|delete} IFADDR dev STRING\n" | ||
37 | //usage: "ipaddr {show|flush} [dev STRING] [scope SCOPE-ID]\n" | ||
38 | //usage: " [to PREFIX] [label PATTERN]\n" | ||
39 | //usage: " IFADDR := PREFIX | ADDR peer PREFIX\n" | ||
40 | //usage: " [broadcast ADDR] [anycast ADDR]\n" | ||
41 | //usage: " [label STRING] [scope SCOPE-ID]\n" | ||
42 | //usage: " SCOPE-ID := [host | link | global | NUMBER]" | ||
43 | //usage: | ||
44 | //usage:#define iplink_trivial_usage | ||
45 | //usage: "{ set DEVICE { up | down | arp { on | off } | show [DEVICE] }" | ||
46 | //usage:#define iplink_full_usage "\n\n" | ||
47 | //usage: "iplink set DEVICE { up | down | arp | multicast { on | off } |\n" | ||
48 | //usage: " dynamic { on | off } |\n" | ||
49 | //usage: " mtu MTU }\n" | ||
50 | //usage: "iplink show [DEVICE]" | ||
51 | //usage: | ||
52 | //usage:#define iproute_trivial_usage | ||
53 | //usage: "{ list | flush | { add | del | change | append |\n" | ||
54 | //usage: " replace | monitor } ROUTE }" | ||
55 | //usage:#define iproute_full_usage "\n\n" | ||
56 | //usage: "iproute { list | flush } SELECTOR\n" | ||
57 | //usage: "iproute get ADDRESS [from ADDRESS iif STRING]\n" | ||
58 | //usage: " [oif STRING] [tos TOS]\n" | ||
59 | //usage: "iproute { add | del | change | append | replace | monitor } ROUTE\n" | ||
60 | //usage: " SELECTOR := [root PREFIX] [match PREFIX] [proto RTPROTO]\n" | ||
61 | //usage: " ROUTE := [TYPE] PREFIX [tos TOS] [proto RTPROTO]\n" | ||
62 | //usage: " [metric METRIC]" | ||
63 | //usage: | ||
64 | //usage:#define iprule_trivial_usage | ||
65 | //usage: "{[list | add | del] RULE}" | ||
66 | //usage:#define iprule_full_usage "\n\n" | ||
67 | //usage: "iprule [list | add | del] SELECTOR ACTION\n" | ||
68 | //usage: " SELECTOR := [from PREFIX] [to PREFIX] [tos TOS] [fwmark FWMARK]\n" | ||
69 | //usage: " [dev STRING] [pref NUMBER]\n" | ||
70 | //usage: " ACTION := [table TABLE_ID] [nat ADDRESS]\n" | ||
71 | //usage: " [prohibit | reject | unreachable]\n" | ||
72 | //usage: " [realms [SRCREALM/]DSTREALM]\n" | ||
73 | //usage: " TABLE_ID := [local | main | default | NUMBER]" | ||
74 | //usage: | ||
75 | //usage:#define iptunnel_trivial_usage | ||
76 | //usage: "{ add | change | del | show } [NAME]\n" | ||
77 | //usage: " [mode { ipip | gre | sit }]\n" | ||
78 | //usage: " [remote ADDR] [local ADDR] [ttl TTL]" | ||
79 | //usage:#define iptunnel_full_usage "\n\n" | ||
80 | //usage: "iptunnel { add | change | del | show } [NAME]\n" | ||
81 | //usage: " [mode { ipip | gre | sit }] [remote ADDR] [local ADDR]\n" | ||
82 | //usage: " [[i|o]seq] [[i|o]key KEY] [[i|o]csum]\n" | ||
83 | //usage: " [ttl TTL] [tos TOS] [[no]pmtudisc] [dev PHYS_DEV]" | ||
84 | |||
12 | #include "libbb.h" | 85 | #include "libbb.h" |
13 | 86 | ||
14 | #include "libiproute/utils.h" | 87 | #include "libiproute/utils.h" |
diff --git a/networking/ipcalc.c b/networking/ipcalc.c index acbaa4ac5..f96c73912 100644 --- a/networking/ipcalc.c +++ b/networking/ipcalc.c | |||
@@ -11,6 +11,33 @@ | |||
11 | * | 11 | * |
12 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 12 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
13 | */ | 13 | */ |
14 | |||
15 | //usage:#define ipcalc_trivial_usage | ||
16 | //usage: "[OPTIONS] ADDRESS[[/]NETMASK] [NETMASK]" | ||
17 | //usage:#define ipcalc_full_usage "\n\n" | ||
18 | //usage: "Calculate IP network settings from a IP address\n" | ||
19 | //usage: "\nOptions:" | ||
20 | //usage: IF_FEATURE_IPCALC_LONG_OPTIONS( | ||
21 | //usage: "\n -b,--broadcast Display calculated broadcast address" | ||
22 | //usage: "\n -n,--network Display calculated network address" | ||
23 | //usage: "\n -m,--netmask Display default netmask for IP" | ||
24 | //usage: IF_FEATURE_IPCALC_FANCY( | ||
25 | //usage: "\n -p,--prefix Display the prefix for IP/NETMASK" | ||
26 | //usage: "\n -h,--hostname Display first resolved host name" | ||
27 | //usage: "\n -s,--silent Don't ever display error messages" | ||
28 | //usage: ) | ||
29 | //usage: ) | ||
30 | //usage: IF_NOT_FEATURE_IPCALC_LONG_OPTIONS( | ||
31 | //usage: "\n -b Display calculated broadcast address" | ||
32 | //usage: "\n -n Display calculated network address" | ||
33 | //usage: "\n -m Display default netmask for IP" | ||
34 | //usage: IF_FEATURE_IPCALC_FANCY( | ||
35 | //usage: "\n -p Display the prefix for IP/NETMASK" | ||
36 | //usage: "\n -h Display first resolved host name" | ||
37 | //usage: "\n -s Don't ever display error messages" | ||
38 | //usage: ) | ||
39 | //usage: ) | ||
40 | |||
14 | #include "libbb.h" | 41 | #include "libbb.h" |
15 | /* After libbb.h, because on some systems it needs other includes */ | 42 | /* After libbb.h, because on some systems it needs other includes */ |
16 | #include <arpa/inet.h> | 43 | #include <arpa/inet.h> |
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c index 18ce59aaf..199e11225 100644 --- a/networking/isrv_identd.c +++ b/networking/isrv_identd.c | |||
@@ -7,6 +7,17 @@ | |||
7 | * Licensed under GPLv2, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define fakeidentd_trivial_usage | ||
11 | //usage: "[-fiw] [-b ADDR] [STRING]" | ||
12 | //usage:#define fakeidentd_full_usage "\n\n" | ||
13 | //usage: "Provide fake ident (auth) service\n" | ||
14 | //usage: "\nOptions:" | ||
15 | //usage: "\n -f Run in foreground" | ||
16 | //usage: "\n -i Inetd mode" | ||
17 | //usage: "\n -w Inetd 'wait' mode" | ||
18 | //usage: "\n -b ADDR Bind to specified address" | ||
19 | //usage: "\n STRING Ident answer string (default: nobody)" | ||
20 | |||
10 | #include "libbb.h" | 21 | #include "libbb.h" |
11 | #include <syslog.h> | 22 | #include <syslog.h> |
12 | #include "isrv.h" | 23 | #include "isrv.h" |
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c index 38b6c0516..bb42e269e 100644 --- a/networking/libiproute/ll_types.c +++ b/networking/libiproute/ll_types.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * | 7 | * |
8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> | 8 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
9 | */ | 9 | */ |
10 | #include <sys/socket.h> /* linux/if_arp.h needs it on some systems */ | ||
10 | #include <arpa/inet.h> | 11 | #include <arpa/inet.h> |
11 | #include <linux/if_arp.h> | 12 | #include <linux/if_arp.h> |
12 | 13 | ||
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index e98a5dd5b..29f99e76b 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -386,10 +386,10 @@ create new one, and bind() it. TODO */ | |||
386 | if (port == 0) { | 386 | if (port == 0) { |
387 | /* "nc -nl -p LPORT RHOST" (w/o RPORT!): | 387 | /* "nc -nl -p LPORT RHOST" (w/o RPORT!): |
388 | * we should accept any remote port */ | 388 | * we should accept any remote port */ |
389 | set_nport(&remend, 0); /* blot out remote port# */ | 389 | set_nport(&remend.u.sa, 0); /* blot out remote port# */ |
390 | } | 390 | } |
391 | r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len); | 391 | r = memcmp(&remend.u.sa, &themaddr->u.sa, remend.len); |
392 | set_nport(&remend, sv_port); /* restore */ | 392 | set_nport(&remend.u.sa, sv_port); /* restore */ |
393 | if (r != 0) { | 393 | if (r != 0) { |
394 | /* nc 1.10 bails out instead, and its error message | 394 | /* nc 1.10 bails out instead, and its error message |
395 | * is not suppressed by o_verbose */ | 395 | * is not suppressed by o_verbose */ |
@@ -486,7 +486,7 @@ static int udptest(void) | |||
486 | us to hang forever, and hit it */ | 486 | us to hang forever, and hit it */ |
487 | o_wait = 5; /* enough that we'll notice?? */ | 487 | o_wait = 5; /* enough that we'll notice?? */ |
488 | rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); | 488 | rr = xsocket(ouraddr->u.sa.sa_family, SOCK_STREAM, 0); |
489 | set_nport(themaddr, htons(SLEAZE_PORT)); | 489 | set_nport(&themaddr->u.sa, htons(SLEAZE_PORT)); |
490 | connect_w_timeout(rr); | 490 | connect_w_timeout(rr); |
491 | /* don't need to restore themaddr's port, it's not used anymore */ | 491 | /* don't need to restore themaddr's port, it's not used anymore */ |
492 | close(rr); | 492 | close(rr); |
@@ -813,7 +813,7 @@ int nc_main(int argc UNUSED_PARAM, char **argv) | |||
813 | (themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC), | 813 | (themaddr ? themaddr->u.sa.sa_family : AF_UNSPEC), |
814 | x); | 814 | x); |
815 | if (o_lport) | 815 | if (o_lport) |
816 | set_nport(ouraddr, htons(o_lport)); | 816 | set_nport(&ouraddr->u.sa, htons(o_lport)); |
817 | } | 817 | } |
818 | xmove_fd(x, netfd); | 818 | xmove_fd(x, netfd); |
819 | setsockopt_reuseaddr(netfd); | 819 | setsockopt_reuseaddr(netfd); |
diff --git a/networking/nslookup.c b/networking/nslookup.c index 67fc01547..f4fd407dd 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c | |||
@@ -11,6 +11,20 @@ | |||
11 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 11 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | //usage:#define nslookup_trivial_usage | ||
15 | //usage: "[HOST] [SERVER]" | ||
16 | //usage:#define nslookup_full_usage "\n\n" | ||
17 | //usage: "Query the nameserver for the IP address of the given HOST\n" | ||
18 | //usage: "optionally using a specified DNS server" | ||
19 | //usage: | ||
20 | //usage:#define nslookup_example_usage | ||
21 | //usage: "$ nslookup localhost\n" | ||
22 | //usage: "Server: default\n" | ||
23 | //usage: "Address: default\n" | ||
24 | //usage: "\n" | ||
25 | //usage: "Name: debian\n" | ||
26 | //usage: "Address: 127.0.0.1\n" | ||
27 | |||
14 | #include <resolv.h> | 28 | #include <resolv.h> |
15 | #include "libbb.h" | 29 | #include "libbb.h" |
16 | 30 | ||
diff --git a/networking/ntpd.c b/networking/ntpd.c index 3ed05ba29..e27dbaa6b 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -27,6 +27,23 @@ | |||
27 | * * | 27 | * * |
28 | *********************************************************************** | 28 | *********************************************************************** |
29 | */ | 29 | */ |
30 | |||
31 | //usage:#define ntpd_trivial_usage | ||
32 | //usage: "[-dnqNw"IF_FEATURE_NTPD_SERVER("l")"] [-S PROG] [-p PEER]..." | ||
33 | //usage:#define ntpd_full_usage "\n\n" | ||
34 | //usage: "NTP client/server\n" | ||
35 | //usage: "\nOptions:" | ||
36 | //usage: "\n -d Verbose" | ||
37 | //usage: "\n -n Do not daemonize" | ||
38 | //usage: "\n -q Quit after clock is set" | ||
39 | //usage: "\n -N Run at high priority" | ||
40 | //usage: "\n -w Do not set time (only query peers), implies -n" | ||
41 | //usage: IF_FEATURE_NTPD_SERVER( | ||
42 | //usage: "\n -l Run as server on port 123" | ||
43 | //usage: ) | ||
44 | //usage: "\n -S PROG Run PROG after stepping time, stratum change, and every 11 mins" | ||
45 | //usage: "\n -p PEER Obtain time from PEER (may be repeated)" | ||
46 | |||
30 | #include "libbb.h" | 47 | #include "libbb.h" |
31 | #include <math.h> | 48 | #include <math.h> |
32 | #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */ | 49 | #include <netinet/ip.h> /* For IPTOS_LOWDELAY definition */ |
@@ -238,6 +255,8 @@ enum { | |||
238 | OPT_p = (1 << 5), | 255 | OPT_p = (1 << 5), |
239 | OPT_S = (1 << 6), | 256 | OPT_S = (1 << 6), |
240 | OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER, | 257 | OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER, |
258 | /* We hijack some bits for other purposes */ | ||
259 | OPT_qq = (1 << 8), | ||
241 | }; | 260 | }; |
242 | 261 | ||
243 | struct globals { | 262 | struct globals { |
@@ -1930,15 +1949,18 @@ static NOINLINE void ntp_init(char **argv) | |||
1930 | setpriority(PRIO_PROCESS, 0, -15); | 1949 | setpriority(PRIO_PROCESS, 0, -15); |
1931 | 1950 | ||
1932 | /* If network is up, syncronization occurs in ~10 seconds. | 1951 | /* If network is up, syncronization occurs in ~10 seconds. |
1933 | * We give "ntpd -q" a full minute to finish, then we exit. | 1952 | * We give "ntpd -q" 10 seconds to get first reply, |
1953 | * then another 50 seconds to finish syncing. | ||
1934 | * | 1954 | * |
1935 | * I tested ntpd 4.2.6p1 and apparently it never exits | 1955 | * I tested ntpd 4.2.6p1 and apparently it never exits |
1936 | * (will try forever), but it does not feel right. | 1956 | * (will try forever), but it does not feel right. |
1937 | * The goal of -q is to act like ntpdate: set time | 1957 | * The goal of -q is to act like ntpdate: set time |
1938 | * after a reasonably small period of polling, or fail. | 1958 | * after a reasonably small period of polling, or fail. |
1939 | */ | 1959 | */ |
1940 | if (opts & OPT_q) | 1960 | if (opts & OPT_q) { |
1941 | alarm(60); | 1961 | option_mask32 |= OPT_qq; |
1962 | alarm(10); | ||
1963 | } | ||
1942 | 1964 | ||
1943 | bb_signals(0 | 1965 | bb_signals(0 |
1944 | | (1 << SIGTERM) | 1966 | | (1 << SIGTERM) |
@@ -2065,6 +2087,15 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2065 | #endif | 2087 | #endif |
2066 | for (; nfds != 0 && j < i; j++) { | 2088 | for (; nfds != 0 && j < i; j++) { |
2067 | if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { | 2089 | if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { |
2090 | /* | ||
2091 | * At init, alarm was set to 10 sec. | ||
2092 | * Now we did get a reply. | ||
2093 | * Increase timeout to 50 seconds to finish syncing. | ||
2094 | */ | ||
2095 | if (option_mask32 & OPT_qq) { | ||
2096 | option_mask32 &= ~OPT_qq; | ||
2097 | alarm(50); | ||
2098 | } | ||
2068 | nfds--; | 2099 | nfds--; |
2069 | recv_and_process_peer_pkt(idx2peer[j]); | 2100 | recv_and_process_peer_pkt(idx2peer[j]); |
2070 | gettime1900d(); /* sets G.cur_time */ | 2101 | gettime1900d(); /* sets G.cur_time */ |
diff --git a/networking/pscan.c b/networking/pscan.c index a8194d1a8..5595148fc 100644 --- a/networking/pscan.c +++ b/networking/pscan.c | |||
@@ -6,6 +6,18 @@ | |||
6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
7 | */ | 7 | */ |
8 | 8 | ||
9 | //usage:#define pscan_trivial_usage | ||
10 | //usage: "[-cb] [-p MIN_PORT] [-P MAX_PORT] [-t TIMEOUT] [-T MIN_RTT] HOST" | ||
11 | //usage:#define pscan_full_usage "\n\n" | ||
12 | //usage: "Scan a host, print all open ports\n" | ||
13 | //usage: "\nOptions:" | ||
14 | //usage: "\n -c Show closed ports too" | ||
15 | //usage: "\n -b Show blocked ports too" | ||
16 | //usage: "\n -p Scan from this port (default 1)" | ||
17 | //usage: "\n -P Scan up to this port (default 1024)" | ||
18 | //usage: "\n -t Timeout (default 5000 ms)" | ||
19 | //usage: "\n -T Minimum rtt (default 5 ms, increase for congested hosts)" | ||
20 | |||
9 | #include "libbb.h" | 21 | #include "libbb.h" |
10 | 22 | ||
11 | /* debugging */ | 23 | /* debugging */ |
@@ -76,7 +88,7 @@ int pscan_main(int argc UNUSED_PARAM, char **argv) | |||
76 | DMSG("rtt %u", rtt_4); | 88 | DMSG("rtt %u", rtt_4); |
77 | 89 | ||
78 | /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */ | 90 | /* The SOCK_STREAM socket type is implemented on the TCP/IP protocol. */ |
79 | set_nport(lsap, htons(port)); | 91 | set_nport(&lsap->u.sa, htons(port)); |
80 | s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0); | 92 | s = xsocket(lsap->u.sa.sa_family, SOCK_STREAM, 0); |
81 | /* We need unblocking socket so we don't need to wait for ETIMEOUT. */ | 93 | /* We need unblocking socket so we don't need to wait for ETIMEOUT. */ |
82 | /* Nonblocking connect typically "fails" with errno == EINPROGRESS */ | 94 | /* Nonblocking connect typically "fails" with errno == EINPROGRESS */ |
diff --git a/networking/route.c b/networking/route.c index 98a03ded7..6699a1c32 100644 --- a/networking/route.c +++ b/networking/route.c | |||
@@ -25,6 +25,15 @@ | |||
25 | * remove ridiculous amounts of bloat. | 25 | * remove ridiculous amounts of bloat. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | //usage:#define route_trivial_usage | ||
29 | //usage: "[{add|del|delete}]" | ||
30 | //usage:#define route_full_usage "\n\n" | ||
31 | //usage: "Edit kernel routing tables\n" | ||
32 | //usage: "\nOptions:" | ||
33 | //usage: "\n -n Don't resolve names" | ||
34 | //usage: "\n -e Display other/more information" | ||
35 | //usage: "\n -A inet" IF_FEATURE_IPV6("{6}") " Select address family" | ||
36 | |||
28 | #include <net/route.h> | 37 | #include <net/route.h> |
29 | #include <net/if.h> | 38 | #include <net/if.h> |
30 | 39 | ||
diff --git a/networking/slattach.c b/networking/slattach.c index 71edd2f27..d1221b11a 100644 --- a/networking/slattach.c +++ b/networking/slattach.c | |||
@@ -13,6 +13,20 @@ | |||
13 | * - The -F options allows disabling of RTS/CTS flow control. | 13 | * - The -F options allows disabling of RTS/CTS flow control. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | //usage:#define slattach_trivial_usage | ||
17 | //usage: "[-cehmLF] [-s SPEED] [-p PROTOCOL] DEVICE" | ||
18 | //usage:#define slattach_full_usage "\n\n" | ||
19 | //usage: "Attach network interface(s) to serial line(s)\n" | ||
20 | //usage: "\nOptions:" | ||
21 | //usage: "\n -p PROT Set protocol (slip, cslip, slip6, clisp6 or adaptive)" | ||
22 | //usage: "\n -s SPD Set line speed" | ||
23 | //usage: "\n -e Exit after initializing device" | ||
24 | //usage: "\n -h Exit when the carrier is lost" | ||
25 | //usage: "\n -c PROG Run PROG when the line is hung up" | ||
26 | //usage: "\n -m Do NOT initialize the line in raw 8 bits mode" | ||
27 | //usage: "\n -L Enable 3-wire operation" | ||
28 | //usage: "\n -F Disable RTS/CTS flow control" | ||
29 | |||
16 | #include "libbb.h" | 30 | #include "libbb.h" |
17 | #include "libiproute/utils.h" /* invarg() */ | 31 | #include "libiproute/utils.h" /* invarg() */ |
18 | 32 | ||
diff --git a/networking/tc.c b/networking/tc.c index 9b3245546..e9848a86b 100644 --- a/networking/tc.c +++ b/networking/tc.c | |||
@@ -7,6 +7,27 @@ | |||
7 | * Bernhard Reutner-Fischer adjusted for busybox | 7 | * Bernhard Reutner-Fischer adjusted for busybox |
8 | */ | 8 | */ |
9 | 9 | ||
10 | //usage:#define tc_trivial_usage | ||
11 | /* //usage: "[OPTIONS] OBJECT CMD [dev STRING]" */ | ||
12 | //usage: "OBJECT CMD [dev STRING]" | ||
13 | //usage:#define tc_full_usage "\n\n" | ||
14 | //usage: "OBJECT: {qdisc|class|filter}\n" | ||
15 | //usage: "CMD: {add|del|change|replace|show}\n" | ||
16 | //usage: "\n" | ||
17 | //usage: "qdisc [ handle QHANDLE ] [ root |"IF_FEATURE_TC_INGRESS(" ingress |")" parent CLASSID ]\n" | ||
18 | /* //usage: "[ estimator INTERVAL TIME_CONSTANT ]\n" */ | ||
19 | //usage: " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n" | ||
20 | //usage: " QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n" | ||
21 | //usage: "qdisc show [ dev STRING ]"IF_FEATURE_TC_INGRESS(" [ingress]")"\n" | ||
22 | //usage: "class [ classid CLASSID ] [ root | parent CLASSID ]\n" | ||
23 | //usage: " [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n" | ||
24 | //usage: "class show [ dev STRING ] [ root | parent CLASSID ]\n" | ||
25 | //usage: "filter [ pref PRIO ] [ protocol PROTO ]\n" | ||
26 | /* //usage: "\t[ estimator INTERVAL TIME_CONSTANT ]\n" */ | ||
27 | //usage: " [ root | classid CLASSID ] [ handle FILTERID ]\n" | ||
28 | //usage: " [ [ FILTER_TYPE ] [ help | OPTIONS ] ]\n" | ||
29 | //usage: "filter show [ dev STRING ] [ root | parent CLASSID ]" | ||
30 | |||
10 | #include "libbb.h" | 31 | #include "libbb.h" |
11 | 32 | ||
12 | #include "libiproute/utils.h" | 33 | #include "libiproute/utils.h" |
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index b532e43cd..a2b8c958c 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c | |||
@@ -29,6 +29,43 @@ | |||
29 | * - don't know how to retrieve ORIGDST for udp. | 29 | * - don't know how to retrieve ORIGDST for udp. |
30 | */ | 30 | */ |
31 | 31 | ||
32 | //usage:#define tcpsvd_trivial_usage | ||
33 | //usage: "[-hEv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] IP PORT PROG" | ||
34 | /* with not-implemented options: */ | ||
35 | /* //usage: "[-hpEvv] [-c N] [-C N[:MSG]] [-b N] [-u USER] [-l NAME] [-i DIR|-x CDB] [-t SEC] IP PORT PROG" */ | ||
36 | //usage:#define tcpsvd_full_usage "\n\n" | ||
37 | //usage: "Create TCP socket, bind to IP:PORT and listen\n" | ||
38 | //usage: "for incoming connection. Run PROG for each connection.\n" | ||
39 | //usage: "\n IP IP to listen on. '0' = all" | ||
40 | //usage: "\n PORT Port to listen on" | ||
41 | //usage: "\n PROG ARGS Program to run" | ||
42 | //usage: "\n -l NAME Local hostname (else looks up local hostname in DNS)" | ||
43 | //usage: "\n -u USER[:GRP] Change to user/group after bind" | ||
44 | //usage: "\n -c N Handle up to N connections simultaneously" | ||
45 | //usage: "\n -b N Allow a backlog of approximately N TCP SYNs" | ||
46 | //usage: "\n -C N[:MSG] Allow only up to N connections from the same IP." | ||
47 | //usage: "\n New connections from this IP address are closed" | ||
48 | //usage: "\n immediately. MSG is written to the peer before close" | ||
49 | //usage: "\n -h Look up peer's hostname" | ||
50 | //usage: "\n -E Don't set up environment variables" | ||
51 | //usage: "\n -v Verbose" | ||
52 | //usage: | ||
53 | //usage:#define udpsvd_trivial_usage | ||
54 | //usage: "[-hEv] [-c N] [-u USER] [-l NAME] IP PORT PROG" | ||
55 | //usage:#define udpsvd_full_usage "\n\n" | ||
56 | //usage: "Create UDP socket, bind to IP:PORT and wait\n" | ||
57 | //usage: "for incoming packets. Run PROG for each packet,\n" | ||
58 | //usage: "redirecting all further packets with same peer ip:port to it.\n" | ||
59 | //usage: "\n IP IP to listen on. '0' = all" | ||
60 | //usage: "\n PORT Port to listen on" | ||
61 | //usage: "\n PROG ARGS Program to run" | ||
62 | //usage: "\n -l NAME Local hostname (else looks up local hostname in DNS)" | ||
63 | //usage: "\n -u USER[:GRP] Change to user/group after bind" | ||
64 | //usage: "\n -c N Handle up to N connections simultaneously" | ||
65 | //usage: "\n -h Look up peer's hostname" | ||
66 | //usage: "\n -E Don't set up environment variables" | ||
67 | //usage: "\n -v Verbose" | ||
68 | |||
32 | #include "libbb.h" | 69 | #include "libbb.h" |
33 | 70 | ||
34 | /* Wants <limits.h> etc, thus included after libbb.h: */ | 71 | /* Wants <limits.h> etc, thus included after libbb.h: */ |
@@ -387,7 +424,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv) | |||
387 | * already bound in parent! This seems to work in Linux. | 424 | * already bound in parent! This seems to work in Linux. |
388 | * (otherwise we can move socket to fd #0 only if bind succeeds) */ | 425 | * (otherwise we can move socket to fd #0 only if bind succeeds) */ |
389 | close(0); | 426 | close(0); |
390 | set_nport(localp, htons(local_port)); | 427 | set_nport(&localp->u.sa, htons(local_port)); |
391 | xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0); | 428 | xmove_fd(xsocket(localp->u.sa.sa_family, SOCK_DGRAM, 0), 0); |
392 | setsockopt_reuseaddr(0); /* crucial */ | 429 | setsockopt_reuseaddr(0); /* crucial */ |
393 | xbind(0, &localp->u.sa, localp->len); | 430 | xbind(0, &localp->u.sa, localp->len); |
diff --git a/networking/telnet.c b/networking/telnet.c index f6fad684c..1f0d85107 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -21,6 +21,22 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //usage:#if ENABLE_FEATURE_TELNET_AUTOLOGIN | ||
25 | //usage:#define telnet_trivial_usage | ||
26 | //usage: "[-a] [-l USER] HOST [PORT]" | ||
27 | //usage:#define telnet_full_usage "\n\n" | ||
28 | //usage: "Connect to telnet server\n" | ||
29 | //usage: "\nOptions:" | ||
30 | //usage: "\n -a Automatic login with $USER variable" | ||
31 | //usage: "\n -l USER Automatic login as USER" | ||
32 | //usage: | ||
33 | //usage:#else | ||
34 | //usage:#define telnet_trivial_usage | ||
35 | //usage: "HOST [PORT]" | ||
36 | //usage:#define telnet_full_usage "\n\n" | ||
37 | //usage: "Connect to telnet server" | ||
38 | //usage:#endif | ||
39 | |||
24 | #include <arpa/telnet.h> | 40 | #include <arpa/telnet.h> |
25 | #include <netinet/in.h> | 41 | #include <netinet/in.h> |
26 | #include "libbb.h" | 42 | #include "libbb.h" |
diff --git a/networking/telnetd.c b/networking/telnetd.c index eec4417ca..4404064fc 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -20,6 +20,28 @@ | |||
20 | * Vladimir Oleynik <dzo@simtreas.ru> 2001 | 20 | * Vladimir Oleynik <dzo@simtreas.ru> 2001 |
21 | * Set process group corrections, initial busybox port | 21 | * Set process group corrections, initial busybox port |
22 | */ | 22 | */ |
23 | |||
24 | //usage:#define telnetd_trivial_usage | ||
25 | //usage: "[OPTIONS]" | ||
26 | //usage:#define telnetd_full_usage "\n\n" | ||
27 | //usage: "Handle incoming telnet connections" | ||
28 | //usage: IF_NOT_FEATURE_TELNETD_STANDALONE(" via inetd") "\n" | ||
29 | //usage: "\nOptions:" | ||
30 | //usage: "\n -l LOGIN Exec LOGIN on connect" | ||
31 | //usage: "\n -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue" | ||
32 | //usage: "\n -K Close connection as soon as login exits" | ||
33 | //usage: "\n (normally wait until all programs close slave pty)" | ||
34 | //usage: IF_FEATURE_TELNETD_STANDALONE( | ||
35 | //usage: "\n -p PORT Port to listen on" | ||
36 | //usage: "\n -b ADDR[:PORT] Address to bind to" | ||
37 | //usage: "\n -F Run in foreground" | ||
38 | //usage: "\n -i Inetd mode" | ||
39 | //usage: IF_FEATURE_TELNETD_INETD_WAIT( | ||
40 | //usage: "\n -w SEC Inetd 'wait' mode, linger time SEC" | ||
41 | //usage: "\n -S Log to syslog (implied by -i or without -F and -w)" | ||
42 | //usage: ) | ||
43 | //usage: ) | ||
44 | |||
23 | #define DEBUG 0 | 45 | #define DEBUG 0 |
24 | 46 | ||
25 | #include "libbb.h" | 47 | #include "libbb.h" |
diff --git a/networking/tftp.c b/networking/tftp.c index 35cf0dbd9..648441016 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -18,7 +18,42 @@ | |||
18 | * | 18 | * |
19 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 19 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
20 | */ | 20 | */ |
21 | |||
22 | //usage:#define tftp_trivial_usage | ||
23 | //usage: "[OPTIONS] HOST [PORT]" | ||
24 | //usage:#define tftp_full_usage "\n\n" | ||
25 | //usage: "Transfer a file from/to tftp server\n" | ||
26 | //usage: "\nOptions:" | ||
27 | //usage: "\n -l FILE Local FILE" | ||
28 | //usage: "\n -r FILE Remote FILE" | ||
29 | //usage: IF_FEATURE_TFTP_GET( | ||
30 | //usage: "\n -g Get file" | ||
31 | //usage: ) | ||
32 | //usage: IF_FEATURE_TFTP_PUT( | ||
33 | //usage: "\n -p Put file" | ||
34 | //usage: ) | ||
35 | //usage: IF_FEATURE_TFTP_BLOCKSIZE( | ||
36 | //usage: "\n -b SIZE Transfer blocks of SIZE octets" | ||
37 | //usage: ) | ||
38 | //usage: | ||
39 | //usage:#define tftpd_trivial_usage | ||
40 | //usage: "[-cr] [-u USER] [DIR]" | ||
41 | //usage:#define tftpd_full_usage "\n\n" | ||
42 | //usage: "Transfer a file on tftp client's request\n" | ||
43 | //usage: "\n" | ||
44 | //usage: "tftpd should be used as an inetd service.\n" | ||
45 | //usage: "tftpd's line for inetd.conf:\n" | ||
46 | //usage: " 69 dgram udp nowait root tftpd tftpd -l /files/to/serve\n" | ||
47 | //usage: "It also can be ran from udpsvd:\n" | ||
48 | //usage: " udpsvd -vE 0.0.0.0 69 tftpd /files/to/serve\n" | ||
49 | //usage: "\nOptions:" | ||
50 | //usage: "\n -r Prohibit upload" | ||
51 | //usage: "\n -c Allow file creation via upload" | ||
52 | //usage: "\n -u Access files as USER" | ||
53 | //usage: "\n -l Log to syslog (inetd mode requires this)" | ||
54 | |||
21 | #include "libbb.h" | 55 | #include "libbb.h" |
56 | #include <syslog.h> | ||
22 | 57 | ||
23 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT | 58 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT |
24 | 59 | ||
@@ -59,6 +94,7 @@ enum { | |||
59 | TFTPD_OPT_r = (1 << 8) * ENABLE_TFTPD, | 94 | TFTPD_OPT_r = (1 << 8) * ENABLE_TFTPD, |
60 | TFTPD_OPT_c = (1 << 9) * ENABLE_TFTPD, | 95 | TFTPD_OPT_c = (1 << 9) * ENABLE_TFTPD, |
61 | TFTPD_OPT_u = (1 << 10) * ENABLE_TFTPD, | 96 | TFTPD_OPT_u = (1 << 10) * ENABLE_TFTPD, |
97 | TFTPD_OPT_l = (1 << 11) * ENABLE_TFTPD, | ||
62 | }; | 98 | }; |
63 | 99 | ||
64 | #if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT | 100 | #if ENABLE_FEATURE_TFTP_GET && !ENABLE_FEATURE_TFTP_PUT |
@@ -422,6 +458,7 @@ static int tftp_protocol( | |||
422 | finished = 1; | 458 | finished = 1; |
423 | } | 459 | } |
424 | cp += len; | 460 | cp += len; |
461 | IF_FEATURE_TFTP_PROGRESS_BAR(G.pos += len;) | ||
425 | } | 462 | } |
426 | send_pkt: | 463 | send_pkt: |
427 | /* Send packet */ | 464 | /* Send packet */ |
@@ -443,8 +480,6 @@ static int tftp_protocol( | |||
443 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); | 480 | xsendto(socket_fd, xbuf, send_len, &peer_lsa->u.sa, peer_lsa->len); |
444 | 481 | ||
445 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR | 482 | #if ENABLE_FEATURE_TFTP_PROGRESS_BAR |
446 | if (ENABLE_TFTP && remote_file) /* tftp */ | ||
447 | G.pos = (block_nr - 1) * (uoff_t)blksize; | ||
448 | if (is_bb_progress_inited(&G.pmt)) | 483 | if (is_bb_progress_inited(&G.pmt)) |
449 | tftp_progress_update(); | 484 | tftp_progress_update(); |
450 | #endif | 485 | #endif |
@@ -588,6 +623,7 @@ static int tftp_protocol( | |||
588 | if (sz != blksize) { | 623 | if (sz != blksize) { |
589 | finished = 1; | 624 | finished = 1; |
590 | } | 625 | } |
626 | IF_FEATURE_TFTP_PROGRESS_BAR(G.pos += sz;) | ||
591 | continue; /* send ACK */ | 627 | continue; /* send ACK */ |
592 | } | 628 | } |
593 | /* Disabled to cope with servers with Sorcerer's Apprentice Syndrome */ | 629 | /* Disabled to cope with servers with Sorcerer's Apprentice Syndrome */ |
@@ -749,8 +785,12 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) | |||
749 | peer_lsa->len = our_lsa->len; | 785 | peer_lsa->len = our_lsa->len; |
750 | 786 | ||
751 | /* Shifting to not collide with TFTP_OPTs */ | 787 | /* Shifting to not collide with TFTP_OPTs */ |
752 | opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:", &user_opt) << 8); | 788 | opt = option_mask32 = TFTPD_OPT | (getopt32(argv, "rcu:l", &user_opt) << 8); |
753 | argv += optind; | 789 | argv += optind; |
790 | if (opt & TFTPD_OPT_l) { | ||
791 | openlog(applet_name, LOG_PID, LOG_DAEMON); | ||
792 | logmode = LOGMODE_SYSLOG; | ||
793 | } | ||
754 | if (argv[0]) | 794 | if (argv[0]) |
755 | xchdir(argv[0]); | 795 | xchdir(argv[0]); |
756 | 796 | ||
diff --git a/networking/traceroute.c b/networking/traceroute.c index 82bb0118c..96f9d3472 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c | |||
@@ -210,6 +210,51 @@ | |||
210 | * Tue Dec 20 03:50:13 PST 1988 | 210 | * Tue Dec 20 03:50:13 PST 1988 |
211 | */ | 211 | */ |
212 | 212 | ||
213 | //usage:#define traceroute_trivial_usage | ||
214 | //usage: "[-"IF_TRACEROUTE6("46")"FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]\n" | ||
215 | //usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]\n" | ||
216 | //usage: " [-z PAUSE_MSEC] HOST [BYTES]" | ||
217 | //usage:#define traceroute_full_usage "\n\n" | ||
218 | //usage: "Trace the route to HOST\n" | ||
219 | //usage: "\nOptions:" | ||
220 | //usage: IF_TRACEROUTE6( | ||
221 | //usage: "\n -4,-6 Force IP or IPv6 name resolution" | ||
222 | //usage: ) | ||
223 | //usage: "\n -F Set the don't fragment bit" | ||
224 | //usage: "\n -I Use ICMP ECHO instead of UDP datagrams" | ||
225 | //usage: "\n -l Display the TTL value of the returned packet" | ||
226 | //usage: "\n -d Set SO_DEBUG options to socket" | ||
227 | //usage: "\n -n Print numeric addresses" | ||
228 | //usage: "\n -r Bypass routing tables, send directly to HOST" | ||
229 | //usage: "\n -v Verbose" | ||
230 | //usage: "\n -m Max time-to-live (max number of hops)" | ||
231 | //usage: "\n -p Base UDP port number used in probes" | ||
232 | //usage: "\n (default 33434)" | ||
233 | //usage: "\n -q Number of probes per TTL (default 3)" | ||
234 | //usage: "\n -s IP address to use as the source address" | ||
235 | //usage: "\n -t Type-of-service in probe packets (default 0)" | ||
236 | //usage: "\n -w Time in seconds to wait for a response (default 3)" | ||
237 | //usage: "\n -g Loose source route gateway (8 max)" | ||
238 | //usage: | ||
239 | //usage:#define traceroute6_trivial_usage | ||
240 | //usage: "[-dnrv] [-m MAXTTL] [-p PORT] [-q PROBES]\n" | ||
241 | //usage: " [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-i IFACE]\n" | ||
242 | //usage: " HOST [BYTES]" | ||
243 | //usage:#define traceroute6_full_usage "\n\n" | ||
244 | //usage: "Trace the route to HOST\n" | ||
245 | //usage: "\nOptions:" | ||
246 | //usage: "\n -d Set SO_DEBUG options to socket" | ||
247 | //usage: "\n -n Print numeric addresses" | ||
248 | //usage: "\n -r Bypass routing tables, send directly to HOST" | ||
249 | //usage: "\n -v Verbose" | ||
250 | //usage: "\n -m Max time-to-live (max number of hops)" | ||
251 | //usage: "\n -p Base UDP port number used in probes" | ||
252 | //usage: "\n (default is 33434)" | ||
253 | //usage: "\n -q Number of probes per TTL (default 3)" | ||
254 | //usage: "\n -s IP address to use as the source address" | ||
255 | //usage: "\n -t Type-of-service in probe packets (default 0)" | ||
256 | //usage: "\n -w Time in seconds to wait for a response (default 3)" | ||
257 | |||
213 | #define TRACEROUTE_SO_DEBUG 0 | 258 | #define TRACEROUTE_SO_DEBUG 0 |
214 | 259 | ||
215 | /* TODO: undefs were uncommented - ??! we have config system for that! */ | 260 | /* TODO: undefs were uncommented - ??! we have config system for that! */ |
@@ -482,7 +527,7 @@ send_probe(int seq, int ttl) | |||
482 | if (!(option_mask32 & OPT_USE_ICMP)) { | 527 | if (!(option_mask32 & OPT_USE_ICMP)) { |
483 | out = outdata; | 528 | out = outdata; |
484 | len -= sizeof(*outudp); | 529 | len -= sizeof(*outudp); |
485 | set_nport(dest_lsa, htons(port + seq)); | 530 | set_nport(&dest_lsa->u.sa, htons(port + seq)); |
486 | } | 531 | } |
487 | } | 532 | } |
488 | 533 | ||
@@ -1018,10 +1063,10 @@ common_traceroute_main(int op, char **argv) | |||
1018 | int probe_fd = xsocket(af, SOCK_DGRAM, 0); | 1063 | int probe_fd = xsocket(af, SOCK_DGRAM, 0); |
1019 | if (op & OPT_DEVICE) | 1064 | if (op & OPT_DEVICE) |
1020 | setsockopt_bindtodevice(probe_fd, device); | 1065 | setsockopt_bindtodevice(probe_fd, device); |
1021 | set_nport(dest_lsa, htons(1025)); | 1066 | set_nport(&dest_lsa->u.sa, htons(1025)); |
1022 | /* dummy connect. makes kernel pick source IP (and port) */ | 1067 | /* dummy connect. makes kernel pick source IP (and port) */ |
1023 | xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len); | 1068 | xconnect(probe_fd, &dest_lsa->u.sa, dest_lsa->len); |
1024 | set_nport(dest_lsa, htons(port)); | 1069 | set_nport(&dest_lsa->u.sa, htons(port)); |
1025 | 1070 | ||
1026 | /* read IP and port */ | 1071 | /* read IP and port */ |
1027 | source_lsa = get_sock_lsa(probe_fd); | 1072 | source_lsa = get_sock_lsa(probe_fd); |
@@ -1031,7 +1076,7 @@ common_traceroute_main(int op, char **argv) | |||
1031 | close(probe_fd); | 1076 | close(probe_fd); |
1032 | 1077 | ||
1033 | /* bind our sockets to this IP (but not port) */ | 1078 | /* bind our sockets to this IP (but not port) */ |
1034 | set_nport(source_lsa, 0); | 1079 | set_nport(&source_lsa->u.sa, 0); |
1035 | xbind(sndsock, &source_lsa->u.sa, source_lsa->len); | 1080 | xbind(sndsock, &source_lsa->u.sa, source_lsa->len); |
1036 | xbind(rcvsock, &source_lsa->u.sa, source_lsa->len); | 1081 | xbind(rcvsock, &source_lsa->u.sa, source_lsa->len); |
1037 | 1082 | ||
diff --git a/networking/tunctl.c b/networking/tunctl.c index e17a9db64..8cb733b68 100644 --- a/networking/tunctl.c +++ b/networking/tunctl.c | |||
@@ -9,6 +9,25 @@ | |||
9 | * | 9 | * |
10 | * Licensed under GPLv2, see file LICENSE in this source tree. | 10 | * Licensed under GPLv2, see file LICENSE in this source tree. |
11 | */ | 11 | */ |
12 | |||
13 | //usage:#define tunctl_trivial_usage | ||
14 | //usage: "[-f device] ([-t name] | -d name)" IF_FEATURE_TUNCTL_UG(" [-u owner] [-g group] [-b]") | ||
15 | //usage:#define tunctl_full_usage "\n\n" | ||
16 | //usage: "Create or delete tun interfaces\n" | ||
17 | //usage: "\nOptions:" | ||
18 | //usage: "\n -f name tun device (/dev/net/tun)" | ||
19 | //usage: "\n -t name Create iface 'name'" | ||
20 | //usage: "\n -d name Delete iface 'name'" | ||
21 | //usage: IF_FEATURE_TUNCTL_UG( | ||
22 | //usage: "\n -u owner Set iface owner" | ||
23 | //usage: "\n -g group Set iface group" | ||
24 | //usage: "\n -b Brief output" | ||
25 | //usage: ) | ||
26 | //usage: | ||
27 | //usage:#define tunctl_example_usage | ||
28 | //usage: "# tunctl\n" | ||
29 | //usage: "# tunctl -d tun0\n" | ||
30 | |||
12 | #include <netinet/in.h> | 31 | #include <netinet/in.h> |
13 | #include <net/if.h> | 32 | #include <net/if.h> |
14 | #include <linux/if_tun.h> | 33 | #include <linux/if_tun.h> |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 6fb48a19a..747472d0c 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -20,6 +20,17 @@ | |||
20 | * along with this program; if not, write to the Free Software | 20 | * along with this program; if not, write to the Free Software |
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
22 | */ | 22 | */ |
23 | |||
24 | //usage:#define udhcpd_trivial_usage | ||
25 | //usage: "[-fS]" IF_FEATURE_UDHCP_PORT(" [-P N]") " [CONFFILE]" | ||
26 | //usage:#define udhcpd_full_usage "\n\n" | ||
27 | //usage: "DHCP server\n" | ||
28 | //usage: "\n -f Run in foreground" | ||
29 | //usage: "\n -S Log to syslog too" | ||
30 | //usage: IF_FEATURE_UDHCP_PORT( | ||
31 | //usage: "\n -P N Use port N (default 67)" | ||
32 | //usage: ) | ||
33 | |||
23 | #include <syslog.h> | 34 | #include <syslog.h> |
24 | #include "common.h" | 35 | #include "common.h" |
25 | #include "dhcpc.h" | 36 | #include "dhcpc.h" |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index 86ef04a62..f82ac05b4 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -9,6 +9,12 @@ | |||
9 | * Netbeat AG | 9 | * Netbeat AG |
10 | * Upstream has GPL v2 or later | 10 | * Upstream has GPL v2 or later |
11 | */ | 11 | */ |
12 | |||
13 | //usage:#define dhcprelay_trivial_usage | ||
14 | //usage: "CLIENT_IFACE[,CLIENT_IFACE2]... SERVER_IFACE [SERVER_IP]" | ||
15 | //usage:#define dhcprelay_full_usage "\n\n" | ||
16 | //usage: "Relay DHCP requests between clients and server" | ||
17 | |||
12 | #include "common.h" | 18 | #include "common.h" |
13 | 19 | ||
14 | #define SERVER_PORT 67 | 20 | #define SERVER_PORT 67 |
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index 21d62a2d2..ec07192c1 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c | |||
@@ -2,6 +2,23 @@ | |||
2 | /* | 2 | /* |
3 | * 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. |
4 | */ | 4 | */ |
5 | |||
6 | //usage:#define dumpleases_trivial_usage | ||
7 | //usage: "[-r|-a] [-f LEASEFILE]" | ||
8 | //usage:#define dumpleases_full_usage "\n\n" | ||
9 | //usage: "Display DHCP leases granted by udhcpd\n" | ||
10 | //usage: "\nOptions:" | ||
11 | //usage: IF_LONG_OPTS( | ||
12 | //usage: "\n -f,--file=FILE Lease file" | ||
13 | //usage: "\n -r,--remaining Show remaining time" | ||
14 | //usage: "\n -a,--absolute Show expiration time" | ||
15 | //usage: ) | ||
16 | //usage: IF_NOT_LONG_OPTS( | ||
17 | //usage: "\n -f FILE Lease file" | ||
18 | //usage: "\n -r Show remaining time" | ||
19 | //usage: "\n -a Show expiration time" | ||
20 | //usage: ) | ||
21 | |||
5 | #include "common.h" | 22 | #include "common.h" |
6 | #include "dhcpd.h" | 23 | #include "dhcpd.h" |
7 | #include "unicode.h" | 24 | #include "unicode.h" |
diff --git a/networking/vconfig.c b/networking/vconfig.c index 13c65ad78..4fa341ac3 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c | |||
@@ -9,6 +9,18 @@ | |||
9 | 9 | ||
10 | /* BB_AUDIT SUSv3 N/A */ | 10 | /* BB_AUDIT SUSv3 N/A */ |
11 | 11 | ||
12 | //usage:#define vconfig_trivial_usage | ||
13 | //usage: "COMMAND [OPTIONS]" | ||
14 | //usage:#define vconfig_full_usage "\n\n" | ||
15 | //usage: "Create and remove virtual ethernet devices\n" | ||
16 | //usage: "\nOptions:" | ||
17 | //usage: "\n add [interface-name] [vlan_id]" | ||
18 | //usage: "\n rem [vlan-name]" | ||
19 | //usage: "\n set_flag [interface-name] [flag-num] [0 | 1]" | ||
20 | //usage: "\n set_egress_map [vlan-name] [skb_priority] [vlan_qos]" | ||
21 | //usage: "\n set_ingress_map [vlan-name] [skb_priority] [vlan_qos]" | ||
22 | //usage: "\n set_name_type [name-type]" | ||
23 | |||
12 | #include "libbb.h" | 24 | #include "libbb.h" |
13 | #include <net/if.h> | 25 | #include <net/if.h> |
14 | 26 | ||
diff --git a/networking/wget.c b/networking/wget.c index 41ec7f6dc..5f6e8155f 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -344,44 +344,6 @@ static char *gethdr(FILE *fp) | |||
344 | return hdrval; | 344 | return hdrval; |
345 | } | 345 | } |
346 | 346 | ||
347 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | ||
348 | static char *URL_escape(const char *str) | ||
349 | { | ||
350 | /* URL encode, see RFC 2396 */ | ||
351 | char *dst; | ||
352 | char *res = dst = xmalloc(strlen(str) * 3 + 1); | ||
353 | unsigned char c; | ||
354 | |||
355 | while (1) { | ||
356 | c = *str++; | ||
357 | if (c == '\0' | ||
358 | /* || strchr("!&'()*-.=_~", c) - more code */ | ||
359 | || c == '!' | ||
360 | || c == '&' | ||
361 | || c == '\'' | ||
362 | || c == '(' | ||
363 | || c == ')' | ||
364 | || c == '*' | ||
365 | || c == '-' | ||
366 | || c == '.' | ||
367 | || c == '=' | ||
368 | || c == '_' | ||
369 | || c == '~' | ||
370 | || (c >= '0' && c <= '9') | ||
371 | || ((c|0x20) >= 'a' && (c|0x20) <= 'z') | ||
372 | ) { | ||
373 | *dst++ = c; | ||
374 | if (c == '\0') | ||
375 | return res; | ||
376 | } else { | ||
377 | *dst++ = '%'; | ||
378 | *dst++ = bb_hexdigits_upcase[c >> 4]; | ||
379 | *dst++ = bb_hexdigits_upcase[c & 0xf]; | ||
380 | } | ||
381 | } | ||
382 | } | ||
383 | #endif | ||
384 | |||
385 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) | 347 | static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_sockaddr *lsa) |
386 | { | 348 | { |
387 | FILE *sfp; | 349 | FILE *sfp; |
@@ -445,7 +407,7 @@ static FILE* prepare_ftp_session(FILE **dfpp, struct host_info *target, len_and_ | |||
445 | str = strrchr(G.wget_buf, ','); | 407 | str = strrchr(G.wget_buf, ','); |
446 | if (!str) goto pasv_error; | 408 | if (!str) goto pasv_error; |
447 | port += xatou_range(str+1, 0, 255) * 256; | 409 | port += xatou_range(str+1, 0, 255) * 256; |
448 | set_nport(lsa, htons(port)); | 410 | set_nport(&lsa->u.sa, htons(port)); |
449 | 411 | ||
450 | *dfpp = open_socket(lsa); | 412 | *dfpp = open_socket(lsa); |
451 | 413 | ||
@@ -699,6 +661,12 @@ static void download_one_url(const char *url) | |||
699 | 661 | ||
700 | #if ENABLE_FEATURE_WGET_AUTHENTICATION | 662 | #if ENABLE_FEATURE_WGET_AUTHENTICATION |
701 | if (target.user) { | 663 | if (target.user) { |
664 | //TODO: URL-decode "user:password" string before base64-encoding: | ||
665 | //wget http://test:my%20pass@example.com should send | ||
666 | // Authorization: Basic dGVzdDpteSBwYXNz | ||
667 | //which decodes to "test:my pass", instead of what we send now: | ||
668 | // Authorization: Basic dGVzdDpteSUyMHBhc3M= | ||
669 | //Can reuse decodeString() from httpd.c | ||
702 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, | 670 | fprintf(sfp, "Proxy-Authorization: Basic %s\r\n"+6, |
703 | base64enc(target.user)); | 671 | base64enc(target.user)); |
704 | } | 672 | } |
@@ -716,15 +684,13 @@ static void download_one_url(const char *url) | |||
716 | fputs(G.extra_headers, sfp); | 684 | fputs(G.extra_headers, sfp); |
717 | 685 | ||
718 | if (option_mask32 & WGET_OPT_POST_DATA) { | 686 | if (option_mask32 & WGET_OPT_POST_DATA) { |
719 | char *estr = URL_escape(G.post_data); | ||
720 | fprintf(sfp, | 687 | fprintf(sfp, |
721 | "Content-Type: application/x-www-form-urlencoded\r\n" | 688 | "Content-Type: application/x-www-form-urlencoded\r\n" |
722 | "Content-Length: %u\r\n" | 689 | "Content-Length: %u\r\n" |
723 | "\r\n" | 690 | "\r\n" |
724 | "%s", | 691 | "%s", |
725 | (int) strlen(estr), estr | 692 | (int) strlen(G.post_data), G.post_data |
726 | ); | 693 | ); |
727 | free(estr); | ||
728 | } else | 694 | } else |
729 | #endif | 695 | #endif |
730 | { | 696 | { |
diff --git a/networking/zcip.c b/networking/zcip.c index 6fa265ad4..7250fb2fd 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -23,6 +23,19 @@ | |||
23 | // - avoid silent script failures, especially under load... | 23 | // - avoid silent script failures, especially under load... |
24 | // - link status monitoring (restart on link-up; stop on link-down) | 24 | // - link status monitoring (restart on link-up; stop on link-down) |
25 | 25 | ||
26 | //usage:#define zcip_trivial_usage | ||
27 | //usage: "[OPTIONS] IFACE SCRIPT" | ||
28 | //usage:#define zcip_full_usage "\n\n" | ||
29 | //usage: "Manage a ZeroConf IPv4 link-local address\n" | ||
30 | //usage: "\nOptions:" | ||
31 | //usage: "\n -f Run in foreground" | ||
32 | //usage: "\n -q Quit after obtaining address" | ||
33 | //usage: "\n -r 169.254.x.x Request this address first" | ||
34 | //usage: "\n -v Verbose" | ||
35 | //usage: "\n" | ||
36 | //usage: "\nWith no -q, runs continuously monitoring for ARP conflicts," | ||
37 | //usage: "\nexits only on I/O errors (link down etc)" | ||
38 | |||
26 | #include <netinet/ether.h> | 39 | #include <netinet/ether.h> |
27 | #include <net/ethernet.h> | 40 | #include <net/ethernet.h> |
28 | #include <net/if.h> | 41 | #include <net/if.h> |