aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/dhcpc.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-12-10 07:03:38 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-12-10 07:03:38 +0000
commit191836845e4551fe6191dc0d43b45a0232bff8be (patch)
treee6fd859b756304842334d0e0603856be2a5948e6 /networking/udhcp/dhcpc.c
parent75aa615bef478622cd0695b95adcf182fbbc3d95 (diff)
downloadbusybox-w32-191836845e4551fe6191dc0d43b45a0232bff8be.tar.gz
busybox-w32-191836845e4551fe6191dc0d43b45a0232bff8be.tar.bz2
busybox-w32-191836845e4551fe6191dc0d43b45a0232bff8be.zip
udhcpc: support for -O <option>.
Two important notes: * nissrv and nisdomain are not requested by default anymore! * inconsistency between "XXXsvr" and "XXsrv" in option names resolved, all are "XXXsrv" now. function old new delta udhcpc_main 2494 2600 +106 packed_usage 23023 23067 +44 add_requests 91 119 +28 static.udhcpc_longopts 209 226 +17 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 195/0) Total: 195 bytes
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r--networking/udhcp/dhcpc.c61
1 files changed, 36 insertions, 25 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index d8077f7e8..69c35ca50 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -133,6 +133,7 @@ int udhcpc_main(int argc, char **argv)
133{ 133{
134 uint8_t *temp, *message; 134 uint8_t *temp, *message;
135 char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_A, *str_t; 135 char *str_c, *str_V, *str_h, *str_F, *str_r, *str_T, *str_A, *str_t;
136 llist_t *list_O = NULL;
136#if ENABLE_FEATURE_UDHCPC_ARPING 137#if ENABLE_FEATURE_UDHCPC_ARPING
137 char *str_W; 138 char *str_W;
138#endif 139#endif
@@ -183,28 +184,29 @@ int udhcpc_main(int argc, char **argv)
183 }; 184 };
184#if ENABLE_GETOPT_LONG 185#if ENABLE_GETOPT_LONG
185 static const char udhcpc_longopts[] ALIGN1 = 186 static const char udhcpc_longopts[] ALIGN1 =
186 "clientid\0" Required_argument "c" 187 "clientid\0" Required_argument "c"
187 "clientid-none\0" No_argument "C" 188 "clientid-none\0" No_argument "C"
188 "vendorclass\0" Required_argument "V" 189 "vendorclass\0" Required_argument "V"
189 "foreground\0" No_argument "f" 190 "foreground\0" No_argument "f"
190 "background\0" No_argument "b" 191 "background\0" No_argument "b"
191 "hostname\0" Required_argument "H" 192 "hostname\0" Required_argument "H"
192 "fqdn\0" Required_argument "F" 193 "fqdn\0" Required_argument "F"
193 "interface\0" Required_argument "i" 194 "interface\0" Required_argument "i"
194 "now\0" No_argument "n" 195 "now\0" No_argument "n"
195 "pidfile\0" Required_argument "p" 196 "pidfile\0" Required_argument "p"
196 "quit\0" No_argument "q" 197 "quit\0" No_argument "q"
197 "release\0" No_argument "R" 198 "release\0" No_argument "R"
198 "request\0" Required_argument "r" 199 "request\0" Required_argument "r"
199 "script\0" Required_argument "s" 200 "script\0" Required_argument "s"
200 "timeout\0" Required_argument "T" 201 "timeout\0" Required_argument "T"
201 "version\0" No_argument "v" 202 "version\0" No_argument "v"
202 "retries\0" Required_argument "t" 203 "retries\0" Required_argument "t"
203 "tryagain\0" Required_argument "A" 204 "tryagain\0" Required_argument "A"
204 "syslog\0" No_argument "S" 205 "syslog\0" No_argument "S"
205#if ENABLE_FEATURE_UDHCPC_ARPING 206#if ENABLE_FEATURE_UDHCPC_ARPING
206 "arping\0" No_argument "a" 207 "arping\0" No_argument "a"
207#endif 208#endif
209 "request-option\0" Required_argument "O"
208 ; 210 ;
209#endif 211#endif
210 /* Default options. */ 212 /* Default options. */
@@ -212,16 +214,18 @@ int udhcpc_main(int argc, char **argv)
212 client_config.script = DEFAULT_SCRIPT; 214 client_config.script = DEFAULT_SCRIPT;
213 215
214 /* Parse command line */ 216 /* Parse command line */
215 opt_complementary = "c--C:C--c"; // mutually exclusive 217 opt_complementary = "c--C:C--c:O::"; // Cc: mutually exclusive; O: list
216#if ENABLE_GETOPT_LONG 218#if ENABLE_GETOPT_LONG
217 applet_long_options = udhcpc_longopts; 219 applet_long_options = udhcpc_longopts;
218#endif 220#endif
219 opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vSA:" 221 opt = getopt32(argv, "c:CV:fbH:h:F:i:np:qRr:s:T:t:vSA:"
220 USE_FEATURE_UDHCPC_ARPING("aW:") 222 USE_FEATURE_UDHCPC_ARPING("aW:")
221 , &str_c, &str_V, &str_h, &str_h, &str_F, 223 "O:"
222 &client_config.interface, &client_config.pidfile, &str_r, 224 , &str_c, &str_V, &str_h, &str_h, &str_F
223 &client_config.script, &str_T, &str_t, &str_A 225 , &client_config.interface, &client_config.pidfile, &str_r
226 , &client_config.script, &str_T, &str_t, &str_A
224 USE_FEATURE_UDHCPC_ARPING(, &str_W) 227 USE_FEATURE_UDHCPC_ARPING(, &str_W)
228 , &list_O
225 ); 229 );
226 230
227 if (opt & OPT_c) 231 if (opt & OPT_c)
@@ -268,11 +272,18 @@ int udhcpc_main(int argc, char **argv)
268 puts("version "BB_VER); 272 puts("version "BB_VER);
269 return 0; 273 return 0;
270 } 274 }
271
272 if (opt & OPT_S) { 275 if (opt & OPT_S) {
273 openlog(applet_name, LOG_PID, LOG_LOCAL0); 276 openlog(applet_name, LOG_PID, LOG_LOCAL0);
274 logmode |= LOGMODE_SYSLOG; 277 logmode |= LOGMODE_SYSLOG;
275 } 278 }
279 while (list_O) {
280 int n = index_in_strings(dhcp_option_strings, list_O->data);
281 if (n < 0)
282 bb_error_msg_and_die("unknown option '%s'", list_O->data);
283 n = dhcp_options[n].code;
284 client_config.opt_mask[n >> 3] |= 1 << (n & 7);
285 list_O = list_O->link;
286 }
276 287
277 if (read_interface(client_config.interface, &client_config.ifindex, 288 if (read_interface(client_config.interface, &client_config.ifindex,
278 NULL, client_config.arp)) 289 NULL, client_config.arp))