summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
diff options
context:
space:
mode:
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;
}