summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-08 02:13:36 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2009-06-08 02:13:36 +0000
commit434ce3feca7f5a430db3d5853c54a06343d02ed2 (patch)
treed88d9d1cf6f976585088073e242be8b92f23f11b /MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
parent84478dedd0e120980d03eb11615c3254eea7612e (diff)
downloadedk2-platforms-434ce3feca7f5a430db3d5853c54a06343d02ed2.tar.xz
sync tracker:PXE misused the parameter of second since boot in DHCP header.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8496 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c')
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
index 7c48340d8b..dc9b0412a8 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
@@ -1,7 +1,7 @@
/** @file
EFI DHCP protocol implementation.
-Copyright (c) 2006 - 2008, Intel Corporation.<BR>
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -227,7 +227,7 @@ DhcpSetState (
DhcpSb->CurRetry = 0;
DhcpSb->PacketToLive = 0;
-
+ DhcpSb->LastTimeout = 0;
DhcpSb->DhcpState = State;
return EFI_SUCCESS;
}
@@ -260,6 +260,7 @@ DhcpSetTransmitTimer (
}
DhcpSb->PacketToLive = Times[DhcpSb->CurRetry];
+ DhcpSb->LastTimeout = DhcpSb->PacketToLive;
return;
}
@@ -470,11 +471,12 @@ DhcpCleanLease (
}
if (DhcpSb->LastPacket != NULL) {
- NetbufFree (DhcpSb->LastPacket);
+ FreePool (DhcpSb->LastPacket);
DhcpSb->LastPacket = NULL;
}
DhcpSb->PacketToLive = 0;
+ DhcpSb->LastTimeout = 0;
DhcpSb->CurRetry = 0;
DhcpSb->MaxRetries = 0;
DhcpSb->LeaseLife = 0;
@@ -1353,11 +1355,10 @@ DhcpSendMessage (
// Save it as the last sent packet for retransmission
//
if (DhcpSb->LastPacket != NULL) {
- NetbufFree (DhcpSb->LastPacket);
+ FreePool (DhcpSb->LastPacket);
}
- NET_GET_REF (Wrap);
- DhcpSb->LastPacket = Wrap;
+ DhcpSb->LastPacket = Packet;
DhcpSetTransmitTimer (DhcpSb);
//
@@ -1377,10 +1378,19 @@ DhcpSendMessage (
}
ASSERT (UdpIo != NULL);
- Status = UdpIoSendDatagram (UdpIo, Wrap, &EndPoint, 0, DhcpOnPacketSent, DhcpSb);
+ NET_GET_REF (Wrap);
+
+ Status = UdpIoSendDatagram (
+ UdpIo,
+ Wrap,
+ &EndPoint,
+ 0,
+ DhcpOnPacketSent,
+ DhcpSb
+ );
if (EFI_ERROR (Status)) {
- NetbufFree (Wrap);
+ NET_PUT_REF (Wrap);
return EFI_ACCESS_DENIED;
}
@@ -1405,10 +1415,25 @@ DhcpRetransmit (
{
UDP_IO_PORT *UdpIo;
UDP_POINTS EndPoint;
+ NET_BUF *Wrap;
+ NET_FRAGMENT Frag;
EFI_STATUS Status;
ASSERT (DhcpSb->LastPacket != NULL);
+ DhcpSb->LastPacket->Dhcp4.Header.Seconds = HTONS (*(UINT16 *)(&DhcpSb->LastTimeout));
+
+ //
+ // Wrap it into a netbuf then send it.
+ //
+ Frag.Bulk = (UINT8 *) &DhcpSb->LastPacket->Dhcp4.Header;
+ Frag.Len = DhcpSb->LastPacket->Length;
+ Wrap = NetbufFromExt (&Frag, 1, 0, 0, DhcpReleasePacket, DhcpSb->LastPacket);
+
+ if (Wrap == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
//
// Broadcast the message, unless we know the server address.
//
@@ -1426,10 +1451,10 @@ DhcpRetransmit (
ASSERT (UdpIo != NULL);
- NET_GET_REF (DhcpSb->LastPacket);
+ NET_GET_REF (Wrap);
Status = UdpIoSendDatagram (
UdpIo,
- DhcpSb->LastPacket,
+ Wrap,
&EndPoint,
0,
DhcpOnPacketSent,
@@ -1437,7 +1462,7 @@ DhcpRetransmit (
);
if (EFI_ERROR (Status)) {
- NET_PUT_REF (DhcpSb->LastPacket);
+ NET_PUT_REF (Wrap);
return EFI_ACCESS_DENIED;
}