|
@@ -640,9 +640,37 @@ static void dhcp_set_state ( struct dhcp_session *dhcp,
|
640
|
640
|
dhcp, dhcp_state_name ( state ) );
|
641
|
641
|
dhcp->state = state;
|
642
|
642
|
dhcp->start = currticks();
|
|
643
|
+ dhcp->timer.min_timeout = 0;
|
643
|
644
|
start_timer_nodelay ( &dhcp->timer );
|
644
|
645
|
}
|
645
|
646
|
|
|
647
|
+/**
|
|
648
|
+ * Transition to next DHCP state
|
|
649
|
+ *
|
|
650
|
+ * @v dhcp DHCP session
|
|
651
|
+ */
|
|
652
|
+static void dhcp_next_state ( struct dhcp_session *dhcp ) {
|
|
653
|
+
|
|
654
|
+ switch ( dhcp->state ) {
|
|
655
|
+ case DHCP_STATE_DISCOVER:
|
|
656
|
+ dhcp_set_state ( dhcp, DHCP_STATE_REQUEST );
|
|
657
|
+ break;
|
|
658
|
+ case DHCP_STATE_REQUEST:
|
|
659
|
+ if ( dhcp->proxydhcpoffer ) {
|
|
660
|
+ dhcp_set_state ( dhcp, DHCP_STATE_PROXYREQUEST );
|
|
661
|
+ break;
|
|
662
|
+ }
|
|
663
|
+ /* Fall through */
|
|
664
|
+ case DHCP_STATE_PROXYREQUEST:
|
|
665
|
+ dhcp_finished ( dhcp, 0 );
|
|
666
|
+ break;
|
|
667
|
+ default:
|
|
668
|
+ assert ( 0 );
|
|
669
|
+ return;
|
|
670
|
+ }
|
|
671
|
+
|
|
672
|
+}
|
|
673
|
+
|
646
|
674
|
/**
|
647
|
675
|
* Store received DHCPOFFER
|
648
|
676
|
*
|
|
@@ -759,7 +787,7 @@ static void dhcp_rx_dhcpoffer ( struct dhcp_session *dhcp,
|
759
|
787
|
return;
|
760
|
788
|
|
761
|
789
|
/* Transition to DHCPREQUEST */
|
762
|
|
- dhcp_set_state ( dhcp, DHCP_STATE_REQUEST );
|
|
790
|
+ dhcp_next_state ( dhcp );
|
763
|
791
|
}
|
764
|
792
|
|
765
|
793
|
/**
|
|
@@ -822,15 +850,8 @@ static void dhcp_rx_dhcpack ( struct dhcp_session *dhcp,
|
822
|
850
|
if ( ( rc = dhcp_store_dhcpack ( dhcp, dhcpack, parent ) ) !=0 )
|
823
|
851
|
return;
|
824
|
852
|
|
825
|
|
- /* If we have a ProxyDHCPOFFER, transition to PROXYDHCPREQUEST */
|
826
|
|
- if ( dhcp->proxydhcpoffer ) {
|
827
|
|
- dhcp->timer.min_timeout = 0;
|
828
|
|
- dhcp_set_state ( dhcp, DHCP_STATE_PROXYREQUEST );
|
829
|
|
- return;
|
830
|
|
- }
|
831
|
|
-
|
832
|
|
- /* Terminate DHCP */
|
833
|
|
- dhcp_finished ( dhcp, 0 );
|
|
853
|
+ /* Transition to next state */
|
|
854
|
+ dhcp_next_state ( dhcp );
|
834
|
855
|
}
|
835
|
856
|
|
836
|
857
|
/**
|
|
@@ -868,8 +889,8 @@ static void dhcp_rx_proxydhcpack ( struct dhcp_session *dhcp,
|
868
|
889
|
if ( ( rc = dhcp_store_dhcpack ( dhcp, proxydhcpack, NULL ) ) != 0 )
|
869
|
890
|
return;
|
870
|
891
|
|
871
|
|
- /* Terminate DHCP */
|
872
|
|
- dhcp_finished ( dhcp, 0 );
|
|
892
|
+ /* Transition to next state */
|
|
893
|
+ dhcp_next_state ( dhcp );
|
873
|
894
|
}
|
874
|
895
|
|
875
|
896
|
/**
|
|
@@ -991,13 +1012,8 @@ static void dhcp_timer_expired ( struct retry_timer *timer, int fail ) {
|
991
|
1012
|
|
992
|
1013
|
/* Give up waiting for ProxyDHCP before we reach the failure point */
|
993
|
1014
|
if ( dhcp->dhcpoffer && ( elapsed > PROXYDHCP_WAIT_TIME ) ) {
|
994
|
|
- if ( dhcp->state == DHCP_STATE_DISCOVER ) {
|
995
|
|
- dhcp_set_state ( dhcp, DHCP_STATE_REQUEST );
|
996
|
|
- return;
|
997
|
|
- } else if ( dhcp->state == DHCP_STATE_PROXYREQUEST ) {
|
998
|
|
- dhcp_finished ( dhcp, 0 );
|
999
|
|
- return;
|
1000
|
|
- }
|
|
1015
|
+ dhcp_next_state ( dhcp );
|
|
1016
|
+ return;
|
1001
|
1017
|
}
|
1002
|
1018
|
|
1003
|
1019
|
/* Otherwise, retransmit current packet */
|