Sync the latest version from R8.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4400 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff
2007-12-18 07:01:23 +00:00
parent 372787b85a
commit c4a62a12c2
26 changed files with 790 additions and 424 deletions

View File

@ -52,8 +52,6 @@ DhcpInitRequest (
DhcpSb->DhcpState = Dhcp4Init;
return Status;
}
DhcpSb->WaitOffer = DHCP_WAIT_OFFER;
} else {
DhcpSetState (DhcpSb, Dhcp4Rebooting, FALSE);
Status = DhcpSendMessage (DhcpSb, NULL, NULL, DHCP_MSG_REQUEST, NULL);
@ -225,7 +223,7 @@ DhcpSetState (
// This will clear the retry count. This is also why the rule
// first transit the state, then send packets.
//
if (State == Dhcp4Init) {
if (State == Dhcp4Selecting) {
DhcpSb->MaxRetries = DhcpSb->ActiveConfig.DiscoverTryCount;
} else {
DhcpSb->MaxRetries = DhcpSb->ActiveConfig.RequestTryCount;
@ -262,7 +260,7 @@ DhcpSetTransmitTimer (
ASSERT (DhcpSb->MaxRetries > DhcpSb->CurRetry);
if (DhcpSb->DhcpState == Dhcp4Init) {
if (DhcpSb->DhcpState == Dhcp4Selecting) {
Times = DhcpSb->ActiveConfig.DiscoverTimeout;
} else {
Times = DhcpSb->ActiveConfig.RequestTimeout;
@ -273,8 +271,11 @@ DhcpSetTransmitTimer (
}
DhcpSb->PacketToLive = Times[DhcpSb->CurRetry];
}
if (DhcpSb->DhcpState == Dhcp4Selecting) {
DhcpSb->WaitOffer = DhcpSb->PacketToLive;
}
}
/**
Compute the lease. If the server grants a permanent lease, just
@ -519,6 +520,7 @@ DhcpChooseOffer (
{
EFI_DHCP4_PACKET *Selected;
EFI_DHCP4_PACKET *NewPacket;
EFI_DHCP4_PACKET *TempPacket;
EFI_STATUS Status;
ASSERT (DhcpSb->LastOffer != NULL);
@ -542,12 +544,12 @@ DhcpChooseOffer (
Selected = DhcpSb->LastOffer;
if (NewPacket != NULL) {
if (EFI_ERROR (DhcpValidateOptions (NewPacket, NULL))) {
NetFreePool (NewPacket);
} else {
if ((NewPacket != NULL) && !EFI_ERROR (DhcpValidateOptions (NewPacket, NULL))) {
TempPacket = (EFI_DHCP4_PACKET *) NetAllocatePool (NewPacket->Size);
if (TempPacket != NULL) {
NetCopyMem (TempPacket, NewPacket, NewPacket->Size);
NetFreePool (Selected);
Selected = NewPacket;
Selected = TempPacket;
}
}
@ -650,10 +652,6 @@ DhcpHandleSelect (
//
Head = &Packet->Dhcp4.Header;
if (!Ip4IsUnicast (EFI_NTOHL (Head->YourAddr), (Para == NULL ? 0 : Para->NetMask))) {
goto ON_EXIT;
}
if (!DHCP_IS_BOOTP (Para) &&
((Para->DhcpType != DHCP_MSG_OFFER) || (Para->ServerId == 0))) {
goto ON_EXIT;
@ -1495,12 +1493,32 @@ DhcpOnTimerTick (
)
{
DHCP_SERVICE *DhcpSb;
DHCP_PROTOCOL *Instance;
EFI_STATUS Status;
DhcpSb = (DHCP_SERVICE *) Context;
DhcpSb = (DHCP_SERVICE *) Context;
Instance = DhcpSb->ActiveChild;
//
// Check the retransmit timer first
// Check the time to wait offer
//
if ((DhcpSb->WaitOffer > 0) && (--DhcpSb->WaitOffer == 0)) {
//
// OK, offer collection finished, select a offer
//
ASSERT (DhcpSb->DhcpState == Dhcp4Selecting);
if (DhcpSb->LastOffer == NULL) {
goto END_SESSION;
}
if (EFI_ERROR (DhcpChooseOffer (DhcpSb))) {
goto END_SESSION;
}
}
//
// Check the retransmit timer
//
if ((DhcpSb->PacketToLive > 0) && (--DhcpSb->PacketToLive == 0)) {
@ -1543,22 +1561,7 @@ DhcpOnTimerTick (
}
}
}
if ((DhcpSb->WaitOffer > 0) && (--DhcpSb->WaitOffer == 0)) {
//
// OK, offer collection finished, select a offer
//
ASSERT (DhcpSb->DhcpState == Dhcp4Selecting);
if (DhcpSb->LastOffer == NULL) {
goto END_SESSION;
}
if (EFI_ERROR (DhcpChooseOffer (DhcpSb))) {
goto END_SESSION;
}
}
//
// If an address has been acquired, check whether need to
// refresh or whether it has expired.
@ -1622,6 +1625,16 @@ DhcpOnTimerTick (
}
}
//
//
//
if ((Instance != NULL) && (Instance->Token != NULL)) {
Instance->Timeout--;
if (Instance->Timeout == 0) {
PxeDhcpDone (Instance);
}
}
return ;
END_SESSION: