|
@@ -44,6 +44,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
44
|
44
|
#include <ipxe/dhcppkt.h>
|
45
|
45
|
#include <ipxe/dhcp_arch.h>
|
46
|
46
|
#include <ipxe/features.h>
|
|
47
|
+#include <config/dhcp.h>
|
47
|
48
|
|
48
|
49
|
/** @file
|
49
|
50
|
*
|
|
@@ -171,8 +172,9 @@ struct dhcp_session_state {
|
171
|
172
|
void ( * expired ) ( struct dhcp_session *dhcp );
|
172
|
173
|
/** Transmitted message type */
|
173
|
174
|
uint8_t tx_msgtype;
|
174
|
|
- /** Apply minimum timeout */
|
175
|
|
- uint8_t apply_min_timeout;
|
|
175
|
+ /** Timeout parameters */
|
|
176
|
+ uint8_t min_timeout_sec;
|
|
177
|
+ uint8_t max_timeout_sec;
|
176
|
178
|
};
|
177
|
179
|
|
178
|
180
|
static struct dhcp_session_state dhcp_state_discover;
|
|
@@ -272,9 +274,8 @@ static void dhcp_set_state ( struct dhcp_session *dhcp,
|
272
|
274
|
dhcp->state = state;
|
273
|
275
|
dhcp->start = currticks();
|
274
|
276
|
stop_timer ( &dhcp->timer );
|
275
|
|
- dhcp->timer.min_timeout =
|
276
|
|
- ( state->apply_min_timeout ? DHCP_MIN_TIMEOUT : 0 );
|
277
|
|
- dhcp->timer.max_timeout = DHCP_MAX_TIMEOUT;
|
|
277
|
+ dhcp->timer.min_timeout = state->min_timeout_sec * TICKS_PER_SEC;
|
|
278
|
+ dhcp->timer.max_timeout = state->max_timeout_sec * TICKS_PER_SEC;
|
278
|
279
|
start_timer_nodelay ( &dhcp->timer );
|
279
|
280
|
}
|
280
|
281
|
|
|
@@ -415,7 +416,7 @@ static void dhcp_discovery_rx ( struct dhcp_session *dhcp,
|
415
|
416
|
/* If we can't yet transition to DHCPREQUEST, do nothing */
|
416
|
417
|
elapsed = ( currticks() - dhcp->start );
|
417
|
418
|
if ( ! ( dhcp->no_pxedhcp || dhcp->proxy_offer ||
|
418
|
|
- ( elapsed > PROXYDHCP_MAX_TIMEOUT ) ) )
|
|
419
|
+ ( elapsed > DHCP_DISC_PROXY_TIMEOUT_SEC * TICKS_PER_SEC ) ) )
|
419
|
420
|
return;
|
420
|
421
|
|
421
|
422
|
/* Transition to DHCPREQUEST */
|
|
@@ -431,7 +432,8 @@ static void dhcp_discovery_expired ( struct dhcp_session *dhcp ) {
|
431
|
432
|
unsigned long elapsed = ( currticks() - dhcp->start );
|
432
|
433
|
|
433
|
434
|
/* Give up waiting for ProxyDHCP before we reach the failure point */
|
434
|
|
- if ( dhcp->offer.s_addr && ( elapsed > PROXYDHCP_MAX_TIMEOUT ) ) {
|
|
435
|
+ if ( dhcp->offer.s_addr &&
|
|
436
|
+ ( elapsed > DHCP_DISC_PROXY_TIMEOUT_SEC * TICKS_PER_SEC ) ) {
|
435
|
437
|
dhcp_set_state ( dhcp, &dhcp_state_request );
|
436
|
438
|
return;
|
437
|
439
|
}
|
|
@@ -447,7 +449,8 @@ static struct dhcp_session_state dhcp_state_discover = {
|
447
|
449
|
.rx = dhcp_discovery_rx,
|
448
|
450
|
.expired = dhcp_discovery_expired,
|
449
|
451
|
.tx_msgtype = DHCPDISCOVER,
|
450
|
|
- .apply_min_timeout = 1,
|
|
452
|
+ .min_timeout_sec = DHCP_DISC_START_TIMEOUT_SEC,
|
|
453
|
+ .max_timeout_sec = DHCP_DISC_END_TIMEOUT_SEC,
|
451
|
454
|
};
|
452
|
455
|
|
453
|
456
|
/**
|
|
@@ -584,7 +587,8 @@ static struct dhcp_session_state dhcp_state_request = {
|
584
|
587
|
.rx = dhcp_request_rx,
|
585
|
588
|
.expired = dhcp_request_expired,
|
586
|
589
|
.tx_msgtype = DHCPREQUEST,
|
587
|
|
- .apply_min_timeout = 0,
|
|
590
|
+ .min_timeout_sec = DHCP_REQ_START_TIMEOUT_SEC,
|
|
591
|
+ .max_timeout_sec = DHCP_REQ_END_TIMEOUT_SEC,
|
588
|
592
|
};
|
589
|
593
|
|
590
|
594
|
/**
|
|
@@ -669,7 +673,7 @@ static void dhcp_proxy_expired ( struct dhcp_session *dhcp ) {
|
669
|
673
|
unsigned long elapsed = ( currticks() - dhcp->start );
|
670
|
674
|
|
671
|
675
|
/* Give up waiting for ProxyDHCP before we reach the failure point */
|
672
|
|
- if ( elapsed > PROXYDHCP_MAX_TIMEOUT ) {
|
|
676
|
+ if ( elapsed > DHCP_REQ_PROXY_TIMEOUT_SEC * TICKS_PER_SEC ) {
|
673
|
677
|
dhcp_finished ( dhcp, 0 );
|
674
|
678
|
return;
|
675
|
679
|
}
|
|
@@ -685,7 +689,8 @@ static struct dhcp_session_state dhcp_state_proxy = {
|
685
|
689
|
.rx = dhcp_proxy_rx,
|
686
|
690
|
.expired = dhcp_proxy_expired,
|
687
|
691
|
.tx_msgtype = DHCPREQUEST,
|
688
|
|
- .apply_min_timeout = 0,
|
|
692
|
+ .min_timeout_sec = DHCP_PROXY_START_TIMEOUT_SEC,
|
|
693
|
+ .max_timeout_sec = DHCP_PROXY_END_TIMEOUT_SEC,
|
689
|
694
|
};
|
690
|
695
|
|
691
|
696
|
/**
|
|
@@ -810,7 +815,7 @@ static void dhcp_pxebs_expired ( struct dhcp_session *dhcp ) {
|
810
|
815
|
/* Give up waiting before we reach the failure point, and fail
|
811
|
816
|
* over to the next server in the attempt list
|
812
|
817
|
*/
|
813
|
|
- if ( elapsed > PXEBS_MAX_TIMEOUT ) {
|
|
818
|
+ if ( elapsed > PXEBS_MAX_TIMEOUT_SEC * TICKS_PER_SEC ) {
|
814
|
819
|
dhcp->pxe_attempt++;
|
815
|
820
|
if ( dhcp->pxe_attempt->s_addr ) {
|
816
|
821
|
dhcp_set_state ( dhcp, &dhcp_state_pxebs );
|
|
@@ -832,7 +837,8 @@ static struct dhcp_session_state dhcp_state_pxebs = {
|
832
|
837
|
.rx = dhcp_pxebs_rx,
|
833
|
838
|
.expired = dhcp_pxebs_expired,
|
834
|
839
|
.tx_msgtype = DHCPREQUEST,
|
835
|
|
- .apply_min_timeout = 1,
|
|
840
|
+ .min_timeout_sec = PXEBS_START_TIMEOUT_SEC,
|
|
841
|
+ .max_timeout_sec = PXEBS_END_TIMEOUT_SEC,
|
836
|
842
|
};
|
837
|
843
|
|
838
|
844
|
/****************************************************************************
|