ifupdown.c: allow options to udhcpc to be configurable from .config

This allows more control over options that are passed to udhcpc
that are not configurable via /etc/network/interfaces.

Example: rather than quit when an initial lease isn't found,
you could use "--background" so that udhcpc keeps running and
continually attempts to get an ip.  That way, when you plug in
the ethernet after powering on the device, you'll still get an ip.
This commit is contained in:
Wade Berrier 2008-11-14 21:18:45 +00:00
parent 86c285d900
commit 142c5cb2a2
2 changed files with 13 additions and 2 deletions

View File

@ -858,6 +858,15 @@ config FEATURE_TRACEROUTE_USE_ICMP
source networking/udhcp/Config.in source networking/udhcp/Config.in
config IFUPDOWN_UDHCPC_CMD_OPTIONS
string "ifup udhcpc command line options"
default "-R -n"
depends on IFUPDOWN && APP_UDHCPC
help
Command line options to pass to udhcpc from ifup.
Intended to alter options not available in /etc/network/interfaces.
(IE: --syslog --background etc...)
config VCONFIG config VCONFIG
bool "vconfig" bool "vconfig"
default n default n

View File

@ -31,6 +31,8 @@
#define MAX_INTERFACE_LENGTH 10 #define MAX_INTERFACE_LENGTH 10
#endif #endif
#define UDHCPC_CMD_OPTIONS CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS
#define debug_noise(args...) /*fprintf(stderr, args)*/ #define debug_noise(args...) /*fprintf(stderr, args)*/
/* Forward declaration */ /* Forward declaration */
@ -487,7 +489,7 @@ static const struct dhcp_client_t ext_dhcp_clients[] = {
"pump -i %iface% -k", "pump -i %iface% -k",
}, },
{ "udhcpc", { "udhcpc",
"udhcpc -R -n -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]]" "udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid -i %iface%[[ -H %hostname%]][[ -c %clientid%]]"
"[[ -s %script%]][[ %udhcpc_opts%]]", "[[ -s %script%]][[ %udhcpc_opts%]]",
"kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
}, },
@ -526,7 +528,7 @@ static int dhcp_up(struct interface_defn_t *ifd, execfn *exec)
if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec)) if (!execute("ifconfig %iface%[[ hw %hwaddress%]] up", ifd, exec))
return 0; return 0;
#endif #endif
return execute("udhcpc -R -n -p /var/run/udhcpc.%iface%.pid " return execute("udhcpc " UDHCPC_CMD_OPTIONS " -p /var/run/udhcpc.%iface%.pid "
"-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]][[ %udhcpc_opts%]]", "-i %iface%[[ -H %hostname%]][[ -c %clientid%]][[ -s %script%]][[ %udhcpc_opts%]]",
ifd, exec); ifd, exec);
} }