aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-16 15:08:59 +0000
committerRob Landley <rob@landley.net>2006-06-16 15:08:59 +0000
commit1449a2014a4e715a7a52b27caec528a9c802fa5f (patch)
tree281bba4feed27caadd90981d70e713caedbf15f2
parent747041955ed38fb14be3e5d0c3a946cfa74bc15e (diff)
downloadbusybox-w32-1449a2014a4e715a7a52b27caec528a9c802fa5f.tar.gz
busybox-w32-1449a2014a4e715a7a52b27caec528a9c802fa5f.tar.bz2
busybox-w32-1449a2014a4e715a7a52b27caec528a9c802fa5f.zip
This directory was fallout from the great feature freeze of 2003, which led
up to the 1.00 release. I just moved what was left of it to http://busybox.net/~landley/pending because it does _not_ belong in the tree anymore.
-rw-r--r--patches/cmp_n.diff377
-rw-r--r--patches/cross-reference.synopsis.diff31
-rw-r--r--patches/tftp_timeout_multicast.diff1053
-rw-r--r--patches/top_system_cpu.diff51
-rw-r--r--patches/udhcp_additional_items.diff126
-rw-r--r--patches/udhcp_config_paths.diff333
-rw-r--r--patches/udhcpd_foreground.diff33
-rw-r--r--patches/woot.txt26
8 files changed, 0 insertions, 2030 deletions
diff --git a/patches/cmp_n.diff b/patches/cmp_n.diff
deleted file mode 100644
index fc4661cf5..000000000
--- a/patches/cmp_n.diff
+++ /dev/null
@@ -1,377 +0,0 @@
1Index: coreutils/Config.in
2===================================================================
3RCS file: /var/cvs/busybox/coreutils/Config.in,v
4retrieving revision 1.24
5diff -u -r1.24 Config.in
6--- a/coreutils/Config.in 15 Mar 2004 08:28:19 -0000 1.24
7+++ b/coreutils/Config.in 31 Mar 2004 11:51:17 -0000
8@@ -59,6 +59,21 @@
9 cmp is used to compare two files and returns the result
10 to standard output.
11
12+config CONFIG_FEATURE_CMP_SKIP
13+ bool " Enable optional arguments SKIP1 and SKIP2"
14+ default n
15+ depends on CONFIG_CMP
16+ help
17+ SKIP1 and SKIP2 specify how many bytes to ignore
18+ at the start of each file.
19+
20+config CONFIG_FEATURE_CMP_LIMIT
21+ bool " Enable limit of inputs"
22+ default n
23+ depends on CONFIG_CMP
24+ help
25+ Enable cmp option (-n).
26+
27 config CONFIG_CP
28 bool "cp"
29 default n
30Index: coreutils/cmp.c
31===================================================================
32RCS file: /var/cvs/busybox/coreutils/cmp.c,v
33retrieving revision 1.9
34diff -u -r1.9 cmp.c
35--- a/coreutils/cmp.c 19 Mar 2003 09:11:32 -0000 1.9
36+++ b/coreutils/cmp.c 31 Mar 2004 11:51:17 -0000
37@@ -39,6 +39,12 @@
38 #include <unistd.h>
39 #include "busybox.h"
40
41+#ifdef CONFIG_FEATURE_CMP_SKIP
42+#define MAX_OPTIONAL_ARGS 3
43+#else
44+#define MAX_OPTIONAL_ARGS 1
45+#endif
46+
47 static FILE *cmp_xfopen_input(const char *filename)
48 {
49 FILE *fp;
50@@ -58,12 +64,57 @@
51 static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n"; /* nicer gnu format */
52 #endif
53
54-static const char opt_chars[] = "sl";
55+#ifdef CONFIG_FEATURE_CMP_LIMIT
56+#define OPTCHR_LIMIT "n:"
57+#define OPTARG_LIMIT ,&limit_str
58+#else
59+#define OPTCHR_LIMIT
60+#define OPTARG_LIMIT
61+#endif
62+
63+static const char opt_chars[] = "sl" OPTCHR_LIMIT;
64
65 enum {
66 OPT_s = 1,
67- OPT_l = 2
68+ OPT_l = 2,
69+ OPT_n = 4
70+};
71+
72+#ifdef CONFIG_LFS
73+#define SUFFIX_STRUCT suffix_mult64
74+#define PARSE_FUNC bb_xgetllarg10_sfx
75+#else
76+#define SUFFIX_STRUCT suffix_mult
77+#define PARSE_FUNC bb_xgetlarg10_sfx
78+#endif
79+
80+#if defined(CONFIG_FEATURE_CMP_SKIP) || defined(CONFIG_FEATURE_CMP_LIMIT)
81+static const struct SUFFIX_STRUCT suffixes[] = {
82+ { "k", 1UL << 10 },
83+ { "M", 1UL << 20 },
84+ { "G", 1UL << 30 },
85+#ifdef CONFIG_LFS
86+ { "T", 1ULL << 40 },
87+ { "P", 1ULL << 50 },
88+ { "E", 1ULL << 60 },
89+#endif
90+ { NULL, 0 }
91 };
92+#endif
93+
94+#ifdef CONFIG_FEATURE_CMP_SKIP
95+static void skip_input(FILE *fp, off_t skip, const char *filename)
96+{
97+ if (skip > 0 && fseeko(fp, skip, SEEK_CUR) != 0) {
98+ while (skip-- > 0) {
99+ if (getc(fp) == EOF) {
100+ bb_xferror(fp, filename);
101+ break;
102+ }
103+ }
104+ }
105+}
106+#endif
107
108 int cmp_main(int argc, char **argv)
109 {
110@@ -73,12 +124,26 @@
111 int c1, c2, char_pos, line_pos;
112 int opt_flags;
113 int exit_val = 0;
114+#ifdef CONFIG_FEATURE_CMP_SKIP
115+ off_t skip1 = 0, skip2 = 0;
116+#endif
117+#ifdef CONFIG_FEATURE_CMP_LIMIT
118+ off_t limit = -1;
119+ char *limit_str;
120+#endif
121
122 bb_default_error_retval = 2; /* 1 is returned if files are different. */
123
124- opt_flags = bb_getopt_ulflags(argc, argv, opt_chars);
125+ opt_flags = bb_getopt_ulflags(argc, argv, opt_chars OPTARG_LIMIT);
126
127- if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > 1)) {
128+#ifdef CONFIG_FEATURE_CMP_LIMIT
129+ if (opt_flags & OPT_n) {
130+ limit = PARSE_FUNC(limit_str, suffixes);
131+ opt_flags &= 3;
132+ }
133+#endif
134+
135+ if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > MAX_OPTIONAL_ARGS)) {
136 bb_show_usage();
137 }
138
139@@ -87,6 +152,13 @@
140 filename2 = "-";
141 if (*++argv) {
142 filename2 = *argv;
143+#ifdef CONFIG_FEATURE_CMP_SKIP
144+ if (*++argv) {
145+ skip1 = PARSE_FUNC(*argv, suffixes);
146+ if (*++argv)
147+ skip2 = PARSE_FUNC(*argv, suffixes);
148+ }
149+#endif
150 }
151 fp2 = cmp_xfopen_input(filename2);
152
153@@ -98,6 +170,11 @@
154 return 0;
155 }
156
157+#ifdef CONFIG_FEATURE_CMP_SKIP
158+ skip_input(fp1, skip1, filename1);
159+ skip_input(fp2, skip2, filename2);
160+#endif
161+
162 fmt = fmt_differ;
163 if (opt_flags == OPT_l) {
164 fmt = fmt_l_opt;
165@@ -106,6 +183,10 @@
166 char_pos = 0;
167 line_pos = 1;
168 do {
169+#ifdef CONFIG_FEATURE_CMP_LIMIT
170+ if (limit-- == 0)
171+ break;
172+#endif
173 c1 = getc(fp1);
174 c2 = getc(fp2);
175 ++char_pos;
176Index: include/usage.h
177===================================================================
178RCS file: /var/cvs/busybox/include/usage.h,v
179retrieving revision 1.198
180diff -u -r1.198 usage.h
181--- a/include/usage.h 29 Mar 2004 08:20:08 -0000 1.198
182+++ b/include/usage.h 31 Mar 2004 11:51:17 -0000
183@@ -186,14 +186,29 @@
184 #define clear_full_usage \
185 "Clear screen."
186
187+#ifdef CONFIG_FEATURE_CMP_SKIP
188+#define USAGE_CMP_SKIP(a) a
189+#else
190+#define USAGE_CMP_SKIP(a)
191+#endif
192+
193+#ifdef CONFIG_FEATURE_CMP_LIMIT
194+#define USAGE_CMP_LIMIT(a) a
195+#else
196+#define USAGE_CMP_LIMIT(a)
197+#endif
198+
199 #define cmp_trivial_usage \
200- "[OPTION]... FILE1 [FILE2]"
201+ "[OPTION]... FILE1 [FILE2" USAGE_CMP_SKIP(" [SKIP1 [SKIP2]]") "]"
202 #define cmp_full_usage \
203- "Compare files.\n\n" \
204+ "Compare files.\n" \
205+ USAGE_CMP_SKIP("SKIP1 and SKIP2 are the number of bytes to skip in each file.\n") \
206+ "\n" \
207 "Options:\n" \
208- "\t-l\tWrite the byte numbers (decimal) and values (octal)\n" \
209- "\t\t for all differing bytes.\n" \
210- "\t-s\tquiet mode - do not print"
211+ "\t-l\t\tWrite the byte numbers (decimal) and values (octal)\n" \
212+ "\t\t\t for all differing bytes.\n" \
213+ USAGE_CMP_LIMIT("\t-n LIMIT\tCompare at most LIMIT bytes.\n") \
214+ "\t-s\t\tquiet mode - do not print"
215
216 #define cp_trivial_usage \
217 "[OPTION]... SOURCE DEST"
218Index: include/libbb.h
219===================================================================
220RCS file: /var/cvs/busybox/include/libbb.h,v
221retrieving revision 1.129
222diff -u -r1.129 libbb.h
223--- a/include/libbb.h 15 Mar 2004 08:28:38 -0000 1.129
224+++ b/include/libbb.h 31 Mar 2004 11:51:17 -0000
225@@ -217,6 +217,21 @@
226 const struct suffix_mult *suffixes);
227 extern long bb_xgetlarg10_sfx(const char *arg, const struct suffix_mult *suffixes);
228
229+struct suffix_mult64 {
230+ const char *suffix;
231+ unsigned long long mult;
232+};
233+
234+extern unsigned long long bb_xgetullarg_bnd_sfx(const char *arg, int base,
235+ unsigned long long lower,
236+ unsigned long long upper,
237+ const struct suffix_mult64 *suffixes);
238+
239+extern long long bb_xgetllarg_bnd_sfx(const char *arg, int base,
240+ long long lower,
241+ long long upper,
242+ const struct suffix_mult64 *suffixes);
243+extern long long bb_xgetllarg10_sfx(const char *arg, const struct suffix_mult64 *suffixes);
244
245 //#warning pitchable now?
246 extern unsigned long bb_xparse_number(const char *numstr,
247Index: libbb/Makefile.in
248===================================================================
249RCS file: /var/cvs/busybox/libbb/Makefile.in,v
250retrieving revision 1.34
251diff -u -r1.34 Makefile.in
252--- a/libbb/Makefile.in 6 Mar 2004 22:11:45 -0000 1.34
253+++ b/libbb/Makefile.in 31 Mar 2004 11:51:17 -0000
254@@ -70,7 +70,8 @@
255
256 LIBBB_MSRC3:=$(LIBBB_DIR)xgetularg.c
257 LIBBB_MOBJ3:=xgetularg_bnd_sfx.o xgetlarg_bnd_sfx.o getlarg10_sfx.o \
258- xgetularg_bnd.o xgetularg10_bnd.o xgetularg10.o
259+ xgetularg_bnd.o xgetularg10_bnd.o xgetularg10.o \
260+ xgetullarg_bnd_sfx.o xgetllarg_bnd_sfx.o xgetllarg10_sfx.o
261
262 LIBBB_MSRC4:=$(LIBBB_DIR)/safe_strtol.c
263 LIBBB_MOBJ4:=safe_strtoi.o safe_strtod.o safe_strtol.o safe_strtoul.o
264Index: libbb/xgetularg.c
265===================================================================
266RCS file: /var/cvs/busybox/libbb/xgetularg.c,v
267retrieving revision 1.2
268diff -u -r1.2 xgetularg.c
269--- a/libbb/xgetularg.c 15 Mar 2004 08:28:44 -0000 1.2
270+++ b/libbb/xgetularg.c 31 Mar 2004 11:51:17 -0000
271@@ -158,3 +158,106 @@
272 return bb_xgetularg10_bnd(arg, 0, ULONG_MAX);
273 }
274 #endif
275+
276+#ifdef L_xgetullarg_bnd_sfx
277+extern
278+unsigned long long bb_xgetullarg_bnd_sfx(const char *arg, int base,
279+ unsigned long long lower,
280+ unsigned long long upper,
281+ const struct suffix_mult64 *suffixes)
282+{
283+ unsigned long long r;
284+ int old_errno;
285+ char *e;
286+
287+ assert(arg);
288+
289+ /* Disallow '-' and any leading whitespace. Speed isn't critical here
290+ * since we're parsing commandline args. So make sure we get the
291+ * actual isspace function rather than a larger macro implementaion. */
292+ if ((*arg == '-') || (isspace)(*arg)) {
293+ bb_show_usage();
294+ }
295+
296+ /* Since this is a lib function, we're not allowed to reset errno to 0.
297+ * Doing so could break an app that is deferring checking of errno.
298+ * So, save the old value so that we can restore it if successful. */
299+ old_errno = errno;
300+ errno = 0;
301+ r = strtoull(arg, &e, base);
302+ /* Do the initial validity check. Note: The standards do not
303+ * guarantee that errno is set if no digits were found. So we
304+ * must test for this explicitly. */
305+ if (errno || (arg == e)) { /* error or no digits */
306+ bb_show_usage();
307+ }
308+ errno = old_errno; /* Ok. So restore errno. */
309+
310+ /* Do optional suffix parsing. Allow 'empty' suffix tables.
311+ * Note that we also all nul suffixes with associated multipliers,
312+ * to allow for scaling of the arg by some default multiplier. */
313+
314+ if (suffixes) {
315+ while (suffixes->suffix) {
316+ if (strcmp(suffixes->suffix, e) == 0) {
317+ if (ULONG_LONG_MAX / suffixes->mult < r) { /* Overflow! */
318+ bb_show_usage();
319+ }
320+ ++e;
321+ r *= suffixes->mult;
322+ break;
323+ }
324+ ++suffixes;
325+ }
326+ }
327+
328+ /* Finally, check for illegal trailing chars and range limits. */
329+ /* Note: although we allow leading space (via stroul), trailing space
330+ * is an error. It would be easy enough to allow though if desired. */
331+ if (*e || (r < lower) || (r > upper)) {
332+ bb_show_usage();
333+ }
334+
335+ return r;
336+}
337+#endif
338+
339+#ifdef L_xgetllarg_bnd_sfx
340+extern
341+long long bb_xgetllarg_bnd_sfx(const char *arg, int base,
342+ long long lower,
343+ long long upper,
344+ const struct suffix_mult64 *suffixes)
345+{
346+ unsigned long long u = LONG_LONG_MAX;
347+ long long r;
348+ const char *p = arg;
349+
350+ if ((*p == '-') && (p[1] != '+')) {
351+ ++p;
352+#if LONG_LONG_MAX == (-(LONG_LONG_MIN + 1))
353+ ++u; /* two's complement */
354+#endif
355+ }
356+
357+ r = bb_xgetullarg_bnd_sfx(p, base, 0, u, suffixes);
358+
359+ if (*arg == '-') {
360+ r = -r;
361+ }
362+
363+ if ((r < lower) || (r > upper)) {
364+ bb_show_usage();
365+ }
366+
367+ return r;
368+}
369+#endif
370+
371+#ifdef L_xgetllarg10_sfx
372+extern
373+long long bb_xgetllarg10_sfx(const char *arg, const struct suffix_mult64 *suffixes)
374+{
375+ return bb_xgetllarg_bnd_sfx(arg, 10, LONG_LONG_MIN, LONG_LONG_MAX, suffixes);
376+}
377+#endif
diff --git a/patches/cross-reference.synopsis.diff b/patches/cross-reference.synopsis.diff
deleted file mode 100644
index bc4536648..000000000
--- a/patches/cross-reference.synopsis.diff
+++ /dev/null
@@ -1,31 +0,0 @@
1Index: Makefile
2===================================================================
3--- Makefile (revision 15403)
4+++ Makefile (working copy)
5@@ -473,7 +473,7 @@ clean:
6 libbusybox.so* \
7 .config.old busybox busybox_unstripped
8 - rm -r -f _install testsuite/links
9- - find . -name .\*.flags -o -name \*.o -o -name \*.om \
10+ - find . -name .\*.flags -o -name \*.o -o -name \*.om -o -name \*.syn \
11 -o -name \*.os -o -name \*.osm -o -name \*.a | xargs rm -f
12
13 distclean: clean
14@@ -503,6 +503,17 @@ release: distclean #doc
15 tags:
16 ctags -R .
17
18+# documentation, cross-reference
19+# Modern distributions already ship synopsis packages (e.g. debian)
20+# If you have an old distribution go to http://synopsis.fresco.org/
21+hdr := $(wildcard $(patsubst %,%/*.h,$(SRC_DIRS)))
22+syn := $(patsubst %.h, %.syn, $(hdr))
23+
24+%.syn: %.h
25+ synopsis -p C -l Comments.SSDFilter,Comments.Previous $(INCS) -Wp,verbose,debug,preprocess,cppflags="'$(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) $(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) $(APPLETS_DEFINE) $(BUSYBOX_DEFINE)'" -o $@ $<
26+html: $(syn)
27+ synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
28+
29
30 endif # ifeq ($(skip-makefile),)
31
diff --git a/patches/tftp_timeout_multicast.diff b/patches/tftp_timeout_multicast.diff
deleted file mode 100644
index 5147a6714..000000000
--- a/patches/tftp_timeout_multicast.diff
+++ /dev/null
@@ -1,1053 +0,0 @@
1Index: AUTHORS
2===================================================================
3RCS file: /var/cvs/busybox/AUTHORS,v
4retrieving revision 1.40
5diff -u -r1.40 AUTHORS
6--- a/AUTHORS 9 Oct 2003 21:19:21 -0000 1.40
7+++ b/AUTHORS 5 Mar 2004 15:45:47 -0000
8@@ -92,6 +92,9 @@
9 Original author of BusyBox in 1995, 1996. Some of his code can
10 still be found hiding here and there...
11
12+John Powers <jpp@ti.com>
13+ Added multicast option (rfc2090) and timeout option (rfc2349) to tftp.
14+
15 Tim Riker <Tim@Rikers.org>
16 bug fixes, member of fan club
17
18Index: include/usage.h
19===================================================================
20RCS file: /var/cvs/busybox/include/usage.h,v
21retrieving revision 1.191
22diff -u -r1.191 usage.h
23--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
24+++ b/include/usage.h 5 Mar 2004 15:45:59 -0000
25@@ -2492,6 +2492,21 @@
26 #else
27 #define USAGE_TFTP_BS(a)
28 #endif
29+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
30+ #define USAGE_TFTP_TIMEOUT(a) a
31+#else
32+ #define USAGE_TFTP_TIMEOUT(a)
33+#endif
34+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
35+ #define USAGE_TFTP_MULTICAST(a) a
36+#else
37+ #define USAGE_TFTP_MULTICAST(a)
38+#endif
39+#ifdef CONFIG_FEATURE_TFTP_DEBUG
40+ #define USAGE_TFTP_DEBUG(a) a
41+#else
42+ #define USAGE_TFTP_DEBUG(a)
43+#endif
44
45 #define tftp_trivial_usage \
46 "[OPTION]... HOST [PORT]"
47@@ -2508,6 +2523,16 @@
48 ) \
49 USAGE_TFTP_BS( \
50 "\t-b SIZE\tTransfer blocks of SIZE octets.\n" \
51+ ) \
52+ USAGE_TFTP_TIMEOUT( \
53+ "\t-T SEC\tClient timeout SEC seconds (default: 5).\n" \
54+ "\t-t SEC\tServer timeout SEC seconds\n" \
55+ ) \
56+ USAGE_TFTP_MULTICAST( \
57+ "\t-m\tMulticast get file.\n" \
58+ ) \
59+ USAGE_TFTP_DEBUG( \
60+ "\t-D\tPrint debug messages.\n" \
61 )
62 #define time_trivial_usage \
63 "[OPTION]... COMMAND [ARGS...]"
64Index: networking/Config.in
65===================================================================
66RCS file: /var/cvs/busybox/networking/Config.in,v
67retrieving revision 1.27
68diff -u -r1.27 Config.in
69--- a/networking/Config.in 22 Feb 2004 12:25:47 -0000 1.27
70+++ b/networking/Config.in 5 Mar 2004 15:45:59 -0000
71@@ -522,6 +522,13 @@
72 Add support for the GET command within the TFTP client. This allows
73 a client to retrieve a file from a TFTP server.
74
75+config CONFIG_FEATURE_TFTP_MULTICAST
76+ bool " Enable \"multicast\" option"
77+ default n
78+ depends on CONFIG_FEATURE_TFTP_GET
79+ help
80+ Allow the client to receive multicast file transfers.
81+
82 config CONFIG_FEATURE_TFTP_PUT
83 bool " Enable \"put\" command"
84 default y
85@@ -531,12 +538,19 @@
86 a client to transfer a file to a TFTP server.
87
88 config CONFIG_FEATURE_TFTP_BLOCKSIZE
89- bool " Enable \"blocksize\" command"
90+ bool " Enable \"blksize\" option"
91 default n
92 depends on CONFIG_TFTP
93 help
94 Allow the client to specify the desired block size for transfers.
95
96+config CONFIG_FEATURE_TFTP_TIMEOUT
97+ bool " Enable \"timeout\" option"
98+ default n
99+ depends on CONFIG_TFTP
100+ help
101+ Allow the client to negotiate timeout option with server.
102+
103 config CONFIG_FEATURE_TFTP_DEBUG
104 bool " Enable debug"
105 default n
106Index: networking/tftp.c
107===================================================================
108RCS file: /var/cvs/busybox/networking/tftp.c,v
109retrieving revision 1.25
110diff -u -r1.25 tftp.c
111--- a/networking/tftp.c 5 Mar 2004 13:04:39 -0000 1.25
112+++ b/networking/tftp.c 5 Mar 2004 15:46:00 -0000
113@@ -1,11 +1,26 @@
114+/* vi: set sw=4 ts=4: */
115 /* ------------------------------------------------------------------------- */
116 /* tftp.c */
117+/* Copyright (c) 2003, 2004 Texas Instruments */
118+/* */
119+/* This package is free software; you can redistribute it and/or */
120+/* modify it under the terms of the license found in the file */
121+/* named COPYING that should have accompanied this file. */
122+/* */
123+/* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
124+/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
125+/* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
126 /* */
127 /* A simple tftp client for busybox. */
128 /* Tries to follow RFC1350. */
129 /* Only "octet" mode supported. */
130 /* Optional blocksize negotiation (RFC2347 + RFC2348) */
131 /* */
132+/* New features added at Texas Instruments, October 2003 */
133+/* Author: John Powers */
134+/* Multicast option: rfc2090 */
135+/* Timeout option: rfc2349 */
136+/* */
137 /* Copyright (C) 2001 Magnus Damm <damm@opensource.se> */
138 /* */
139 /* Parts of the code based on: */
140@@ -46,8 +61,20 @@
141
142 #include "busybox.h"
143
144+#if defined(CONFIG_FEATURE_TFTP_BLOCKSIZE) || defined(CONFIG_FEATURE_TFTP_MULTICAST) || defined(CONFIG_FEATURE_TFTP_TIMEOUT)
145+ #define TFTP_OPTIONS
146+#endif
147+
148 //#define CONFIG_FEATURE_TFTP_DEBUG
149
150+#ifdef CONFIG_FEATURE_TFTP_DEBUG
151+ static void printtime(void);
152+ #define dprintf(fmt...) if (debug) {printtime(); printf(fmt);}
153+ int debug = 0;
154+#else
155+ #define dprintf(fmt...)
156+#endif
157+
158 #define TFTP_BLOCKSIZE_DEFAULT 512 /* according to RFC 1350, don't change */
159 #define TFTP_TIMEOUT 5 /* seconds */
160
161@@ -68,12 +95,24 @@
162 "Illegal TFTP operation",
163 "Unknown transfer ID",
164 "File already exists",
165- "No such user"
166+ "No such user",
167+#ifdef TFTP_OPTIONS
168+ "Unsupported option",
169+#endif
170 };
171
172 const int tftp_cmd_get = 1;
173 const int tftp_cmd_put = 2;
174
175+
176+struct tftp_option {
177+ int multicast;
178+ int blksize;
179+ int client_timeout;
180+ int server_timeout;
181+};
182+
183+
184 #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
185
186 static int tftp_blocksize_check(int blocksize, int bufsize)
187@@ -93,16 +132,158 @@
188 return blocksize;
189 }
190
191+#endif
192+
193+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
194+
195+static int
196+tftp_timeout_check(int timeout)
197+{
198+ /* Check if timeout seconds is valid:
199+ * RFC2349 says between 1 and 255.
200+ */
201+
202+ if (timeout < 1 || timeout > 255) {
203+ bb_error_msg("bad timeout value");
204+ return 0;
205+ }
206+ return timeout;
207+}
208+
209+#endif
210+
211+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
212+static int
213+tftp_multicast_check(const char *opt, char **phost, unsigned short *pport, int *pactive)
214+{
215+ /* Option string contains comma delimited addr,port,active.
216+ * addr = multicast IP address
217+ * port = port number
218+ * active = 1 if active client
219+ * 0 if passive client
220+ *
221+ * Addr and port will be empty fields when the server notifies a
222+ * passive client that it is now the active client.
223+ *
224+ * The host address string must be freed by the caller. Neither host
225+ * nor port will be set/changed if the input fields are empty.
226+ *
227+ * If any tokenization errors occur in the opt string, the host
228+ * address string is automatically freed.
229+ *
230+ * Return 0 if any tokenization error, 1 if all parameters are good.
231+ */
232+
233+ char *token = NULL;
234+ char *parse_buf = NULL;
235+ char *tokenv = NULL;
236+ char *host = NULL;
237+ int port;
238+ int active;
239+
240+ parse_buf = bb_xstrdup(opt);
241+
242+ dprintf("multicast option=%s\n", opt);
243+
244+ /* IP address */
245+ if ((token = strtok_r(parse_buf, ",", &tokenv)) == NULL) {
246+ dprintf("tftp_multicast_check: cannot parse IP address from %s\n", parse_buf);
247+ free(parse_buf);
248+ return 0;
249+ }
250+ if (strlen(token) > 0)
251+ *phost = host = bb_xstrdup(token);
252+
253+ /* Port */
254+ if ((token = strtok_r(NULL, ",", &tokenv)) == NULL) {
255+ dprintf("tftp_multicast_check: cannot parse port number from %s\n", tokenv);
256+ goto token_error;
257+ }
258+ if (strlen(token) > 0) {
259+ port = atoi(token);
260+ if (port < 0 || port > 0xFFFF) {
261+ dprintf("tftp_multicast_check: bad port number (%d)\n", port);
262+ goto token_error;
263+ }
264+ *pport = htons(port);
265+ }
266+
267+ /* Active/passive */
268+ if ((token = strtok_r(NULL, ",", &tokenv)) == NULL) {
269+ dprintf("tftp_multicast_check: cannot parse active/passive from %s\n", tokenv);
270+ goto token_error;
271+ }
272+ active = atoi(token);
273+ if (active != 0 && active != 1) {
274+ dprintf("tftp_multicast_check: bad active/passive flag (%d)\n", active);
275+ goto token_error;
276+ }
277+ *pactive = active;
278+
279+ free(parse_buf);
280+ return 1;
281+
282+token_error:
283+ free(parse_buf);
284+ if (host != NULL)
285+ free(host);
286+ *phost = NULL;
287+ return 0;
288+
289+}
290+
291+#define VECTOR_QUANTUM_WIDTH 8
292+#define VECTOR_QUANTUM_ALL_ONES ((1<<VECTOR_QUANTUM_WIDTH)-1)
293+
294+static void inline
295+bit_set(int bit, unsigned char *vector)
296+{
297+ int offset = bit / VECTOR_QUANTUM_WIDTH;
298+ int mask = 1 << (bit % VECTOR_QUANTUM_WIDTH);
299+ vector[offset] |= mask;
300+}
301+
302+static int inline
303+bit_isset(int bit, const unsigned char *vector)
304+{
305+ int offset = bit / VECTOR_QUANTUM_WIDTH;
306+ int mask = 1 << (bit % VECTOR_QUANTUM_WIDTH);
307+ return vector[offset] & mask ? 1 : 0;
308+}
309+
310+static int inline
311+bit_lmz(const unsigned char *vector)
312+{
313+ /* Return number of left-most zero in bit vector */
314+ const unsigned char *vp = vector;
315+ int i;
316+ unsigned char velem;
317+
318+ while (*vp == VECTOR_QUANTUM_ALL_ONES)
319+ vp++;
320+ velem = *vp;
321+ for (i = 0; i < VECTOR_QUANTUM_WIDTH; i++) {
322+ if ((velem & (1 << i)) == 0)
323+ break;
324+ }
325+ dprintf("bit_lmz: block=%d\n", (vp - vector)*VECTOR_QUANTUM_WIDTH + i);
326+ return (vp - vector)*VECTOR_QUANTUM_WIDTH + i;
327+}
328+
329+#endif
330+
331+
332+
333+#ifdef TFTP_OPTIONS
334+
335 static char *tftp_option_get(char *buf, int len, char *option)
336 {
337- int opt_val = 0;
338+ int opt_val = 0;
339 int opt_found = 0;
340 int k;
341-
342- while (len > 0) {
343
344+ while (len > 0) {
345 /* Make sure the options are terminated correctly */
346-
347 for (k = 0; k < len; k++) {
348 if (buf[k] == '\0') {
349 break;
350@@ -117,9 +298,8 @@
351 if (strcasecmp(buf, option) == 0) {
352 opt_found = 1;
353 }
354- }
355- else {
356- if (opt_found) {
357+ } else {
358+ if (opt_found) {
359 return buf;
360 }
361 }
362@@ -138,7 +318,8 @@
363 #endif
364
365 static inline int tftp(const int cmd, const struct hostent *host,
366- const char *remotefile, int localfd, const unsigned short port, int tftp_bufsize)
367+ const char *remotefile, int localfd, const unsigned short port,
368+ struct tftp_option *option)
369 {
370 const int cmd_get = cmd & tftp_cmd_get;
371 const int cmd_put = cmd & tftp_cmd_put;
372@@ -155,18 +336,29 @@
373 int len;
374 int opcode = 0;
375 int finished = 0;
376- int timeout = bb_tftp_num_retries;
377+ int retry = bb_tftp_num_retries;
378 unsigned short block_nr = 1;
379
380-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
381- int want_option_ack = 0;
382+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
383+ struct hostent *mchost;
384+ struct sockaddr_in mcsa;
385+ char *mchostname;
386+ unsigned short mcport;
387+ unsigned char *mcblockmap = NULL;
388+ int master_client = 1;
389+ int mcfd = -1;
390+ int mcmaxblock = 0x10000;
391+ int ack_oack = 0;
392+#else
393+ #define master_client 1
394+ #define ack_oack 0
395 #endif
396
397 /* Can't use RESERVE_CONFIG_BUFFER here since the allocation
398 * size varies meaning BUFFERS_GO_ON_STACK would fail */
399- char *buf=xmalloc(tftp_bufsize + 4);
400+ char *buf=xmalloc(option->blksize + 4);
401
402- tftp_bufsize += 4;
403+ int tftp_bufsize = option->blksize + 4;
404
405 if ((socketfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
406 bb_perror_msg("socket");
407@@ -183,15 +375,21 @@
408 memcpy(&sa.sin_addr, (struct in_addr *) host->h_addr,
409 sizeof(sa.sin_addr));
410
411- /* build opcode */
412-
413- if (cmd_get) {
414- opcode = TFTP_RRQ;
415+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
416+ if (option->multicast) {
417+ const int bmsize = 0x10000 / VECTOR_QUANTUM_WIDTH;
418+ if ((mcfd = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
419+ bb_perror_msg("multicast socket");
420+ return EXIT_FAILURE;
421+ }
422+ mcblockmap = xmalloc(bmsize+1);
423+ memset(mcblockmap, 0, bmsize+1);
424 }
425+#endif
426
427- if (cmd_put) {
428- opcode = TFTP_WRQ;
429- }
430+ /* build opcode */
431+
432+ opcode = cmd_get ? TFTP_RRQ : TFTP_WRQ;
433
434 while (1) {
435
436@@ -203,7 +401,7 @@
437
438 cp += 2;
439
440- /* add filename and mode */
441+ /* First packet of file transfer includes file name, mode, and options */
442
443 if ((cmd_get && (opcode == TFTP_RRQ)) ||
444 (cmd_put && (opcode == TFTP_WRQ))) {
445@@ -223,7 +421,7 @@
446 }
447
448 if (too_long || ((&buf[tftp_bufsize - 1] - cp) < 6)) {
449- bb_error_msg("too long remote-filename");
450+ bb_error_msg("too long: remote filename");
451 break;
452 }
453
454@@ -238,8 +436,8 @@
455
456 if (len != TFTP_BLOCKSIZE_DEFAULT) {
457
458- if ((&buf[tftp_bufsize - 1] - cp) < 15) {
459- bb_error_msg("too long remote-filename");
460+ if ((&buf[tftp_bufsize - 1] - cp) < 15) {
461+ bb_error_msg("buffer too small for blksize option");
462 break;
463 }
464
465@@ -249,16 +447,65 @@
466 cp += 8;
467
468 cp += snprintf(cp, 6, "%d", len) + 1;
469+ }
470+#endif
471+
472+
473+
474+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
475+
476+ if (option->multicast) {
477+ if ((&buf[tftp_bufsize - 1] - cp) < 12) {
478+ bb_error_msg("buffer too small for multicast option");
479+ break;
480+ }
481+
482+ /* add "multicast" option */
483
484- want_option_ack = 1;
485+ memcpy(cp, "multicast\0", 11);
486+ cp += 11;
487+
488+ option->multicast = 0; /* turn back on when server accepts option */
489+ ack_oack = 1; /* acknowledge OACK */
490 }
491+
492 #endif
493+
494+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
495+
496+ if (option->server_timeout != TFTP_TIMEOUT) {
497+ if ((&buf[tftp_bufsize - 1] - cp) < 12) {
498+ bb_error_msg("buffer too small for timeout option");
499+ break;
500+ }
501+
502+ /* add "timeout" option */
503+
504+ memcpy(cp, "timeout", 8);
505+ cp += 8;
506+
507+ cp += snprintf(cp, 4, "%d", option->server_timeout) + 1;
508+ }
509+#endif
510+
511 }
512
513 /* add ack and data */
514
515- if ((cmd_get && (opcode == TFTP_ACK)) ||
516- (cmd_put && (opcode == TFTP_DATA))) {
517+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
518+ else if (option->multicast && opcode == TFTP_ACK) {
519+ if (master_client || ack_oack) {
520+ int blocknum = bit_lmz(mcblockmap);
521+ *((unsigned short *) cp) = htons(blocknum);
522+ cp += 2;
523+ if (blocknum >= mcmaxblock)
524+ finished = 1;
525+ dprintf("ack block %d/%d %s\n", blocknum, mcmaxblock, finished? "finished": "");
526+ }
527+ }
528+#endif
529+ else if ((cmd_get && opcode == TFTP_ACK) ||
530+ (cmd_put && opcode == TFTP_DATA)) {
531
532 *((unsigned short *) cp) = htons(block_nr);
533
534@@ -275,7 +522,7 @@
535 }
536
537 if (len != (tftp_bufsize - 4)) {
538- finished++;
539+ finished = 1;
540 }
541
542 cp += len;
543@@ -283,82 +530,119 @@
544 }
545
546
547- /* send packet */
548+ /* send packet and receive reply */
549
550
551- timeout = bb_tftp_num_retries; /* re-initialize */
552+ retry = bb_tftp_num_retries; /* re-initialize */
553 do {
554-
555+ int selectrc;
556 len = cp - buf;
557
558-#ifdef CONFIG_FEATURE_TFTP_DEBUG
559- fprintf(stderr, "sending %u bytes\n", len);
560- for (cp = buf; cp < &buf[len]; cp++)
561- fprintf(stderr, "%02x ", (unsigned char)*cp);
562- fprintf(stderr, "\n");
563-#endif
564- if (sendto(socketfd, buf, len, 0,
565- (struct sockaddr *) &sa, sizeof(sa)) < 0) {
566- bb_perror_msg("send");
567- len = -1;
568- break;
569- }
570-
571+ /* send packet */
572+ if ((len > 2) && (! option->multicast || master_client || ack_oack)) {
573
574- if (finished && (opcode == TFTP_ACK)) {
575- break;
576+#ifdef CONFIG_FEATURE_TFTP_DEBUG
577+ dprintf("sending %u bytes\n", len);
578+ for (cp = buf; cp < &buf[len]; cp++)
579+ if (debug)
580+ printf("%02x ", *(unsigned char *)cp);
581+ if (debug)
582+ printf("\n");
583+#endif
584+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
585+ ack_oack = 0;
586+#endif
587+ if (sendto(socketfd, buf, len, 0, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
588+ bb_perror_msg("send");
589+ len = -1;
590+ break;
591+ }
592+ if (finished && opcode == TFTP_ACK) {
593+ break;
594+ }
595 }
596
597- /* receive packet */
598+ /* receive reply packet */
599
600 memset(&from, 0, sizeof(from));
601 fromlen = sizeof(from);
602
603- tv.tv_sec = TFTP_TIMEOUT;
604+ tv.tv_sec = option->client_timeout;
605 tv.tv_usec = 0;
606
607 FD_ZERO(&rfds);
608 FD_SET(socketfd, &rfds);
609+ dprintf("set to receive from socketfd (%d)\n", socketfd);
610+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
611+ if (option->multicast) {
612+ FD_SET(mcfd, &rfds);
613+ dprintf("set to receive from mcfd (%d)\n", mcfd);
614+ }
615+#endif
616
617- switch (select(FD_SETSIZE, &rfds, NULL, NULL, &tv)) {
618- case 1:
619- len = recvfrom(socketfd, buf, tftp_bufsize, 0,
620- (struct sockaddr *) &from, &fromlen);
621-
622- if (len < 0) {
623- bb_perror_msg("recvfrom");
624- break;
625+ dprintf("select\n");
626+ selectrc = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);
627+ if (selectrc > 0) {
628+ /* A packet was received */
629+ if (FD_ISSET(socketfd, &rfds)) { /* Unicast packet */
630+ dprintf("from socketfd\n");
631+ len = recvfrom(socketfd, buf, tftp_bufsize, 0, (struct sockaddr *) &from, &fromlen);
632+
633+ if (len < 0) {
634+ bb_perror_msg("recvfrom");
635+ } else {
636+ if (sa.sin_port == port) {
637+ sa.sin_port = from.sin_port;
638+ }
639+ if (sa.sin_port == from.sin_port) {
640+ retry = 0;
641+ } else {
642+ /* bad packet */
643+ /* discard the packet - treat as timeout */
644+ retry = bb_tftp_num_retries;
645+ bb_error_msg("timeout");
646+ }
647+ }
648 }
649
650- timeout = 0;
651-
652- if (sa.sin_port == port) {
653- sa.sin_port = from.sin_port;
654+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
655+ else if (option->multicast && FD_ISSET(mcfd, &rfds)) { /* Multicast packet */
656+ dprintf("from mcfd\n");
657+ len = recvfrom(mcfd, buf, tftp_bufsize, 0, (struct sockaddr *) &from, &fromlen);
658+ if (len < 0) {
659+ bb_perror_msg("multicast recvfrom");
660+ } else {
661+ if (mcsa.sin_port == mcport) {
662+ mcsa.sin_port = from.sin_port;
663+ }
664+ if (mcsa.sin_port == from.sin_port) {
665+ retry = 0;
666+ } else {
667+ retry = bb_tftp_num_retries;
668+ bb_error_msg("multicast timeout");
669+ }
670+ }
671 }
672- if (sa.sin_port == from.sin_port) {
673- break;
674- }
675-
676- /* fall-through for bad packets! */
677- /* discard the packet - treat as timeout */
678- timeout = bb_tftp_num_retries;
679+#endif
680
681- case 0:
682+ } else if (selectrc == 0) {
683+ /* Time out */
684+ dprintf("timeout\n");
685 bb_error_msg("timeout");
686
687- timeout--;
688- if (timeout == 0) {
689+ retry--;
690+ if (retry == 0) {
691 len = -1;
692 bb_error_msg("last timeout");
693 }
694- break;
695-
696- default:
697+ } else {
698+ /* Error condition */
699+ dprintf("error\n");
700 bb_perror_msg("select");
701 len = -1;
702 }
703
704- } while (timeout && (len >= 0));
705+ } while (retry && len >= 0);
706
707 if ((finished) || (len < 0)) {
708 break;
709@@ -370,9 +654,8 @@
710 opcode = ntohs(*((unsigned short *) buf));
711 tmp = ntohs(*((unsigned short *) &buf[2]));
712
713-#ifdef CONFIG_FEATURE_TFTP_DEBUG
714- fprintf(stderr, "received %d bytes: %04x %04x\n", len, opcode, tmp);
715-#endif
716+ dprintf("received %d bytes: %04x %04x\n", len, opcode, tmp);
717+ dprintf("master_client=%d\n", master_client);
718
719 if (opcode == TFTP_ERROR) {
720 char *msg = NULL;
721@@ -393,55 +676,116 @@
722 break;
723 }
724
725-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
726- if (want_option_ack) {
727+#ifdef TFTP_OPTIONS
728
729- want_option_ack = 0;
730+ if (opcode == TFTP_OACK) {
731
732- if (opcode == TFTP_OACK) {
733+ /* server seems to support options */
734
735- /* server seems to support options */
736+ char *res;
737+
738+ block_nr = 0; /* acknowledge option packet with block number 0 */
739+ opcode = cmd_put ? TFTP_DATA : TFTP_ACK;
740
741- char *res;
742
743- res = tftp_option_get(&buf[2], len-2,
744- "blksize");
745+#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
746+ res = tftp_option_get(&buf[2], len-2, "blksize");
747
748- if (res) {
749- int blksize = atoi(res);
750-
751- if (tftp_blocksize_check(blksize,
752- tftp_bufsize - 4)) {
753+ if (res) {
754+ int blksize = atoi(res);
755
756- if (cmd_put) {
757- opcode = TFTP_DATA;
758- }
759- else {
760- opcode = TFTP_ACK;
761- }
762-#ifdef CONFIG_FEATURE_TFTP_DEBUG
763- fprintf(stderr, "using blksize %u\n", blksize);
764+ if (tftp_blocksize_check(blksize, tftp_bufsize - 4)) {
765+ dprintf("using blksize %d\n", blksize);
766+ tftp_bufsize = blksize + 4;
767+ free(buf);
768+ buf = xmalloc(tftp_bufsize);
769+ } else {
770+ bb_error_msg("bad blksize %d", blksize);
771+ break;
772+ }
773+ }
774 #endif
775- tftp_bufsize = blksize + 4;
776- block_nr = 0;
777- continue;
778- }
779- }
780- /* FIXME:
781- * we should send ERROR 8 */
782- bb_error_msg("bad server option");
783- break;
784- }
785
786- bb_error_msg("warning: blksize not supported by server"
787- " - reverting to 512");
788
789- tftp_bufsize = TFTP_BLOCKSIZE_DEFAULT + 4;
790+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
791+ res = tftp_option_get(&buf[2], len-2, "multicast");
792+
793+ if (res) {
794+ ack_oack = 1;
795+ if (tftp_multicast_check(res, &mchostname, &mcport, &master_client)) {
796+ struct ip_mreq mreq;
797+ struct in_addr mcaddr;
798+
799+ dprintf("using multicast\n");
800+
801+ mchost = xgethostbyname(mchostname);
802+ if (mchost) {
803+ memcpy(&mcaddr, mchost->h_addr, mchost->h_length);
804+ if (! IN_MULTICAST(ntohl(mcaddr.s_addr))) {
805+ bb_error_msg("bad multicast address: %s", mchostname);
806+ break;
807+ }
808+ } else {
809+ bb_error_msg("bad multicast address: %s", mchostname);
810+ break;
811+ }
812+
813+ memset(&mcsa, 0, sizeof(mcsa));
814+ mcsa.sin_family = AF_INET;
815+ mcsa.sin_addr.s_addr = htonl(INADDR_ANY);
816+ mcsa.sin_port = mcport;
817+
818+ bind(mcfd, (struct sockaddr *)&mcsa, sizeof(mcsa));
819+
820+ mreq.imr_multiaddr.s_addr = mcaddr.s_addr;
821+ mreq.imr_interface.s_addr = htonl(INADDR_ANY);
822+
823+ if (setsockopt(mcfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0)
824+ {
825+ bb_error_msg("setsockopt");
826+ break;
827+ }
828+
829+ option->multicast = 1;
830+ } else {
831+ bb_error_msg("bad multicast option value: %s", res);
832+ break;
833+ }
834+ }
835+#endif
836+
837 }
838+ else
839 #endif
840
841 if (cmd_get && (opcode == TFTP_DATA)) {
842
843+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
844+ if (option->multicast) {
845+ int bn = tmp - 1;
846+ /* Do I need this block? */
847+ if (! bit_isset(bn, mcblockmap)) {
848+ lseek(localfd, bn*(tftp_bufsize-4), SEEK_SET);
849+ len = write(localfd, &buf[4], len-4);
850+ if (len < 0) {
851+ bb_perror_msg(bb_msg_write_error);
852+ break;
853+ }
854+ bit_set(bn, mcblockmap);
855+ if (len != (tftp_bufsize-4)) {
856+ mcmaxblock = tmp;
857+ dprintf("mcmaxblock=%d, (len(%d) != tftp_bufsize-4(%d))\n", mcmaxblock, len, tftp_bufsize-4);
858+ }
859+ opcode = TFTP_ACK;
860+ }
861+ /* Do not acknowledge block if I already have a copy of the block. A situation can arise when the server
862+ * and client timeout nearly simultaneously. The server retransmits the block at the same time the client
863+ * re-requests the block. From then on out, each block is transmitted twice--not a good use of bandwidth.
864+ */
865+ }
866+ else
867+#endif
868+
869 if (tmp == block_nr) {
870
871 len = write(localfd, &buf[4], len - 4);
872@@ -452,15 +796,14 @@
873 }
874
875 if (len != (tftp_bufsize - 4)) {
876- finished++;
877+ finished = 1;
878 }
879
880 opcode = TFTP_ACK;
881- continue;
882 }
883 }
884
885- if (cmd_put && (opcode == TFTP_ACK)) {
886+ else if (cmd_put && opcode == TFTP_ACK) {
887
888 if (tmp == (unsigned short)(block_nr - 1)) {
889 if (finished) {
890@@ -468,15 +811,19 @@
891 }
892
893 opcode = TFTP_DATA;
894- continue;
895 }
896 }
897 }
898
899 #ifdef CONFIG_FEATURE_CLEAN_UP
900 close(socketfd);
901+ free(buf);
902+
903+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
904+ if (mcblockmap != NULL)
905+ free(mcblockmap);
906+#endif
907
908- free(buf);
909 #endif
910
911 return finished ? EXIT_SUCCESS : EXIT_FAILURE;
912@@ -487,13 +834,18 @@
913 struct hostent *host = NULL;
914 char *localfile = NULL;
915 char *remotefile = NULL;
916- int port;
917+ unsigned short port;
918 int cmd = 0;
919 int fd = -1;
920 int flags = 0;
921 int opt;
922 int result;
923- int blocksize = TFTP_BLOCKSIZE_DEFAULT;
924+ struct tftp_option option = {
925+ .multicast = 0,
926+ .blksize = TFTP_BLOCKSIZE_DEFAULT,
927+ .client_timeout = TFTP_TIMEOUT,
928+ .server_timeout = TFTP_TIMEOUT,
929+ };
930
931 /* figure out what to pass to getopt */
932
933@@ -515,13 +867,45 @@
934 #define PUT
935 #endif
936
937- while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) {
938+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
939+#define TO "T:t:"
940+#else
941+#define TO
942+#endif
943+
944+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
945+#define MC "m"
946+#else
947+#define MC
948+#endif
949+
950+#ifdef CONFIG_FEATURE_TFTP_DEBUG
951+#define DB "D"
952+#else
953+#define DB
954+#endif
955+
956+ while ((opt = getopt(argc, argv, BS GET PUT TO MC DB "l:r:")) != -1) {
957 switch (opt) {
958 #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
959 case 'b':
960- blocksize = atoi(optarg);
961- if (!tftp_blocksize_check(blocksize, 0)) {
962- return EXIT_FAILURE;
963+ option.blksize = atoi(optarg);
964+ if (!tftp_blocksize_check(option.blksize, 0)) {
965+ return EXIT_FAILURE;
966+ }
967+ break;
968+#endif
969+#ifdef CONFIG_FEATURE_TFTP_TIMEOUT
970+ case 'T':
971+ option.client_timeout = atoi(optarg);
972+ if (!tftp_timeout_check(option.client_timeout)) {
973+ return EXIT_FAILURE;
974+ }
975+ break;
976+ case 't':
977+ option.server_timeout = atoi(optarg);
978+ if (!tftp_timeout_check(option.server_timeout)) {
979+ return EXIT_FAILURE;
980 }
981 break;
982 #endif
983@@ -537,18 +921,34 @@
984 flags = O_RDONLY;
985 break;
986 #endif
987+#ifdef CONFIG_FEATURE_TFTP_MULTICAST
988+ case 'm':
989+ option.multicast = 1; /* receive multicast file */
990+ break;
991+#endif
992+#ifdef CONFIG_FEATURE_TFTP_DEBUG
993+ case 'D':
994+ debug = 1;
995+ break;
996+#endif
997 case 'l':
998 localfile = bb_xstrdup(optarg);
999 break;
1000 case 'r':
1001 remotefile = bb_xstrdup(optarg);
1002 break;
1003+ default:
1004+ bb_show_usage();
1005 }
1006 }
1007
1008 if ((cmd == 0) || (optind == argc)) {
1009 bb_show_usage();
1010 }
1011+ if (cmd == tftp_cmd_put && option.multicast) {
1012+ fprintf(stderr, "Multicast (-m) invalid option with put (-p) command\n");
1013+ exit(EXIT_FAILURE);
1014+ }
1015 if(localfile && strcmp(localfile, "-") == 0) {
1016 fd = fileno((cmd==tftp_cmd_get)? stdout : stdin);
1017 }
1018@@ -566,14 +966,12 @@
1019 host = xgethostbyname(argv[optind]);
1020 port = bb_lookup_port(argv[optind + 1], "udp", 69);
1021
1022-#ifdef CONFIG_FEATURE_TFTP_DEBUG
1023- fprintf(stderr, "using server \"%s\", remotefile \"%s\", "
1024+ dprintf("using server \"%s\", remotefile \"%s\", "
1025 "localfile \"%s\".\n",
1026 inet_ntoa(*((struct in_addr *) host->h_addr)),
1027 remotefile, localfile);
1028-#endif
1029
1030- result = tftp(cmd, host, remotefile, fd, port, blocksize);
1031+ result = tftp(cmd, host, remotefile, fd, port, &option);
1032
1033 #ifdef CONFIG_FEATURE_CLEAN_UP
1034 if (!(fd == STDOUT_FILENO || fd == STDIN_FILENO)) {
1035@@ -582,3 +980,18 @@
1036 #endif
1037 return(result);
1038 }
1039+
1040+
1041+#ifdef CONFIG_FEATURE_TFTP_DEBUG
1042+
1043+#include <sys/time.h>
1044+
1045+static void
1046+printtime(void)
1047+{
1048+ struct timeval tv;
1049+ gettimeofday(&tv, NULL);
1050+ printf("%11lu.%06lu ", tv.tv_sec, tv.tv_usec);
1051+}
1052+
1053+#endif
diff --git a/patches/top_system_cpu.diff b/patches/top_system_cpu.diff
deleted file mode 100644
index 5d213e76a..000000000
--- a/patches/top_system_cpu.diff
+++ /dev/null
@@ -1,51 +0,0 @@
1diff -purN busybox.ori/include/libbb.h busybox/include/libbb.h
2--- busybox.ori/include/libbb.h 2004-03-21 14:39:35.000000000 +0100
3+++ busybox-1.0/include/libbb.h 2004-03-21 14:45:35.000000000 +0100
4@@ -447,6 +447,7 @@ typedef struct {
5 int ppid;
6 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
7 unsigned pcpu;
8+ unsigned pscpu;
9 unsigned long stime, utime;
10 #endif
11 char *cmd;
12diff -purN busybox.ori/procps/top.c busybox/procps/top.c
13--- busybox.ori/procps/top.c 2004-03-21 14:40:09.000000000 +0100
14+++ busybox-1.0/procps/top.c 2004-03-21 17:27:52.961951448 +0100
15@@ -289,6 +289,15 @@ static void do_stats(void)
16 i = 999;
17 cur->pcpu = i;
18
19+ /*
20+ * Calculate percent of system time from cpu time
21+ */
22+ if (systime != 0) {
23+ cur->pscpu = 100 * total_time / systime;
24+ } else {
25+ cur->pscpu = 0;
26+ }
27+
28 }
29
30 /*
31@@ -393,7 +402,7 @@ static void display_status(int count, in
32
33 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
34 /* what info of the processes is shown */
35- printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%MEM COMMAND\e[0m\n");
36+ printf("\n\e[7m PID USER STATUS RSS PPID %%CPU %%SCPU %%MEM COMMAND\e[0m\n");
37 #else
38 printf("\n\e[7m PID USER STATUS RSS PPID %%MEM COMMAND\e[0m\n");
39 #endif
40@@ -410,9 +419,9 @@ static void display_status(int count, in
41 else
42 sprintf(rss_str_buf, "%7ld", s->rss);
43 #ifdef FEATURE_CPU_USAGE_PERCENTAGE
44- printf("%5d %-8s %s %s %5d %2d.%d %2u.%u ",
45+ printf("%5d %-8s %s %s %5d %2d.%d %2d.%d %2u.%u ",
46 s->pid, s->user, s->state, rss_str_buf, s->ppid,
47- s->pcpu/10, s->pcpu%10, pmem/10, pmem%10);
48+ s->pcpu/10, s->pcpu%10,s->pscpu/10, s->pscpu%10, pmem/10, pmem%10);
49 #else
50 printf("%5d %-8s %s %s %5d %2u.%u ",
51 s->pid, s->user, s->state, rss_str_buf, s->ppid,
diff --git a/patches/udhcp_additional_items.diff b/patches/udhcp_additional_items.diff
deleted file mode 100644
index 933be2ad4..000000000
--- a/patches/udhcp_additional_items.diff
+++ /dev/null
@@ -1,126 +0,0 @@
1Index: include/usage.h
2===================================================================
3RCS file: /var/cvs/busybox/include/usage.h,v
4retrieving revision 1.191
5diff -u -r1.191 usage.h
6--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
7+++ b/include/usage.h 5 Mar 2004 14:32:45 -0000
8@@ -2606,6 +2606,7 @@
9 "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
10 "\t-q,\t--quit\tQuit after obtaining lease\n" \
11 "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
12+ "\t-R,\t--require=NAME\tAdd NAME to request\n" \
13 "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
14 "\t-v,\t--version\tDisplay version"
15
16Index: networking/udhcp/README.udhcpc
17===================================================================
18RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v
19retrieving revision 1.3
20diff -u -r1.3 README.udhcpc
21--- a/networking/udhcp/README.udhcpc 11 Dec 2002 21:12:44 -0000 1.3
22+++ b/networking/udhcp/README.udhcpc 5 Mar 2004 14:32:46 -0000
23@@ -22,6 +22,7 @@
24 -p, --pidfile=file Store process ID of daemon in file
25 -q, --quit Quit after obtaining lease
26 -r, --request=IP IP address to request (default: none)
27+-R, --require=NAME Add NAME to request
28 -s, --script=file Run file at dhcp events (default:
29 /usr/share/udhcpc/default.script)
30 -v, --version Display version
31@@ -101,6 +102,8 @@
32
33 additional options are easily added in options.c.
34
35+By default, only a few basic items are requested. To request additional
36+items use the -R option. Example: "-R rootpath"
37
38 note on udhcpc's random seed
39 ---------------------------
40Index: networking/udhcp/dhcpc.c
41===================================================================
42RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.c,v
43retrieving revision 1.16
44diff -u -r1.16 dhcpc.c
45--- a/networking/udhcp/dhcpc.c 30 Jan 2004 23:45:12 -0000 1.16
46+++ b/networking/udhcp/dhcpc.c 5 Mar 2004 14:32:46 -0000
47@@ -88,6 +88,7 @@
48 " -p, --pidfile=file Store process ID of daemon in file\n"
49 " -q, --quit Quit after obtaining lease\n"
50 " -r, --request=IP IP address to request (default: none)\n"
51+" -R, --require=NAME Add NAME to the request\n"
52 " -s, --script=file Run file at dhcp events (default:\n"
53 " " DEFAULT_SCRIPT ")\n"
54 " -v, --version Display version\n"
55@@ -203,6 +204,7 @@
56 {"pidfile", required_argument, 0, 'p'},
57 {"quit", no_argument, 0, 'q'},
58 {"request", required_argument, 0, 'r'},
59+ {"require", required_argument, 0, 'R'},
60 {"script", required_argument, 0, 's'},
61 {"version", no_argument, 0, 'v'},
62 {0, 0, 0, 0}
63@@ -211,7 +213,7 @@
64 /* get options */
65 while (1) {
66 int option_index = 0;
67- c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index);
68+ c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:R:s:v", arg_options, &option_index);
69 if (c == -1) break;
70
71 switch (c) {
72@@ -254,6 +256,11 @@
73 case 'r':
74 requested_ip = inet_addr(optarg);
75 break;
76+ case 'R':
77+ if (require_option(optarg)) {
78+ fprintf(stderr,"WARNING: %s unknown/not-supported (Ignored)\n", optarg );
79+ }
80+ break;
81 case 's':
82 client_config.script = optarg;
83 break;
84Index: networking/udhcp/options.c
85===================================================================
86RCS file: /var/cvs/busybox/networking/udhcp/options.c,v
87retrieving revision 1.7
88diff -u -r1.7 options.c
89--- a/networking/udhcp/options.c 30 Jan 2004 23:45:12 -0000 1.7
90+++ b/networking/udhcp/options.c 5 Mar 2004 14:32:46 -0000
91@@ -57,7 +57,19 @@
92 [OPTION_S32] = 4
93 };
94
95-
96+/* find and mark requested item as required */
97+int require_option(char *name)
98+{
99+ int i;
100+ for (i = 0; dhcp_options[i].code; i++) {
101+ if (strcmp(name, dhcp_options[i].name) == 0 ){
102+ dhcp_options[i].flags |= OPTION_REQ;
103+ return 0;
104+ }
105+ }
106+ return 1;
107+}
108+
109 /* get an option with bounds checking (warning, not aligned). */
110 uint8_t *get_option(struct dhcpMessage *packet, int code)
111 {
112Index: networking/udhcp/options.h
113===================================================================
114RCS file: /var/cvs/busybox/networking/udhcp/options.h,v
115retrieving revision 1.5
116diff -u -r1.5 options.h
117--- a/networking/udhcp/options.h 30 Jan 2004 23:45:12 -0000 1.5
118+++ b/networking/udhcp/options.h 5 Mar 2004 14:32:46 -0000
119@@ -30,6 +30,7 @@
120 extern struct dhcp_option dhcp_options[];
121 extern int option_lengths[];
122
123+int require_option(char *name);
124 uint8_t *get_option(struct dhcpMessage *packet, int code);
125 int end_option(uint8_t *optionptr);
126 int add_option_string(uint8_t *optionptr, uint8_t *string);
diff --git a/patches/udhcp_config_paths.diff b/patches/udhcp_config_paths.diff
deleted file mode 100644
index 1d3a6b4b0..000000000
--- a/patches/udhcp_config_paths.diff
+++ /dev/null
@@ -1,333 +0,0 @@
1Index: include/usage.h
2===================================================================
3RCS file: /var/cvs/busybox/include/usage.h,v
4retrieving revision 1.191
5diff -u -r1.191 usage.h
6--- a/include/usage.h 25 Feb 2004 10:35:55 -0000 1.191
7+++ b/include/usage.h 5 Mar 2004 13:20:11 -0000
8@@ -2606,7 +2606,8 @@
9 "\t-p,\t--pidfile=file\tStore process ID of daemon in file\n" \
10 "\t-q,\t--quit\tQuit after obtaining lease\n" \
11 "\t-r,\t--request=IP\tIP address to request (default: none)\n" \
12- "\t-s,\t--script=file\tRun file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
13+ "\t-s,\t--script=file\tRun file at dhcp events (default: " \
14+ CONFIG_UDHCPC_SCRIPT_PATH ")\n" \
15 "\t-v,\t--version\tDisplay version"
16
17 #define udhcpd_trivial_usage \
18Index: networking/udhcp/AUTHORS
19===================================================================
20RCS file: /var/cvs/busybox/networking/udhcp/AUTHORS,v
21retrieving revision 1.3
22diff -u -r1.3 AUTHORS
23--- a/networking/udhcp/AUTHORS 18 Dec 2003 22:25:38 -0000 1.3
24+++ b/networking/udhcp/AUTHORS 5 Mar 2004 13:20:11 -0000
25@@ -10,5 +10,5 @@
26 Moreton Bay (http://www.moretonbay.com/)
27 Vladimir Oleynik <dzo@simtrea.ru> Size optimizations
28
29-
30+Tony J. White <tjw@tjw.org> additional busybox build options
31
32Index: networking/udhcp/Config.in
33===================================================================
34RCS file: /var/cvs/busybox/networking/udhcp/Config.in,v
35retrieving revision 1.5
36diff -u -r1.5 Config.in
37--- a/networking/udhcp/Config.in 22 Oct 2003 09:58:38 -0000 1.5
38+++ b/networking/udhcp/Config.in 5 Mar 2004 13:20:11 -0000
39@@ -58,5 +58,62 @@
40
41 See http://udhcp.busybox.net for further details.
42
43+menu "udhcpd Configuration Options"
44+ depends on CONFIG_UDHCPD
45+
46+config CONFIG_UDHCPD_CONF_PATH
47+ string "Path to default udhcpd.conf"
48+ default "/etc/udhcpd.conf"
49+ depends on CONFIG_UDHCPD
50+ help
51+ The full path to udhcpd's default configuration file.
52+ (default is: /etc/udhcpd.conf)
53+
54+config CONFIG_UDHCPD_LEASE_PATH
55+ string "Path to default udhcpd.leases"
56+ default "/var/lib/misc/udhcpd.leases"
57+ depends on CONFIG_UDHCPD
58+ help
59+ The full path to udhcpd's default leases file.
60+ (default is: /var/lib/misc/udhcpd.leases)
61+
62+config CONFIG_UDHCPD_PID_PATH
63+ string "Path to default udhcpd PID file"
64+ default "/var/run/udhcpd.pid"
65+ depends on CONFIG_UDHCPD
66+ help
67+ The full path to udhcpd's default pid file.
68+ (default is: /var/run/udhcpd.pid)
69+
70+endmenu
71+
72+menu "udhcpc Configuration Options"
73+ depends on CONFIG_UDHCPC
74+
75+config CONFIG_UDHCPC_SCRIPT_PATH
76+ string "Path to default udhcpc event script"
77+ depends on CONFIG_UDHCPC
78+ help
79+ The full path to udhcpc's default event script file.
80+ (default is: /usr/share/udhcpc/default.script OR
81+ /share/udhcpc/default.script if CONFIG_INSTALL_NO_USR is set)
82+
83+ When udhcpc is started it executes this script to take care
84+ of system tasks after it completes DHCP communication. Such
85+ tasks include putting network interfaces up or down, setting
86+ DNS info, adding routing information, etc.
87+
88+if CONFIG_INSTALL_NO_USR
89+config CONFIG_UDHCPC_SCRIPT_PATH
90+ default "/share/udhcpc/default.script"
91+endif
92+
93+if !CONFIG_INSTALL_NO_USR
94+config CONFIG_UDHCPC_SCRIPT_PATH
95+ default "/usr/share/udhcpc/default.script"
96+endif
97+
98+endmenu
99+
100 endmenu
101
102Index: networking/udhcp/README
103===================================================================
104RCS file: /var/cvs/busybox/networking/udhcp/README,v
105retrieving revision 1.3
106diff -u -r1.3 README
107--- a/networking/udhcp/README 18 Dec 2003 22:25:38 -0000 1.3
108+++ b/networking/udhcp/README 5 Mar 2004 13:20:11 -0000
109@@ -9,27 +9,42 @@
110 compile time options
111 -------------------
112
113-The Makefile contains three of the compile time options:
114+The following options can be adjusted when configuring busybox:
115
116- UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra
117- debugging output, compile with -g, and not fork to the background when
118- run.
119- UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its
120- messages syslog, otherwise, it will attempt to log them to stdout.
121-
122- COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd,
123- is created. If called as udhcpd, the dhcp server will be started.
124- If called as udhcpc, the dhcp client will be started.
125-
126-dhcpd.h contains the other three compile time options:
127-
128- LEASE_TIME: The default lease time if not specified in the config
129- file.
130+ CONFIG_FEATURE_UDHCP_DEBUG:
131+ If this is defined, udhcpd will output extra debugging output,
132+ compile with -g, and not fork to the background when run.
133
134- LEASES_FILE: The default file for storing leases.
135-
136- DHCPD_CONFIG_FILE: The defualt config file to use.
137+ CONFIG_FEATURE_UDHCP_SYSLOG:
138+ If this is defined, udhcpd will log all its messages syslog,
139+ otherwise, it will attempt to log them to stdout.
140+
141+ CONFIG_UDHCPD_CONF_PATH:
142+ The full path to udhcpd's default configuration file.
143+
144+ CONFIG_UDHCPD_LEASE_PATH:
145+ The full path to udhcpd's default leases file.
146+
147+ CONFIG_UDHCPD_PID_PATH:
148+ The full path to udhcpd's default pid file.
149+
150+ CONFIG_UDHCPC_SCRIPT_PATH:
151+ The full path to udhcpc's default event script file.
152+ (default is: /usr/share/udhcpc/default.script)
153+
154+ When udhcpc is started it executes this script to take care
155+ of system tasks after it completes DHCP communication. Such
156+ tasks include putting network interfaces up or down, setting
157+ DNS info, adding routing information, etc.
158+
159+
160+dhcpd.h contains the another compile time option:
161
162+ LEASE_TIME:
163+ The default lease time if not specified in the config file.
164+ This option can also be changed at runtime with the 'lease'
165+ configuration option.
166+
167 options.c contains a set of dhcp options for the client:
168
169 name[10]: The name of the option as it will appear in scripts
170Index: networking/udhcp/README.udhcpc
171===================================================================
172RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpc,v
173retrieving revision 1.3
174diff -u -r1.3 README.udhcpc
175--- a/networking/udhcp/README.udhcpc 11 Dec 2002 21:12:44 -0000 1.3
176+++ b/networking/udhcp/README.udhcpc 5 Mar 2004 13:20:11 -0000
177@@ -23,7 +23,8 @@
178 -q, --quit Quit after obtaining lease
179 -r, --request=IP IP address to request (default: none)
180 -s, --script=file Run file at dhcp events (default:
181- /usr/share/udhcpc/default.script)
182+ /usr/share/udhcpc/default.script or
183+ CONFIG_UDHCPC_SCRIPT_PATH at build time)
184 -v, --version Display version
185
186
187Index: networking/udhcp/README.udhcpd
188===================================================================
189RCS file: /var/cvs/busybox/networking/udhcp/README.udhcpd,v
190retrieving revision 1.1
191diff -u -r1.1 README.udhcpd
192--- a/networking/udhcp/README.udhcpd 31 Oct 2002 19:21:27 -0000 1.1
193+++ b/networking/udhcp/README.udhcpd 5 Mar 2004 13:20:11 -0000
194@@ -50,10 +50,14 @@
195
196 compile time options
197 -------------------
198+
199+During busybox configuration, you can change the default paths for
200+udhcpd.conf, udhcpd.leases, and udhcpd.pid files. See README for
201+more details.
202
203-dhcpd.h contains the other two compile time options:
204+dhcpd.h contains the compile time option:
205
206 LEASE_TIME: The default lease time if not specified in the config
207 file.
208+
209
210- DHCPD_CONFIG_FILE: The defualt config file to use.
211Index: networking/udhcp/dhcpc.h
212===================================================================
213RCS file: /var/cvs/busybox/networking/udhcp/dhcpc.h,v
214retrieving revision 1.4
215diff -u -r1.4 dhcpc.h
216--- a/networking/udhcp/dhcpc.h 30 Jan 2004 23:45:12 -0000 1.4
217+++ b/networking/udhcp/dhcpc.h 5 Mar 2004 13:20:11 -0000
218@@ -2,7 +2,11 @@
219 #ifndef _DHCPC_H
220 #define _DHCPC_H
221
222-#define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
223+#ifdef CONFIG_UDHCPC_SCRIPT_PATH
224+ #define DEFAULT_SCRIPT CONFIG_UDHCPC_SCRIPT_PATH
225+#else
226+ #define DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
227+#endif
228
229 /* allow libbb_udhcp.h to redefine DEFAULT_SCRIPT */
230 #include "libbb_udhcp.h"
231Index: networking/udhcp/dhcpd.c
232===================================================================
233RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.c,v
234retrieving revision 1.5
235diff -u -r1.5 dhcpd.c
236--- a/networking/udhcp/dhcpd.c 30 Jan 2004 23:45:12 -0000 1.5
237+++ b/networking/udhcp/dhcpd.c 5 Mar 2004 13:20:11 -0000
238@@ -70,6 +70,13 @@
239 struct dhcpOfferedAddr *lease;
240 int max_sock;
241 unsigned long num_ips;
242+ int daemonize = 1;
243+
244+ while (strcmp(argv[1],"-f")==0 || strcmp(argv[1],"--foreground")==0) {
245+ daemonize = 0;
246+ argv++;
247+ argc--;
248+ }
249
250 memset(&server_config, 0, sizeof(struct server_config_t));
251 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
252@@ -99,9 +106,8 @@
253 &server_config.server, server_config.arp) < 0)
254 return 1;
255
256-#ifndef UDHCP_DEBUG
257- background(server_config.pidfile); /* hold lock during fork. */
258-#endif
259+ if(daemonize)
260+ background(server_config.pidfile); /* hold lock during fork. */
261
262 /* Setup the signal pipe */
263 udhcp_sp_setup();
264Index: networking/udhcp/dhcpd.h
265===================================================================
266RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.h,v
267retrieving revision 1.5
268diff -u -r1.5 dhcpd.h
269--- a/networking/udhcp/dhcpd.h 30 Jan 2004 23:45:12 -0000 1.5
270+++ b/networking/udhcp/dhcpd.h 5 Mar 2004 13:20:12 -0000
271@@ -15,11 +15,25 @@
272
273 /* the period of time the client is allowed to use that address */
274 #define LEASE_TIME (60*60*24*10) /* 10 days of seconds */
275-#define LEASES_FILE "/var/lib/misc/udhcpd.leases"
276+
277+#ifdef CONFIG_UDHCPD_LEASE_PATH
278+ #define LEASES_FILE CONFIG_UDHCPD_LEASE_PATH
279+#else
280+ #define LEASES_FILE "/var/lib/misc/udhcpd.leases"
281+#endif
282
283 /* where to find the DHCP server configuration file */
284-#define DHCPD_CONF_FILE "/etc/udhcpd.conf"
285+#ifdef CONFIG_UDHCPD_CONF_PATH
286+ #define DHCPD_CONF_FILE CONFIG_UDHCPD_CONF_PATH
287+#else
288+ #define DHCPD_CONF_FILE "/etc/udhcpd.conf"
289+#endif
290
291+#ifdef CONFIG_UDHCPD_PID_PATH
292+ #define DHCPD_PID_FILE CONFIG_UDHCPD_PID_PATH
293+#else
294+ #define DHCPD_PID_FILE "/var/run/udhcpd.pid"
295+#endif
296 /*****************************************************************/
297 /* Do not modify below here unless you know what you are doing!! */
298 /*****************************************************************/
299Index: networking/udhcp/files.c
300===================================================================
301RCS file: /var/cvs/busybox/networking/udhcp/files.c,v
302retrieving revision 1.13
303diff -u -r1.13 files.c
304--- a/networking/udhcp/files.c 30 Jan 2004 23:45:12 -0000 1.13
305+++ b/networking/udhcp/files.c 5 Mar 2004 13:20:13 -0000
306@@ -166,7 +166,7 @@
307 {"offer_time", read_u32, &(server_config.offer_time), "60"},
308 {"min_lease", read_u32, &(server_config.min_lease), "60"},
309 {"lease_file", read_str, &(server_config.lease_file), LEASES_FILE},
310- {"pidfile", read_str, &(server_config.pidfile), "/var/run/udhcpd.pid"},
311+ {"pidfile", read_str, &(server_config.pidfile), DHCPD_PID_FILE},
312 {"notify_file", read_str, &(server_config.notify_file), ""},
313 {"siaddr", read_ip, &(server_config.siaddr), "0.0.0.0"},
314 {"sname", read_str, &(server_config.sname), ""},
315Index: networking/udhcp/libbb_udhcp.h
316===================================================================
317RCS file: /var/cvs/busybox/networking/udhcp/libbb_udhcp.h,v
318retrieving revision 1.5
319diff -u -r1.5 libbb_udhcp.h
320--- a/networking/udhcp/libbb_udhcp.h 18 Dec 2003 22:25:38 -0000 1.5
321+++ b/networking/udhcp/libbb_udhcp.h 5 Mar 2004 13:20:13 -0000
322@@ -3,11 +3,6 @@
323 /* bit of a hack, do this no matter what the order of the includes.
324 * (for busybox) */
325
326-#ifdef CONFIG_INSTALL_NO_USR
327-#undef DEFUALT_SCRIPT
328-#define DEFAULT_SCRIPT "/share/udhcpc/default.script"
329-#endif
330-
331 #ifndef _LIBBB_UDHCP_H
332 #define _LIBBB_UDHCP_H
333
diff --git a/patches/udhcpd_foreground.diff b/patches/udhcpd_foreground.diff
deleted file mode 100644
index 3b8c7eb0c..000000000
--- a/patches/udhcpd_foreground.diff
+++ /dev/null
@@ -1,33 +0,0 @@
1Index: ./networking/udhcp/dhcpd.c
2===================================================================
3RCS file: /var/cvs/busybox/networking/udhcp/dhcpd.c,v
4retrieving revision 1.5
5diff -u -r1.5 dhcpd.c
6--- a/./networking/udhcp/dhcpd.c 30 Jan 2004 23:45:12 -0000 1.5
7+++ b/./networking/udhcp/dhcpd.c 5 Mar 2004 13:09:05 -0000
8@@ -70,6 +70,13 @@
9 struct dhcpOfferedAddr *lease;
10 int max_sock;
11 unsigned long num_ips;
12+ int daemonize = 1;
13+
14+ while (strcmp(argv[1],"-f")==0 || strcmp(argv[1],"--foreground")==0) {
15+ daemonize = 0;
16+ argv++;
17+ argc--;
18+ }
19
20 memset(&server_config, 0, sizeof(struct server_config_t));
21 read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]);
22@@ -99,9 +106,8 @@
23 &server_config.server, server_config.arp) < 0)
24 return 1;
25
26-#ifndef UDHCP_DEBUG
27- background(server_config.pidfile); /* hold lock during fork. */
28-#endif
29+ if(daemonize)
30+ background(server_config.pidfile); /* hold lock during fork. */
31
32 /* Setup the signal pipe */
33 udhcp_sp_setup();
diff --git a/patches/woot.txt b/patches/woot.txt
deleted file mode 100644
index 22b521e41..000000000
--- a/patches/woot.txt
+++ /dev/null
@@ -1,26 +0,0 @@
1Testing to see if I can rename a file without blanking its history.
2
3That'd be dalias' suggestion..
4
5Mine was #define isdigit(a) (a>='0'&&a<='9'), but i forgot to record the
6exact savings..
7 text data bss dec hex filename
8 864252 10252 645860 1520364 1732ec busybox_old
9 863714 10244 645892 1519850 1730ea busybox_unstripped
10
11
12Index: include/libbb.h
13===================================================================
14--- include/libbb.h (revision 15244)
15+++ include/libbb.h (working copy)
16@@ -531,4 +531,10 @@
17 #include <dmalloc.h>
18 #endif
19
20+#if 1
21+#include <ctype.h>
22+#define _CTYPE_H 1 /* muahahaha */
23+#undef isdigit
24+#define isdigit(a) ((unsigned)(a)-'0' < 10)
25+#endif
26 #endif /* __LIBBUSYBOX_H__ */