aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index e468b7bbb..35e7c2070 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -54,7 +54,7 @@ static const char udhcpc_longopts[] ALIGN1 =
54 "foreground\0" No_argument "f" 54 "foreground\0" No_argument "f"
55 "background\0" No_argument "b" 55 "background\0" No_argument "b"
56 "broadcast\0" No_argument "B" 56 "broadcast\0" No_argument "B"
57 IF_FEATURE_UDHCPC_ARPING("arping\0" No_argument "a") 57 IF_FEATURE_UDHCPC_ARPING("arping\0" Optional_argument "a")
58 IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P") 58 IF_FEATURE_UDHCP_PORT("client-port\0" Required_argument "P")
59 ; 59 ;
60#endif 60#endif
@@ -1150,7 +1150,7 @@ static void client_background(void)
1150//usage:# define IF_UDHCP_VERBOSE(...) 1150//usage:# define IF_UDHCP_VERBOSE(...)
1151//usage:#endif 1151//usage:#endif
1152//usage:#define udhcpc_trivial_usage 1152//usage:#define udhcpc_trivial_usage
1153//usage: "[-fbq"IF_UDHCP_VERBOSE("v")IF_FEATURE_UDHCPC_ARPING("a")"RB] [-t N] [-T SEC] [-A SEC/-n]\n" 1153//usage: "[-fbq"IF_UDHCP_VERBOSE("v")"RB]"IF_FEATURE_UDHCPC_ARPING(" [-a[MSEC]]")" [-t N] [-T SEC] [-A SEC/-n]\n"
1154//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n" 1154//usage: " [-i IFACE]"IF_FEATURE_UDHCP_PORT(" [-P PORT]")" [-s PROG] [-p PIDFILE]\n"
1155//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..." 1155//usage: " [-oC] [-r IP] [-V VENDOR] [-F NAME] [-x OPT:VAL]... [-O OPT]..."
1156//usage:#define udhcpc_full_usage "\n" 1156//usage:#define udhcpc_full_usage "\n"
@@ -1174,7 +1174,7 @@ static void client_background(void)
1174//usage: ) 1174//usage: )
1175//usage: "\n -S,--syslog Log to syslog too" 1175//usage: "\n -S,--syslog Log to syslog too"
1176//usage: IF_FEATURE_UDHCPC_ARPING( 1176//usage: IF_FEATURE_UDHCPC_ARPING(
1177//usage: "\n -a,--arping Use arping to validate offered address" 1177//usage: "\n -a[MSEC],--arping[=MSEC] Validate offered address with ARP ping"
1178//usage: ) 1178//usage: )
1179//usage: "\n -r,--request IP Request this IP address" 1179//usage: "\n -r,--request IP Request this IP address"
1180//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)" 1180//usage: "\n -o,--no-default-options Don't request any options (unless -O is given)"
@@ -1211,7 +1211,7 @@ static void client_background(void)
1211//usage: ) 1211//usage: )
1212//usage: "\n -S Log to syslog too" 1212//usage: "\n -S Log to syslog too"
1213//usage: IF_FEATURE_UDHCPC_ARPING( 1213//usage: IF_FEATURE_UDHCPC_ARPING(
1214//usage: "\n -a Use arping to validate offered address" 1214//usage: "\n -a[MSEC] Validate offered address with ARP ping"
1215//usage: ) 1215//usage: )
1216//usage: "\n -r IP Request this IP address" 1216//usage: "\n -r IP Request this IP address"
1217//usage: "\n -o Don't request any options (unless -O is given)" 1217//usage: "\n -o Don't request any options (unless -O is given)"
@@ -1238,6 +1238,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1238{ 1238{
1239 uint8_t *message; 1239 uint8_t *message;
1240 const char *str_V, *str_h, *str_F, *str_r; 1240 const char *str_V, *str_h, *str_F, *str_r;
1241 IF_FEATURE_UDHCPC_ARPING(const char *str_a = "2000";)
1241 IF_FEATURE_UDHCP_PORT(char *str_P;) 1242 IF_FEATURE_UDHCP_PORT(char *str_P;)
1242 void *clientid_mac_ptr; 1243 void *clientid_mac_ptr;
1243 llist_t *list_O = NULL; 1244 llist_t *list_O = NULL;
@@ -1252,6 +1253,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1252 int timeout; /* must be signed */ 1253 int timeout; /* must be signed */
1253 unsigned already_waited_sec; 1254 unsigned already_waited_sec;
1254 unsigned opt; 1255 unsigned opt;
1256 IF_FEATURE_UDHCPC_ARPING(unsigned arpping_ms;)
1255 int max_fd; 1257 int max_fd;
1256 int retval; 1258 int retval;
1257 fd_set rfds; 1259 fd_set rfds;
@@ -1269,7 +1271,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1269 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;) 1271 IF_LONG_OPTS(applet_long_options = udhcpc_longopts;)
1270 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB" 1272 opt = getopt32(argv, "CV:H:h:F:i:np:qRr:s:T:t:SA:O:ox:fB"
1271 USE_FOR_MMU("b") 1273 USE_FOR_MMU("b")
1272 IF_FEATURE_UDHCPC_ARPING("a") 1274 IF_FEATURE_UDHCPC_ARPING("a::")
1273 IF_FEATURE_UDHCP_PORT("P:") 1275 IF_FEATURE_UDHCP_PORT("P:")
1274 "v" 1276 "v"
1275 , &str_V, &str_h, &str_h, &str_F 1277 , &str_V, &str_h, &str_h, &str_F
@@ -1278,6 +1280,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1278 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */ 1280 , &discover_timeout, &discover_retries, &tryagain_timeout /* T,t,A */
1279 , &list_O 1281 , &list_O
1280 , &list_x 1282 , &list_x
1283 IF_FEATURE_UDHCPC_ARPING(, &str_a)
1281 IF_FEATURE_UDHCP_PORT(, &str_P) 1284 IF_FEATURE_UDHCP_PORT(, &str_P)
1282 IF_UDHCP_VERBOSE(, &dhcp_verbose) 1285 IF_UDHCP_VERBOSE(, &dhcp_verbose)
1283 ); 1286 );
@@ -1309,6 +1312,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1309 SERVER_PORT = CLIENT_PORT - 1; 1312 SERVER_PORT = CLIENT_PORT - 1;
1310 } 1313 }
1311#endif 1314#endif
1315 IF_FEATURE_UDHCPC_ARPING(arpping_ms = xatou(str_a);)
1312 while (list_O) { 1316 while (list_O) {
1313 char *optstr = llist_pop(&list_O); 1317 char *optstr = llist_pop(&list_O);
1314 unsigned n = bb_strtou(optstr, NULL, 0); 1318 unsigned n = bb_strtou(optstr, NULL, 0);
@@ -1726,7 +1730,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1726 NULL, 1730 NULL,
1727 (uint32_t) 0, 1731 (uint32_t) 0,
1728 client_config.client_mac, 1732 client_config.client_mac,
1729 client_config.interface) 1733 client_config.interface,
1734 arpping_ms)
1730 ) { 1735 ) {
1731 bb_info_msg("Offered address is in use " 1736 bb_info_msg("Offered address is in use "
1732 "(got ARP reply), declining"); 1737 "(got ARP reply), declining");