diff options
Diffstat (limited to 'networking/udhcp/dhcpc.c')
-rw-r--r-- | networking/udhcp/dhcpc.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 1d9ab6db6..c36c87602 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include "options.h" | 27 | #include "options.h" |
28 | #include "clientpacket.h" | 28 | #include "clientpacket.h" |
29 | #include "clientsocket.h" | 29 | #include "clientsocket.h" |
30 | #include "script.h" | ||
31 | #include "socket.h" | 30 | #include "socket.h" |
32 | #include "signalpipe.h" | 31 | #include "signalpipe.h" |
33 | 32 | ||
@@ -120,7 +119,7 @@ static void perform_renew(void) | |||
120 | state = RENEW_REQUESTED; | 119 | state = RENEW_REQUESTED; |
121 | break; | 120 | break; |
122 | case RENEW_REQUESTED: /* impatient are we? fine, square 1 */ | 121 | case RENEW_REQUESTED: /* impatient are we? fine, square 1 */ |
123 | run_script(NULL, "deconfig"); | 122 | udhcp_run_script(NULL, "deconfig"); |
124 | case REQUESTING: | 123 | case REQUESTING: |
125 | case RELEASED: | 124 | case RELEASED: |
126 | change_mode(LISTEN_RAW); | 125 | change_mode(LISTEN_RAW); |
@@ -152,7 +151,7 @@ static void perform_release(void) | |||
152 | LOG(LOG_INFO, "Unicasting a release of %s to %s", | 151 | LOG(LOG_INFO, "Unicasting a release of %s to %s", |
153 | inet_ntoa(temp_addr), buffer); | 152 | inet_ntoa(temp_addr), buffer); |
154 | send_release(server_addr, requested_ip); /* unicast */ | 153 | send_release(server_addr, requested_ip); /* unicast */ |
155 | run_script(NULL, "deconfig"); | 154 | udhcp_run_script(NULL, "deconfig"); |
156 | } | 155 | } |
157 | LOG(LOG_INFO, "Entering released state"); | 156 | LOG(LOG_INFO, "Entering released state"); |
158 | 157 | ||
@@ -164,7 +163,7 @@ static void perform_release(void) | |||
164 | 163 | ||
165 | static void client_background(void) | 164 | static void client_background(void) |
166 | { | 165 | { |
167 | background(client_config.pidfile); | 166 | udhcp_background(client_config.pidfile); |
168 | client_config.foreground = 1; /* Do not fork again. */ | 167 | client_config.foreground = 1; /* Do not fork again. */ |
169 | client_config.background_if_no_lease = 0; | 168 | client_config.background_if_no_lease = 0; |
170 | } | 169 | } |
@@ -297,7 +296,7 @@ int main(int argc, char *argv[]) | |||
297 | client_config.retries = atoi(optarg); | 296 | client_config.retries = atoi(optarg); |
298 | break; | 297 | break; |
299 | case 'v': | 298 | case 'v': |
300 | printf("udhcpcd, version %s\n\n", VERSION); | 299 | printf("version %s\n\n", BB_VER); |
301 | return 0; | 300 | return 0; |
302 | break; | 301 | break; |
303 | default: | 302 | default: |
@@ -306,7 +305,7 @@ int main(int argc, char *argv[]) | |||
306 | } | 305 | } |
307 | 306 | ||
308 | /* Start the log, sanitize fd's, and write a pid file */ | 307 | /* Start the log, sanitize fd's, and write a pid file */ |
309 | start_log_and_pid("udhcpc", client_config.pidfile); | 308 | udhcp_start_log_and_pid("udhcpc", client_config.pidfile); |
310 | 309 | ||
311 | if (read_interface(client_config.interface, &client_config.ifindex, | 310 | if (read_interface(client_config.interface, &client_config.ifindex, |
312 | NULL, client_config.arp) < 0) | 311 | NULL, client_config.arp) < 0) |
@@ -322,12 +321,12 @@ int main(int argc, char *argv[]) | |||
322 | } | 321 | } |
323 | 322 | ||
324 | if (!client_config.vendorclass) { | 323 | if (!client_config.vendorclass) { |
325 | client_config.vendorclass = xmalloc(sizeof("udhcp "VERSION) + 2); | 324 | client_config.vendorclass = xmalloc(sizeof("udhcp "BB_VER) + 2); |
326 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; | 325 | client_config.vendorclass[OPT_CODE] = DHCP_VENDOR; |
327 | client_config.vendorclass[OPT_LEN] = sizeof("udhcp "VERSION) - 1; | 326 | client_config.vendorclass[OPT_LEN] = sizeof("udhcp "BB_VER) - 1; |
328 | client_config.vendorclass[OPT_DATA] = 1; | 327 | client_config.vendorclass[OPT_DATA] = 1; |
329 | memcpy(&client_config.vendorclass[OPT_DATA], | 328 | memcpy(&client_config.vendorclass[OPT_DATA], |
330 | "udhcp "VERSION, sizeof("udhcp "VERSION) - 1); | 329 | "udhcp "BB_VER, sizeof("udhcp "BB_VER) - 1); |
331 | } | 330 | } |
332 | 331 | ||
333 | 332 | ||
@@ -335,7 +334,7 @@ int main(int argc, char *argv[]) | |||
335 | udhcp_sp_setup(); | 334 | udhcp_sp_setup(); |
336 | 335 | ||
337 | state = INIT_SELECTING; | 336 | state = INIT_SELECTING; |
338 | run_script(NULL, "deconfig"); | 337 | udhcp_run_script(NULL, "deconfig"); |
339 | change_mode(LISTEN_RAW); | 338 | change_mode(LISTEN_RAW); |
340 | 339 | ||
341 | for (;;) { | 340 | for (;;) { |
@@ -375,7 +374,7 @@ int main(int argc, char *argv[]) | |||
375 | timeout = now + client_config.timeout; | 374 | timeout = now + client_config.timeout; |
376 | packet_num++; | 375 | packet_num++; |
377 | } else { | 376 | } else { |
378 | run_script(NULL, "leasefail"); | 377 | udhcp_run_script(NULL, "leasefail"); |
379 | if (client_config.background_if_no_lease) { | 378 | if (client_config.background_if_no_lease) { |
380 | LOG(LOG_INFO, "No lease, forking to background."); | 379 | LOG(LOG_INFO, "No lease, forking to background."); |
381 | client_background(); | 380 | client_background(); |
@@ -400,7 +399,7 @@ int main(int argc, char *argv[]) | |||
400 | packet_num++; | 399 | packet_num++; |
401 | } else { | 400 | } else { |
402 | /* timed out, go back to init state */ | 401 | /* timed out, go back to init state */ |
403 | if (state == RENEW_REQUESTED) run_script(NULL, "deconfig"); | 402 | if (state == RENEW_REQUESTED) udhcp_run_script(NULL, "deconfig"); |
404 | state = INIT_SELECTING; | 403 | state = INIT_SELECTING; |
405 | timeout = now; | 404 | timeout = now; |
406 | packet_num = 0; | 405 | packet_num = 0; |
@@ -434,7 +433,7 @@ int main(int argc, char *argv[]) | |||
434 | /* timed out, enter init state */ | 433 | /* timed out, enter init state */ |
435 | state = INIT_SELECTING; | 434 | state = INIT_SELECTING; |
436 | LOG(LOG_INFO, "Lease lost, entering init state"); | 435 | LOG(LOG_INFO, "Lease lost, entering init state"); |
437 | run_script(NULL, "deconfig"); | 436 | udhcp_run_script(NULL, "deconfig"); |
438 | timeout = now; | 437 | timeout = now; |
439 | packet_num = 0; | 438 | packet_num = 0; |
440 | change_mode(LISTEN_RAW); | 439 | change_mode(LISTEN_RAW); |
@@ -455,7 +454,7 @@ int main(int argc, char *argv[]) | |||
455 | /* a packet is ready, read it */ | 454 | /* a packet is ready, read it */ |
456 | 455 | ||
457 | if (listen_mode == LISTEN_KERNEL) | 456 | if (listen_mode == LISTEN_KERNEL) |
458 | len = get_packet(&packet, fd); | 457 | len = udhcp_get_packet(&packet, fd); |
459 | else len = get_raw_packet(&packet, fd); | 458 | else len = get_raw_packet(&packet, fd); |
460 | 459 | ||
461 | if (len == -1 && errno != EINTR) { | 460 | if (len == -1 && errno != EINTR) { |
@@ -523,7 +522,7 @@ int main(int argc, char *argv[]) | |||
523 | start = now; | 522 | start = now; |
524 | timeout = t1 + start; | 523 | timeout = t1 + start; |
525 | requested_ip = packet.yiaddr; | 524 | requested_ip = packet.yiaddr; |
526 | run_script(&packet, | 525 | udhcp_run_script(&packet, |
527 | ((state == RENEWING || state == REBINDING) ? "renew" : "bound")); | 526 | ((state == RENEWING || state == REBINDING) ? "renew" : "bound")); |
528 | 527 | ||
529 | state = BOUND; | 528 | state = BOUND; |
@@ -536,9 +535,9 @@ int main(int argc, char *argv[]) | |||
536 | } else if (*message == DHCPNAK) { | 535 | } else if (*message == DHCPNAK) { |
537 | /* return to init state */ | 536 | /* return to init state */ |
538 | LOG(LOG_INFO, "Received DHCP NAK"); | 537 | LOG(LOG_INFO, "Received DHCP NAK"); |
539 | run_script(&packet, "nak"); | 538 | udhcp_run_script(&packet, "nak"); |
540 | if (state != REQUESTING) | 539 | if (state != REQUESTING) |
541 | run_script(NULL, "deconfig"); | 540 | udhcp_run_script(NULL, "deconfig"); |
542 | state = INIT_SELECTING; | 541 | state = INIT_SELECTING; |
543 | timeout = now; | 542 | timeout = now; |
544 | requested_ip = 0; | 543 | requested_ip = 0; |