TianoCore EDK2 master
|
#include <Uefi.h>
#include <Protocol/ServiceBinding.h>
#include <Library/NetLib.h>
#include <Library/UdpIoLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
Go to the source code of this file.
Macros | |
#define | DHCP_WAIT_OFFER 3 |
#define | DHCP_DEFAULT_LEASE 7 * 24 * 60 * 60 |
#define | DHCP_SERVER_PORT 67 |
#define | DHCP_CLIENT_PORT 68 |
#define | BOOTP_REQUEST 1 |
#define | BOOTP_REPLY 2 |
#define | DHCP_MSG_DISCOVER 1 |
#define | DHCP_MSG_OFFER 2 |
#define | DHCP_MSG_REQUEST 3 |
#define | DHCP_MSG_DECLINE 4 |
#define | DHCP_MSG_ACK 5 |
#define | DHCP_MSG_NAK 6 |
#define | DHCP_MSG_RELEASE 7 |
#define | DHCP_MSG_INFORM 8 |
#define | DHCP_NOTIFY_COMPLETION 1 |
#define | DHCP_NOTIFY_RENEWREBIND 2 |
#define | DHCP_NOTIFY_ALL 3 |
#define | DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0)) |
#define | DHCP_CONNECTED(State) (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding)) |
Functions | |
EFI_STATUS | DhcpSetState (IN OUT DHCP_SERVICE *DhcpSb, IN INTN State, IN BOOLEAN CallUser) |
EFI_STATUS | DhcpSendMessage (IN DHCP_SERVICE *DhcpSb, IN EFI_DHCP4_PACKET *Seed, IN DHCP_PARAMETER *Para, IN UINT8 Type, IN UINT8 *Msg) |
VOID EFIAPI | DhcpOnTimerTick (IN EFI_EVENT Event, IN VOID *Context) |
VOID EFIAPI | DhcpInput (NET_BUF *UdpPacket, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context) |
EFI_STATUS | DhcpInitRequest (IN DHCP_SERVICE *DhcpSb) |
VOID | DhcpCleanLease (IN DHCP_SERVICE *DhcpSb) |
VOID EFIAPI | DhcpOnPacketSent (NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context) |
The DHCP4 protocol implementation.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dhcp4Io.h.
#define DHCP_CONNECTED | ( | State | ) | (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding)) |
#define DHCP_IS_BOOTP | ( | Parameter | ) | (((Parameter) == NULL) || ((Parameter)->DhcpType == 0)) |
VOID DhcpCleanLease | ( | IN DHCP_SERVICE * | DhcpSb | ) |
EFI_STATUS DhcpInitRequest | ( | IN DHCP_SERVICE * | DhcpSb | ) |
VOID EFIAPI DhcpInput | ( | NET_BUF * | UdpPacket, |
UDP_END_POINT * | EndPoint, | ||
EFI_STATUS | IoStatus, | ||
VOID * | Context | ||
) |
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 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. |