Changeset 1b0602a3 in mainline
- Timestamp:
- 2013-09-24T21:11:46Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ee20e8a
- Parents:
- b417559
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dhcp/dhcp.c
rb417559 r1b0602a3 53 53 #include "transport.h" 54 54 55 #define DHCP_DISCOVER_TIMEOUT_VAL (5 * 1000 * 1000) 56 #define DHCP_REQUEST_TIMEOUT_VAL (1 * 1000 * 1000) 55 enum { 56 /** In microseconds */ 57 dhcp_discover_timeout_val = 5 * 1000 * 1000, 58 /** In microseconds */ 59 dhcp_request_timeout_val = 1 * 1000 * 1000, 60 dhcp_discover_retries = 5, 61 dhcp_request_retries = 3 62 }; 57 63 58 64 #define MAX_MSG_SIZE 1024 … … 67 73 typedef enum { 68 74 ds_bound, 75 ds_fail, 69 76 ds_init, 70 77 ds_init_reboot, … … 99 106 /** Transport timeout */ 100 107 fibril_timer_t *timeout; 108 /** Number of retries */ 109 int retries_left; 101 110 /** Link state */ 102 111 dhcp_state_t state; … … 455 464 rc = dhcp_send_discover(dlink); 456 465 if (rc != EOK) { 466 dlink->state = ds_fail; 457 467 rc = EIO; 458 468 goto error; 459 469 } 460 470 461 fibril_timer_set(dlink->timeout, DHCP_DISCOVER_TIMEOUT_VAL, 471 dlink->retries_left = dhcp_discover_retries; 472 fibril_timer_set(dlink->timeout, dhcp_discover_timeout_val, 462 473 dhcpsrv_discover_timeout, dlink); 463 474 … … 498 509 } 499 510 500 fibril_timer_set(dlink->timeout, DHCP_REQUEST_TIMEOUT_VAL, 511 dlink->retries_left = dhcp_request_retries; 512 fibril_timer_set(dlink->timeout, dhcp_request_timeout_val, 501 513 dhcpsrv_request_timeout, dlink); 502 514 } … … 559 571 log_msg(LOG_DEFAULT, LVL_NOTE, "dcpsrv_discover_timeout"); 560 572 573 if (dlink->retries_left == 0) { 574 log_msg(LOG_DEFAULT, LVL_NOTE, "Retries exhausted"); 575 dlink->state = ds_fail; 576 return; 577 } 578 --dlink->retries_left; 579 561 580 log_msg(LOG_DEFAULT, LVL_DEBUG, "Send DHCPDISCOVER"); 562 581 rc = dhcp_send_discover(dlink); 563 582 if (rc != EOK) { 564 583 log_msg(LOG_DEFAULT, LVL_ERROR, "Error sending DHCPDISCOVER"); 565 return; 566 } 567 568 fibril_timer_set(dlink->timeout, DHCP_DISCOVER_TIMEOUT_VAL, 584 dlink->state = ds_fail; 585 return; 586 } 587 588 fibril_timer_set(dlink->timeout, dhcp_discover_timeout_val, 569 589 dhcpsrv_discover_timeout, dlink); 570 590 } … … 578 598 log_msg(LOG_DEFAULT, LVL_NOTE, "dcpsrv_request_timeout"); 579 599 600 if (dlink->retries_left == 0) { 601 log_msg(LOG_DEFAULT, LVL_NOTE, "Retries exhausted"); 602 dlink->state = ds_fail; 603 return; 604 } 605 --dlink->retries_left; 606 580 607 log_msg(LOG_DEFAULT, LVL_DEBUG, "Send DHCPREQUEST"); 581 608 rc = dhcp_send_request(dlink, &dlink->offer); 582 609 if (rc != EOK) { 583 610 log_msg(LOG_DEFAULT, LVL_DEBUG, "Error sending request."); 584 return; 585 } 586 587 fibril_timer_set(dlink->timeout, DHCP_REQUEST_TIMEOUT_VAL, 611 dlink->state = ds_fail; 612 return; 613 } 614 615 fibril_timer_set(dlink->timeout, dhcp_request_timeout_val, 588 616 dhcpsrv_request_timeout, dlink); 589 617 }
Note:
See TracChangeset
for help on using the changeset viewer.