aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /networking
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'networking')
-rw-r--r--networking/Config.in10
-rw-r--r--networking/Makefile2
-rw-r--r--networking/Makefile.in2
-rw-r--r--networking/ftpgetput.c14
-rw-r--r--networking/httpd.c28
-rw-r--r--networking/ifconfig.c6
-rw-r--r--networking/ifupdown.c28
-rw-r--r--networking/libiproute/Makefile2
-rw-r--r--networking/libiproute/Makefile.in2
-rw-r--r--networking/libiproute/ip_parse_common_args.c2
-rw-r--r--networking/libiproute/ipaddress.c8
-rw-r--r--networking/libiproute/iplink.c30
-rw-r--r--networking/libiproute/iproute.c8
-rw-r--r--networking/libiproute/iptunnel.c6
-rw-r--r--networking/libiproute/libnetlink.c4
-rw-r--r--networking/libiproute/linux/pkt_sched.h20
-rw-r--r--networking/libiproute/ll_proto.c72
-rw-r--r--networking/libiproute/utils.h2
-rw-r--r--networking/nc.c6
-rw-r--r--networking/netstat.c16
-rw-r--r--networking/nslookup.c4
-rw-r--r--networking/ping.c10
-rw-r--r--networking/ping6.c14
-rw-r--r--networking/route.c8
-rw-r--r--networking/telnet.c54
-rw-r--r--networking/telnetd.c6
-rw-r--r--networking/tftp.c36
-rw-r--r--networking/traceroute.c2
-rw-r--r--networking/udhcp/AUTHORS1
-rw-r--r--networking/udhcp/ChangeLog2
-rw-r--r--networking/udhcp/Makefile2
-rw-r--r--networking/udhcp/Makefile.in2
-rw-r--r--networking/udhcp/README16
-rw-r--r--networking/udhcp/README.udhcpc10
-rw-r--r--networking/udhcp/README.udhcpd8
-rw-r--r--networking/udhcp/arpping.c16
-rw-r--r--networking/udhcp/arpping.h2
-rw-r--r--networking/udhcp/clientpacket.c32
-rw-r--r--networking/udhcp/common.c2
-rw-r--r--networking/udhcp/common.h2
-rw-r--r--networking/udhcp/dhcpc.c48
-rw-r--r--networking/udhcp/dhcpd.c34
-rw-r--r--networking/udhcp/dhcpd.h4
-rw-r--r--networking/udhcp/dumpleases.c10
-rw-r--r--networking/udhcp/files.c44
-rw-r--r--networking/udhcp/frontend.c4
-rw-r--r--networking/udhcp/leases.c30
-rw-r--r--networking/udhcp/options.c30
-rw-r--r--networking/udhcp/packet.c18
-rw-r--r--networking/udhcp/packet.h2
-rw-r--r--networking/udhcp/script.c10
-rw-r--r--networking/udhcp/serverpacket.c48
-rw-r--r--networking/udhcp/socket.c8
-rw-r--r--networking/vconfig.c4
-rw-r--r--networking/wget.c50
55 files changed, 420 insertions, 421 deletions
diff --git a/networking/Config.in b/networking/Config.in
index d2916e7cd..a7cef41bf 100644
--- a/networking/Config.in
+++ b/networking/Config.in
@@ -63,7 +63,7 @@ config CONFIG_FEATURE_HTTPD_AUTH_MD5
63 default n 63 default n
64 depends on CONFIG_FEATURE_HTTPD_BASIC_AUTH 64 depends on CONFIG_FEATURE_HTTPD_BASIC_AUTH
65 help 65 help
66 Enables basic per url authentication from /etc/httpd.conf 66 Enables basic per url authentication from /etc/httpd.conf
67 using md5 passwords. 67 using md5 passwords.
68 68
69 69
@@ -187,7 +187,7 @@ config CONFIG_IFUPDOWN
187config CONFIG_FEATURE_IFUPDOWN_IP 187config CONFIG_FEATURE_IFUPDOWN_IP
188 bool " Use ip applet" 188 bool " Use ip applet"
189 default n 189 default n
190 depends on CONFIG_IFUPDOWN 190 depends on CONFIG_IFUPDOWN
191 help 191 help
192 Use the iproute "ip" command to implement "ifup" and "ifdown", rather 192 Use the iproute "ip" command to implement "ifup" and "ifdown", rather
193 than the default of using the older 'ifconfig' and 'route' utilities. 193 than the default of using the older 'ifconfig' and 'route' utilities.
@@ -213,11 +213,11 @@ config CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN
213 select CONFIG_IFCONFIG 213 select CONFIG_IFCONFIG
214 select CONFIG_ROUTE 214 select CONFIG_ROUTE
215 help 215 help
216 Use the busybox iproute "ifconfig" and "route" applets to 216 Use the busybox iproute "ifconfig" and "route" applets to
217 implement the "ifup" and "ifdown" utilities. 217 implement the "ifup" and "ifdown" utilities.
218 218
219 If leave this disabled, you must install the full-blown ifconfig 219 If leave this disabled, you must install the full-blown ifconfig
220 and route utilities, or the "ifup" and "ifdown" applets will not 220 and route utilities, or the "ifup" and "ifdown" applets will not
221 work. 221 work.
222 222
223config CONFIG_FEATURE_IFUPDOWN_IPV4 223config CONFIG_FEATURE_IFUPDOWN_IPV4
@@ -339,7 +339,7 @@ if !(CONFIG_IP && CONFIG_IPROUTE)
339 default y 339 default y
340 depends on CONFIG_IP 340 depends on CONFIG_IP
341 help 341 help
342 Add support for routing table management to "ip". 342 Add support for routing table management to "ip".
343endif 343endif
344 344
345if CONFIG_IP && CONFIG_IPTUNNEL 345if CONFIG_IP && CONFIG_IPTUNNEL
diff --git a/networking/Makefile b/networking/Makefile
index 022f29e46..456c433fd 100644
--- a/networking/Makefile
+++ b/networking/Makefile
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/Makefile.in b/networking/Makefile.in
index 7748d066b..31de77fea 100644
--- a/networking/Makefile.in
+++ b/networking/Makefile.in
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index 17ee8a536..814253b53 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -1,7 +1,7 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * ftpget 3 * ftpget
4 * 4 *
5 * Mini implementation of FTP to retrieve a remote file. 5 * Mini implementation of FTP to retrieve a remote file.
6 * 6 *
7 * Copyright (C) 2002 Jeff Angielski, The PTR Group <jeff@theptrgroup.com> 7 * Copyright (C) 2002 Jeff Angielski, The PTR Group <jeff@theptrgroup.com>
@@ -131,7 +131,7 @@ static FILE *ftp_login(ftp_host_info_t *server)
131} 131}
132 132
133#ifdef CONFIG_FTPGET 133#ifdef CONFIG_FTPGET
134static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, 134static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream,
135 const char *local_path, char *server_path) 135 const char *local_path, char *server_path)
136{ 136{
137 char buf[512]; 137 char buf[512];
@@ -203,13 +203,13 @@ static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream,
203 bb_error_msg_and_die("ftp error: %s", buf + 4); 203 bb_error_msg_and_die("ftp error: %s", buf + 4);
204 } 204 }
205 ftpcmd("QUIT", NULL, control_stream, buf); 205 ftpcmd("QUIT", NULL, control_stream, buf);
206 206
207 return(EXIT_SUCCESS); 207 return(EXIT_SUCCESS);
208} 208}
209#endif 209#endif
210 210
211#ifdef CONFIG_FTPPUT 211#ifdef CONFIG_FTPPUT
212static int ftp_send(ftp_host_info_t *server, FILE *control_stream, 212static int ftp_send(ftp_host_info_t *server, FILE *control_stream,
213 const char *server_path, char *local_path) 213 const char *server_path, char *local_path)
214{ 214{
215 struct stat sbuf; 215 struct stat sbuf;
@@ -329,8 +329,8 @@ int ftpgetput_main(int argc, char **argv)
329 server->password = "busybox@"; 329 server->password = "busybox@";
330 verbose_flag = 0; 330 verbose_flag = 0;
331 331
332 /* 332 /*
333 * Decipher the command line 333 * Decipher the command line
334 */ 334 */
335 bb_applet_long_options = ftpgetput_long_options; 335 bb_applet_long_options = ftpgetput_long_options;
336 opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port); 336 opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port);
diff --git a/networking/httpd.c b/networking/httpd.c
index f2fd2b38d..aad30a1a1 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -44,7 +44,7 @@
44 * for page display. 44 * for page display.
45 * 45 *
46 * httpd.conf has the following format: 46 * httpd.conf has the following format:
47 * 47 *
48 * A:172.20. # Allow address from 172.20.0.0/16 48 * A:172.20. # Allow address from 172.20.0.0/16
49 * A:10.0.0.0/25 # Allow any address from 10.0.0.0-10.0.0.127 49 * A:10.0.0.0/25 # Allow any address from 10.0.0.0-10.0.0.127
50 * A:10.0.0.0/255.255.255.128 # Allow any address that previous set 50 * A:10.0.0.0/255.255.255.128 # Allow any address that previous set
@@ -54,13 +54,13 @@
54 * /adm:admin:setup # Require user admin, pwd setup on urls starting with /adm/ 54 * /adm:admin:setup # Require user admin, pwd setup on urls starting with /adm/
55 * /adm:toor:PaSsWd # or user toor, pwd PaSsWd on urls starting with /adm/ 55 * /adm:toor:PaSsWd # or user toor, pwd PaSsWd on urls starting with /adm/
56 * .au:audio/basic # additional mime type for audio.au files 56 * .au:audio/basic # additional mime type for audio.au files
57 * 57 *
58 * A/D may be as a/d or allow/deny - first char case unsensitive 58 * A/D may be as a/d or allow/deny - first char case unsensitive
59 * Deny IP rules take precedence over allow rules. 59 * Deny IP rules take precedence over allow rules.
60 * 60 *
61 * 61 *
62 * The Deny/Allow IP logic: 62 * The Deny/Allow IP logic:
63 * 63 *
64 * - Default is to allow all. No addresses are denied unless 64 * - Default is to allow all. No addresses are denied unless
65 * denied with a D: rule. 65 * denied with a D: rule.
66 * - Order of Deny/Allow rules is significant 66 * - Order of Deny/Allow rules is significant
@@ -68,19 +68,19 @@
68 * - If a deny all rule (D:*) is used it acts as a catch-all for unmatched 68 * - If a deny all rule (D:*) is used it acts as a catch-all for unmatched
69 * addresses. 69 * addresses.
70 * - Specification of Allow all (A:*) is a no-op 70 * - Specification of Allow all (A:*) is a no-op
71 * 71 *
72 * Example: 72 * Example:
73 * 1. Allow only specified addresses 73 * 1. Allow only specified addresses
74 * A:172.20 # Allow any address that begins with 172.20. 74 * A:172.20 # Allow any address that begins with 172.20.
75 * A:10.10. # Allow any address that begins with 10.10. 75 * A:10.10. # Allow any address that begins with 10.10.
76 * A:127.0.0.1 # Allow local loopback connections 76 * A:127.0.0.1 # Allow local loopback connections
77 * D:* # Deny from other IP connections 77 * D:* # Deny from other IP connections
78 * 78 *
79 * 2. Only deny specified addresses 79 * 2. Only deny specified addresses
80 * D:1.2.3. # deny from 1.2.3.0 - 1.2.3.255 80 * D:1.2.3. # deny from 1.2.3.0 - 1.2.3.255
81 * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255 81 * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255
82 * A:* # (optional line added for clarity) 82 * A:* # (optional line added for clarity)
83 * 83 *
84 * If a sub directory contains a config file it is parsed and merged with 84 * If a sub directory contains a config file it is parsed and merged with
85 * any existing settings as if it was appended to the original configuration. 85 * any existing settings as if it was appended to the original configuration.
86 * 86 *
@@ -91,11 +91,11 @@
91 * subdir http request, any merge is discarded when the process exits. As a 91 * subdir http request, any merge is discarded when the process exits. As a
92 * result, the subdir settings only have a lifetime of a single request. 92 * result, the subdir settings only have a lifetime of a single request.
93 * 93 *
94 * 94 *
95 * If -c is not set, an attempt will be made to open the default 95 * If -c is not set, an attempt will be made to open the default
96 * root configuration file. If -c is set and the file is not found, the 96 * root configuration file. If -c is set and the file is not found, the
97 * server exits with an error. 97 * server exits with an error.
98 * 98 *
99*/ 99*/
100 100
101 101
@@ -447,7 +447,7 @@ static void free_config_lines(Htaccess **pprev)
447 > $Function: parse_conf() 447 > $Function: parse_conf()
448 * 448 *
449 * $Description: parse configuration file into in-memory linked list. 449 * $Description: parse configuration file into in-memory linked list.
450 * 450 *
451 * The first non-white character is examined to determine if the config line 451 * The first non-white character is examined to determine if the config line
452 * is one of the following: 452 * is one of the following:
453 * .ext:mime/type # new mime type not compiled into httpd 453 * .ext:mime/type # new mime type not compiled into httpd
@@ -464,7 +464,7 @@ static void free_config_lines(Htaccess **pprev)
464 * checks. 464 * checks.
465 * (int) flag . . . . . . the source of the parse request. 465 * (int) flag . . . . . . the source of the parse request.
466 * 466 *
467 * $Return: (None) 467 * $Return: (None)
468 * 468 *
469 ****************************************************************************/ 469 ****************************************************************************/
470static void parse_conf(const char *path, int flag) 470static void parse_conf(const char *path, int flag)
@@ -1726,7 +1726,7 @@ FORBIDDEN: /* protect listing /cgi-bin */
1726 /* Properly wait for remote to closed */ 1726 /* Properly wait for remote to closed */
1727 FD_ZERO (&s_fd) ; 1727 FD_ZERO (&s_fd) ;
1728 FD_SET (a_c_w, &s_fd) ; 1728 FD_SET (a_c_w, &s_fd) ;
1729 1729
1730 do { 1730 do {
1731 tv.tv_sec = 2 ; 1731 tv.tv_sec = 2 ;
1732 tv.tv_usec = 0 ; 1732 tv.tv_usec = 0 ;
diff --git a/networking/ifconfig.c b/networking/ifconfig.c
index 341998d8d..b884ef7c3 100644
--- a/networking/ifconfig.c
+++ b/networking/ifconfig.c
@@ -6,7 +6,7 @@
6 * Bjorn Wesen, Axis Communications AB 6 * Bjorn Wesen, Axis Communications AB
7 * 7 *
8 * 8 *
9 * Authors of the original ifconfig was: 9 * Authors of the original ifconfig was:
10 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> 10 * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
11 * 11 *
12 * This program is free software; you can redistribute it 12 * This program is free software; you can redistribute it
@@ -15,7 +15,7 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: ifconfig.c,v 1.28 2004/03/06 22:11:44 andersen Exp $ 18 * $Id: ifconfig.c,v 1.29 2004/03/15 08:28:48 andersen Exp $
19 * 19 *
20 */ 20 */
21 21
@@ -510,7 +510,7 @@ int ifconfig_main(int argc, char **argv)
510 * a - at the end, since it's deleted already! - Roman 510 * a - at the end, since it's deleted already! - Roman
511 * 511 *
512 * Should really use regex.h here, not sure though how well 512 * Should really use regex.h here, not sure though how well
513 * it'll go with the cross-platform support etc. 513 * it'll go with the cross-platform support etc.
514 */ 514 */
515 char *ptr; 515 char *ptr;
516 short int found_colon = 0; 516 short int found_colon = 0;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index bd0021ab4..c34e2b955 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -2,7 +2,7 @@
2/* 2/*
3 * ifupdown for busybox 3 * ifupdown for busybox
4 * Copyright (c) 2002 Glenn McGrath <bug1@optushome.com.au> 4 * Copyright (c) 2002 Glenn McGrath <bug1@optushome.com.au>
5 * Copyright (c) 2003 Erik Andersen <andersen@codepoet.org> 5 * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org>
6 * 6 *
7 * Based on ifupdown v 0.6.4 by Anthony Towns 7 * Based on ifupdown v 0.6.4 by Anthony Towns
8 * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> 8 * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au>
@@ -56,7 +56,7 @@
56#if 0 56#if 0
57#define debug_noise(fmt, args...) printf(fmt, ## args) 57#define debug_noise(fmt, args...) printf(fmt, ## args)
58#else 58#else
59#define debug_noise(fmt, args...) 59#define debug_noise(fmt, args...)
60#endif 60#endif
61 61
62/* Forward declaration */ 62/* Forward declaration */
@@ -72,7 +72,7 @@ extern llist_t *llist_add_to_end(llist_t *list_head, char *data)
72 new_item = xmalloc(sizeof(llist_t)); 72 new_item = xmalloc(sizeof(llist_t));
73 new_item->data = data; 73 new_item->data = data;
74 new_item->link = NULL; 74 new_item->link = NULL;
75 75
76 prev = NULL; 76 prev = NULL;
77 tmp = list_head; 77 tmp = list_head;
78 while(tmp) { 78 while(tmp) {
@@ -80,7 +80,7 @@ extern llist_t *llist_add_to_end(llist_t *list_head, char *data)
80 tmp = tmp->link; 80 tmp = tmp->link;
81 } 81 }
82 if (prev) { 82 if (prev) {
83 prev->link = new_item; 83 prev->link = new_item;
84 } else { 84 } else {
85 list_head = new_item; 85 list_head = new_item;
86 } 86 }
@@ -123,7 +123,7 @@ struct variable_t
123 char *value; 123 char *value;
124}; 124};
125 125
126struct interface_defn_t 126struct interface_defn_t
127{ 127{
128 struct interface_defn_t *prev; 128 struct interface_defn_t *prev;
129 struct interface_defn_t *next; 129 struct interface_defn_t *next;
@@ -598,7 +598,7 @@ static int wvdial_down(struct interface_defn_t *ifd, execfn *exec)
598 "-p /var/run/wvdial.%iface% -s 2", ifd, exec)); 598 "-p /var/run/wvdial.%iface% -s 2", ifd, exec));
599} 599}
600 600
601static struct method_t methods[] = 601static struct method_t methods[] =
602{ 602{
603 { "wvdial", wvdial_up, wvdial_down, }, 603 { "wvdial", wvdial_up, wvdial_down, },
604 { "ppp", ppp_up, ppp_down, }, 604 { "ppp", ppp_up, ppp_down, },
@@ -608,7 +608,7 @@ static struct method_t methods[] =
608 { "loopback", loopback_up, loopback_down, }, 608 { "loopback", loopback_up, loopback_down, },
609}; 609};
610 610
611struct address_family_t addr_inet = 611struct address_family_t addr_inet =
612{ 612{
613 "inet", 613 "inet",
614 sizeof(methods) / sizeof(struct method_t), 614 sizeof(methods) / sizeof(struct method_t),
@@ -885,7 +885,7 @@ static struct interfaces_file_t *read_interfaces(char *filename)
885 perror(filename); 885 perror(filename);
886 return NULL; 886 return NULL;
887 } 887 }
888 debug_noise("\t%s=%s\n", currif->option[currif->n_options].name, 888 debug_noise("\t%s=%s\n", currif->option[currif->n_options].name,
889 currif->option[currif->n_options].value); 889 currif->option[currif->n_options].value);
890 currif->n_options++; 890 currif->n_options++;
891 break; 891 break;
@@ -1031,7 +1031,7 @@ static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *o
1031 } 1031 }
1032 } 1032 }
1033 } 1033 }
1034 1034
1035 bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt); 1035 bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt);
1036 (*exec)(buf); 1036 (*exec)(buf);
1037 1037
@@ -1211,7 +1211,7 @@ extern int ifupdown_main(int argc, char **argv)
1211#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING 1211#ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING
1212 while ((i = getopt(argc, argv, "i:hvnamf")) != -1) 1212 while ((i = getopt(argc, argv, "i:hvnamf")) != -1)
1213#else 1213#else
1214 while ((i = getopt(argc, argv, "i:hvnaf")) != -1) 1214 while ((i = getopt(argc, argv, "i:hvnaf")) != -1)
1215#endif 1215#endif
1216 { 1216 {
1217 switch (i) { 1217 switch (i) {
@@ -1249,7 +1249,7 @@ extern int ifupdown_main(int argc, char **argv)
1249 if (!do_all) { 1249 if (!do_all) {
1250 bb_show_usage(); 1250 bb_show_usage();
1251 } 1251 }
1252 } 1252 }
1253 1253
1254 debug_noise("reading %s file:\n", interfaces); 1254 debug_noise("reading %s file:\n", interfaces);
1255 defn = read_interfaces(interfaces); 1255 defn = read_interfaces(interfaces);
@@ -1297,8 +1297,8 @@ extern int ifupdown_main(int argc, char **argv)
1297 list = list->link; 1297 list = list->link;
1298 } 1298 }
1299 target_list = defn->autointerfaces; 1299 target_list = defn->autointerfaces;
1300#endif 1300#endif
1301 } 1301 }
1302 } else { 1302 } else {
1303 target_list = llist_add_to_end(target_list, argv[optind]); 1303 target_list = llist_add_to_end(target_list, argv[optind]);
1304 } 1304 }
@@ -1413,7 +1413,7 @@ extern int ifupdown_main(int argc, char **argv)
1413 } else { 1413 } else {
1414 iface_state->data = NULL; 1414 iface_state->data = NULL;
1415 iface_state->link = NULL; 1415 iface_state->link = NULL;
1416 } 1416 }
1417 } 1417 }
1418 } 1418 }
1419 } 1419 }
diff --git a/networking/libiproute/Makefile b/networking/libiproute/Makefile
index c1f18be7b..0dc7191d3 100644
--- a/networking/libiproute/Makefile
+++ b/networking/libiproute/Makefile
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/libiproute/Makefile.in b/networking/libiproute/Makefile.in
index f39eeb3ee..d6f95048c 100644
--- a/networking/libiproute/Makefile.in
+++ b/networking/libiproute/Makefile.in
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c
index 1f3d73933..a76df48e0 100644
--- a/networking/libiproute/ip_parse_common_args.c
+++ b/networking/libiproute/ip_parse_common_args.c
@@ -47,7 +47,7 @@ void ip_parse_common_args(int *argcp, char ***argvp)
47 if (matches(opt, "-family") == 0) { 47 if (matches(opt, "-family") == 0) {
48 argc--; 48 argc--;
49 argv++; 49 argv++;
50 if (! argv[1]) 50 if (! argv[1])
51 bb_show_usage(); 51 bb_show_usage();
52 if (strcmp(argv[1], "inet") == 0) 52 if (strcmp(argv[1], "inet") == 0)
53 preferred_family = AF_INET; 53 preferred_family = AF_INET;
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 44e871ee5..7e0c75785 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -91,7 +91,7 @@ static void print_queuelen(char *name)
91 91
92 memset(&ifr, 0, sizeof(ifr)); 92 memset(&ifr, 0, sizeof(ifr));
93 strcpy(ifr.ifr_name, name); 93 strcpy(ifr.ifr_name, name);
94 if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) { 94 if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) {
95 perror("SIOCGIFXQLEN"); 95 perror("SIOCGIFXQLEN");
96 close(s); 96 close(s);
97 return; 97 return;
@@ -166,7 +166,7 @@ static int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg
166#endif 166#endif
167 if (filter.showqueue) 167 if (filter.showqueue)
168 print_queuelen((char*)RTA_DATA(tb[IFLA_IFNAME])); 168 print_queuelen((char*)RTA_DATA(tb[IFLA_IFNAME]));
169 169
170 if (!filter.family || filter.family == AF_PACKET) { 170 if (!filter.family || filter.family == AF_PACKET) {
171 SPRINT_BUF(b1); 171 SPRINT_BUF(b1);
172 fprintf(fp, "%s", _SL_); 172 fprintf(fp, "%s", _SL_);
@@ -378,7 +378,7 @@ static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE *
378 if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifa))) 378 if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifa)))
379 return -1; 379 return -1;
380 380
381 if (ifa->ifa_index != ifindex || 381 if (ifa->ifa_index != ifindex ||
382 (filter.family && filter.family != ifa->ifa_family)) 382 (filter.family && filter.family != ifa->ifa_family))
383 continue; 383 continue;
384 384
@@ -564,7 +564,7 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush)
564 struct nlmsghdr *n = &a->h; 564 struct nlmsghdr *n = &a->h;
565 struct ifaddrmsg *ifa = NLMSG_DATA(n); 565 struct ifaddrmsg *ifa = NLMSG_DATA(n);
566 566
567 if (ifa->ifa_index != ifi->ifi_index || 567 if (ifa->ifa_index != ifi->ifi_index ||
568 (filter.family && filter.family != ifa->ifa_family)) 568 (filter.family && filter.family != ifa->ifa_family))
569 continue; 569 continue;
570 if ((filter.scope^ifa->ifa_scope)&filter.scopemask) 570 if ((filter.scope^ifa->ifa_scope)&filter.scopemask)
diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c
index daab6938d..44b546d59 100644
--- a/networking/libiproute/iplink.c
+++ b/networking/libiproute/iplink.c
@@ -128,8 +128,8 @@ static int set_qlen(char *dev, int qlen)
128 return -1; 128 return -1;
129 129
130 memset(&ifr, 0, sizeof(ifr)); 130 memset(&ifr, 0, sizeof(ifr));
131 strcpy(ifr.ifr_name, dev); 131 strcpy(ifr.ifr_name, dev);
132 ifr.ifr_qlen = qlen; 132 ifr.ifr_qlen = qlen;
133 if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) { 133 if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) {
134 perror("SIOCSIFXQLEN"); 134 perror("SIOCSIFXQLEN");
135 close(s); 135 close(s);
@@ -137,7 +137,7 @@ static int set_qlen(char *dev, int qlen)
137 } 137 }
138 close(s); 138 close(s);
139 139
140 return 0; 140 return 0;
141} 141}
142 142
143static int set_mtu(char *dev, int mtu) 143static int set_mtu(char *dev, int mtu)
@@ -150,8 +150,8 @@ static int set_mtu(char *dev, int mtu)
150 return -1; 150 return -1;
151 151
152 memset(&ifr, 0, sizeof(ifr)); 152 memset(&ifr, 0, sizeof(ifr));
153 strcpy(ifr.ifr_name, dev); 153 strcpy(ifr.ifr_name, dev);
154 ifr.ifr_mtu = mtu; 154 ifr.ifr_mtu = mtu;
155 if (ioctl(s, SIOCSIFMTU, &ifr) < 0) { 155 if (ioctl(s, SIOCSIFMTU, &ifr) < 0) {
156 perror("SIOCSIFMTU"); 156 perror("SIOCSIFMTU");
157 close(s); 157 close(s);
@@ -159,7 +159,7 @@ static int set_mtu(char *dev, int mtu)
159 } 159 }
160 close(s); 160 close(s);
161 161
162 return 0; 162 return 0;
163} 163}
164 164
165static int get_address(char *dev, int *htype) 165static int get_address(char *dev, int *htype)
@@ -170,7 +170,7 @@ static int get_address(char *dev, int *htype)
170 int s; 170 int s;
171 171
172 s = socket(PF_PACKET, SOCK_DGRAM, 0); 172 s = socket(PF_PACKET, SOCK_DGRAM, 0);
173 if (s < 0) { 173 if (s < 0) {
174 perror("socket(PF_PACKET)"); 174 perror("socket(PF_PACKET)");
175 return -1; 175 return -1;
176 } 176 }
@@ -218,7 +218,7 @@ static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr
218 bb_error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); 218 bb_error_msg("Wrong address (%s) length: expected %d bytes", lla, halen);
219 return -1; 219 return -1;
220 } 220 }
221 return 0; 221 return 0;
222} 222}
223 223
224static int set_address(struct ifreq *ifr, int brd) 224static int set_address(struct ifreq *ifr, int brd)
@@ -234,7 +234,7 @@ static int set_address(struct ifreq *ifr, int brd)
234 return -1; 234 return -1;
235 } 235 }
236 close(s); 236 close(s);
237 return 0; 237 return 0;
238} 238}
239 239
240 240
@@ -311,7 +311,7 @@ static int do_set(int argc, char **argv)
311 } 311 }
312 if (newbrd) { 312 if (newbrd) {
313 if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0) 313 if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0)
314 return -1; 314 return -1;
315 } 315 }
316 } 316 }
317 317
@@ -320,18 +320,18 @@ static int do_set(int argc, char **argv)
320 return -1; 320 return -1;
321 dev = newname; 321 dev = newname;
322 } 322 }
323 if (qlen != -1) { 323 if (qlen != -1) {
324 if (set_qlen(dev, qlen) < 0) 324 if (set_qlen(dev, qlen) < 0)
325 return -1; 325 return -1;
326 } 326 }
327 if (mtu != -1) { 327 if (mtu != -1) {
328 if (set_mtu(dev, mtu) < 0) 328 if (set_mtu(dev, mtu) < 0)
329 return -1; 329 return -1;
330 } 330 }
331 if (newaddr || newbrd) { 331 if (newaddr || newbrd) {
332 if (newbrd) { 332 if (newbrd) {
333 if (set_address(&ifr1, 1) < 0) 333 if (set_address(&ifr1, 1) < 0)
334 return -1; 334 return -1;
335 } 335 }
336 if (newaddr) { 336 if (newaddr) {
337 if (set_address(&ifr0, 0) < 0) 337 if (set_address(&ifr0, 0) < 0)
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 0fdf7987e..7adbfcd61 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -76,7 +76,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
76 inet_prefix src; 76 inet_prefix src;
77 int host_len = -1; 77 int host_len = -1;
78 SPRINT_BUF(b1); 78 SPRINT_BUF(b1);
79 79
80 80
81 if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) { 81 if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) {
82 fprintf(stderr, "Not a route: %08x %08x %08x\n", 82 fprintf(stderr, "Not a route: %08x %08x %08x\n",
@@ -228,7 +228,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
228 fprintf(fp, "from 0/%u ", r->rtm_src_len); 228 fprintf(fp, "from 0/%u ", r->rtm_src_len);
229 } 229 }
230 if (tb[RTA_GATEWAY] && filter.rvia.bitlen != host_len) { 230 if (tb[RTA_GATEWAY] && filter.rvia.bitlen != host_len) {
231 fprintf(fp, "via %s ", 231 fprintf(fp, "via %s ",
232 format_host(r->rtm_family, 232 format_host(r->rtm_family,
233 RTA_PAYLOAD(tb[RTA_GATEWAY]), 233 RTA_PAYLOAD(tb[RTA_GATEWAY]),
234 RTA_DATA(tb[RTA_GATEWAY]), 234 RTA_DATA(tb[RTA_GATEWAY]),
@@ -242,7 +242,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
242 /* Do not use format_host(). It is our local addr 242 /* Do not use format_host(). It is our local addr
243 and symbolic name will not be useful. 243 and symbolic name will not be useful.
244 */ 244 */
245 fprintf(fp, " src %s ", 245 fprintf(fp, " src %s ",
246 rt_addr_n2a(r->rtm_family, 246 rt_addr_n2a(r->rtm_family,
247 RTA_PAYLOAD(tb[RTA_PREFSRC]), 247 RTA_PAYLOAD(tb[RTA_PREFSRC]),
248 RTA_DATA(tb[RTA_PREFSRC]), 248 RTA_DATA(tb[RTA_PREFSRC]),
@@ -665,7 +665,7 @@ static int iproute_get(int argc, char **argv)
665 req.r.rtm_src_len = 0; 665 req.r.rtm_src_len = 0;
666 req.r.rtm_dst_len = 0; 666 req.r.rtm_dst_len = 0;
667 req.r.rtm_tos = 0; 667 req.r.rtm_tos = 0;
668 668
669 while (argc > 0) { 669 while (argc > 0) {
670 switch (compare_string_array(options, *argv)) { 670 switch (compare_string_array(options, *argv)) {
671 case 0: /* from */ 671 case 0: /* from */
diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c
index eae5bb091..3f5d05ae9 100644
--- a/networking/libiproute/iptunnel.c
+++ b/networking/libiproute/iptunnel.c
@@ -354,7 +354,7 @@ static int do_add(int cmd, int argc, char **argv)
354 return do_add_ioctl(cmd, "gre0", &p); 354 return do_add_ioctl(cmd, "gre0", &p);
355 case IPPROTO_IPV6: 355 case IPPROTO_IPV6:
356 return do_add_ioctl(cmd, "sit0", &p); 356 return do_add_ioctl(cmd, "sit0", &p);
357 default: 357 default:
358 bb_error_msg("cannot determine tunnel mode (ipip, gre or sit)"); 358 bb_error_msg("cannot determine tunnel mode (ipip, gre or sit)");
359 return -1; 359 return -1;
360 } 360 }
@@ -375,7 +375,7 @@ int do_del(int argc, char **argv)
375 return do_del_ioctl("gre0", &p); 375 return do_del_ioctl("gre0", &p);
376 case IPPROTO_IPV6: 376 case IPPROTO_IPV6:
377 return do_del_ioctl("sit0", &p); 377 return do_del_ioctl("sit0", &p);
378 default: 378 default:
379 return do_del_ioctl(p.name, &p); 379 return do_del_ioctl(p.name, &p);
380 } 380 }
381 return -1; 381 return -1;
@@ -506,7 +506,7 @@ static int do_show(int argc, char **argv)
506 return -1; 506 return -1;
507 507
508 switch (p.iph.protocol) { 508 switch (p.iph.protocol) {
509 case IPPROTO_IPIP: 509 case IPPROTO_IPIP:
510 err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p); 510 err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p);
511 break; 511 break;
512 case IPPROTO_GRE: 512 case IPPROTO_GRE:
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c
index 9390e56fb..861daef86 100644
--- a/networking/libiproute/libnetlink.c
+++ b/networking/libiproute/libnetlink.c
@@ -317,7 +317,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
317 } 317 }
318} 318}
319 319
320int rtnl_listen(struct rtnl_handle *rtnl, 320int rtnl_listen(struct rtnl_handle *rtnl,
321 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), 321 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
322 void *jarg) 322 void *jarg)
323{ 323{
@@ -389,7 +389,7 @@ int rtnl_listen(struct rtnl_handle *rtnl,
389 } 389 }
390} 390}
391 391
392int rtnl_from_file(FILE *rtnl, 392int rtnl_from_file(FILE *rtnl,
393 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), 393 int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
394 void *jarg) 394 void *jarg)
395{ 395{
diff --git a/networking/libiproute/linux/pkt_sched.h b/networking/libiproute/linux/pkt_sched.h
index e174588f5..70cbabc26 100644
--- a/networking/libiproute/linux/pkt_sched.h
+++ b/networking/libiproute/linux/pkt_sched.h
@@ -221,19 +221,19 @@ enum
221#define TCA_SET_OFF TCA_GRED_PARMS 221#define TCA_SET_OFF TCA_GRED_PARMS
222struct tc_gred_qopt 222struct tc_gred_qopt
223{ 223{
224 __u32 limit; /* HARD maximal queue length (bytes) 224 __u32 limit; /* HARD maximal queue length (bytes)
225*/ 225*/
226 __u32 qth_min; /* Min average length threshold (bytes) 226 __u32 qth_min; /* Min average length threshold (bytes)
227*/ 227*/
228 __u32 qth_max; /* Max average length threshold (bytes) 228 __u32 qth_max; /* Max average length threshold (bytes)
229*/ 229*/
230 __u32 DP; /* upto 2^32 DPs */ 230 __u32 DP; /* upto 2^32 DPs */
231 __u32 backlog; 231 __u32 backlog;
232 __u32 qave; 232 __u32 qave;
233 __u32 forced; 233 __u32 forced;
234 __u32 early; 234 __u32 early;
235 __u32 other; 235 __u32 other;
236 __u32 pdrop; 236 __u32 pdrop;
237 237
238 unsigned char Wlog; /* log(W) */ 238 unsigned char Wlog; /* log(W) */
239 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ 239 unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
@@ -294,7 +294,7 @@ struct tc_htb_xstats
294 __u32 lends; 294 __u32 lends;
295 __u32 borrows; 295 __u32 borrows;
296 __u32 giants; /* too big packets (rate will not be accurate) */ 296 __u32 giants; /* too big packets (rate will not be accurate) */
297 __u32 injects; /* how many times leaf used injected bw */ 297 __u32 injects; /* how many times leaf used injected bw */
298 __u32 tokens; 298 __u32 tokens;
299 __u32 ctokens; 299 __u32 ctokens;
300}; 300};
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c
index 45afdb82a..9b5260b32 100644
--- a/networking/libiproute/ll_proto.c
+++ b/networking/libiproute/ll_proto.c
@@ -26,62 +26,62 @@ static struct {
26 char *name; 26 char *name;
27} llproto_names[] = { 27} llproto_names[] = {
28__PF(LOOP,loop) 28__PF(LOOP,loop)
29__PF(PUP,pup) 29__PF(PUP,pup)
30#ifdef ETH_P_PUPAT 30#ifdef ETH_P_PUPAT
31__PF(PUPAT,pupat) 31__PF(PUPAT,pupat)
32#endif 32#endif
33__PF(IP,ip) 33__PF(IP,ip)
34__PF(X25,x25) 34__PF(X25,x25)
35__PF(ARP,arp) 35__PF(ARP,arp)
36__PF(BPQ,bpq) 36__PF(BPQ,bpq)
37#ifdef ETH_P_IEEEPUP 37#ifdef ETH_P_IEEEPUP
38__PF(IEEEPUP,ieeepup) 38__PF(IEEEPUP,ieeepup)
39#endif 39#endif
40#ifdef ETH_P_IEEEPUPAT 40#ifdef ETH_P_IEEEPUPAT
41__PF(IEEEPUPAT,ieeepupat) 41__PF(IEEEPUPAT,ieeepupat)
42#endif 42#endif
43__PF(DEC,dec) 43__PF(DEC,dec)
44__PF(DNA_DL,dna_dl) 44__PF(DNA_DL,dna_dl)
45__PF(DNA_RC,dna_rc) 45__PF(DNA_RC,dna_rc)
46__PF(DNA_RT,dna_rt) 46__PF(DNA_RT,dna_rt)
47__PF(LAT,lat) 47__PF(LAT,lat)
48__PF(DIAG,diag) 48__PF(DIAG,diag)
49__PF(CUST,cust) 49__PF(CUST,cust)
50__PF(SCA,sca) 50__PF(SCA,sca)
51__PF(RARP,rarp) 51__PF(RARP,rarp)
52__PF(ATALK,atalk) 52__PF(ATALK,atalk)
53__PF(AARP,aarp) 53__PF(AARP,aarp)
54__PF(IPX,ipx) 54__PF(IPX,ipx)
55__PF(IPV6,ipv6) 55__PF(IPV6,ipv6)
56#ifdef ETH_P_PPP_DISC 56#ifdef ETH_P_PPP_DISC
57__PF(PPP_DISC,ppp_disc) 57__PF(PPP_DISC,ppp_disc)
58#endif 58#endif
59#ifdef ETH_P_PPP_SES 59#ifdef ETH_P_PPP_SES
60__PF(PPP_SES,ppp_ses) 60__PF(PPP_SES,ppp_ses)
61#endif 61#endif
62#ifdef ETH_P_ATMMPOA 62#ifdef ETH_P_ATMMPOA
63__PF(ATMMPOA,atmmpoa) 63__PF(ATMMPOA,atmmpoa)
64#endif 64#endif
65#ifdef ETH_P_ATMFATE 65#ifdef ETH_P_ATMFATE
66__PF(ATMFATE,atmfate) 66__PF(ATMFATE,atmfate)
67#endif 67#endif
68 68
69__PF(802_3,802_3) 69__PF(802_3,802_3)
70__PF(AX25,ax25) 70__PF(AX25,ax25)
71__PF(ALL,all) 71__PF(ALL,all)
72__PF(802_2,802_2) 72__PF(802_2,802_2)
73__PF(SNAP,snap) 73__PF(SNAP,snap)
74__PF(DDCMP,ddcmp) 74__PF(DDCMP,ddcmp)
75__PF(WAN_PPP,wan_ppp) 75__PF(WAN_PPP,wan_ppp)
76__PF(PPP_MP,ppp_mp) 76__PF(PPP_MP,ppp_mp)
77__PF(LOCALTALK,localtalk) 77__PF(LOCALTALK,localtalk)
78__PF(PPPTALK,ppptalk) 78__PF(PPPTALK,ppptalk)
79__PF(TR_802_2,tr_802_2) 79__PF(TR_802_2,tr_802_2)
80__PF(MOBITEX,mobitex) 80__PF(MOBITEX,mobitex)
81__PF(CONTROL,control) 81__PF(CONTROL,control)
82__PF(IRDA,irda) 82__PF(IRDA,irda)
83#ifdef ETH_P_ECONET 83#ifdef ETH_P_ECONET
84__PF(ECONET,econet) 84__PF(ECONET,econet)
85#endif 85#endif
86 86
87{ 0x8100, "802.1Q" }, 87{ 0x8100, "802.1Q" },
diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h
index b51e07be4..e79e177b9 100644
--- a/networking/libiproute/utils.h
+++ b/networking/libiproute/utils.h
@@ -43,7 +43,7 @@ typedef struct
43#define AF_DECnet 12 43#define AF_DECnet 12
44#endif 44#endif
45 45
46struct dn_naddr 46struct dn_naddr
47{ 47{
48 unsigned short a_len; 48 unsigned short a_len;
49 unsigned char a_addr[DN_MAXADDL]; 49 unsigned char a_addr[DN_MAXADDL];
diff --git a/networking/nc.c b/networking/nc.c
index ecb4a007b..9a353c94f 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -4,7 +4,7 @@
4 4
5 0.0.1 6K It works. 5 0.0.1 6K It works.
6 0.0.2 5K Smaller and you can also check the exit condition if you wish. 6 0.0.2 5K Smaller and you can also check the exit condition if you wish.
7 0.0.3 Uses select() 7 0.0.3 Uses select()
8 8
9 19980918 Busy Boxed! Dave Cinege 9 19980918 Busy Boxed! Dave Cinege
10 19990512 Uses Select. Charles P. Wright 10 19990512 Uses Select. Charles P. Wright
@@ -47,7 +47,7 @@ int nc_main(int argc, char **argv)
47 int do_listen = 0, lport = 0, delay = 0, tmpfd, opt, sfd, x; 47 int do_listen = 0, lport = 0, delay = 0, tmpfd, opt, sfd, x;
48 char buf[BUFSIZ]; 48 char buf[BUFSIZ];
49#ifdef GAPING_SECURITY_HOLE 49#ifdef GAPING_SECURITY_HOLE
50 char * pr00gie = NULL; 50 char * pr00gie = NULL;
51#endif 51#endif
52 52
53 struct sockaddr_in address; 53 struct sockaddr_in address;
@@ -79,7 +79,7 @@ int nc_main(int argc, char **argv)
79#ifdef GAPING_SECURITY_HOLE 79#ifdef GAPING_SECURITY_HOLE
80 if (pr00gie) { 80 if (pr00gie) {
81 /* won't need stdin */ 81 /* won't need stdin */
82 close (fileno(stdin)); 82 close (fileno(stdin));
83 } 83 }
84#endif /* GAPING_SECURITY_HOLE */ 84#endif /* GAPING_SECURITY_HOLE */
85 85
diff --git a/networking/netstat.c b/networking/netstat.c
index 17a58876c..bc1ed057b 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -210,7 +210,7 @@ static void tcp_do_one(int lnr, const char *line)
210 snprint_ip_port(local_addr, sizeof(local_addr), 210 snprint_ip_port(local_addr, sizeof(local_addr),
211 (struct sockaddr *) &localaddr, local_port, 211 (struct sockaddr *) &localaddr, local_port,
212 "tcp", flags&NETSTAT_NUMERIC); 212 "tcp", flags&NETSTAT_NUMERIC);
213 213
214 snprint_ip_port(rem_addr, sizeof(rem_addr), 214 snprint_ip_port(rem_addr, sizeof(rem_addr),
215 (struct sockaddr *) &remaddr, rem_port, 215 (struct sockaddr *) &remaddr, rem_port,
216 "tcp", flags&NETSTAT_NUMERIC); 216 "tcp", flags&NETSTAT_NUMERIC);
@@ -305,7 +305,7 @@ static void udp_do_one(int lnr, const char *line)
305 snprint_ip_port(local_addr, sizeof(local_addr), 305 snprint_ip_port(local_addr, sizeof(local_addr),
306 (struct sockaddr *) &localaddr, local_port, 306 (struct sockaddr *) &localaddr, local_port,
307 "udp", flags&NETSTAT_NUMERIC); 307 "udp", flags&NETSTAT_NUMERIC);
308 308
309 snprint_ip_port(rem_addr, sizeof(rem_addr), 309 snprint_ip_port(rem_addr, sizeof(rem_addr),
310 (struct sockaddr *) &remaddr, rem_port, 310 (struct sockaddr *) &remaddr, rem_port,
311 "udp", flags&NETSTAT_NUMERIC); 311 "udp", flags&NETSTAT_NUMERIC);
@@ -387,7 +387,7 @@ static void raw_do_one(int lnr, const char *line)
387 snprint_ip_port(local_addr, sizeof(local_addr), 387 snprint_ip_port(local_addr, sizeof(local_addr),
388 (struct sockaddr *) &localaddr, local_port, 388 (struct sockaddr *) &localaddr, local_port,
389 "raw", flags&NETSTAT_NUMERIC); 389 "raw", flags&NETSTAT_NUMERIC);
390 390
391 snprint_ip_port(rem_addr, sizeof(rem_addr), 391 snprint_ip_port(rem_addr, sizeof(rem_addr),
392 (struct sockaddr *) &remaddr, rem_port, 392 (struct sockaddr *) &remaddr, rem_port,
393 "raw", flags&NETSTAT_NUMERIC); 393 "raw", flags&NETSTAT_NUMERIC);
@@ -558,7 +558,7 @@ int netstat_main(int argc, char **argv)
558{ 558{
559 int opt; 559 int opt;
560 int new_flags=0; 560 int new_flags=0;
561 int showroute = 0, extended = 0; 561 int showroute = 0, extended = 0;
562#ifdef CONFIG_FEATURE_IPV6 562#ifdef CONFIG_FEATURE_IPV6
563 int inet=1; 563 int inet=1;
564 int inet6=1; 564 int inet6=1;
@@ -600,14 +600,14 @@ int netstat_main(int argc, char **argv)
600 bb_show_usage(); 600 bb_show_usage();
601 } 601 }
602 if ( showroute ) { 602 if ( showroute ) {
603#ifdef CONFIG_ROUTE 603#ifdef CONFIG_ROUTE
604 displayroutes ( flags & NETSTAT_NUMERIC, !extended ); 604 displayroutes ( flags & NETSTAT_NUMERIC, !extended );
605 return 0; 605 return 0;
606#else 606#else
607 bb_error_msg_and_die( "-r (display routing table) is not compiled in." ); 607 bb_error_msg_and_die( "-r (display routing table) is not compiled in." );
608#endif 608#endif
609 } 609 }
610 610
611 if (new_flags) { 611 if (new_flags) {
612 flags &= ~(NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX); 612 flags &= ~(NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX);
613 flags |= new_flags; 613 flags |= new_flags;
diff --git a/networking/nslookup.c b/networking/nslookup.c
index 329510630..bb691d687 100644
--- a/networking/nslookup.c
+++ b/networking/nslookup.c
@@ -187,7 +187,7 @@ int nslookup_main(int argc, char **argv)
187 187
188 if (argc < 2 || *argv[1]=='-' || argc > 3) 188 if (argc < 2 || *argv[1]=='-' || argc > 3)
189 bb_show_usage(); 189 bb_show_usage();
190 else if(argc == 3) 190 else if(argc == 3)
191 set_default_dns(argv[2]); 191 set_default_dns(argv[2]);
192 192
193 server_print(); 193 server_print();
@@ -200,4 +200,4 @@ int nslookup_main(int argc, char **argv)
200 return EXIT_SUCCESS; 200 return EXIT_SUCCESS;
201} 201}
202 202
203/* $Id: nslookup.c,v 1.31 2004/01/30 22:40:05 andersen Exp $ */ 203/* $Id: nslookup.c,v 1.32 2004/03/15 08:28:48 andersen Exp $ */
diff --git a/networking/ping.c b/networking/ping.c
index a38f356d6..50f3930ff 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping.c,v 1.55 2003/07/22 08:56:51 andersen Exp $ 3 * $Id: ping.c,v 1.56 2004/03/15 08:28:48 andersen Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -27,7 +27,7 @@
27 * 27 *
28 * This code is derived from software contributed to Berkeley by 28 * This code is derived from software contributed to Berkeley by
29 * Mike Muuss. 29 * Mike Muuss.
30 * 30 *
31 * Original copyright notice is retained at the end of this file. 31 * Original copyright notice is retained at the end of this file.
32 */ 32 */
33 33
@@ -329,7 +329,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from)
329 if (dupflag) 329 if (dupflag)
330 printf(" (DUP!)"); 330 printf(" (DUP!)");
331 printf("\n"); 331 printf("\n");
332 } else 332 } else
333 if (icmppkt->icmp_type != ICMP_ECHO) 333 if (icmppkt->icmp_type != ICMP_ECHO)
334 bb_error_msg("Warning: Got ICMP %d (%s)", 334 bb_error_msg("Warning: Got ICMP %d (%s)",
335 icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); 335 icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type));
@@ -451,8 +451,8 @@ extern int ping_main(int argc, char **argv)
451 * notice, this list of conditions and the following disclaimer in the 451 * notice, this list of conditions and the following disclaimer in the
452 * documentation and/or other materials provided with the distribution. 452 * documentation and/or other materials provided with the distribution.
453 * 453 *
454 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change 454 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
455 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> 455 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
456 * 456 *
457 * 4. Neither the name of the University nor the names of its contributors 457 * 4. Neither the name of the University nor the names of its contributors
458 * may be used to endorse or promote products derived from this software 458 * may be used to endorse or promote products derived from this software
diff --git a/networking/ping6.c b/networking/ping6.c
index d9d0dd343..72867f346 100644
--- a/networking/ping6.c
+++ b/networking/ping6.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * $Id: ping6.c,v 1.5 2003/05/22 07:10:22 andersen Exp $ 3 * $Id: ping6.c,v 1.6 2004/03/15 08:28:48 andersen Exp $
4 * Mini ping implementation for busybox 4 * Mini ping implementation for busybox
5 * 5 *
6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> 6 * Copyright (C) 1999 by Randolph Chung <tausq@debian.org>
@@ -27,7 +27,7 @@
27 * 27 *
28 * This code is derived from software contributed to Berkeley by 28 * This code is derived from software contributed to Berkeley by
29 * Mike Muuss. 29 * Mike Muuss.
30 * 30 *
31 * Original copyright notice is retained at the end of this file. 31 * Original copyright notice is retained at the end of this file.
32 * 32 *
33 * This version is an adaptation of ping.c from busybox. 33 * This version is an adaptation of ping.c from busybox.
@@ -162,7 +162,7 @@ static unsigned long tmin = ULONG_MAX, tmax, tsum;
162static char rcvd_tbl[MAX_DUP_CHK / 8]; 162static char rcvd_tbl[MAX_DUP_CHK / 8];
163 163
164# ifdef CONFIG_FEATURE_FANCY_PING 164# ifdef CONFIG_FEATURE_FANCY_PING
165extern 165extern
166# endif 166# endif
167 struct hostent *hostent; 167 struct hostent *hostent;
168 168
@@ -302,12 +302,12 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit
302 inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr, 302 inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr,
303 buf, sizeof(buf)), 303 buf, sizeof(buf)),
304 icmppkt->icmp6_seq); 304 icmppkt->icmp6_seq);
305 printf(" ttl=%d time=%lu.%lu ms", hoplimit, 305 printf(" ttl=%d time=%lu.%lu ms", hoplimit,
306 triptime / 10, triptime % 10); 306 triptime / 10, triptime % 10);
307 if (dupflag) 307 if (dupflag)
308 printf(" (DUP!)"); 308 printf(" (DUP!)");
309 printf("\n"); 309 printf("\n");
310 } else 310 } else
311 if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) 311 if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST)
312 bb_error_msg("Warning: Got ICMP %d (%s)", 312 bb_error_msg("Warning: Got ICMP %d (%s)",
313 icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); 313 icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type));
@@ -494,8 +494,8 @@ extern int ping6_main(int argc, char **argv)
494 * notice, this list of conditions and the following disclaimer in the 494 * notice, this list of conditions and the following disclaimer in the
495 * documentation and/or other materials provided with the distribution. 495 * documentation and/or other materials provided with the distribution.
496 * 496 *
497 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change 497 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
498 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> 498 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
499 * 499 *
500 * 4. Neither the name of the University nor the names of its contributors 500 * 4. Neither the name of the University nor the names of its contributors
501 * may be used to endorse or promote products derived from this software 501 * may be used to endorse or promote products derived from this software
diff --git a/networking/route.c b/networking/route.c
index 111900d33..9e7a01034 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -15,7 +15,7 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: route.c,v 1.24 2004/03/10 07:42:38 mjn3 Exp $ 18 * $Id: route.c,v 1.25 2004/03/15 08:28:49 andersen Exp $
19 * 19 *
20 * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> 20 * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> 21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -107,7 +107,7 @@ static const char tbl_hash_net_host[] =
107#define KW_IPVx_DYN 042 107#define KW_IPVx_DYN 042
108#define KW_IPVx_REINSTATE 043 108#define KW_IPVx_REINSTATE 043
109 109
110static const char tbl_ipvx[] = 110static const char tbl_ipvx[] =
111 /* 020 is the "takes an arg" bit */ 111 /* 020 is the "takes an arg" bit */
112#if HAVE_NEW_ADDRT 112#if HAVE_NEW_ADDRT
113 "\011\020metric\0" 113 "\011\020metric\0"
@@ -206,7 +206,7 @@ static void INET_setroute(int action, char **args)
206 while (*args) { 206 while (*args) {
207 int k = kw_lookup(tbl_ipvx, &args); 207 int k = kw_lookup(tbl_ipvx, &args);
208 const char *args_m1 = args[-1]; 208 const char *args_m1 = args[-1];
209 209
210 if (k & KW_IPVx_FLAG_ONLY) { 210 if (k & KW_IPVx_FLAG_ONLY) {
211 rt.rt_flags |= flags_ipvx[k & 3]; 211 rt.rt_flags |= flags_ipvx[k & 3];
212 continue; 212 continue;
@@ -666,7 +666,7 @@ int route_main(int argc, char **argv)
666 p[0][0] = '#'; 666 p[0][0] = '#';
667 } 667 }
668 } 668 }
669 } 669 }
670 670
671 opt = bb_getopt_ulflags(argc, argv, "A:ne", &family); 671 opt = bb_getopt_ulflags(argc, argv, "A:ne", &family);
672 672
diff --git a/networking/telnet.c b/networking/telnet.c
index 574fe8dab..6c5f3d15b 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -54,7 +54,7 @@ static const int DOTRACE = 1;
54#include <arpa/inet.h> /* for inet_ntoa()... */ 54#include <arpa/inet.h> /* for inet_ntoa()... */
55#define TRACE(x, y) do { if (x) printf y; } while (0) 55#define TRACE(x, y) do { if (x) printf y; } while (0)
56#else 56#else
57#define TRACE(x, y) 57#define TRACE(x, y)
58#endif 58#endif
59 59
60#if 0 60#if 0
@@ -99,8 +99,8 @@ static struct Globalvars {
99 /* buffer to handle telnet negotiations */ 99 /* buffer to handle telnet negotiations */
100 char iacbuf[IACBUFSIZE]; 100 char iacbuf[IACBUFSIZE];
101 short iaclen; /* could even use byte */ 101 short iaclen; /* could even use byte */
102 struct termios termios_def; 102 struct termios termios_def;
103 struct termios termios_raw; 103 struct termios termios_raw;
104} G; 104} G;
105 105
106#define xUSE_GLOBALVAR_PTR /* xUSE... -> don't use :D (makes smaller code) */ 106#define xUSE_GLOBALVAR_PTR /* xUSE... -> don't use :D (makes smaller code) */
@@ -143,7 +143,7 @@ static void doexit(int ev)
143{ 143{
144 cookmode(); 144 cookmode();
145 exit(ev); 145 exit(ev);
146} 146}
147 147
148static void conescape(void) 148static void conescape(void)
149{ 149{
@@ -190,10 +190,10 @@ static void conescape(void)
190 190
191 if (G.gotsig) 191 if (G.gotsig)
192 cookmode(); 192 cookmode();
193 193
194 rrturn: 194 rrturn:
195 G.gotsig = 0; 195 G.gotsig = 0;
196 196
197} 197}
198static void handlenetoutput(int len) 198static void handlenetoutput(int len)
199{ 199{
@@ -442,7 +442,7 @@ static void will_charmode(void)
442 G.charmode = CHM_TRY; 442 G.charmode = CHM_TRY;
443 G.telflags |= (UF_ECHO | UF_SGA); 443 G.telflags |= (UF_ECHO | UF_SGA);
444 setConMode(); 444 setConMode();
445 445
446 putiac2(DO, TELOPT_ECHO); 446 putiac2(DO, TELOPT_ECHO);
447 putiac2(DO, TELOPT_SGA); 447 putiac2(DO, TELOPT_SGA);
448 iacflush(); 448 iacflush();
@@ -472,7 +472,7 @@ static inline void to_echo(void)
472 /* if server requests ECHO, don't agree */ 472 /* if server requests ECHO, don't agree */
473 if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; } 473 if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; }
474 else if (G.telwish == DONT) return; 474 else if (G.telwish == DONT) return;
475 475
476 if (G.telflags & UF_ECHO) 476 if (G.telflags & UF_ECHO)
477 { 477 {
478 if (G.telwish == WILL) 478 if (G.telwish == WILL)
@@ -506,7 +506,7 @@ static inline void to_sga(void)
506 else 506 else
507 if (G.telwish == WONT) 507 if (G.telwish == WONT)
508 return; 508 return;
509 509
510 if ((G.telflags ^= UF_SGA) & UF_SGA) /* toggle */ 510 if ((G.telflags ^= UF_SGA) & UF_SGA) /* toggle */
511 putiac2(DO, TELOPT_SGA); 511 putiac2(DO, TELOPT_SGA);
512 else 512 else
@@ -545,11 +545,11 @@ static inline void to_new_environ(void)
545 545
546#ifdef CONFIG_FEATURE_AUTOWIDTH 546#ifdef CONFIG_FEATURE_AUTOWIDTH
547static inline void to_naws(void) 547static inline void to_naws(void)
548{ 548{
549 /* Tell server we will do NAWS */ 549 /* Tell server we will do NAWS */
550 putiac2(WILL, TELOPT_NAWS); 550 putiac2(WILL, TELOPT_NAWS);
551 return; 551 return;
552} 552}
553#endif 553#endif
554 554
555static void telopt(byte c) 555static void telopt(byte c)
@@ -617,7 +617,7 @@ static void fgotsig(int sig)
617static void rawmode(void) 617static void rawmode(void)
618{ 618{
619 tcsetattr(0, TCSADRAIN, &G.termios_raw); 619 tcsetattr(0, TCSADRAIN, &G.termios_raw);
620} 620}
621 621
622static void cookmode(void) 622static void cookmode(void)
623{ 623{
@@ -630,10 +630,10 @@ extern int telnet_main(int argc, char** argv)
630 struct sockaddr_in s_in; 630 struct sockaddr_in s_in;
631#ifdef USE_POLL 631#ifdef USE_POLL
632 struct pollfd ufds[2]; 632 struct pollfd ufds[2];
633#else 633#else
634 fd_set readfds; 634 fd_set readfds;
635 int maxfd; 635 int maxfd;
636#endif 636#endif
637 637
638#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN 638#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
639 int opt; 639 int opt;
@@ -651,13 +651,13 @@ extern int telnet_main(int argc, char** argv)
651 651
652 if (tcgetattr(0, &G.termios_def) < 0) 652 if (tcgetattr(0, &G.termios_def) < 0)
653 exit(1); 653 exit(1);
654 654
655 G.termios_raw = G.termios_def; 655 G.termios_raw = G.termios_def;
656 cfmakeraw(&G.termios_raw); 656 cfmakeraw(&G.termios_raw);
657 657
658 if (argc < 2) 658 if (argc < 2)
659 bb_show_usage(); 659 bb_show_usage();
660 660
661#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN 661#ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN
662 autologin = NULL; 662 autologin = NULL;
663 while ((opt = getopt(argc, argv, "al:")) != EOF) { 663 while ((opt = getopt(argc, argv, "al:")) != EOF) {
@@ -685,7 +685,7 @@ extern int telnet_main(int argc, char** argv)
685 bb_lookup_host(&s_in, argv[1]); 685 bb_lookup_host(&s_in, argv[1]);
686 s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23); 686 s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23);
687#endif 687#endif
688 688
689 G.netfd = xconnect(&s_in); 689 G.netfd = xconnect(&s_in);
690 690
691 setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); 691 setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one);
@@ -695,22 +695,22 @@ extern int telnet_main(int argc, char** argv)
695#ifdef USE_POLL 695#ifdef USE_POLL
696 ufds[0].fd = 0; ufds[1].fd = G.netfd; 696 ufds[0].fd = 0; ufds[1].fd = G.netfd;
697 ufds[0].events = ufds[1].events = POLLIN; 697 ufds[0].events = ufds[1].events = POLLIN;
698#else 698#else
699 FD_ZERO(&readfds); 699 FD_ZERO(&readfds);
700 FD_SET(0, &readfds); 700 FD_SET(0, &readfds);
701 FD_SET(G.netfd, &readfds); 701 FD_SET(G.netfd, &readfds);
702 maxfd = G.netfd + 1; 702 maxfd = G.netfd + 1;
703#endif 703#endif
704 704
705 while (1) 705 while (1)
706 { 706 {
707#ifndef USE_POLL 707#ifndef USE_POLL
708 fd_set rfds = readfds; 708 fd_set rfds = readfds;
709 709
710 switch (select(maxfd, &rfds, NULL, NULL, NULL)) 710 switch (select(maxfd, &rfds, NULL, NULL, NULL))
711#else 711#else
712 switch (poll(ufds, 2, -1)) 712 switch (poll(ufds, 2, -1))
713#endif 713#endif
714 { 714 {
715 case 0: 715 case 0:
716 /* timeout */ 716 /* timeout */
@@ -725,9 +725,9 @@ extern int telnet_main(int argc, char** argv)
725 725
726#ifdef USE_POLL 726#ifdef USE_POLL
727 if (ufds[0].revents) /* well, should check POLLIN, but ... */ 727 if (ufds[0].revents) /* well, should check POLLIN, but ... */
728#else 728#else
729 if (FD_ISSET(0, &rfds)) 729 if (FD_ISSET(0, &rfds))
730#endif 730#endif
731 { 731 {
732 len = read(0, G.buf, DATABUFSIZE); 732 len = read(0, G.buf, DATABUFSIZE);
733 733
@@ -735,15 +735,15 @@ extern int telnet_main(int argc, char** argv)
735 doexit(0); 735 doexit(0);
736 736
737 TRACE(0, ("Read con: %d\n", len)); 737 TRACE(0, ("Read con: %d\n", len));
738 738
739 handlenetoutput(len); 739 handlenetoutput(len);
740 } 740 }
741 741
742#ifdef USE_POLL 742#ifdef USE_POLL
743 if (ufds[1].revents) /* well, should check POLLIN, but ... */ 743 if (ufds[1].revents) /* well, should check POLLIN, but ... */
744#else 744#else
745 if (FD_ISSET(G.netfd, &rfds)) 745 if (FD_ISSET(G.netfd, &rfds))
746#endif 746#endif
747 { 747 {
748 len = read(G.netfd, G.buf, DATABUFSIZE); 748 len = read(G.netfd, G.buf, DATABUFSIZE);
749 749
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 3051cfa1e..efb2988b3 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -1,4 +1,4 @@
1/* $Id: telnetd.c,v 1.10 2004/02/22 09:45:57 bug1 Exp $ 1/* $Id: telnetd.c,v 1.11 2004/03/15 08:28:53 andersen Exp $
2 * 2 *
3 * Simple telnet server 3 * Simple telnet server
4 * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) 4 * Bjorn Wesen, Axis Communications AB (bjornw@axis.com)
@@ -49,7 +49,7 @@
49 49
50#define BUFSIZE 4000 50#define BUFSIZE 4000
51 51
52static const char *loginpath 52static const char *loginpath
53#ifdef CONFIG_LOGIN 53#ifdef CONFIG_LOGIN
54 = "/bin/login"; 54 = "/bin/login";
55#else 55#else
@@ -540,7 +540,7 @@ telnetd_main(int argc, char **argv)
540#ifndef CONFIG_FEATURE_TELNETD_INETD 540#ifndef CONFIG_FEATURE_TELNETD_INETD
541 struct tsession *next = ts->next; /* in case we free ts. */ 541 struct tsession *next = ts->next; /* in case we free ts. */
542#endif /* CONFIG_FEATURE_TELNETD_INETD */ 542#endif /* CONFIG_FEATURE_TELNETD_INETD */
543 543
544 if (ts->size1 && FD_ISSET(ts->ptyfd, &wrfdset)) { 544 if (ts->size1 && FD_ISSET(ts->ptyfd, &wrfdset)) {
545 int num_totty; 545 int num_totty;
546 char *ptr; 546 char *ptr;
diff --git a/networking/tftp.c b/networking/tftp.c
index 10aa63bb9..bd973d79a 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -76,15 +76,15 @@ const int tftp_cmd_put = 2;
76 76
77#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE 77#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
78 78
79static int tftp_blocksize_check(int blocksize, int bufsize) 79static int tftp_blocksize_check(int blocksize, int bufsize)
80{ 80{
81 /* Check if the blocksize is valid: 81 /* Check if the blocksize is valid:
82 * RFC2348 says between 8 and 65464, 82 * RFC2348 says between 8 and 65464,
83 * but our implementation makes it impossible 83 * but our implementation makes it impossible
84 * to use blocksizes smaller than 22 octets. 84 * to use blocksizes smaller than 22 octets.
85 */ 85 */
86 86
87 if ((bufsize && (blocksize > bufsize)) || 87 if ((bufsize && (blocksize > bufsize)) ||
88 (blocksize < 8) || (blocksize > 65464)) { 88 (blocksize < 8) || (blocksize > 65464)) {
89 bb_error_msg("bad blocksize"); 89 bb_error_msg("bad blocksize");
90 return 0; 90 return 0;
@@ -93,12 +93,12 @@ static int tftp_blocksize_check(int blocksize, int bufsize)
93 return blocksize; 93 return blocksize;
94} 94}
95 95
96static char *tftp_option_get(char *buf, int len, char *option) 96static char *tftp_option_get(char *buf, int len, char *option)
97{ 97{
98 int opt_val = 0; 98 int opt_val = 0;
99 int opt_found = 0; 99 int opt_found = 0;
100 int k; 100 int k;
101 101
102 while (len > 0) { 102 while (len > 0) {
103 103
104 /* Make sure the options are terminated correctly */ 104 /* Make sure the options are terminated correctly */
@@ -117,21 +117,21 @@ static char *tftp_option_get(char *buf, int len, char *option)
117 if (strcasecmp(buf, option) == 0) { 117 if (strcasecmp(buf, option) == 0) {
118 opt_found = 1; 118 opt_found = 1;
119 } 119 }
120 } 120 }
121 else { 121 else {
122 if (opt_found) { 122 if (opt_found) {
123 return buf; 123 return buf;
124 } 124 }
125 } 125 }
126 126
127 k++; 127 k++;
128 128
129 buf += k; 129 buf += k;
130 len -= k; 130 len -= k;
131 131
132 opt_val ^= 1; 132 opt_val ^= 1;
133 } 133 }
134 134
135 return NULL; 135 return NULL;
136} 136}
137 137
@@ -207,7 +207,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
207 207
208 if ((cmd_get && (opcode == TFTP_RRQ)) || 208 if ((cmd_get && (opcode == TFTP_RRQ)) ||
209 (cmd_put && (opcode == TFTP_WRQ))) { 209 (cmd_put && (opcode == TFTP_WRQ))) {
210 int too_long = 0; 210 int too_long = 0;
211 211
212 /* see if the filename fits into buf */ 212 /* see if the filename fits into buf */
213 /* and fill in packet */ 213 /* and fill in packet */
@@ -380,7 +380,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
380 if (buf[4] != '\0') { 380 if (buf[4] != '\0') {
381 msg = &buf[4]; 381 msg = &buf[4];
382 buf[tftp_bufsize - 1] = '\0'; 382 buf[tftp_bufsize - 1] = '\0';
383 } else if (tmp < (sizeof(tftp_bb_error_msg) 383 } else if (tmp < (sizeof(tftp_bb_error_msg)
384 / sizeof(char *))) { 384 / sizeof(char *))) {
385 385
386 msg = (char *) tftp_bb_error_msg[tmp]; 386 msg = (char *) tftp_bb_error_msg[tmp];
@@ -404,12 +404,12 @@ static inline int tftp(const int cmd, const struct hostent *host,
404 404
405 char *res; 405 char *res;
406 406
407 res = tftp_option_get(&buf[2], len-2, 407 res = tftp_option_get(&buf[2], len-2,
408 "blksize"); 408 "blksize");
409 409
410 if (res) { 410 if (res) {
411 int blksize = atoi(res); 411 int blksize = atoi(res);
412 412
413 if (tftp_blocksize_check(blksize, 413 if (tftp_blocksize_check(blksize,
414 tftp_bufsize - 4)) { 414 tftp_bufsize - 4)) {
415 415
@@ -443,7 +443,7 @@ static inline int tftp(const int cmd, const struct hostent *host,
443 if (cmd_get && (opcode == TFTP_DATA)) { 443 if (cmd_get && (opcode == TFTP_DATA)) {
444 444
445 if (tmp == block_nr) { 445 if (tmp == block_nr) {
446 446
447 len = write(localfd, &buf[4], len - 4); 447 len = write(localfd, &buf[4], len - 4);
448 448
449 if (len < 0) { 449 if (len < 0) {
@@ -506,13 +506,13 @@ int tftp_main(int argc, char **argv)
506#ifdef CONFIG_FEATURE_TFTP_GET 506#ifdef CONFIG_FEATURE_TFTP_GET
507#define GET "g" 507#define GET "g"
508#else 508#else
509#define GET 509#define GET
510#endif 510#endif
511 511
512#ifdef CONFIG_FEATURE_TFTP_PUT 512#ifdef CONFIG_FEATURE_TFTP_PUT
513#define PUT "p" 513#define PUT "p"
514#else 514#else
515#define PUT 515#define PUT
516#endif 516#endif
517 517
518 while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) { 518 while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) {
@@ -537,7 +537,7 @@ int tftp_main(int argc, char **argv)
537 flags = O_RDONLY; 537 flags = O_RDONLY;
538 break; 538 break;
539#endif 539#endif
540 case 'l': 540 case 'l':
541 localfile = bb_xstrdup(optarg); 541 localfile = bb_xstrdup(optarg);
542 break; 542 break;
543 case 'r': 543 case 'r':
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 5f8989fd1..44ffdf07e 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -75,7 +75,7 @@
75#include <netinet/ip.h> 75#include <netinet/ip.h>
76#include <netinet/ip_icmp.h> 76#include <netinet/ip_icmp.h>
77 77
78 78
79#define MAXPACKET 65535 /* max ip packet size */ 79#define MAXPACKET 65535 /* max ip packet size */
80#ifndef MAXHOSTNAMELEN 80#ifndef MAXHOSTNAMELEN
81#define MAXHOSTNAMELEN 64 81#define MAXHOSTNAMELEN 64
diff --git a/networking/udhcp/AUTHORS b/networking/udhcp/AUTHORS
index bb58de13e..f3f43364a 100644
--- a/networking/udhcp/AUTHORS
+++ b/networking/udhcp/AUTHORS
@@ -8,7 +8,6 @@ Chris Trew <christ@moreton.com.au>
8Other Credits: 8Other Credits:
9-------------- 9--------------
10Moreton Bay (http://www.moretonbay.com/) 10Moreton Bay (http://www.moretonbay.com/)
11Lineo (http://opensource.lineo.com)
12Vladimir Oleynik <dzo@simtrea.ru> Size optimizations 11Vladimir Oleynik <dzo@simtrea.ru> Size optimizations
13 12
14 13
diff --git a/networking/udhcp/ChangeLog b/networking/udhcp/ChangeLog
index f1aac060e..2feffc776 100644
--- a/networking/udhcp/ChangeLog
+++ b/networking/udhcp/ChangeLog
@@ -39,7 +39,7 @@
39 (Ted Lemon <Ted.Lemon@nominum.com>) 39 (Ted Lemon <Ted.Lemon@nominum.com>)
40+ Improved (hopefully) NAKing behavior (me) 40+ Improved (hopefully) NAKing behavior (me)
41+ Added -b option (Jouni Malinen) 41+ Added -b option (Jouni Malinen)
42+ Compute checksums correctly on big endian hosts 42+ Compute checksums correctly on big endian hosts
43 (Jouni Malinen <jkmaline@cc.hut.fi>) 43 (Jouni Malinen <jkmaline@cc.hut.fi>)
44 44
450.9.7 (020526) 450.9.7 (020526)
diff --git a/networking/udhcp/Makefile b/networking/udhcp/Makefile
index ee34d48ff..2b79d2293 100644
--- a/networking/udhcp/Makefile
+++ b/networking/udhcp/Makefile
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/udhcp/Makefile.in b/networking/udhcp/Makefile.in
index 4d3f27093..b48079429 100644
--- a/networking/udhcp/Makefile.in
+++ b/networking/udhcp/Makefile.in
@@ -1,6 +1,6 @@
1# Makefile for busybox 1# Makefile for busybox
2# 2#
3# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> 3# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
4# 4#
5# This program is free software; you can redistribute it and/or modify 5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by 6# it under the terms of the GNU General Public License as published by
diff --git a/networking/udhcp/README b/networking/udhcp/README
index eddb24be7..dd992949a 100644
--- a/networking/udhcp/README
+++ b/networking/udhcp/README
@@ -10,30 +10,30 @@ compile time options
10------------------- 10-------------------
11 11
12The Makefile contains three of the compile time options: 12The Makefile contains three of the compile time options:
13 13
14 UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra 14 UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra
15 debugging output, compile with -g, and not fork to the background when 15 debugging output, compile with -g, and not fork to the background when
16 run. 16 run.
17 UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its 17 UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its
18 messages syslog, otherwise, it will attempt to log them to stdout. 18 messages syslog, otherwise, it will attempt to log them to stdout.
19 19
20 COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd, 20 COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd,
21 is created. If called as udhcpd, the dhcp server will be started. 21 is created. If called as udhcpd, the dhcp server will be started.
22 If called as udhcpc, the dhcp client will be started. 22 If called as udhcpc, the dhcp client will be started.
23 23
24dhcpd.h contains the other three compile time options: 24dhcpd.h contains the other three compile time options:
25 25
26 LEASE_TIME: The default lease time if not specified in the config 26 LEASE_TIME: The default lease time if not specified in the config
27 file. 27 file.
28 28
29 LEASES_FILE: The default file for storing leases. 29 LEASES_FILE: The default file for storing leases.
30 30
31 DHCPD_CONFIG_FILE: The defualt config file to use. 31 DHCPD_CONFIG_FILE: The defualt config file to use.
32 32
33options.c contains a set of dhcp options for the client: 33options.c contains a set of dhcp options for the client:
34 34
35 name[10]: The name of the option as it will appear in scripts 35 name[10]: The name of the option as it will appear in scripts
36 36
37 flags: The type of option, as well as if it will be requested 37 flags: The type of option, as well as if it will be requested
38 by the client (OPTION_REQ) 38 by the client (OPTION_REQ)
39 39
@@ -45,7 +45,7 @@ busybox drop-in
45udhcp is now a drop-in component for busybox (http://busybox.net). 45udhcp is now a drop-in component for busybox (http://busybox.net).
46To update busybox to the latest revision, simply do a: 46To update busybox to the latest revision, simply do a:
47 47
48cp *.[ch] README AUTHORS COPYING ChangeLog TODO \ 48cp *.[ch] README AUTHORS COPYING ChangeLog TODO \
49 <busybox_source>/networking/udhcp 49 <busybox_source>/networking/udhcp
50 50
51The only two files udhcp does not provide are config.in and 51The only two files udhcp does not provide are config.in and
diff --git a/networking/udhcp/README.udhcpc b/networking/udhcp/README.udhcpc
index 8aee9814b..d720a37cf 100644
--- a/networking/udhcp/README.udhcpc
+++ b/networking/udhcp/README.udhcpc
@@ -36,20 +36,20 @@ udhcp client scripts
36 36
37When an event occurs, udhcpc calls the action script. udhcpc never does 37When an event occurs, udhcpc calls the action script. udhcpc never does
38any configuration of the network interface itself, but instead relies on 38any configuration of the network interface itself, but instead relies on
39a set of scripts. The script by default is 39a set of scripts. The script by default is
40/usr/share/udhcpc/default.script but this can be changed via the command 40/usr/share/udhcpc/default.script but this can be changed via the command
41line arguments. The three possible arguments to the script are: 41line arguments. The three possible arguments to the script are:
42 42
43 deconfig: This argument is used when udhcpc starts, and 43 deconfig: This argument is used when udhcpc starts, and
44 when a leases is lost. The script must put the interface in an 44 when a leases is lost. The script must put the interface in an
45 up, but deconfigured state, ie: ifconfig $interface 0.0.0.0. 45 up, but deconfigured state, ie: ifconfig $interface 0.0.0.0.
46 46
47 bound: This argument is used when udhcpc moves from an 47 bound: This argument is used when udhcpc moves from an
48 unbound, to a bound state. All of the paramaters are set in 48 unbound, to a bound state. All of the paramaters are set in
49 enviromental variables, The script should configure the interface, 49 enviromental variables, The script should configure the interface,
50 and set any other relavent parameters (default gateway, dns server, 50 and set any other relavent parameters (default gateway, dns server,
51 etc). 51 etc).
52 52
53 renew: This argument is used when a DHCP lease is renewed. All of 53 renew: This argument is used when a DHCP lease is renewed. All of
54 the paramaters are set in enviromental variables. This argument is 54 the paramaters are set in enviromental variables. This argument is
55 used when the interface is already configured, so the IP address, 55 used when the interface is already configured, so the IP address,
@@ -133,7 +133,7 @@ compile time options
133options.c contains a set of dhcp options for the client: 133options.c contains a set of dhcp options for the client:
134 134
135 name[10]: The name of the option as it will appear in scripts 135 name[10]: The name of the option as it will appear in scripts
136 136
137 flags: The type of option, as well as if it will be requested 137 flags: The type of option, as well as if it will be requested
138 by the client (OPTION_REQ) 138 by the client (OPTION_REQ)
139 139
diff --git a/networking/udhcp/README.udhcpd b/networking/udhcp/README.udhcpd
index bc6137de3..169de78ec 100644
--- a/networking/udhcp/README.udhcpd
+++ b/networking/udhcp/README.udhcpd
@@ -14,7 +14,7 @@ udhcpd.leases
14 14
15The udhcpd.leases behavior is designed for an embedded system. The 15The udhcpd.leases behavior is designed for an embedded system. The
16file is written either every auto_time seconds, or when a SIGUSR1 16file is written either every auto_time seconds, or when a SIGUSR1
17is received (the auto_time timer restarts if a SIGUSR1 is received). 17is received (the auto_time timer restarts if a SIGUSR1 is received).
18If you send a SIGTERM to udhcpd directly after a SIGUSR1, udhcpd will 18If you send a SIGTERM to udhcpd directly after a SIGUSR1, udhcpd will
19finish writing the leases file and wait for the aftermentioned script 19finish writing the leases file and wait for the aftermentioned script
20to be executed and finish before quiting, so you do not need to sleep 20to be executed and finish before quiting, so you do not need to sleep
@@ -50,10 +50,10 @@ available options and comments describing them in samples/udhcpd.conf
50 50
51compile time options 51compile time options
52------------------- 52-------------------
53 53
54dhcpd.h contains the other two compile time options: 54dhcpd.h contains the other two compile time options:
55 55
56 LEASE_TIME: The default lease time if not specified in the config 56 LEASE_TIME: The default lease time if not specified in the config
57 file. 57 file.
58 58
59 DHCPD_CONFIG_FILE: The defualt config file to use. 59 DHCPD_CONFIG_FILE: The defualt config file to use.
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 23c7d46b3..ab4c6d20c 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -25,8 +25,8 @@
25 * interface - interface to use 25 * interface - interface to use
26 * retn: 1 addr free 26 * retn: 1 addr free
27 * 0 addr used 27 * 0 addr used
28 * -1 error 28 * -1 error
29 */ 29 */
30 30
31/* FIXME: match response against chaddr */ 31/* FIXME: match response against chaddr */
32int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) 32int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
@@ -51,7 +51,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
51#endif 51#endif
52 return -1; 52 return -1;
53 } 53 }
54 54
55 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { 55 if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) {
56 LOG(LOG_ERR, "Could not setsocketopt on raw socket"); 56 LOG(LOG_ERR, "Could not setsocketopt on raw socket");
57 close(s); 57 close(s);
@@ -71,12 +71,12 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
71 memcpy(arp.sInaddr, &ip, sizeof(ip)); /* source IP address */ 71 memcpy(arp.sInaddr, &ip, sizeof(ip)); /* source IP address */
72 memcpy(arp.sHaddr, mac, 6); /* source hardware address */ 72 memcpy(arp.sHaddr, mac, 6); /* source hardware address */
73 memcpy(arp.tInaddr, &yiaddr, sizeof(yiaddr)); /* target IP address */ 73 memcpy(arp.tInaddr, &yiaddr, sizeof(yiaddr)); /* target IP address */
74 74
75 memset(&addr, 0, sizeof(addr)); 75 memset(&addr, 0, sizeof(addr));
76 strcpy(addr.sa_data, interface); 76 strcpy(addr.sa_data, interface);
77 if (sendto(s, &arp, sizeof(arp), 0, &addr, sizeof(addr)) < 0) 77 if (sendto(s, &arp, sizeof(arp), 0, &addr, sizeof(addr)) < 0)
78 rv = 0; 78 rv = 0;
79 79
80 /* wait arp reply, and check it */ 80 /* wait arp reply, and check it */
81 tm.tv_usec = 0; 81 tm.tv_usec = 0;
82 time(&prevTime); 82 time(&prevTime);
@@ -89,8 +89,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
89 if (errno != EINTR) rv = 0; 89 if (errno != EINTR) rv = 0;
90 } else if (FD_ISSET(s, &fdset)) { 90 } else if (FD_ISSET(s, &fdset)) {
91 if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0; 91 if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0;
92 if (arp.operation == htons(ARPOP_REPLY) && 92 if (arp.operation == htons(ARPOP_REPLY) &&
93 bcmp(arp.tHaddr, mac, 6) == 0 && 93 bcmp(arp.tHaddr, mac, 6) == 0 &&
94 *((uint32_t *) arp.sInaddr) == yiaddr) { 94 *((uint32_t *) arp.sInaddr) == yiaddr) {
95 DEBUG(LOG_INFO, "Valid arp reply receved for this address"); 95 DEBUG(LOG_INFO, "Valid arp reply receved for this address");
96 rv = 0; 96 rv = 0;
@@ -101,6 +101,6 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface)
101 time(&prevTime); 101 time(&prevTime);
102 } 102 }
103 close(s); 103 close(s);
104 DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); 104 DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V");
105 return rv; 105 return rv;
106} 106}
diff --git a/networking/udhcp/arpping.h b/networking/udhcp/arpping.h
index 6cbd2979f..6f27d9f75 100644
--- a/networking/udhcp/arpping.h
+++ b/networking/udhcp/arpping.h
@@ -15,7 +15,7 @@ struct arpMsg {
15 u_char h_dest[6]; /* destination ether addr */ 15 u_char h_dest[6]; /* destination ether addr */
16 u_char h_source[6]; /* source ether addr */ 16 u_char h_source[6]; /* source ether addr */
17 u_short h_proto; /* packet type ID field */ 17 u_short h_proto; /* packet type ID field */
18 18
19 /* ARP packet */ 19 /* ARP packet */
20 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */ 20 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */
21 uint16_t ptype; /* protocol type (must be ETH_P_IP) */ 21 uint16_t ptype; /* protocol type (must be ETH_P_IP) */
diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c
index 6838c07e8..5b27004f9 100644
--- a/networking/udhcp/clientpacket.c
+++ b/networking/udhcp/clientpacket.c
@@ -18,7 +18,7 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <string.h> 22#include <string.h>
23#include <sys/socket.h> 23#include <sys/socket.h>
24#include <features.h> 24#include <features.h>
@@ -73,7 +73,7 @@ static void init_packet(struct dhcpMessage *packet, char type)
73 char vendor, length; 73 char vendor, length;
74 char str[sizeof("udhcp "VERSION)]; 74 char str[sizeof("udhcp "VERSION)];
75 } vendor_id = { DHCP_VENDOR, sizeof("udhcp "VERSION) - 1, "udhcp "VERSION}; 75 } vendor_id = { DHCP_VENDOR, sizeof("udhcp "VERSION) - 1, "udhcp "VERSION};
76 76
77 init_header(packet, type); 77 init_header(packet, type);
78 memcpy(packet->chaddr, client_config.arp, 6); 78 memcpy(packet->chaddr, client_config.arp, 6);
79 add_option_string(packet->options, client_config.clientid); 79 add_option_string(packet->options, client_config.clientid);
@@ -112,7 +112,7 @@ int send_discover(unsigned long xid, unsigned long requested)
112 112
113 add_requests(&packet); 113 add_requests(&packet);
114 LOG(LOG_DEBUG, "Sending discover..."); 114 LOG(LOG_DEBUG, "Sending discover...");
115 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 115 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
116 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 116 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
117} 117}
118 118
@@ -128,11 +128,11 @@ int send_selecting(unsigned long xid, unsigned long server, unsigned long reques
128 128
129 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested); 129 add_simple_option(packet.options, DHCP_REQUESTED_IP, requested);
130 add_simple_option(packet.options, DHCP_SERVER_ID, server); 130 add_simple_option(packet.options, DHCP_SERVER_ID, server);
131 131
132 add_requests(&packet); 132 add_requests(&packet);
133 addr.s_addr = requested; 133 addr.s_addr = requested;
134 LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr)); 134 LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr));
135 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 135 return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
136 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 136 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
137} 137}
138 138
@@ -149,12 +149,12 @@ int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr)
149 149
150 add_requests(&packet); 150 add_requests(&packet);
151 LOG(LOG_DEBUG, "Sending renew..."); 151 LOG(LOG_DEBUG, "Sending renew...");
152 if (server) 152 if (server)
153 ret = kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); 153 ret = kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT);
154 else ret = raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, 154 else ret = raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST,
155 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); 155 SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex);
156 return ret; 156 return ret;
157} 157}
158 158
159 159
160/* Unicasts a DHCP release message */ 160/* Unicasts a DHCP release message */
@@ -165,7 +165,7 @@ int send_release(unsigned long server, unsigned long ciaddr)
165 init_packet(&packet, DHCPRELEASE); 165 init_packet(&packet, DHCPRELEASE);
166 packet.xid = random_xid(); 166 packet.xid = random_xid();
167 packet.ciaddr = ciaddr; 167 packet.ciaddr = ciaddr;
168 168
169 add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr); 169 add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr);
170 add_simple_option(packet.options, DHCP_SERVER_ID, server); 170 add_simple_option(packet.options, DHCP_SERVER_ID, server);
171 171
@@ -189,20 +189,20 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
189 usleep(500000); /* possible down interface, looping condition */ 189 usleep(500000); /* possible down interface, looping condition */
190 return -1; 190 return -1;
191 } 191 }
192 192
193 if (bytes < (int) (sizeof(struct iphdr) + sizeof(struct udphdr))) { 193 if (bytes < (int) (sizeof(struct iphdr) + sizeof(struct udphdr))) {
194 DEBUG(LOG_INFO, "message too short, ignoring"); 194 DEBUG(LOG_INFO, "message too short, ignoring");
195 return -2; 195 return -2;
196 } 196 }
197 197
198 if (bytes < ntohs(packet.ip.tot_len)) { 198 if (bytes < ntohs(packet.ip.tot_len)) {
199 DEBUG(LOG_INFO, "Truncated packet"); 199 DEBUG(LOG_INFO, "Truncated packet");
200 return -2; 200 return -2;
201 } 201 }
202 202
203 /* ignore any extra garbage bytes */ 203 /* ignore any extra garbage bytes */
204 bytes = ntohs(packet.ip.tot_len); 204 bytes = ntohs(packet.ip.tot_len);
205 205
206 /* Make sure its the right packet for us, and that it passes sanity checks */ 206 /* Make sure its the right packet for us, and that it passes sanity checks */
207 if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION || 207 if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION ||
208 packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) || 208 packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) ||
@@ -219,7 +219,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
219 DEBUG(LOG_INFO, "bad IP header checksum, ignoring"); 219 DEBUG(LOG_INFO, "bad IP header checksum, ignoring");
220 return -1; 220 return -1;
221 } 221 }
222 222
223 /* verify the UDP checksum by replacing the header with a psuedo header */ 223 /* verify the UDP checksum by replacing the header with a psuedo header */
224 source = packet.ip.saddr; 224 source = packet.ip.saddr;
225 dest = packet.ip.daddr; 225 dest = packet.ip.daddr;
@@ -235,14 +235,14 @@ int get_raw_packet(struct dhcpMessage *payload, int fd)
235 DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring"); 235 DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring");
236 return -2; 236 return -2;
237 } 237 }
238 238
239 memcpy(payload, &(packet.data), bytes - (sizeof(packet.ip) + sizeof(packet.udp))); 239 memcpy(payload, &(packet.data), bytes - (sizeof(packet.ip) + sizeof(packet.udp)));
240 240
241 if (ntohl(payload->cookie) != DHCP_MAGIC) { 241 if (ntohl(payload->cookie) != DHCP_MAGIC) {
242 LOG(LOG_ERR, "received bogus message (bad magic) -- ignoring"); 242 LOG(LOG_ERR, "received bogus message (bad magic) -- ignoring");
243 return -2; 243 return -2;
244 } 244 }
245 DEBUG(LOG_INFO, "oooooh!!! got some!"); 245 DEBUG(LOG_INFO, "oooooh!!! got some!");
246 return bytes - (sizeof(packet.ip) + sizeof(packet.udp)); 246 return bytes - (sizeof(packet.ip) + sizeof(packet.udp));
247 247
248} 248}
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index 8542c664c..5dad7d51c 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -55,7 +55,7 @@ static inline void sanitize_fds(void)
55void background(const char *pidfile) 55void background(const char *pidfile)
56{ 56{
57#ifdef __uClinux__ 57#ifdef __uClinux__
58 LOG(LOG_ERR, "Cannot background in uclinux (yet)"); 58 LOG(LOG_ERR, "Cannot background in uclinux (yet)");
59#else /* __uClinux__ */ 59#else /* __uClinux__ */
60 int pid_fd; 60 int pid_fd;
61 61
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 78eb1c147..677bbfd17 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -43,7 +43,7 @@ void background(const char *pidfile);
43void start_log_and_pid(const char *client_server, const char *pidfile); 43void start_log_and_pid(const char *client_server, const char *pidfile);
44void background(const char *pidfile); 44void background(const char *pidfile);
45void udhcp_logging(int level, const char *fmt, ...); 45void udhcp_logging(int level, const char *fmt, ...);
46 46
47#define LOG(level, str, args...) udhcp_logging(level, str, ## args) 47#define LOG(level, str, args...) udhcp_logging(level, str, ## args)
48 48
49#ifdef UDHCP_DEBUG 49#ifdef UDHCP_DEBUG
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 2ba42d295..dda678933 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -18,7 +18,7 @@
18 * along with this program; if not, write to the Free Software 18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */ 20 */
21 21
22#include <sys/time.h> 22#include <sys/time.h>
23#include <sys/file.h> 23#include <sys/file.h>
24#include <unistd.h> 24#include <unistd.h>
@@ -152,7 +152,7 @@ static void perform_release(void)
152 temp_addr.s_addr = server_addr; 152 temp_addr.s_addr = server_addr;
153 sprintf(buffer, "%s", inet_ntoa(temp_addr)); 153 sprintf(buffer, "%s", inet_ntoa(temp_addr));
154 temp_addr.s_addr = requested_ip; 154 temp_addr.s_addr = requested_ip;
155 LOG(LOG_INFO, "Unicasting a release of %s to %s", 155 LOG(LOG_INFO, "Unicasting a release of %s to %s",
156 inet_ntoa(temp_addr), buffer); 156 inet_ntoa(temp_addr), buffer);
157 send_release(server_addr, requested_ip); /* unicast */ 157 send_release(server_addr, requested_ip); /* unicast */
158 run_script(NULL, "deconfig"); 158 run_script(NULL, "deconfig");
@@ -213,7 +213,7 @@ int main(int argc, char *argv[])
213 int option_index = 0; 213 int option_index = 0;
214 c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); 214 c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
215 if (c == -1) break; 215 if (c == -1) break;
216 216
217 switch (c) { 217 switch (c) {
218 case 'c': 218 case 'c':
219 len = strlen(optarg) > 255 ? 255 : strlen(optarg); 219 len = strlen(optarg) > 255 ? 255 : strlen(optarg);
@@ -269,10 +269,10 @@ int main(int argc, char *argv[])
269 /* Start the log, sanitize fd's, and write a pid file */ 269 /* Start the log, sanitize fd's, and write a pid file */
270 start_log_and_pid("udhcpc", client_config.pidfile); 270 start_log_and_pid("udhcpc", client_config.pidfile);
271 271
272 if (read_interface(client_config.interface, &client_config.ifindex, 272 if (read_interface(client_config.interface, &client_config.ifindex,
273 NULL, client_config.arp) < 0) 273 NULL, client_config.arp) < 0)
274 return 1; 274 return 1;
275 275
276 if (!client_config.clientid) { 276 if (!client_config.clientid) {
277 client_config.clientid = xmalloc(6 + 3); 277 client_config.clientid = xmalloc(6 + 3);
278 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; 278 client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID;
@@ -282,8 +282,8 @@ int main(int argc, char *argv[])
282 } 282 }
283 283
284 /* setup the signal pipe */ 284 /* setup the signal pipe */
285 udhcp_sp_setup(); 285 udhcp_sp_setup();
286 286
287 state = INIT_SELECTING; 287 state = INIT_SELECTING;
288 run_script(NULL, "deconfig"); 288 run_script(NULL, "deconfig");
289 change_mode(LISTEN_RAW); 289 change_mode(LISTEN_RAW);
@@ -321,7 +321,7 @@ int main(int argc, char *argv[])
321 321
322 /* send discover packet */ 322 /* send discover packet */
323 send_discover(xid, requested_ip); /* broadcast */ 323 send_discover(xid, requested_ip); /* broadcast */
324 324
325 timeout = now + ((packet_num == 2) ? 4 : 2); 325 timeout = now + ((packet_num == 2) ? 4 : 2);
326 packet_num++; 326 packet_num++;
327 } else { 327 } else {
@@ -345,7 +345,7 @@ int main(int argc, char *argv[])
345 if (state == RENEW_REQUESTED) 345 if (state == RENEW_REQUESTED)
346 send_renew(xid, server_addr, requested_ip); /* unicast */ 346 send_renew(xid, server_addr, requested_ip); /* unicast */
347 else send_selecting(xid, server_addr, requested_ip); /* broadcast */ 347 else send_selecting(xid, server_addr, requested_ip); /* broadcast */
348 348
349 timeout = now + ((packet_num == 2) ? 10 : 2); 349 timeout = now + ((packet_num == 2) ? 10 : 2);
350 packet_num++; 350 packet_num++;
351 } else { 351 } else {
@@ -373,7 +373,7 @@ int main(int argc, char *argv[])
373 } else { 373 } else {
374 /* send a request packet */ 374 /* send a request packet */
375 send_renew(xid, server_addr, requested_ip); /* unicast */ 375 send_renew(xid, server_addr, requested_ip); /* unicast */
376 376
377 t1 = (t2 - t1) / 2 + t1; 377 t1 = (t2 - t1) / 2 + t1;
378 timeout = t1 + start; 378 timeout = t1 + start;
379 } 379 }
@@ -403,28 +403,28 @@ int main(int argc, char *argv[])
403 } 403 }
404 } else if (retval > 0 && listen_mode != LISTEN_NONE && FD_ISSET(fd, &rfds)) { 404 } else if (retval > 0 && listen_mode != LISTEN_NONE && FD_ISSET(fd, &rfds)) {
405 /* a packet is ready, read it */ 405 /* a packet is ready, read it */
406 406
407 if (listen_mode == LISTEN_KERNEL) 407 if (listen_mode == LISTEN_KERNEL)
408 len = get_packet(&packet, fd); 408 len = get_packet(&packet, fd);
409 else len = get_raw_packet(&packet, fd); 409 else len = get_raw_packet(&packet, fd);
410 410
411 if (len == -1 && errno != EINTR) { 411 if (len == -1 && errno != EINTR) {
412 DEBUG(LOG_INFO, "error on read, %m, reopening socket"); 412 DEBUG(LOG_INFO, "error on read, %m, reopening socket");
413 change_mode(listen_mode); /* just close and reopen */ 413 change_mode(listen_mode); /* just close and reopen */
414 } 414 }
415 if (len < 0) continue; 415 if (len < 0) continue;
416 416
417 if (packet.xid != xid) { 417 if (packet.xid != xid) {
418 DEBUG(LOG_INFO, "Ignoring XID %lx (our xid is %lx)", 418 DEBUG(LOG_INFO, "Ignoring XID %lx (our xid is %lx)",
419 (unsigned long) packet.xid, xid); 419 (unsigned long) packet.xid, xid);
420 continue; 420 continue;
421 } 421 }
422 422
423 if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { 423 if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) {
424 DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring"); 424 DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring");
425 continue; 425 continue;
426 } 426 }
427 427
428 switch (state) { 428 switch (state) {
429 case INIT_SELECTING: 429 case INIT_SELECTING:
430 /* Must be a DHCPOFFER to one of our xid's */ 430 /* Must be a DHCPOFFER to one of our xid's */
@@ -433,7 +433,7 @@ int main(int argc, char *argv[])
433 memcpy(&server_addr, temp, 4); 433 memcpy(&server_addr, temp, 4);
434 xid = packet.xid; 434 xid = packet.xid;
435 requested_ip = packet.yiaddr; 435 requested_ip = packet.yiaddr;
436 436
437 /* enter requesting state */ 437 /* enter requesting state */
438 state = REQUESTING; 438 state = REQUESTING;
439 timeout = now; 439 timeout = now;
@@ -455,14 +455,14 @@ int main(int argc, char *argv[])
455 memcpy(&lease, temp, 4); 455 memcpy(&lease, temp, 4);
456 lease = ntohl(lease); 456 lease = ntohl(lease);
457 } 457 }
458 458
459 /* enter bound state */ 459 /* enter bound state */
460 t1 = lease / 2; 460 t1 = lease / 2;
461 461
462 /* little fixed point for n * .875 */ 462 /* little fixed point for n * .875 */
463 t2 = (lease * 0x7) >> 3; 463 t2 = (lease * 0x7) >> 3;
464 temp_addr.s_addr = packet.yiaddr; 464 temp_addr.s_addr = packet.yiaddr;
465 LOG(LOG_INFO, "Lease of %s obtained, lease time %ld", 465 LOG(LOG_INFO, "Lease of %s obtained, lease time %ld",
466 inet_ntoa(temp_addr), lease); 466 inet_ntoa(temp_addr), lease);
467 start = now; 467 start = now;
468 timeout = t1 + start; 468 timeout = t1 + start;
@@ -472,7 +472,7 @@ int main(int argc, char *argv[])
472 472
473 state = BOUND; 473 state = BOUND;
474 change_mode(LISTEN_NONE); 474 change_mode(LISTEN_NONE);
475 if (client_config.quit_after_lease) 475 if (client_config.quit_after_lease)
476 return 0; 476 return 0;
477 if (!client_config.foreground) 477 if (!client_config.foreground)
478 client_background(); 478 client_background();
@@ -492,10 +492,10 @@ int main(int argc, char *argv[])
492 } 492 }
493 break; 493 break;
494 /* case BOUND, RELEASED: - ignore all packets */ 494 /* case BOUND, RELEASED: - ignore all packets */
495 } 495 }
496 } else if (retval > 0 && (sig = udhcp_sp_read(&rfds))) { 496 } else if (retval > 0 && (sig = udhcp_sp_read(&rfds))) {
497 switch (sig) { 497 switch (sig) {
498 case SIGUSR1: 498 case SIGUSR1:
499 perform_renew(); 499 perform_renew();
500 break; 500 break;
501 case SIGUSR2: 501 case SIGUSR2:
@@ -506,12 +506,12 @@ int main(int argc, char *argv[])
506 return 0; 506 return 0;
507 } 507 }
508 } else if (retval == -1 && errno == EINTR) { 508 } else if (retval == -1 && errno == EINTR) {
509 /* a signal was caught */ 509 /* a signal was caught */
510 } else { 510 } else {
511 /* An error occured */ 511 /* An error occured */
512 DEBUG(LOG_ERR, "Error on select"); 512 DEBUG(LOG_ERR, "Error on select");
513 } 513 }
514 514
515 } 515 }
516 return 0; 516 return 0;
517} 517}
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 8c944f243..6f38f07f7 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -51,12 +51,12 @@ struct dhcpOfferedAddr *leases;
51struct server_config_t server_config; 51struct server_config_t server_config;
52 52
53 53
54#ifdef COMBINED_BINARY 54#ifdef COMBINED_BINARY
55int udhcpd_main(int argc, char *argv[]) 55int udhcpd_main(int argc, char *argv[])
56#else 56#else
57int main(int argc, char *argv[]) 57int main(int argc, char *argv[])
58#endif 58#endif
59{ 59{
60 fd_set rfds; 60 fd_set rfds;
61 struct timeval tv; 61 struct timeval tv;
62 int server_socket = -1; 62 int server_socket = -1;
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
70 struct dhcpOfferedAddr *lease; 70 struct dhcpOfferedAddr *lease;
71 int max_sock; 71 int max_sock;
72 unsigned long num_ips; 72 unsigned long num_ips;
73 73
74 memset(&server_config, 0, sizeof(struct server_config_t)); 74 memset(&server_config, 0, sizeof(struct server_config_t));
75 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); 75 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
76 76
@@ -82,7 +82,7 @@ int main(int argc, char *argv[])
82 server_config.lease = ntohl(server_config.lease); 82 server_config.lease = ntohl(server_config.lease);
83 } 83 }
84 else server_config.lease = LEASE_TIME; 84 else server_config.lease = LEASE_TIME;
85 85
86 /* Sanity check */ 86 /* Sanity check */
87 num_ips = ntohl(server_config.end) - ntohl(server_config.start); 87 num_ips = ntohl(server_config.end) - ntohl(server_config.start);
88 if (server_config.max_leases > num_ips) { 88 if (server_config.max_leases > num_ips) {
@@ -113,7 +113,7 @@ int main(int argc, char *argv[])
113 if ((server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface)) < 0) { 113 if ((server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface)) < 0) {
114 LOG(LOG_ERR, "FATAL: couldn't create server socket, %m"); 114 LOG(LOG_ERR, "FATAL: couldn't create server socket, %m");
115 return 2; 115 return 2;
116 } 116 }
117 117
118 max_sock = udhcp_sp_fd_set(&rfds, server_socket); 118 max_sock = udhcp_sp_fd_set(&rfds, server_socket);
119 if (server_config.auto_time) { 119 if (server_config.auto_time) {
@@ -121,7 +121,7 @@ int main(int argc, char *argv[])
121 tv.tv_usec = 0; 121 tv.tv_usec = 0;
122 } 122 }
123 if (!server_config.auto_time || tv.tv_sec > 0) { 123 if (!server_config.auto_time || tv.tv_sec > 0) {
124 retval = select(max_sock + 1, &rfds, NULL, NULL, 124 retval = select(max_sock + 1, &rfds, NULL, NULL,
125 server_config.auto_time ? &tv : NULL); 125 server_config.auto_time ? &tv : NULL);
126 } else retval = 0; /* If we already timed out, fall through */ 126 } else retval = 0; /* If we already timed out, fall through */
127 127
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
133 DEBUG(LOG_INFO, "error on select"); 133 DEBUG(LOG_INFO, "error on select");
134 continue; 134 continue;
135 } 135 }
136 136
137 switch (udhcp_sp_read(&rfds)) { 137 switch (udhcp_sp_read(&rfds)) {
138 case SIGUSR1: 138 case SIGUSR1:
139 LOG(LOG_INFO, "Received a SIGUSR1"); 139 LOG(LOG_INFO, "Received a SIGUSR1");
@@ -161,17 +161,17 @@ int main(int argc, char *argv[])
161 DEBUG(LOG_ERR, "couldn't get option from packet, ignoring"); 161 DEBUG(LOG_ERR, "couldn't get option from packet, ignoring");
162 continue; 162 continue;
163 } 163 }
164 164
165 /* ADDME: look for a static lease */ 165 /* ADDME: look for a static lease */
166 lease = find_lease_by_chaddr(packet.chaddr); 166 lease = find_lease_by_chaddr(packet.chaddr);
167 switch (state[0]) { 167 switch (state[0]) {
168 case DHCPDISCOVER: 168 case DHCPDISCOVER:
169 DEBUG(LOG_INFO,"received DISCOVER"); 169 DEBUG(LOG_INFO,"received DISCOVER");
170 170
171 if (sendOffer(&packet) < 0) { 171 if (sendOffer(&packet) < 0) {
172 LOG(LOG_ERR, "send OFFER failed"); 172 LOG(LOG_ERR, "send OFFER failed");
173 } 173 }
174 break; 174 break;
175 case DHCPREQUEST: 175 case DHCPREQUEST:
176 DEBUG(LOG_INFO, "received REQUEST"); 176 DEBUG(LOG_INFO, "received REQUEST");
177 177
@@ -180,12 +180,12 @@ int main(int argc, char *argv[])
180 180
181 if (requested) memcpy(&requested_align, requested, 4); 181 if (requested) memcpy(&requested_align, requested, 4);
182 if (server_id) memcpy(&server_id_align, server_id, 4); 182 if (server_id) memcpy(&server_id_align, server_id, 4);
183 183
184 if (lease) { /*ADDME: or static lease */ 184 if (lease) { /*ADDME: or static lease */
185 if (server_id) { 185 if (server_id) {
186 /* SELECTING State */ 186 /* SELECTING State */
187 DEBUG(LOG_INFO, "server_id = %08x", ntohl(server_id_align)); 187 DEBUG(LOG_INFO, "server_id = %08x", ntohl(server_id_align));
188 if (server_id_align == server_config.server && requested && 188 if (server_id_align == server_config.server && requested &&
189 requested_align == lease->yiaddr) { 189 requested_align == lease->yiaddr) {
190 sendACK(&packet, lease->yiaddr); 190 sendACK(&packet, lease->yiaddr);
191 } 191 }
@@ -203,9 +203,9 @@ int main(int argc, char *argv[])
203 /* don't know what to do!!!! */ 203 /* don't know what to do!!!! */
204 sendNAK(&packet); 204 sendNAK(&packet);
205 } 205 }
206 } 206 }
207 } 207 }
208 208
209 /* what to do if we have no record of the client */ 209 /* what to do if we have no record of the client */
210 } else if (server_id) { 210 } else if (server_id) {
211 /* SELECTING State */ 211 /* SELECTING State */
@@ -218,7 +218,7 @@ int main(int argc, char *argv[])
218 memset(lease->chaddr, 0, 16); 218 memset(lease->chaddr, 0, 16);
219 /* make some contention for this address */ 219 /* make some contention for this address */
220 } else sendNAK(&packet); 220 } else sendNAK(&packet);
221 } else if (requested_align < server_config.start || 221 } else if (requested_align < server_config.start ||
222 requested_align > server_config.end) { 222 requested_align > server_config.end) {
223 sendNAK(&packet); 223 sendNAK(&packet);
224 } /* else remain silent */ 224 } /* else remain silent */
@@ -232,7 +232,7 @@ int main(int argc, char *argv[])
232 if (lease) { 232 if (lease) {
233 memset(lease->chaddr, 0, 16); 233 memset(lease->chaddr, 0, 16);
234 lease->expires = time(0) + server_config.decline_time; 234 lease->expires = time(0) + server_config.decline_time;
235 } 235 }
236 break; 236 break;
237 case DHCPRELEASE: 237 case DHCPRELEASE:
238 DEBUG(LOG_INFO,"received RELEASE"); 238 DEBUG(LOG_INFO,"received RELEASE");
@@ -241,7 +241,7 @@ int main(int argc, char *argv[])
241 case DHCPINFORM: 241 case DHCPINFORM:
242 DEBUG(LOG_INFO,"received INFORM"); 242 DEBUG(LOG_INFO,"received INFORM");
243 send_inform(&packet); 243 send_inform(&packet);
244 break; 244 break;
245 default: 245 default:
246 LOG(LOG_WARNING, "unsupported DHCP message (%02x) -- ignoring", state[0]); 246 LOG(LOG_WARNING, "unsupported DHCP message (%02x) -- ignoring", state[0]);
247 } 247 }
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 925634461..39658a8ff 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -124,10 +124,10 @@ struct server_config_t {
124 uint32_t siaddr; /* next server bootp option */ 124 uint32_t siaddr; /* next server bootp option */
125 char *sname; /* bootp server name */ 125 char *sname; /* bootp server name */
126 char *boot_file; /* bootp boot file option */ 126 char *boot_file; /* bootp boot file option */
127}; 127};
128 128
129extern struct server_config_t server_config; 129extern struct server_config_t server_config;
130extern struct dhcpOfferedAddr *leases; 130extern struct dhcpOfferedAddr *leases;
131 131
132 132
133#endif 133#endif
diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c
index e2b19315d..a9036dfbd 100644
--- a/networking/udhcp/dumpleases.c
+++ b/networking/udhcp/dumpleases.c
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
47 const char *file = LEASES_FILE; 47 const char *file = LEASES_FILE;
48 struct dhcpOfferedAddr lease; 48 struct dhcpOfferedAddr lease;
49 struct in_addr addr; 49 struct in_addr addr;
50 50
51 static const struct option options[] = { 51 static const struct option options[] = {
52 {"absolute", 0, 0, 'a'}, 52 {"absolute", 0, 0, 'a'},
53 {"remaining", 0, 0, 'r'}, 53 {"remaining", 0, 0, 'r'},
@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
59 int option_index = 0; 59 int option_index = 0;
60 c = getopt_long(argc, argv, "arf:", options, &option_index); 60 c = getopt_long(argc, argv, "arf:", options, &option_index);
61 if (c == -1) break; 61 if (c == -1) break;
62 62
63 switch (c) { 63 switch (c) {
64 case 'a': mode = ABSOLUTE; break; 64 case 'a': mode = ABSOLUTE; break;
65 case 'r': mode = REMAINING; break; 65 case 'r': mode = REMAINING; break;
@@ -70,10 +70,10 @@ int main(int argc, char *argv[])
70 show_usage(); 70 show_usage();
71 } 71 }
72 } 72 }
73 73
74 fp = xfopen(file, "r"); 74 fp = xfopen(file, "r");
75 75
76 printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at"); 76 printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at");
77 /* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */ 77 /* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */
78 while (fread(&lease, sizeof(lease), 1, fp)) { 78 while (fread(&lease, sizeof(lease), 1, fp)) {
79 79
@@ -105,6 +105,6 @@ int main(int argc, char *argv[])
105 } else printf("%s", ctime(&expires)); 105 } else printf("%s", ctime(&expires));
106 } 106 }
107 fclose(fp); 107 fclose(fp);
108 108
109 return 0; 109 return 0;
110} 110}
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 0802bb316..89287ca2d 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * files.c -- DHCP server file manipulation * 2 * files.c -- DHCP server file manipulation *
3 * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 3 * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001
4 */ 4 */
5 5
6#include <sys/socket.h> 6#include <sys/socket.h>
7#include <arpa/inet.h> 7#include <arpa/inet.h>
8#include <string.h> 8#include <string.h>
@@ -16,7 +16,7 @@
16#include "options.h" 16#include "options.h"
17#include "common.h" 17#include "common.h"
18 18
19/* 19/*
20 * Domain names may have 254 chars, and string options can be 254 20 * Domain names may have 254 chars, and string options can be 254
21 * chars long. However, 80 bytes will be enough for most, and won't 21 * chars long. However, 80 bytes will be enough for most, and won't
22 * hog up memory. If you have a special application, change it 22 * hog up memory. If you have a special application, change it
@@ -31,7 +31,7 @@ static int read_ip(const char *line, void *arg)
31 int retval = 1; 31 int retval = 1;
32 32
33 if (!inet_aton(line, addr)) { 33 if (!inet_aton(line, addr)) {
34 if ((host = gethostbyname(line))) 34 if ((host = gethostbyname(line)))
35 addr->s_addr = *((unsigned long *) host->h_addr_list[0]); 35 addr->s_addr = *((unsigned long *) host->h_addr_list[0]);
36 else retval = 0; 36 else retval = 0;
37 } 37 }
@@ -42,10 +42,10 @@ static int read_ip(const char *line, void *arg)
42static int read_str(const char *line, void *arg) 42static int read_str(const char *line, void *arg)
43{ 43{
44 char **dest = arg; 44 char **dest = arg;
45 45
46 if (*dest) free(*dest); 46 if (*dest) free(*dest);
47 *dest = strdup(line); 47 *dest = strdup(line);
48 48
49 return 1; 49 return 1;
50} 50}
51 51
@@ -69,7 +69,7 @@ static int read_yn(const char *line, void *arg)
69 else if (!strcasecmp("no", line)) 69 else if (!strcasecmp("no", line))
70 *dest = 0; 70 *dest = 0;
71 else retval = 0; 71 else retval = 0;
72 72
73 return retval; 73 return retval;
74} 74}
75 75
@@ -89,11 +89,11 @@ static int read_opt(const char *const_line, void *arg)
89 /* Cheat, the only const line we'll actually get is "" */ 89 /* Cheat, the only const line we'll actually get is "" */
90 line = (char *) const_line; 90 line = (char *) const_line;
91 if (!(opt = strtok(line, " \t="))) return 0; 91 if (!(opt = strtok(line, " \t="))) return 0;
92 92
93 for (option = dhcp_options; option->code; option++) 93 for (option = dhcp_options; option->code; option++)
94 if (!strcasecmp(option->name, opt)) 94 if (!strcasecmp(option->name, opt))
95 break; 95 break;
96 96
97 if (!option->code) return 0; 97 if (!option->code) return 0;
98 98
99 do { 99 do {
@@ -134,17 +134,17 @@ static int read_opt(const char *const_line, void *arg)
134 retval = (endptr[0] == '\0'); 134 retval = (endptr[0] == '\0');
135 break; 135 break;
136 case OPTION_U32: 136 case OPTION_U32:
137 *result_u32 = htonl(strtoul(val, &endptr, 0)); 137 *result_u32 = htonl(strtoul(val, &endptr, 0));
138 retval = (endptr[0] == '\0'); 138 retval = (endptr[0] == '\0');
139 break; 139 break;
140 case OPTION_S32: 140 case OPTION_S32:
141 *result_u32 = htonl(strtol(val, &endptr, 0)); 141 *result_u32 = htonl(strtol(val, &endptr, 0));
142 retval = (endptr[0] == '\0'); 142 retval = (endptr[0] == '\0');
143 break; 143 break;
144 default: 144 default:
145 break; 145 break;
146 } 146 }
147 if (retval) 147 if (retval)
148 attach_option(opt_list, option, opt, length); 148 attach_option(opt_list, option, opt, length);
149 } while (retval && option->flags & OPTION_LIST); 149 } while (retval && option->flags & OPTION_LIST);
150 return retval; 150 return retval;
@@ -193,7 +193,7 @@ int read_config(const char *file)
193 LOG(LOG_ERR, "unable to open config file: %s", file); 193 LOG(LOG_ERR, "unable to open config file: %s", file);
194 return 0; 194 return 0;
195 } 195 }
196 196
197 while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) { 197 while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) {
198 lm++; 198 lm++;
199 if (strchr(buffer, '\n')) *(strchr(buffer, '\n')) = '\0'; 199 if (strchr(buffer, '\n')) *(strchr(buffer, '\n')) = '\0';
@@ -203,14 +203,14 @@ int read_config(const char *file)
203 if (strchr(buffer, '#')) *(strchr(buffer, '#')) = '\0'; 203 if (strchr(buffer, '#')) *(strchr(buffer, '#')) = '\0';
204 204
205 if (!(token = strtok(buffer, " \t"))) continue; 205 if (!(token = strtok(buffer, " \t"))) continue;
206 if (!(line = strtok(NULL, ""))) continue; 206 if (!(line = strtok(NULL, ""))) continue;
207 207
208 /* eat leading whitespace */ 208 /* eat leading whitespace */
209 line = line + strspn(line, " \t="); 209 line = line + strspn(line, " \t=");
210 /* eat trailing whitespace */ 210 /* eat trailing whitespace */
211 for (i = strlen(line); i > 0 && isspace(line[i - 1]); i--); 211 for (i = strlen(line); i > 0 && isspace(line[i - 1]); i--);
212 line[i] = '\0'; 212 line[i] = '\0';
213 213
214 for (i = 0; keywords[i].keyword[0]; i++) 214 for (i = 0; keywords[i].keyword[0]; i++)
215 if (!strcasecmp(token, keywords[i].keyword)) 215 if (!strcasecmp(token, keywords[i].keyword))
216 if (!keywords[i].handler(line, keywords[i].var)) { 216 if (!keywords[i].handler(line, keywords[i].var)) {
@@ -232,12 +232,12 @@ void write_leases(void)
232 char buf[255]; 232 char buf[255];
233 time_t curr = time(0); 233 time_t curr = time(0);
234 unsigned long tmp_time; 234 unsigned long tmp_time;
235 235
236 if (!(fp = fopen(server_config.lease_file, "w"))) { 236 if (!(fp = fopen(server_config.lease_file, "w"))) {
237 LOG(LOG_ERR, "Unable to open %s for writing", server_config.lease_file); 237 LOG(LOG_ERR, "Unable to open %s for writing", server_config.lease_file);
238 return; 238 return;
239 } 239 }
240 240
241 for (i = 0; i < server_config.max_leases; i++) { 241 for (i = 0; i < server_config.max_leases; i++) {
242 if (leases[i].yiaddr != 0) { 242 if (leases[i].yiaddr != 0) {
243 243
@@ -257,7 +257,7 @@ void write_leases(void)
257 } 257 }
258 } 258 }
259 fclose(fp); 259 fclose(fp);
260 260
261 if (server_config.notify_file) { 261 if (server_config.notify_file) {
262 sprintf(buf, "%s %s", server_config.notify_file, server_config.lease_file); 262 sprintf(buf, "%s %s", server_config.notify_file, server_config.lease_file);
263 system(buf); 263 system(buf);
@@ -270,12 +270,12 @@ void read_leases(const char *file)
270 FILE *fp; 270 FILE *fp;
271 unsigned int i = 0; 271 unsigned int i = 0;
272 struct dhcpOfferedAddr lease; 272 struct dhcpOfferedAddr lease;
273 273
274 if (!(fp = fopen(file, "r"))) { 274 if (!(fp = fopen(file, "r"))) {
275 LOG(LOG_ERR, "Unable to open %s for reading", file); 275 LOG(LOG_ERR, "Unable to open %s for reading", file);
276 return; 276 return;
277 } 277 }
278 278
279 while (i < server_config.max_leases && (fread(&lease, sizeof lease, 1, fp) == 1)) { 279 while (i < server_config.max_leases && (fread(&lease, sizeof lease, 1, fp) == 1)) {
280 /* ADDME: is it a static lease */ 280 /* ADDME: is it a static lease */
281 if (lease.yiaddr >= server_config.start && lease.yiaddr <= server_config.end) { 281 if (lease.yiaddr >= server_config.start && lease.yiaddr <= server_config.end) {
@@ -284,7 +284,7 @@ void read_leases(const char *file)
284 if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) { 284 if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) {
285 LOG(LOG_WARNING, "Too many leases while loading %s\n", file); 285 LOG(LOG_WARNING, "Too many leases while loading %s\n", file);
286 break; 286 break;
287 } 287 }
288 i++; 288 i++;
289 } 289 }
290 } 290 }
diff --git a/networking/udhcp/frontend.c b/networking/udhcp/frontend.c
index de5779508..fa77ab977 100644
--- a/networking/udhcp/frontend.c
+++ b/networking/udhcp/frontend.c
@@ -7,10 +7,10 @@ int main(int argc, char *argv[])
7{ 7{
8 int ret = 0; 8 int ret = 0;
9 char *base = strrchr(argv[0], '/'); 9 char *base = strrchr(argv[0], '/');
10 10
11 if (strstr(base ? (base + 1) : argv[0], "dhcpd")) 11 if (strstr(base ? (base + 1) : argv[0], "dhcpd"))
12 ret = udhcpd_main(argc, argv); 12 ret = udhcpd_main(argc, argv);
13 else ret = udhcpc_main(argc, argv); 13 else ret = udhcpc_main(argc, argv);
14 14
15 return ret; 15 return ret;
16} 16}
diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c
index dce056654..d478880a3 100644
--- a/networking/udhcp/leases.c
+++ b/networking/udhcp/leases.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * leases.c -- tools to manage DHCP leases 2 * leases.c -- tools to manage DHCP leases
3 * Russ Dill <Russ.Dill@asu.edu> July 2001 3 * Russ Dill <Russ.Dill@asu.edu> July 2001
4 */ 4 */
5 5
@@ -23,9 +23,9 @@ uint8_t blank_chaddr[] = {[0 ... 15] = 0};
23void clear_lease(uint8_t *chaddr, uint32_t yiaddr) 23void clear_lease(uint8_t *chaddr, uint32_t yiaddr)
24{ 24{
25 unsigned int i, j; 25 unsigned int i, j;
26 26
27 for (j = 0; j < 16 && !chaddr[j]; j++); 27 for (j = 0; j < 16 && !chaddr[j]; j++);
28 28
29 for (i = 0; i < server_config.max_leases; i++) 29 for (i = 0; i < server_config.max_leases; i++)
30 if ((j != 16 && !memcmp(leases[i].chaddr, chaddr, 16)) || 30 if ((j != 16 && !memcmp(leases[i].chaddr, chaddr, 16)) ||
31 (yiaddr && leases[i].yiaddr == yiaddr)) { 31 (yiaddr && leases[i].yiaddr == yiaddr)) {
@@ -38,18 +38,18 @@ void clear_lease(uint8_t *chaddr, uint32_t yiaddr)
38struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease) 38struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease)
39{ 39{
40 struct dhcpOfferedAddr *oldest; 40 struct dhcpOfferedAddr *oldest;
41 41
42 /* clean out any old ones */ 42 /* clean out any old ones */
43 clear_lease(chaddr, yiaddr); 43 clear_lease(chaddr, yiaddr);
44 44
45 oldest = oldest_expired_lease(); 45 oldest = oldest_expired_lease();
46 46
47 if (oldest) { 47 if (oldest) {
48 memcpy(oldest->chaddr, chaddr, 16); 48 memcpy(oldest->chaddr, chaddr, 16);
49 oldest->yiaddr = yiaddr; 49 oldest->yiaddr = yiaddr;
50 oldest->expires = time(0) + lease; 50 oldest->expires = time(0) + lease;
51 } 51 }
52 52
53 return oldest; 53 return oldest;
54} 54}
55 55
@@ -58,7 +58,7 @@ struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned lon
58int lease_expired(struct dhcpOfferedAddr *lease) 58int lease_expired(struct dhcpOfferedAddr *lease)
59{ 59{
60 return (lease->expires < (unsigned long) time(0)); 60 return (lease->expires < (unsigned long) time(0));
61} 61}
62 62
63 63
64/* Find the oldest expired lease, NULL if there are no expired leases */ 64/* Find the oldest expired lease, NULL if there are no expired leases */
@@ -68,14 +68,14 @@ struct dhcpOfferedAddr *oldest_expired_lease(void)
68 unsigned long oldest_lease = time(0); 68 unsigned long oldest_lease = time(0);
69 unsigned int i; 69 unsigned int i;
70 70
71 71
72 for (i = 0; i < server_config.max_leases; i++) 72 for (i = 0; i < server_config.max_leases; i++)
73 if (oldest_lease > leases[i].expires) { 73 if (oldest_lease > leases[i].expires) {
74 oldest_lease = leases[i].expires; 74 oldest_lease = leases[i].expires;
75 oldest = &(leases[i]); 75 oldest = &(leases[i]);
76 } 76 }
77 return oldest; 77 return oldest;
78 78
79} 79}
80 80
81 81
@@ -86,7 +86,7 @@ struct dhcpOfferedAddr *find_lease_by_chaddr(uint8_t *chaddr)
86 86
87 for (i = 0; i < server_config.max_leases; i++) 87 for (i = 0; i < server_config.max_leases; i++)
88 if (!memcmp(leases[i].chaddr, chaddr, 16)) return &(leases[i]); 88 if (!memcmp(leases[i].chaddr, chaddr, 16)) return &(leases[i]);
89 89
90 return NULL; 90 return NULL;
91} 91}
92 92
@@ -98,7 +98,7 @@ struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr)
98 98
99 for (i = 0; i < server_config.max_leases; i++) 99 for (i = 0; i < server_config.max_leases; i++)
100 if (leases[i].yiaddr == yiaddr) return &(leases[i]); 100 if (leases[i].yiaddr == yiaddr) return &(leases[i]);
101 101
102 return NULL; 102 return NULL;
103} 103}
104 104
@@ -120,10 +120,10 @@ static int check_ip(uint32_t addr)
120 120
121/* find an assignable address, it check_expired is true, we check all the expired leases as well. 121/* find an assignable address, it check_expired is true, we check all the expired leases as well.
122 * Maybe this should try expired leases by age... */ 122 * Maybe this should try expired leases by age... */
123uint32_t find_address(int check_expired) 123uint32_t find_address(int check_expired)
124{ 124{
125 uint32_t addr, ret; 125 uint32_t addr, ret;
126 struct dhcpOfferedAddr *lease = NULL; 126 struct dhcpOfferedAddr *lease = NULL;
127 127
128 addr = ntohl(server_config.start); /* addr is in host order here */ 128 addr = ntohl(server_config.start); /* addr is in host order here */
129 for (;addr <= ntohl(server_config.end); addr++) { 129 for (;addr <= ntohl(server_config.end); addr++) {
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 1bdf25708..d75bc5aff 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -1,8 +1,8 @@
1/* 1/*
2 * options.c -- DHCP server option packet tools 2 * options.c -- DHCP server option packet tools
3 * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 3 * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001
4 */ 4 */
5 5
6#include <stdlib.h> 6#include <stdlib.h>
7#include <string.h> 7#include <string.h>
8 8
@@ -64,7 +64,7 @@ uint8_t *get_option(struct dhcpMessage *packet, int code)
64 int i, length; 64 int i, length;
65 uint8_t *optionptr; 65 uint8_t *optionptr;
66 int over = 0, done = 0, curr = OPTION_FIELD; 66 int over = 0, done = 0, curr = OPTION_FIELD;
67 67
68 optionptr = packet->options; 68 optionptr = packet->options;
69 i = 0; 69 i = 0;
70 length = 308; 70 length = 308;
@@ -79,7 +79,7 @@ uint8_t *get_option(struct dhcpMessage *packet, int code)
79 return NULL; 79 return NULL;
80 } 80 }
81 return optionptr + i + 2; 81 return optionptr + i + 2;
82 } 82 }
83 switch (optionptr[i + OPT_CODE]) { 83 switch (optionptr[i + OPT_CODE]) {
84 case DHCP_PADDING: 84 case DHCP_PADDING:
85 i++; 85 i++;
@@ -114,10 +114,10 @@ uint8_t *get_option(struct dhcpMessage *packet, int code)
114 114
115 115
116/* return the position of the 'end' option (no bounds checking) */ 116/* return the position of the 'end' option (no bounds checking) */
117int end_option(uint8_t *optionptr) 117int end_option(uint8_t *optionptr)
118{ 118{
119 int i = 0; 119 int i = 0;
120 120
121 while (optionptr[i] != DHCP_END) { 121 while (optionptr[i] != DHCP_END) {
122 if (optionptr[i] == DHCP_PADDING) i++; 122 if (optionptr[i] == DHCP_PADDING) i++;
123 else i += optionptr[i + OPT_LEN] + 2; 123 else i += optionptr[i + OPT_LEN] + 2;
@@ -131,7 +131,7 @@ int end_option(uint8_t *optionptr)
131int add_option_string(uint8_t *optionptr, uint8_t *string) 131int add_option_string(uint8_t *optionptr, uint8_t *string)
132{ 132{
133 int end = end_option(optionptr); 133 int end = end_option(optionptr);
134 134
135 /* end position + string length + option code/length + end option */ 135 /* end position + string length + option code/length + end option */
136 if (end + string[OPT_LEN] + 2 + 1 >= 308) { 136 if (end + string[OPT_LEN] + 2 + 1 >= 308) {
137 LOG(LOG_ERR, "Option 0x%02x did not fit into the packet!", string[OPT_CODE]); 137 LOG(LOG_ERR, "Option 0x%02x did not fit into the packet!", string[OPT_CODE]);
@@ -162,12 +162,12 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
162 if (dhcp_options[i].code == code) { 162 if (dhcp_options[i].code == code) {
163 length = option_lengths[dhcp_options[i].flags & TYPE_MASK]; 163 length = option_lengths[dhcp_options[i].flags & TYPE_MASK];
164 } 164 }
165 165
166 if (!length) { 166 if (!length) {
167 DEBUG(LOG_ERR, "Could not add option 0x%02x", code); 167 DEBUG(LOG_ERR, "Could not add option 0x%02x", code);
168 return 0; 168 return 0;
169 } 169 }
170 170
171 option[OPT_CODE] = code; 171 option[OPT_CODE] = code;
172 option[OPT_LEN] = length; 172 option[OPT_LEN] = length;
173 173
@@ -202,7 +202,7 @@ void attach_option(struct option_set **opt_list, struct dhcp_option *option, cha
202 DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name); 202 DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name);
203 if (option->flags & OPTION_LIST) { 203 if (option->flags & OPTION_LIST) {
204 if (existing->data[OPT_LEN] + length <= 255) { 204 if (existing->data[OPT_LEN] + length <= 255) {
205 existing->data = realloc(existing->data, 205 existing->data = realloc(existing->data,
206 existing->data[OPT_LEN] + length + 2); 206 existing->data[OPT_LEN] + length + 2);
207 memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); 207 memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
208 existing->data[OPT_LEN] += length; 208 existing->data[OPT_LEN] += length;
@@ -210,19 +210,19 @@ void attach_option(struct option_set **opt_list, struct dhcp_option *option, cha
210 } /* else, ignore the new data */ 210 } /* else, ignore the new data */
211 } else { 211 } else {
212 DEBUG(LOG_INFO, "Attaching option %s to list", option->name); 212 DEBUG(LOG_INFO, "Attaching option %s to list", option->name);
213 213
214 /* make a new option */ 214 /* make a new option */
215 new = xmalloc(sizeof(struct option_set)); 215 new = xmalloc(sizeof(struct option_set));
216 new->data = xmalloc(length + 2); 216 new->data = xmalloc(length + 2);
217 new->data[OPT_CODE] = option->code; 217 new->data[OPT_CODE] = option->code;
218 new->data[OPT_LEN] = length; 218 new->data[OPT_LEN] = length;
219 memcpy(new->data + 2, buffer, length); 219 memcpy(new->data + 2, buffer, length);
220 220
221 curr = opt_list; 221 curr = opt_list;
222 while (*curr && (*curr)->data[OPT_CODE] < option->code) 222 while (*curr && (*curr)->data[OPT_CODE] < option->code)
223 curr = &(*curr)->next; 223 curr = &(*curr)->next;
224 224
225 new->next = *curr; 225 new->next = *curr;
226 *curr = new; 226 *curr = new;
227 } 227 }
228} 228}
diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c
index a3c7ae153..7cbd83a35 100644
--- a/networking/udhcp/packet.c
+++ b/networking/udhcp/packet.c
@@ -66,7 +66,7 @@ int get_packet(struct dhcpMessage *packet, int fd)
66 return -2; 66 return -2;
67 } 67 }
68 DEBUG(LOG_INFO, "Received a packet"); 68 DEBUG(LOG_INFO, "Received a packet");
69 69
70 if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { 70 if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) {
71 for (i = 0; broken_vendors[i][0]; i++) { 71 for (i = 0; broken_vendors[i][0]; i++) {
72 if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && 72 if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) &&
@@ -77,7 +77,7 @@ int get_packet(struct dhcpMessage *packet, int fd)
77 } 77 }
78 } 78 }
79 } 79 }
80 80
81 81
82 return bytes; 82 return bytes;
83} 83}
@@ -126,10 +126,10 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
126 DEBUG(LOG_ERR, "socket call failed: %m"); 126 DEBUG(LOG_ERR, "socket call failed: %m");
127 return -1; 127 return -1;
128 } 128 }
129 129
130 memset(&dest, 0, sizeof(dest)); 130 memset(&dest, 0, sizeof(dest));
131 memset(&packet, 0, sizeof(packet)); 131 memset(&packet, 0, sizeof(packet));
132 132
133 dest.sll_family = AF_PACKET; 133 dest.sll_family = AF_PACKET;
134 dest.sll_protocol = htons(ETH_P_IP); 134 dest.sll_protocol = htons(ETH_P_IP);
135 dest.sll_ifindex = ifindex; 135 dest.sll_ifindex = ifindex;
@@ -150,7 +150,7 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port,
150 packet.ip.tot_len = packet.udp.len; 150 packet.ip.tot_len = packet.udp.len;
151 memcpy(&(packet.data), payload, sizeof(struct dhcpMessage)); 151 memcpy(&(packet.data), payload, sizeof(struct dhcpMessage));
152 packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet)); 152 packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet));
153 153
154 packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet)); 154 packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet));
155 packet.ip.ihl = sizeof(packet.ip) >> 2; 155 packet.ip.ihl = sizeof(packet.ip) >> 2;
156 packet.ip.version = IPVERSION; 156 packet.ip.version = IPVERSION;
@@ -173,10 +173,10 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po
173 int n = 1; 173 int n = 1;
174 int fd, result; 174 int fd, result;
175 struct sockaddr_in client; 175 struct sockaddr_in client;
176 176
177 if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) 177 if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
178 return -1; 178 return -1;
179 179
180 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) 180 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1)
181 return -1; 181 return -1;
182 182
@@ -191,7 +191,7 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po
191 memset(&client, 0, sizeof(client)); 191 memset(&client, 0, sizeof(client));
192 client.sin_family = AF_INET; 192 client.sin_family = AF_INET;
193 client.sin_port = htons(dest_port); 193 client.sin_port = htons(dest_port);
194 client.sin_addr.s_addr = dest_ip; 194 client.sin_addr.s_addr = dest_ip;
195 195
196 if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) 196 if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1)
197 return -1; 197 return -1;
@@ -199,4 +199,4 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po
199 result = write(fd, payload, sizeof(struct dhcpMessage)); 199 result = write(fd, payload, sizeof(struct dhcpMessage));
200 close(fd); 200 close(fd);
201 return result; 201 return result;
202} 202}
diff --git a/networking/udhcp/packet.h b/networking/udhcp/packet.h
index 22c4d09c3..f5859e824 100644
--- a/networking/udhcp/packet.h
+++ b/networking/udhcp/packet.h
@@ -20,7 +20,7 @@ struct dhcpMessage {
20 uint8_t sname[64]; 20 uint8_t sname[64];
21 uint8_t file[128]; 21 uint8_t file[128];
22 uint32_t cookie; 22 uint32_t cookie;
23 uint8_t options[308]; /* 312 - cookie */ 23 uint8_t options[308]; /* 312 - cookie */
24}; 24};
25 25
26struct udp_dhcp_packet { 26struct udp_dhcp_packet {
diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c
index b7d78624c..cae4db7af 100644
--- a/networking/udhcp/script.c
+++ b/networking/udhcp/script.c
@@ -1,6 +1,6 @@
1/* script.c 1/* script.c
2 * 2 *
3 * Functions to call the DHCP client notification scripts 3 * Functions to call the DHCP client notification scripts
4 * 4 *
5 * Russ Dill <Russ.Dill@asu.edu> July 2001 5 * Russ Dill <Russ.Dill@asu.edu> July 2001
6 * 6 *
@@ -157,7 +157,7 @@ static char **fill_envp(struct dhcpMessage *packet)
157 if (!(over & FILE_FIELD) && packet->file[0]) num_options++; 157 if (!(over & FILE_FIELD) && packet->file[0]) num_options++;
158 if (!(over & SNAME_FIELD) && packet->sname[0]) num_options++; 158 if (!(over & SNAME_FIELD) && packet->sname[0]) num_options++;
159 } 159 }
160 160
161 envp = xcalloc(sizeof(char *), num_options + 5); 161 envp = xcalloc(sizeof(char *), num_options + 5);
162 j = 0; 162 j = 0;
163 asprintf(&envp[j++], "interface=%s", client_config.interface); 163 asprintf(&envp[j++], "interface=%s", client_config.interface);
@@ -220,13 +220,13 @@ void run_script(struct dhcpMessage *packet, const char *name)
220 return; 220 return;
221 } else if (pid == 0) { 221 } else if (pid == 0) {
222 envp = fill_envp(packet); 222 envp = fill_envp(packet);
223 223
224 /* close fd's? */ 224 /* close fd's? */
225 225
226 /* exec script */ 226 /* exec script */
227 execle(client_config.script, client_config.script, 227 execle(client_config.script, client_config.script,
228 name, NULL, envp); 228 name, NULL, envp);
229 LOG(LOG_ERR, "script %s failed: %m", client_config.script); 229 LOG(LOG_ERR, "script %s failed: %m", client_config.script);
230 exit(1); 230 exit(1);
231 } 231 }
232} 232}
diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c
index d39e6ba17..937436a11 100644
--- a/networking/udhcp/serverpacket.c
+++ b/networking/udhcp/serverpacket.c
@@ -45,7 +45,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas
45{ 45{
46 uint8_t *chaddr; 46 uint8_t *chaddr;
47 uint32_t ciaddr; 47 uint32_t ciaddr;
48 48
49 if (force_broadcast) { 49 if (force_broadcast) {
50 DEBUG(LOG_INFO, "broadcasting packet to client (NAK)"); 50 DEBUG(LOG_INFO, "broadcasting packet to client (NAK)");
51 ciaddr = INADDR_BROADCAST; 51 ciaddr = INADDR_BROADCAST;
@@ -63,7 +63,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas
63 ciaddr = payload->yiaddr; 63 ciaddr = payload->yiaddr;
64 chaddr = payload->chaddr; 64 chaddr = payload->chaddr;
65 } 65 }
66 return raw_packet(payload, server_config.server, SERVER_PORT, 66 return raw_packet(payload, server_config.server, SERVER_PORT,
67 ciaddr, CLIENT_PORT, chaddr, server_config.ifindex); 67 ciaddr, CLIENT_PORT, chaddr, server_config.ifindex);
68} 68}
69 69
@@ -101,7 +101,7 @@ static void add_bootp_options(struct dhcpMessage *packet)
101 if (server_config.boot_file) 101 if (server_config.boot_file)
102 strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1); 102 strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1);
103} 103}
104 104
105 105
106/* send a DHCP OFFER to a DHCP DISCOVER */ 106/* send a DHCP OFFER to a DHCP DISCOVER */
107int sendOffer(struct dhcpMessage *oldpacket) 107int sendOffer(struct dhcpMessage *oldpacket)
@@ -114,14 +114,14 @@ int sendOffer(struct dhcpMessage *oldpacket)
114 struct in_addr addr; 114 struct in_addr addr;
115 115
116 init_packet(&packet, oldpacket, DHCPOFFER); 116 init_packet(&packet, oldpacket, DHCPOFFER);
117 117
118 /* ADDME: if static, short circuit */ 118 /* ADDME: if static, short circuit */
119 /* the client is in our lease/offered table */ 119 /* the client is in our lease/offered table */
120 if ((lease = find_lease_by_chaddr(oldpacket->chaddr))) { 120 if ((lease = find_lease_by_chaddr(oldpacket->chaddr))) {
121 if (!lease_expired(lease)) 121 if (!lease_expired(lease))
122 lease_time_align = lease->expires - time(0); 122 lease_time_align = lease->expires - time(0);
123 packet.yiaddr = lease->yiaddr; 123 packet.yiaddr = lease->yiaddr;
124 124
125 /* Or the client has a requested ip */ 125 /* Or the client has a requested ip */
126 } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) && 126 } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) &&
127 127
@@ -131,10 +131,10 @@ int sendOffer(struct dhcpMessage *oldpacket)
131 /* and the ip is in the lease range */ 131 /* and the ip is in the lease range */
132 ntohl(req_align) >= ntohl(server_config.start) && 132 ntohl(req_align) >= ntohl(server_config.start) &&
133 ntohl(req_align) <= ntohl(server_config.end) && 133 ntohl(req_align) <= ntohl(server_config.end) &&
134 134
135 /* and its not already taken/offered */ /* ADDME: check that its not a static lease */ 135 /* and its not already taken/offered */ /* ADDME: check that its not a static lease */
136 ((!(lease = find_lease_by_yiaddr(req_align)) || 136 ((!(lease = find_lease_by_yiaddr(req_align)) ||
137 137
138 /* or its taken, but expired */ /* ADDME: or maybe in here */ 138 /* or its taken, but expired */ /* ADDME: or maybe in here */
139 lease_expired(lease)))) { 139 lease_expired(lease)))) {
140 packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */ 140 packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */
@@ -142,32 +142,32 @@ int sendOffer(struct dhcpMessage *oldpacket)
142 /* otherwise, find a free IP */ /*ADDME: is it a static lease? */ 142 /* otherwise, find a free IP */ /*ADDME: is it a static lease? */
143 } else { 143 } else {
144 packet.yiaddr = find_address(0); 144 packet.yiaddr = find_address(0);
145 145
146 /* try for an expired lease */ 146 /* try for an expired lease */
147 if (!packet.yiaddr) packet.yiaddr = find_address(1); 147 if (!packet.yiaddr) packet.yiaddr = find_address(1);
148 } 148 }
149 149
150 if(!packet.yiaddr) { 150 if(!packet.yiaddr) {
151 LOG(LOG_WARNING, "no IP addresses to give -- OFFER abandoned"); 151 LOG(LOG_WARNING, "no IP addresses to give -- OFFER abandoned");
152 return -1; 152 return -1;
153 } 153 }
154 154
155 if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) { 155 if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) {
156 LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned"); 156 LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned");
157 return -1; 157 return -1;
158 } 158 }
159 159
160 if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { 160 if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) {
161 memcpy(&lease_time_align, lease_time, 4); 161 memcpy(&lease_time_align, lease_time, 4);
162 lease_time_align = ntohl(lease_time_align); 162 lease_time_align = ntohl(lease_time_align);
163 if (lease_time_align > server_config.lease) 163 if (lease_time_align > server_config.lease)
164 lease_time_align = server_config.lease; 164 lease_time_align = server_config.lease;
165 } 165 }
166 166
167 /* Make sure we aren't just using the lease time from the previous offer */ 167 /* Make sure we aren't just using the lease time from the previous offer */
168 if (lease_time_align < server_config.min_lease) 168 if (lease_time_align < server_config.min_lease)
169 lease_time_align = server_config.lease; 169 lease_time_align = server_config.lease;
170 /* ADDME: end of short circuit */ 170 /* ADDME: end of short circuit */
171 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); 171 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align));
172 172
173 curr = server_config.options; 173 curr = server_config.options;
@@ -178,7 +178,7 @@ int sendOffer(struct dhcpMessage *oldpacket)
178 } 178 }
179 179
180 add_bootp_options(&packet); 180 add_bootp_options(&packet);
181 181
182 addr.s_addr = packet.yiaddr; 182 addr.s_addr = packet.yiaddr;
183 LOG(LOG_INFO, "sending OFFER of %s", inet_ntoa(addr)); 183 LOG(LOG_INFO, "sending OFFER of %s", inet_ntoa(addr));
184 return send_packet(&packet, 0); 184 return send_packet(&packet, 0);
@@ -190,7 +190,7 @@ int sendNAK(struct dhcpMessage *oldpacket)
190 struct dhcpMessage packet; 190 struct dhcpMessage packet;
191 191
192 init_packet(&packet, oldpacket, DHCPNAK); 192 init_packet(&packet, oldpacket, DHCPNAK);
193 193
194 DEBUG(LOG_INFO, "sending NAK"); 194 DEBUG(LOG_INFO, "sending NAK");
195 return send_packet(&packet, 1); 195 return send_packet(&packet, 1);
196} 196}
@@ -206,18 +206,18 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr)
206 206
207 init_packet(&packet, oldpacket, DHCPACK); 207 init_packet(&packet, oldpacket, DHCPACK);
208 packet.yiaddr = yiaddr; 208 packet.yiaddr = yiaddr;
209 209
210 if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { 210 if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) {
211 memcpy(&lease_time_align, lease_time, 4); 211 memcpy(&lease_time_align, lease_time, 4);
212 lease_time_align = ntohl(lease_time_align); 212 lease_time_align = ntohl(lease_time_align);
213 if (lease_time_align > server_config.lease) 213 if (lease_time_align > server_config.lease)
214 lease_time_align = server_config.lease; 214 lease_time_align = server_config.lease;
215 else if (lease_time_align < server_config.min_lease) 215 else if (lease_time_align < server_config.min_lease)
216 lease_time_align = server_config.lease; 216 lease_time_align = server_config.lease;
217 } 217 }
218 218
219 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); 219 add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align));
220 220
221 curr = server_config.options; 221 curr = server_config.options;
222 while (curr) { 222 while (curr) {
223 if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) 223 if (curr->data[OPT_CODE] != DHCP_LEASE_TIME)
@@ -230,7 +230,7 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr)
230 addr.s_addr = packet.yiaddr; 230 addr.s_addr = packet.yiaddr;
231 LOG(LOG_INFO, "sending ACK to %s", inet_ntoa(addr)); 231 LOG(LOG_INFO, "sending ACK to %s", inet_ntoa(addr));
232 232
233 if (send_packet(&packet, 0) < 0) 233 if (send_packet(&packet, 0) < 0)
234 return -1; 234 return -1;
235 235
236 add_lease(packet.chaddr, packet.yiaddr, lease_time_align); 236 add_lease(packet.chaddr, packet.yiaddr, lease_time_align);
@@ -245,7 +245,7 @@ int send_inform(struct dhcpMessage *oldpacket)
245 struct option_set *curr; 245 struct option_set *curr;
246 246
247 init_packet(&packet, oldpacket, DHCPACK); 247 init_packet(&packet, oldpacket, DHCPACK);
248 248
249 curr = server_config.options; 249 curr = server_config.options;
250 while (curr) { 250 while (curr) {
251 if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) 251 if (curr->data[OPT_CODE] != DHCP_LEASE_TIME)
diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c
index 582f0fce5..7b057523a 100644
--- a/networking/udhcp/socket.c
+++ b/networking/udhcp/socket.c
@@ -55,7 +55,7 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp)
55 ifr.ifr_addr.sa_family = AF_INET; 55 ifr.ifr_addr.sa_family = AF_INET;
56 strcpy(ifr.ifr_name, interface); 56 strcpy(ifr.ifr_name, interface);
57 57
58 if (addr) { 58 if (addr) {
59 if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { 59 if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) {
60 our_ip = (struct sockaddr_in *) &ifr.ifr_addr; 60 our_ip = (struct sockaddr_in *) &ifr.ifr_addr;
61 *addr = our_ip->sin_addr.s_addr; 61 *addr = our_ip->sin_addr.s_addr;
@@ -65,7 +65,7 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp)
65 return -1; 65 return -1;
66 } 66 }
67 } 67 }
68 68
69 if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) { 69 if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) {
70 DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex); 70 DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex);
71 *ifindex = ifr.ifr_ifindex; 71 *ifindex = ifr.ifr_ifindex;
@@ -102,7 +102,7 @@ int listen_socket(uint32_t ip, int port, char *inf)
102 DEBUG(LOG_ERR, "socket call failed: %m"); 102 DEBUG(LOG_ERR, "socket call failed: %m");
103 return -1; 103 return -1;
104 } 104 }
105 105
106 memset(&addr, 0, sizeof(addr)); 106 memset(&addr, 0, sizeof(addr));
107 addr.sin_family = AF_INET; 107 addr.sin_family = AF_INET;
108 addr.sin_port = htons(port); 108 addr.sin_port = htons(port);
@@ -127,6 +127,6 @@ int listen_socket(uint32_t ip, int port, char *inf)
127 close(fd); 127 close(fd);
128 return -1; 128 return -1;
129 } 129 }
130 130
131 return fd; 131 return fd;
132} 132}
diff --git a/networking/vconfig.c b/networking/vconfig.c
index 0bb33084a..bbd29873c 100644
--- a/networking/vconfig.c
+++ b/networking/vconfig.c
@@ -63,7 +63,7 @@ struct vlan_ioctl_args {
63 unsigned int flag; /* Matches vlan_dev_info flags */ 63 unsigned int flag; /* Matches vlan_dev_info flags */
64 } u; 64 } u;
65 65
66 short vlan_qos; 66 short vlan_qos;
67}; 67};
68 68
69#define VLAN_GROUP_ARRAY_LEN 4096 69#define VLAN_GROUP_ARRAY_LEN 4096
@@ -110,7 +110,7 @@ static const char name_types[] = {
110 '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D', 110 '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D',
111 0, 111 0,
112 VLAN_NAME_TYPE_PLUS_VID_NO_PAD, 22, 112 VLAN_NAME_TYPE_PLUS_VID_NO_PAD, 22,
113 'V', 'L', 'A', 'N', 113 'V', 'L', 'A', 'N',
114 '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D', 114 '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D',
115 '_', 'N', 'O', '_', 'P', 'A', 'D', 0, 115 '_', 'N', 'O', '_', 'P', 'A', 'D', 0,
116 VLAN_NAME_TYPE_RAW_PLUS_VID, 15, 116 VLAN_NAME_TYPE_RAW_PLUS_VID, 15,
diff --git a/networking/wget.c b/networking/wget.c
index cb0790ea7..619c138ba 100644
--- a/networking/wget.c
+++ b/networking/wget.c
@@ -55,7 +55,7 @@ static volatile unsigned long statbytes = 0; /* Number of bytes transferred so f
55/* For progressmeter() -- number of seconds before xfer considered "stalled" */ 55/* For progressmeter() -- number of seconds before xfer considered "stalled" */
56static const int STALLTIME = 5; 56static const int STALLTIME = 5;
57#endif 57#endif
58 58
59static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue) 59static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue)
60{ 60{
61 if (output != stdout && do_continue==0) { 61 if (output != stdout && do_continue==0) {
@@ -236,18 +236,18 @@ int wget_main(int argc, char **argv)
236 use_proxy = 0; 236 use_proxy = 0;
237 } 237 }
238 } 238 }
239 239
240 /* Guess an output filename */ 240 /* Guess an output filename */
241 if (!fname_out) { 241 if (!fname_out) {
242 fname_out = 242 fname_out =
243#ifdef CONFIG_FEATURE_WGET_STATUSBAR 243#ifdef CONFIG_FEATURE_WGET_STATUSBAR
244 curfile = 244 curfile =
245#endif 245#endif
246 bb_get_last_path_component(target.path); 246 bb_get_last_path_component(target.path);
247 if (fname_out==NULL || strlen(fname_out)<1) { 247 if (fname_out==NULL || strlen(fname_out)<1) {
248 fname_out = 248 fname_out =
249#ifdef CONFIG_FEATURE_WGET_STATUSBAR 249#ifdef CONFIG_FEATURE_WGET_STATUSBAR
250 curfile = 250 curfile =
251#endif 251#endif
252 "index.html"; 252 "index.html";
253 } 253 }
@@ -309,7 +309,7 @@ int wget_main(int argc, char **argv)
309 */ 309 */
310 if (sfp) fclose(sfp); 310 if (sfp) fclose(sfp);
311 sfp = open_socket(&s_in); 311 sfp = open_socket(&s_in);
312 312
313 /* 313 /*
314 * Send HTTP request. 314 * Send HTTP request.
315 */ 315 */
@@ -351,7 +351,7 @@ int wget_main(int argc, char **argv)
351read_response: 351read_response:
352 if (fgets(buf, sizeof(buf), sfp) == NULL) 352 if (fgets(buf, sizeof(buf), sfp) == NULL)
353 close_delete_and_die("no response from server"); 353 close_delete_and_die("no response from server");
354 354
355 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s) 355 for (s = buf ; *s != '\0' && !isspace(*s) ; ++s)
356 ; 356 ;
357 for ( ; isspace(*s) ; ++s) 357 for ( ; isspace(*s) ; ++s)
@@ -379,7 +379,7 @@ read_response:
379 chomp(buf); 379 chomp(buf);
380 close_delete_and_die("server returned error %d: %s", atoi(s), buf); 380 close_delete_and_die("server returned error %d: %s", atoi(s), buf);
381 } 381 }
382 382
383 /* 383 /*
384 * Retrieve HTTP headers. 384 * Retrieve HTTP headers.
385 */ 385 */
@@ -416,7 +416,7 @@ read_response:
416 } 416 }
417 } 417 }
418 } while(status >= 300); 418 } while(status >= 300);
419 419
420 dfp = sfp; 420 dfp = sfp;
421 } 421 }
422 else 422 else
@@ -431,7 +431,7 @@ read_response:
431 if (ftpcmd(NULL, NULL, sfp, buf) != 220) 431 if (ftpcmd(NULL, NULL, sfp, buf) != 220)
432 close_delete_and_die("%s", buf+4); 432 close_delete_and_die("%s", buf+4);
433 433
434 /* 434 /*
435 * Splitting username:password pair, 435 * Splitting username:password pair,
436 * trying to log in 436 * trying to log in
437 */ 437 */
@@ -448,10 +448,10 @@ read_response:
448 default: 448 default:
449 close_delete_and_die("ftp login: %s", buf+4); 449 close_delete_and_die("ftp login: %s", buf+4);
450 } 450 }
451 451
452 ftpcmd("CDUP", NULL, sfp, buf); 452 ftpcmd("CDUP", NULL, sfp, buf);
453 ftpcmd("TYPE I", NULL, sfp, buf); 453 ftpcmd("TYPE I", NULL, sfp, buf);
454 454
455 /* 455 /*
456 * Querying file size 456 * Querying file size
457 */ 457 */
@@ -463,7 +463,7 @@ read_response:
463 filesize = value; 463 filesize = value;
464 got_clen = 1; 464 got_clen = 1;
465 } 465 }
466 466
467 /* 467 /*
468 * Entering passive mode 468 * Entering passive mode
469 */ 469 */
@@ -486,7 +486,7 @@ read_response:
486 } else 486 } else
487 filesize -= beg_range; 487 filesize -= beg_range;
488 } 488 }
489 489
490 if (ftpcmd("RETR /", target.path, sfp, buf) > 150) 490 if (ftpcmd("RETR /", target.path, sfp, buf) > 150)
491 close_delete_and_die("RETR: %s", buf+4); 491 close_delete_and_die("RETR: %s", buf+4);
492 492
@@ -661,27 +661,27 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc)
661static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) 661static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf)
662{ 662{
663 char *p; 663 char *p;
664 664
665 if (s1) { 665 if (s1) {
666 if (!s2) s2=""; 666 if (!s2) s2="";
667 fprintf(fp, "%s%s\r\n", s1, s2); 667 fprintf(fp, "%s%s\r\n", s1, s2);
668 fflush(fp); 668 fflush(fp);
669 } 669 }
670 670
671 do { 671 do {
672 p = fgets(buf, 510, fp); 672 p = fgets(buf, 510, fp);
673 if (!p) 673 if (!p)
674 bb_perror_msg_and_die("fgets()"); 674 bb_perror_msg_and_die("fgets()");
675 } while (! isdigit(buf[0]) || buf[3] != ' '); 675 } while (! isdigit(buf[0]) || buf[3] != ' ');
676 676
677 return atoi(buf); 677 return atoi(buf);
678} 678}
679 679
680#ifdef CONFIG_FEATURE_WGET_STATUSBAR 680#ifdef CONFIG_FEATURE_WGET_STATUSBAR
681/* Stuff below is from BSD rcp util.c, as added to openshh. 681/* Stuff below is from BSD rcp util.c, as added to openshh.
682 * Original copyright notice is retained at the end of this file. 682 * Original copyright notice is retained at the end of this file.
683 * 683 *
684 */ 684 */
685 685
686 686
687static int 687static int
@@ -813,7 +813,7 @@ progressmeter(int flag)
813 813
814/* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff, 814/* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff,
815 * much of which was blatently stolen from openssh. */ 815 * much of which was blatently stolen from openssh. */
816 816
817/*- 817/*-
818 * Copyright (c) 1992, 1993 818 * Copyright (c) 1992, 1993
819 * The Regents of the University of California. All rights reserved. 819 * The Regents of the University of California. All rights reserved.
@@ -827,8 +827,8 @@ progressmeter(int flag)
827 * notice, this list of conditions and the following disclaimer in the 827 * notice, this list of conditions and the following disclaimer in the
828 * documentation and/or other materials provided with the distribution. 828 * documentation and/or other materials provided with the distribution.
829 * 829 *
830 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change 830 * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
831 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> 831 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
832 * 832 *
833 * 4. Neither the name of the University nor the names of its contributors 833 * 4. Neither the name of the University nor the names of its contributors
834 * may be used to endorse or promote products derived from this software 834 * may be used to endorse or promote products derived from this software
@@ -846,7 +846,7 @@ progressmeter(int flag)
846 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 846 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
847 * SUCH DAMAGE. 847 * SUCH DAMAGE.
848 * 848 *
849 * $Id: wget.c,v 1.70 2004/03/06 22:11:44 andersen Exp $ 849 * $Id: wget.c,v 1.71 2004/03/15 08:28:53 andersen Exp $
850 */ 850 */
851 851
852 852