From d55fe3e595eb0aad60484d273e251cfee4ef8aa5 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 4 Feb 2008 13:12:16 +0000 Subject: udhcp: optional support for non-standard DHCP ports (+300 bytes when selected) --- networking/udhcp/dhcpc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'networking/udhcp/dhcpc.c') diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index f54bc08f1..7fca184ab 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -133,6 +133,7 @@ int udhcpc_main(int argc, char **argv) { uint8_t *temp, *message; char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_A, *str_t; + USE_FEATURE_UDHCP_PORT(char *str_P;) llist_t *list_O = NULL; #if ENABLE_FEATURE_UDHCPC_ARPING char *str_W; @@ -181,6 +182,7 @@ int udhcpc_main(int argc, char **argv) OPT_a = 1 << 20, OPT_W = 1 << 21, #endif + OPT_P = 1 << 22, }; #if ENABLE_GETOPT_LONG static const char udhcpc_longopts[] ALIGN1 = @@ -207,9 +209,16 @@ int udhcpc_main(int argc, char **argv) "arping\0" No_argument "a" #endif "request-option\0" Required_argument "O" +#if ENABLE_FEATURE_UDHCP_PORT + "client-port\0" Required_argument "P" +#endif ; #endif /* Default options. */ +#if ENABLE_FEATURE_UDHCP_PORT + SERVER_PORT = 67; + CLIENT_PORT = 68; +#endif client_config.interface = "eth0"; client_config.script = DEFAULT_SCRIPT; @@ -220,11 +229,13 @@ int udhcpc_main(int argc, char **argv) #endif opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vSA:" USE_FEATURE_UDHCPC_ARPING("aW:") + USE_FEATURE_UDHCP_PORT("P:") "O:" , &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, &str_A USE_FEATURE_UDHCPC_ARPING(, &str_W) + USE_FEATURE_UDHCP_PORT(, &str_P) , &list_O ); @@ -276,6 +287,12 @@ int udhcpc_main(int argc, char **argv) openlog(applet_name, LOG_PID, LOG_LOCAL0); logmode |= LOGMODE_SYSLOG; } +#if ENABLE_FEATURE_UDHCP_PORT + if (opt & OPT_P) { + CLIENT_PORT = xatou16(str_P); + SERVER_PORT = CLIENT_PORT - 1; + } +#endif while (list_O) { int n = index_in_strings(dhcp_option_strings, list_O->data); if (n < 0) -- cgit v1.2.3