svn commit: trunk/busybox: include networking/udhcp

vda at busybox.net vda at busybox.net
Tue Aug 14 16:45:30 UTC 2007


Author: vda
Date: 2007-08-14 09:45:29 -0700 (Tue, 14 Aug 2007)
New Revision: 19507

Log:
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



Modified:
   trunk/busybox/include/usage.h
   trunk/busybox/networking/udhcp/Config.in
   trunk/busybox/networking/udhcp/dhcpc.c
   trunk/busybox/networking/udhcp/dhcpd.c


Changeset:
Modified: trunk/busybox/include/usage.h
===================================================================
--- trunk/busybox/include/usage.h	2007-08-14 16:43:01 UTC (rev 19506)
+++ trunk/busybox/include/usage.h	2007-08-14 16:45:29 UTC (rev 19507)
@@ -3654,27 +3654,29 @@
        "[-Cfbnqtv] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]\n" \
        "	[-p pidfile] [-r IP] [-s script]"
 #define udhcpc_full_usage \
-       "	-V,--vendorclass=CLASSID	Set vendor class identifier\n" \
-       "	-i,--interface=INTERFACE	Interface to use (default: eth0)\n" \
-       "	-H,-h,--hostname=HOSTNAME	Client hostname\n" \
-       "	-c,--clientid=CLIENTID	Set client identifier\n" \
-       "	-C,--clientid-none	Suppress default client identifier\n" \
-       "	-p,--pidfile=file	Store process ID of daemon in file\n" \
-       "	-r,--request=IP		IP address to request (default: none)\n" \
-       "	-s,--script=file	Run file at dhcp events (default: /usr/share/udhcpc/default.script)\n" \
-       "	-t,--retries=NUM	Send up to NUM request packets\n"\
-       "	-f,--foreground	Do not fork after getting lease\n" \
-       "	-b,--background	Fork to background if lease cannot be immediately negotiated\n" \
-       "	-n,--now	Exit with failure if lease cannot be immediately negotiated\n" \
-       "	-q,--quit	Quit after obtaining lease\n" \
-       "	-R,--release	Release IP on quit\n" \
-       "	-v,--version	Display version" \
+       "\n	-V,--vendorclass=CLASSID	Set vendor class identifier" \
+       "\n	-i,--interface=INTERFACE	Interface to use (default: eth0)" \
+       "\n	-H,-h,--hostname=HOSTNAME	Client hostname" \
+       "\n	-c,--clientid=CLIENTID	Set client identifier" \
+       "\n	-C,--clientid-none	Suppress default client identifier" \
+       "\n	-p,--pidfile=file	Store process ID of daemon in file" \
+       "\n	-r,--request=IP		IP address to request" \
+       "\n	-s,--script=file	Run file at dhcp events (default: /usr/share/udhcpc/default.script)" \
+       "\n	-t,--retries=N		Send up to N request packets"\
+       "\n	-f,--foreground	Stay in foreground" \
+       "\n	-b,--background	Background if lease cannot be immediately negotiated" \
+       "\n	-S,--syslog	Log to syslog too" \
+       "\n	-n,--now	Exit with failure if lease cannot be immediately negotiated" \
+       "\n	-q,--quit	Quit after obtaining lease" \
+       "\n	-R,--release	Release IP on quit" \
+       "\n	-v,--version	Display version" \
 
 #define udhcpd_trivial_usage \
-       "[configfile]" \
+       "[-fS] [configfile]" \
 
 #define udhcpd_full_usage \
-       ""
+       "\n	-f	Stay in foreground" \
+       "\n	-S	Log to syslog too"
 
 #define umount_trivial_usage \
        "[flags] FILESYSTEM|DIRECTORY"

Modified: trunk/busybox/networking/udhcp/Config.in
===================================================================
--- trunk/busybox/networking/udhcp/Config.in	2007-08-14 16:43:01 UTC (rev 19506)
+++ trunk/busybox/networking/udhcp/Config.in	2007-08-14 16:45:29 UTC (rev 19507)
@@ -54,17 +54,6 @@
 
 	  See http://udhcp.busybox.net for further details.
 
-config FEATURE_UDHCP_SYSLOG
-	bool "Log udhcp messages to syslog"
-	default n
-	depends on APP_UDHCPD || APP_UDHCPC
-	select FEATURE_SYSLOG
-	help
-	  If not daemonized, udhcpd prints its messages to stdout/stderr.
-	  If this option is selected, it will also log them to syslog.
-
-	  See http://udhcp.busybox.net for further details.
-
 config FEATURE_UDHCP_DEBUG
 	bool "Compile udhcp with noisy debugging messages"
 	default n

Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c	2007-08-14 16:43:01 UTC (rev 19506)
+++ trunk/busybox/networking/udhcp/dhcpc.c	2007-08-14 16:45:29 UTC (rev 19507)
@@ -178,6 +178,7 @@
 		OPT_T = 1 << 15,
 		OPT_t = 1 << 16,
 		OPT_v = 1 << 17,
+		OPT_S = 1 << 18,
 	};
 #if ENABLE_GETOPT_LONG
 	static const char udhcpc_longopts[] ALIGN1 =
@@ -199,6 +200,7 @@
 		"timeout\0"       Required_argument "T"
 		"version\0"       No_argument       "v"
 		"retries\0"       Required_argument "t"
+		"syslog\0"        No_argument       "S"
 		;
 #endif
 	/* Default options. */
@@ -213,7 +215,7 @@
 #if ENABLE_GETOPT_LONG
 	applet_long_options = udhcpc_longopts;
 #endif
-	opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:v",
+	opt = getopt32(argc, argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vS",
 		&str_c, &str_V, &str_h, &str_h, &str_F,
 		&client_config.interface, &client_config.pidfile, &str_r,
 		&client_config.script, &str_T, &str_t
@@ -262,7 +264,7 @@
 		return 0;
 	}
 
-	if (ENABLE_FEATURE_UDHCP_SYSLOG) {
+	if (opt & OPT_S) {
 		openlog(applet_name, LOG_PID, LOG_LOCAL0);
 		logmode |= LOGMODE_SYSLOG;
 	}

Modified: trunk/busybox/networking/udhcp/dhcpd.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpd.c	2007-08-14 16:43:01 UTC (rev 19506)
+++ trunk/busybox/networking/udhcp/dhcpd.c	2007-08-14 16:45:29 UTC (rev 19507)
@@ -32,17 +32,18 @@
 	uint32_t server_id_align, requested_align, static_lease_ip;
 	unsigned timeout_end;
 	unsigned num_ips;
+	unsigned opt;
 	struct option_set *option;
 	struct dhcpOfferedAddr *lease, static_lease;
 
-//Huh, dhcpd don't have --foreground, --syslog options?? TODO
+	opt = getopt32(argc, argv, "fS");
 
-	if (!ENABLE_FEATURE_UDHCP_DEBUG) {
+	if (!(opt & 1)) { /* no -f */
 		bb_daemonize_or_rexec(0, argv);
 		logmode &= ~LOGMODE_STDIO;
 	}
 
-	if (ENABLE_FEATURE_UDHCP_SYSLOG) {
+	if (opt & 2) { /* -S */
 		openlog(applet_name, LOG_PID, LOG_LOCAL0);
 		logmode |= LOGMODE_SYSLOG;
 	}




More information about the busybox-cvs mailing list