aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-08-14 16:45:29 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-08-14 16:45:29 +0000
commit3d17d2b430a6a68c967b789c990cc441154d695e (patch)
treeb01535085348ea653c1c9d5ef3b525b461c02fc3
parentdbe6e66d6a8addbbf9438f40a645be8ae105fa8a (diff)
downloadbusybox-w32-3d17d2b430a6a68c967b789c990cc441154d695e.tar.gz
busybox-w32-3d17d2b430a6a68c967b789c990cc441154d695e.tar.bz2
busybox-w32-3d17d2b430a6a68c967b789c990cc441154d695e.zip
udhcpd: add -f "foreground" and -S "syslog" options
udhcpc: add -S "syslog" options remove CONFIG_FEATURE_UDHCP_SYSLOG function old new delta udhcpd_main 1168 1201 +33 udhcpc_main 2414 2425 +11 static.udhcpc_longopts 191 200 +9 qgravechar 112 108 -4 packed_usage 22843 22827 -16 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/2 up/down: 53/-20) Total: 33 bytes
-rw-r--r--include/usage.h36
-rw-r--r--networking/udhcp/Config.in11
-rw-r--r--networking/udhcp/dhcpc.c6
-rw-r--r--networking/udhcp/dhcpd.c7
4 files changed, 27 insertions, 33 deletions
diff --git a/include/usage.h b/include/usage.h
index d01e3e4f3..1d4459df1 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -3654,27 +3654,29 @@ USE_FEATURE_RUN_PARTS_FANCY("\n -l Prints names of all matching files even when
3654 "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n" \ 3654 "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n" \
3655 " [-p pidfile] [-r IP] [-s script]" 3655 " [-p pidfile] [-r IP] [-s script]"
3656#define udhcpc_full_usage \ 3656#define udhcpc_full_usage \
3657 " -V,--vendorclass=CLASSID Set vendor class identifier\n" \ 3657 "\n -V,--vendorclass=CLASSID Set vendor class identifier" \
3658 " -i,--interface=INTERFACE Interface to use (default: eth0)\n" \ 3658 "\n -i,--interface=INTERFACE Interface to use (default: eth0)" \
3659 " -H,-h,--hostname=HOSTNAME Client hostname\n" \ 3659 "\n -H,-h,--hostname=HOSTNAME Client hostname" \
3660 " -c,--clientid=CLIENTID Set client identifier\n" \ 3660 "\n -c,--clientid=CLIENTID Set client identifier" \
3661 " -C,--clientid-none Suppress default client identifier\n" \ 3661 "\n -C,--clientid-none Suppress default client identifier" \
3662 " -p,--pidfile=file Store process ID of daemon in file\n" \ 3662 "\n -p,--pidfile=file Store process ID of daemon in file" \
3663 " -r,--request=IP IP address to request (default: none)\n" \ 3663 "\n -r,--request=IP IP address to request" \
3664 " -s,--script=file Run file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \ 3664 "\n -s,--script=file Run file at dhcp events (default: /usr/share/udhcpc/default.script)" \
3665 " -t,--retries=NUM Send up to NUM request packets\n"\ 3665 "\n -t,--retries=N Send up to N request packets"\
3666 " -f,--foreground Do not fork after getting lease\n" \ 3666 "\n -f,--foreground Stay in foreground" \
3667 " -b,--background Fork to background if lease cannot be immediately negotiated\n" \ 3667 "\n -b,--background Background if lease cannot be immediately negotiated" \
3668 " -n,--now Exit with failure if lease cannot be immediately negotiated\n" \ 3668 "\n -S,--syslog Log to syslog too" \
3669 " -q,--quit Quit after obtaining lease\n" \ 3669 "\n -n,--now Exit with failure if lease cannot be immediately negotiated" \
3670 " -R,--release Release IP on quit\n" \ 3670 "\n -q,--quit Quit after obtaining lease" \
3671 " -v,--version Display version" \ 3671 "\n -R,--release Release IP on quit" \
3672 "\n -v,--version Display version" \
3672 3673
3673#define udhcpd_trivial_usage \ 3674#define udhcpd_trivial_usage \
3674 "[configfile]" \ 3675 "[-fS] [configfile]" \
3675 3676
3676#define udhcpd_full_usage \ 3677#define udhcpd_full_usage \
3677 "" 3678 "\n -f Stay in foreground" \
3679 "\n -S Log to syslog too"
3678 3680
3679#define umount_trivial_usage \ 3681#define umount_trivial_usage \
3680 "[flags] FILESYSTEM|DIRECTORY" 3682 "[flags] FILESYSTEM|DIRECTORY"
diff --git a/networking/udhcp/Config.in b/networking/udhcp/Config.in
index 7a3eda9cc..76b078001 100644
--- a/networking/udhcp/Config.in
+++ b/networking/udhcp/Config.in
@@ -54,17 +54,6 @@ config APP_UDHCPC
54 54
55 See http://udhcp.busybox.net for further details. 55 See http://udhcp.busybox.net for further details.
56 56
57config FEATURE_UDHCP_SYSLOG
58 bool "Log udhcp messages to syslog"
59 default n
60 depends on APP_UDHCPD || APP_UDHCPC
61 select FEATURE_SYSLOG
62 help
63 If not daemonized, udhcpd prints its messages to stdout/stderr.
64 If this option is selected, it will also log them to syslog.
65
66 See http://udhcp.busybox.net for further details.
67
68config FEATURE_UDHCP_DEBUG 57config FEATURE_UDHCP_DEBUG
69 bool "Compile udhcp with noisy debugging messages" 58 bool "Compile udhcp with noisy debugging messages"
70 default n 59 default n
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 0e89c3cae..7cb1dfe5d 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -178,6 +178,7 @@ int udhcpc_main(int argc, char **argv)
178 OPT_T = 1 << 15, 178 OPT_T = 1 << 15,
179 OPT_t = 1 << 16, 179 OPT_t = 1 << 16,
180 OPT_v = 1 << 17, 180 OPT_v = 1 << 17,
181 OPT_S = 1 << 18,
181 }; 182 };
182#if ENABLE_GETOPT_LONG 183#if ENABLE_GETOPT_LONG
183 static const char udhcpc_longopts[] ALIGN1 = 184 static const char udhcpc_longopts[] ALIGN1 =
@@ -199,6 +200,7 @@ int udhcpc_main(int argc, char **argv)
199 "timeout\0" Required_argument "T" 200 "timeout\0" Required_argument "T"
200 "version\0" No_argument "v" 201 "version\0" No_argument "v"
201 "retries\0" Required_argument "t" 202 "retries\0" Required_argument "t"
203 "syslog\0" No_argument "S"
202 ; 204 ;
203#endif 205#endif
204 /* Default options. */ 206 /* Default options. */
@@ -213,7 +215,7 @@ int udhcpc_main(int argc, char **argv)
213#if ENABLE_GETOPT_LONG 215#if ENABLE_GETOPT_LONG
214 applet_long_options = udhcpc_longopts; 216 applet_long_options = udhcpc_longopts;
215#endif 217#endif
216 opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v", 218 opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vS",
217 &str_c, &str_V, &str_h, &str_h, &str_F, 219 &str_c, &str_V, &str_h, &str_h, &str_F,
218 &client_config.interface, &client_config.pidfile, &str_r, 220 &client_config.interface, &client_config.pidfile, &str_r,
219 &client_config.script, &str_T, &str_t 221 &client_config.script, &str_T, &str_t
@@ -262,7 +264,7 @@ int udhcpc_main(int argc, char **argv)
262 return 0; 264 return 0;
263 } 265 }
264 266
265 if (ENABLE_FEATURE_UDHCP_SYSLOG) { 267 if (opt & OPT_S) {
266 openlog(applet_name, LOG_PID, LOG_LOCAL0); 268 openlog(applet_name, LOG_PID, LOG_LOCAL0);
267 logmode |= LOGMODE_SYSLOG; 269 logmode |= LOGMODE_SYSLOG;
268 } 270 }
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c
index 89f57bfe8..d8e80e30d 100644
--- a/networking/udhcp/dhcpd.c
+++ b/networking/udhcp/dhcpd.c
@@ -32,17 +32,18 @@ int udhcpd_main(int argc, char **argv)
32 uint32_t server_id_align, requested_align, static_lease_ip; 32 uint32_t server_id_align, requested_align, static_lease_ip;
33 unsigned timeout_end; 33 unsigned timeout_end;
34 unsigned num_ips; 34 unsigned num_ips;
35 unsigned opt;
35 struct option_set *option; 36 struct option_set *option;
36 struct dhcpOfferedAddr *lease, static_lease; 37 struct dhcpOfferedAddr *lease, static_lease;
37 38
38//Huh, dhcpd don't have --foreground, --syslog options?? TODO 39 opt = getopt32(argc, argv, "fS");
39 40
40 if (!ENABLE_FEATURE_UDHCP_DEBUG) { 41 if (!(opt & 1)) { /* no -f */
41 bb_daemonize_or_rexec(0, argv); 42 bb_daemonize_or_rexec(0, argv);
42 logmode &= ~LOGMODE_STDIO; 43 logmode &= ~LOGMODE_STDIO;
43 } 44 }
44 45
45 if (ENABLE_FEATURE_UDHCP_SYSLOG) { 46 if (opt & 2) { /* -S */
46 openlog(applet_name, LOG_PID, LOG_LOCAL0); 47 openlog(applet_name, LOG_PID, LOG_LOCAL0);
47 logmode |= LOGMODE_SYSLOG; 48 logmode |= LOGMODE_SYSLOG;
48 } 49 }