TianoCore EDK2 master
|
#include "Dhcp4Impl.h"
Go to the source code of this file.
Variables | |
UINT32 | mDhcp4DefaultTimeout [4] = { 4, 8, 16, 32 } |
EFI DHCP protocol implementation.
Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dhcp4Io.c.
EFI_STATUS DhcpCallUser | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_EVENT | Event, | ||
IN EFI_DHCP4_PACKET *Packet | OPTIONAL, | ||
OUT EFI_DHCP4_PACKET **NewPacket | OPTIONAL | ||
) |
Call user provided callback function, and return the value the function returns. If the user doesn't provide a callback, a proper return value is selected to let the caller continue the normal process.
[in] | DhcpSb | The DHCP service instance |
[in] | Event | The event as defined in the spec |
[in] | Packet | The current packet trigger the event |
[out] | NewPacket | The user's return new packet |
EFI_NOT_READY | Direct the caller to continue collecting the offer. |
EFI_SUCCESS | The user function returns success. |
EFI_ABORTED | The user function ask it to abort. |
EFI_STATUS DhcpChooseOffer | ( | IN DHCP_SERVICE * | DhcpSb | ) |
Select a offer among all the offers collected. If the offer selected is of BOOTP, the lease is recorded and user notified. If the offer is of DHCP, it will request the offer from the server.
[in] | DhcpSb | The DHCP service instance. |
EFI_SUCCESS | One of the offer is selected. |
VOID DhcpCleanLease | ( | IN DHCP_SERVICE * | DhcpSb | ) |
VOID DhcpComputeLease | ( | IN OUT DHCP_SERVICE * | DhcpSb, |
IN DHCP_PARAMETER * | Para | ||
) |
EFI_STATUS EFIAPI DhcpConfigLeaseIoPort | ( | IN UDP_IO * | UdpIo, |
IN VOID * | Context | ||
) |
Configure a UDP IO port to use the acquired lease address. DHCP driver needs this port to unicast packet to the server such as DHCP release.
[in] | UdpIo | The UDP IO to configure |
[in] | Context | Dhcp service instance. |
EFI_SUCCESS | The UDP IO port is successfully configured. |
Others | It failed to configure the port. |
VOID DhcpEndSession | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_STATUS | Status | ||
) |
Terminate the current address acquire. All the allocated resources are released. Be careful when calling this function. A rule related to this is: only call DhcpEndSession at the highest level, such as DhcpInput, DhcpOnTimerTick...At the other level, just return error.
[in] | DhcpSb | The DHCP service instance |
[in] | Status | The result of the DHCP process. |
EFI_STATUS DhcpHandleReboot | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_PACKET * | Packet, | ||
IN DHCP_PARAMETER * | Para | ||
) |
Handle packets in DHCP reboot state.
[in] | DhcpSb | The DHCP service instance |
[in] | Packet | The DHCP packet received |
[in] | Para | The DHCP parameter extracted from the packet. That is, all the option value that we care. |
EFI_SUCCESS | The packet is successfully processed. |
Others | Some error occurred. |
EFI_STATUS DhcpHandleRenewRebind | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_PACKET * | Packet, | ||
IN DHCP_PARAMETER * | Para | ||
) |
Handle packets in DHCP renew/rebound state.
[in] | DhcpSb | The DHCP service instance |
[in] | Packet | The DHCP packet received |
[in] | Para | The DHCP parameter extracted from the packet. That is, all the option value that we care. |
EFI_SUCCESS | The packet is successfully processed. |
Others | Some error occurred. |
EFI_STATUS DhcpHandleRequest | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_PACKET * | Packet, | ||
IN DHCP_PARAMETER * | Para | ||
) |
Handle packets in DHCP request state.
[in] | DhcpSb | The DHCP service instance |
[in] | Packet | The DHCP packet received |
[in] | Para | The DHCP parameter extracted from the packet. That is, all the option value that we care. |
EFI_SUCCESS | The packet is successfully processed. |
Others | Some error occurred. |
EFI_STATUS DhcpHandleSelect | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_PACKET * | Packet, | ||
IN DHCP_PARAMETER * | Para | ||
) |
Handle packets in DHCP select state.
[in] | DhcpSb | The DHCP service instance |
[in] | Packet | The DHCP packet received |
[in] | Para | The DHCP parameter extracted from the packet. That is, all the option value that we care. |
EFI_SUCCESS | The packet is successfully processed. |
Others | Some error occurred. |
EFI_STATUS DhcpInitRequest | ( | IN DHCP_SERVICE * | DhcpSb | ) |
VOID EFIAPI DhcpInput | ( | NET_BUF * | UdpPacket, |
UDP_END_POINT * | EndPoint, | ||
EFI_STATUS | IoStatus, | ||
VOID * | Context | ||
) |
EFI_STATUS DhcpLeaseAcquired | ( | IN OUT DHCP_SERVICE * | DhcpSb | ) |
Update the lease states when a new lease is acquired. It will not only save the acquired the address and lease time, it will also create a UDP child to provide address resolution for the address.
DhcpSb | The DHCP service instance |
EFI_OUT_OF_RESOURCES | Failed to allocate resources. |
EFI_SUCCESS | The lease is recorded. |
VOID DhcpNotifyUser | ( | IN DHCP_SERVICE * | DhcpSb, |
IN INTN | Which | ||
) |
VOID EFIAPI DhcpOnPacketSent | ( | NET_BUF * | Packet, |
UDP_END_POINT * | EndPoint, | ||
EFI_STATUS | IoStatus, | ||
VOID * | Context | ||
) |
Each DHCP service has three timer. Two of them are count down timer. One for the packet retransmission. The other is to collect the offers. The third timer increments the lease life which is compared to T1, T2, and lease to determine the time to renew and rebind the lease. DhcpOnTimerTick will be called once every second.
[in] | Event | The timer event |
[in] | Context | The context, which is the DHCP service instance. |
EFI_STATUS DhcpRetransmit | ( | IN DHCP_SERVICE * | DhcpSb | ) |
EFI_STATUS DhcpSendMessage | ( | IN DHCP_SERVICE * | DhcpSb, |
IN EFI_DHCP4_PACKET * | Seed, | ||
IN DHCP_PARAMETER * | Para, | ||
IN UINT8 | Type, | ||
IN UINT8 * | Msg | ||
) |
Build and transmit a DHCP message according to the current states. This function implement the Table 5. of RFC 2131. Always transits the state (as defined in Figure 5. of the same RFC) before sending a DHCP message. The table is adjusted accordingly.
[in] | DhcpSb | The DHCP service instance |
[in] | Seed | The seed packet which the new packet is based on |
[in] | Para | The DHCP parameter of the Seed packet |
[in] | Type | The message type to send |
[in] | Msg | The human readable message to include in the packet sent. |
EFI_OUT_OF_RESOURCES | Failed to allocate resources for the packet |
EFI_ACCESS_DENIED | Failed to transmit the packet through UDP |
EFI_SUCCESS | The message is sent |
other | Other error occurs |
EFI_STATUS DhcpSetState | ( | IN OUT DHCP_SERVICE * | DhcpSb, |
IN INTN | State, | ||
IN BOOLEAN | CallUser | ||
) |
Set the DHCP state. If CallUser is true, it will try to notify the user before change the state by DhcpNotifyUser. It returns EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test the return value of this function.
DhcpSb | The DHCP service instance |
State | The new DHCP state to change to |
CallUser | Whether we need to call user |
EFI_SUCCESS | The state is changed |
EFI_ABORTED | The user asks to abort the DHCP process. |
VOID DhcpSetTransmitTimer | ( | IN OUT DHCP_SERVICE * | DhcpSb | ) |