diff options
author | Denys Vlasenko | 2013-03-13 22:27:37 +0100 |
---|---|---|
committer | Denys Vlasenko | 2013-03-13 22:27:37 +0100 |
commit | e3f5b73ad094775b0168108bb1fc443bc4b518b1 (patch) | |
tree | 6d8d1ff3555823b1f67deb7d008d81c0af51e9d4 /networking/udhcp | |
parent | b79a0fef99627c457548e804fcd6e162b116cbe8 (diff) | |
download | busybox-e3f5b73ad094775b0168108bb1fc443bc4b518b1.zip busybox-e3f5b73ad094775b0168108bb1fc443bc4b518b1.tar.gz |
udhcpd: add -I LOCAL_ADDR option
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/udhcp')
-rw-r--r-- | networking/udhcp/dhcpd.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 9ad9595..3c2a9cb 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -27,6 +27,7 @@ //usage: "DHCP server\n" //usage: "\n -f Run in foreground" //usage: "\n -S Log to syslog too" +//usage: "\n -I ADDR Local address" //usage: IF_FEATURE_UDHCP_PORT( //usage: "\n -P N Use port N (default 67)" //usage: ) @@ -302,6 +303,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) unsigned num_ips; unsigned opt; struct option_set *option; + char *str_I = str_I; IF_FEATURE_UDHCP_PORT(char *str_P;) #if ENABLE_FEATURE_UDHCP_PORT @@ -312,8 +314,10 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 opt_complementary = "vv"; #endif - opt = getopt32(argv, "fSv" - IF_FEATURE_UDHCP_PORT("P:", &str_P) + opt = getopt32(argv, "fSI:v" + IF_FEATURE_UDHCP_PORT("P:") + , &str_I + IF_FEATURE_UDHCP_PORT(, &str_P) IF_UDHCP_VERBOSE(, &dhcp_verbose) ); if (!(opt & 1)) { /* no -f */ @@ -326,8 +330,13 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) openlog(applet_name, LOG_PID, LOG_DAEMON); logmode |= LOGMODE_SYSLOG; } + if (opt & 4) { /* -I */ + len_and_sockaddr *lsa = xhost_and_af2sockaddr(str_I, 0, AF_INET); + server_config.server_nip = lsa->u.sin.sin_addr.s_addr; + free(lsa); + } #if ENABLE_FEATURE_UDHCP_PORT - if (opt & 8) { /* -P */ + if (opt & 16) { /* -P */ SERVER_PORT = xatou16(str_P); CLIENT_PORT = SERVER_PORT + 1; } @@ -367,7 +376,7 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) if (udhcp_read_interface(server_config.interface, &server_config.ifindex, - &server_config.server_nip, + (server_config.server_nip == 0 ? &server_config.server_nip : NULL), server_config.server_mac) ) { retval = 1; |