TianoCore EDK2 master
|
#include "Dhcp4Impl.h"
Go to the source code of this file.
Variables | |
EFI_DHCP4_PROTOCOL | mDhcp4ProtocolTemplate |
This file implement the EFI_DHCP4_PROTOCOL interface.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dhcp4Impl.c.
EFI_STATUS EFIAPI Dhcp4InstanceConfigUdpIo | ( | IN UDP_IO * | UdpIo, |
IN VOID * | Context | ||
) |
Callback by UdpIoCreatePort() when creating UdpIo for this Dhcp4 instance.
[in] | UdpIo | The UdpIo being created. |
[in] | Context | Dhcp4 instance. |
EFI_SUCCESS | UdpIo is configured successfully. |
EFI_INVALID_PARAMETER | Class E IP address is not supported or other parameters are not valid. |
other | Other error occurs. |
Definition at line 1177 of file Dhcp4Impl.c.
EFI_STATUS Dhcp4InstanceCreateUdpIo | ( | IN OUT DHCP_PROTOCOL * | Instance | ) |
Create UdpIo for this Dhcp4 instance.
Instance | The Dhcp4 instance. |
EFI_SUCCESS | UdpIo is created successfully. |
EFI_OUT_OF_RESOURCES | Fails to create UdpIo because of limited resources or configuration failure. |
Definition at line 1250 of file Dhcp4Impl.c.
EFI_STATUS Dhcp4ParseCheckOption | ( | IN UINT8 | Tag, |
IN UINT8 | Len, | ||
IN UINT8 * | Data, | ||
IN VOID * | Context | ||
) |
Callback function for DhcpIterateOptions. This callback sets the EFI_DHCP4_PACKET_OPTION array in the DHCP_PARSE_CONTEXT to point the individual DHCP option in the packet.
[in] | Tag | The DHCP option type |
[in] | Len | Length of the DHCP option data |
[in] | Data | The DHCP option data |
[in] | Context | The context, to pass several parameters in. |
EFI_SUCCESS | It always returns EFI_SUCCESS |
Definition at line 1673 of file Dhcp4Impl.c.
VOID DhcpCleanConfigure | ( | IN OUT EFI_DHCP4_CONFIG_DATA * | Config | ) |
Free the resource related to the configure parameters. DHCP driver will make a copy of the user's configure such as the time out value.
Config | The DHCP configure data |
Definition at line 415 of file Dhcp4Impl.c.
EFI_STATUS DhcpCopyConfigure | ( | OUT EFI_DHCP4_CONFIG_DATA * | Dst, |
IN EFI_DHCP4_CONFIG_DATA * | Src | ||
) |
Allocate memory for configure parameter such as timeout value for Dst, then copy the configure parameter from Src to Dst.
[out] | Dst | The destination DHCP configure data. |
[in] | Src | The source DHCP configure data. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
EFI_SUCCESS | The configure is copied. |
Definition at line 454 of file Dhcp4Impl.c.
VOID EFIAPI DhcpDummyExtFree | ( | IN VOID * | Arg | ) |
Callback of Dhcp packet. Does nothing.
Arg | The context. |
Definition at line 1296 of file Dhcp4Impl.c.
VOID DhcpYieldControl | ( | IN DHCP_SERVICE * | DhcpSb | ) |
Give up the control of the DHCP service to let other child resume. Don't change the service's DHCP state and the Client address and option list configure as required by RFC2131.
DhcpSb | The DHCP service instance. |
Definition at line 545 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Build | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN EFI_DHCP4_PACKET * | SeedPacket, | ||
IN UINT32 | DeleteCount, | ||
IN UINT8 *DeleteList | OPTIONAL, | ||
IN UINT32 | AppendCount, | ||
IN EFI_DHCP4_PACKET_OPTION *AppendList[] | OPTIONAL, | ||
OUT EFI_DHCP4_PACKET ** | NewPacket | ||
) |
Builds a DHCP packet, given the options to be appended or deleted or replaced.
The Build() function is used to assemble a new packet from the original packet by replacing or deleting existing options or appending new options. This function does not change any state of the EFI DHCPv4 Protocol driver and can be used at any time.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | SeedPacket | Initial packet to be used as a base for building new packet. |
[in] | DeleteCount | Number of opcodes in the DeleteList. |
[in] | DeleteList | List of opcodes to be deleted from the seed packet. Ignored if DeleteCount is zero. |
[in] | AppendCount | Number of entries in the OptionList. |
[in] | AppendList | Pointer to a DHCP option list to be appended to SeedPacket. If SeedPacket also contains options in this list, they are replaced by new options (except pad option). Ignored if AppendCount is zero. Type EFI_DHCP4_PACKET_OPTION |
[out] | NewPacket | Pointer to storage for the pointer to the new allocated packet. Use the EFI Boot Service FreePool() on the resulting pointer when done with the packet. |
EFI_SUCCESS | The new packet was built. |
EFI_OUT_OF_RESOURCES | Storage for the new packet could not be allocated. |
EFI_INVALID_PARAMETER | Some parameter is NULL. |
Definition at line 1124 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Configure | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData | OPTIONAL | ||
) |
Initializes, changes, or resets the operational settings for the EFI DHCPv4 Protocol driver.
The Configure() function is used to initialize, change, or reset the operational settings of the EFI DHCPv4 Protocol driver for the communication device on which the EFI DHCPv4 Service Binding Protocol is installed. This function can be successfully called only if both of the following are true: This instance of the EFI DHCPv4 Protocol driver is in the Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound states. No other EFI DHCPv4 Protocol driver instance that is controlled by this EFI DHCPv4 Service Binding Protocol driver instance has configured this EFI DHCPv4 Protocol driver. When this driver is in the Dhcp4Stopped state, it can transfer into one of the following two possible initial states: Dhcp4Init Dhcp4InitReboot The driver can transfer into these states by calling Configure() with a non-NULL Dhcp4CfgData. The driver will transfer into the appropriate state based on the supplied client network address in the ClientAddress parameter and DHCP options in the OptionList parameter as described in RFC 2131. When Configure() is called successfully while Dhcp4CfgData is set to NULL, the default configuring data will be reset in the EFI DHCPv4 Protocol driver and the state of the EFI DHCPv4 Protocol driver will not be changed. If one instance wants to make it possible for another instance to configure the EFI DHCPv4 Protocol driver, it must call this function with Dhcp4CfgData set to NULL.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | Dhcp4CfgData | Pointer to the EFI_DHCP4_CONFIG_DATA. |
EFI_SUCCESS | The EFI DHCPv4 Protocol driver is now in the Dhcp4Init or Dhcp4InitReboot state, if the original state of this driver was Dhcp4Stopped and the value of Dhcp4CfgData was not NULL. Otherwise, the state was left unchanged. |
EFI_ACCESS_DENIED | This instance of the EFI DHCPv4 Protocol driver was not in the Dhcp4Stopped, Dhcp4Init, Dhcp4InitReboot, or Dhcp4Bound state; Or another instance of this EFI DHCPv4 Protocol driver is already in a valid configured state. |
EFI_INVALID_PARAMETER | Some parameter is NULL. |
EFI_OUT_OF_RESOURCES | Required system resources could not be allocated. |
EFI_DEVICE_ERROR | An unexpected system or network error occurred. |
Definition at line 618 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4GetModeData | ( | IN EFI_DHCP4_PROTOCOL * | This, |
OUT EFI_DHCP4_MODE_DATA * | Dhcp4ModeData | ||
) |
Returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.
The GetModeData() function returns the current operating mode and cached data packet for the EFI DHCPv4 Protocol driver.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[out] | Dhcp4ModeData | Pointer to storage for the EFI_DHCP4_MODE_DATA structure. |
EFI_SUCCESS | The mode data was returned. |
EFI_INVALID_PARAMETER | This is NULL. |
Definition at line 349 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Parse | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN EFI_DHCP4_PACKET * | Packet, | ||
IN OUT UINT32 * | OptionCount, | ||
OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] | OPTIONAL | ||
) |
Parses the packed DHCP option data.
The Parse() function is used to retrieve the option list from a DHCP packet. If *OptionCount isn't zero, and there is enough space for all the DHCP options in the Packet, each element of PacketOptionList is set to point to somewhere in the Packet->Dhcp4.Option where a new DHCP option begins. If RFC3396 is supported, the caller should reassemble the parsed DHCP options to get the finial result. If *OptionCount is zero or there isn't enough space for all of them, the number of DHCP options in the Packet is returned in OptionCount.
This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
Packet | Pointer to packet to be parsed. |
OptionCount | On input, the number of entries in the PacketOptionList. On output, the number of entries that were written into the PacketOptionList. |
PacketOptionList | List of packet option entries to be filled in. End option or pad options are not included. |
EFI_SUCCESS | The packet was successfully parsed. |
EFI_INVALID_PARAMETER | Some parameter is NULL. |
EFI_BUFFER_TOO_SMALL | One or more of the following conditions is TRUE: 1) *OptionCount is smaller than the number of options that were found in the Packet. 2) PacketOptionList is NULL. |
Definition at line 1726 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Release | ( | IN EFI_DHCP4_PROTOCOL * | This | ) |
Releases the current address configuration.
The Release() function releases the current configured IP address by doing either of the following: Sending a DHCPRELEASE packet when the EFI DHCPv4 Protocol driver is in the Dhcp4Bound state Setting the previously assigned IP address that was provided with the EFI_DHCP4_PROTOCOL.Configure() function to 0.0.0.0 when the driver is in Dhcp4InitReboot state After a successful call to this function, the EFI DHCPv4 Protocol driver returns to the Dhcp4Init state and any subsequent incoming packets will be discarded silently.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
EFI_SUCCESS | The EFI DHCPv4 Protocol driver is now in the Dhcp4Init phase. |
EFI_INVALID_PARAMETER | This is NULL. |
EFI_ACCESS_DENIED | The EFI DHCPv4 Protocol driver is not Dhcp4InitReboot state. |
EFI_DEVICE_ERROR | An unexpected system or network error occurred. |
Definition at line 992 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4RenewRebind | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN BOOLEAN | RebindRequest, | ||
IN EFI_EVENT CompletionEvent | OPTIONAL | ||
) |
Extends the lease time by sending a request packet.
The RenewRebind() function is used to manually extend the lease time when the EFI DHCPv4 Protocol driver is in the Dhcp4Bound state and the lease time has not expired yet. This function will send a request packet to the previously found server (or to any server when RebindRequest is TRUE) and transfer the state into the Dhcp4Renewing state (or Dhcp4Rebinding when RebindingRequest is TRUE). When a response is received, the state is returned to Dhcp4Bound. If no response is received before the try count is exceeded (the RequestTryCount field that is specified in EFI_DHCP4_CONFIG_DATA) but before the lease time that was issued by the previous server expires, the driver will return to the Dhcp4Bound state and the previous configuration is restored. The outgoing and incoming packets can be captured by the EFI_DHCP4_CALLBACK function.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | RebindRequest | If TRUE, this function broadcasts the request packets and enters the Dhcp4Rebinding state. Otherwise, it sends a unicast request packet and enters the Dhcp4Renewing state. |
[in] | CompletionEvent | If not NULL, this event is signaled when the renew/rebind phase completes or some error occurs. EFI_DHCP4_PROTOCOL.GetModeData() can be called to check the completion status. If NULL, EFI_DHCP4_PROTOCOL.RenewRebind() will busy-wait until the DHCP process finishes. |
EFI_SUCCESS | The EFI DHCPv4 Protocol driver is now in the Dhcp4Renewing state or is back to the Dhcp4Bound state. |
EFI_NOT_STARTED | The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called. |
EFI_INVALID_PARAMETER | This is NULL. |
EFI_TIMEOUT | There was no response from the server when the try count was exceeded. |
EFI_ACCESS_DENIED | The driver is not in the Dhcp4Bound state. |
EFI_DEVICE_ERROR | An unexpected system or network error occurred. |
Definition at line 878 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Start | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN EFI_EVENT CompletionEvent | OPTIONAL | ||
) |
Starts the DHCP configuration process.
The Start() function starts the DHCP configuration process. This function can be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or Dhcp4InitReboot state. If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL. If the process aborts, either by the user or by some unexpected network error, the state is restored to the Dhcp4Init state. The Start() function can be called again to restart the process. Refer to RFC 2131 for precise state transitions during this process. At the time when each event occurs in this process, the callback function that was set by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this opportunity to control the process.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | CompletionEvent | If not NULL, indicates the event that will be signaled when the EFI DHCPv4 Protocol driver is transferred into the Dhcp4Bound state or when the DHCP process is aborted. EFI_DHCP4_PROTOCOL.GetModeData() can be called to check the completion status. If NULL, EFI_DHCP4_PROTOCOL.Start() will wait until the driver is transferred into the Dhcp4Bound state or the process fails. |
EFI_SUCCESS | The DHCP configuration process has started, or it has completed when CompletionEvent is NULL. |
EFI_NOT_STARTED | The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL. Configure() needs to be called. |
EFI_INVALID_PARAMETER | This is NULL. |
EFI_OUT_OF_RESOURCES | Required system resources could not be allocated. |
EFI_TIMEOUT | The DHCP configuration process failed because no response was received from the server within the specified timeout value. |
EFI_ABORTED | The user aborted the DHCP process. |
EFI_ALREADY_STARTED | Some other EFI DHCPv4 Protocol instance already started the DHCP process. |
EFI_DEVICE_ERROR | An unexpected system or network error occurred. |
Starts the DHCP configuration process.
The Start() function starts the DHCP configuration process. This function can be called only when the EFI DHCPv4 Protocol driver is in the Dhcp4Init or Dhcp4InitReboot state. If the DHCP process completes successfully, the state of the EFI DHCPv4 Protocol driver will be transferred through Dhcp4Selecting and Dhcp4Requesting to the Dhcp4Bound state. The CompletionEvent will then be signaled if it is not NULL. If the process aborts, either by the user or by some unexpected network error, the state is restored to the Dhcp4Init state. The Start() function can be called again to restart the process. Refer to RFC 2131 for precise state transitions during this process. At the time when each event occurs in this process, the callback function that was set by EFI_DHCP4_PROTOCOL.Configure() will be called and the user can take this opportunity to control the process.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | CompletionEvent | If not NULL, indicates the event that will be signaled when the EFI DHCPv4 Protocol driver is transferred into the Dhcp4Bound state or when the DHCP process is aborted. EFI_DHCP4_PROTOCOL.GetModeData() can be called to check the completion status. If NULL, EFI_DHCP4_PROTOCOL.Start() will wait until the driver is transferred into the Dhcp4Bound state or the process fails. |
EFI_SUCCESS | The DHCP configuration process has started, or it has completed when CompletionEvent is NULL. |
EFI_NOT_STARTED | The EFI DHCPv4 Protocol driver is in the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL. Configure() needs to be called. |
EFI_INVALID_PARAMETER | This is NULL. |
EFI_OUT_OF_RESOURCES | Required system resources could not be allocated. |
EFI_TIMEOUT | The DHCP configuration process failed because no response was received from the server within the specified timeout value. |
EFI_ABORTED | The user aborted the DHCP process. |
EFI_ALREADY_STARTED | Some other EFI DHCPv4 Protocol instance already started the DHCP process. |
EFI_DEVICE_ERROR | An unexpected system or network error occurred. |
EFI_NO_MEDIA | There was a media error. |
Definition at line 763 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4Stop | ( | IN EFI_DHCP4_PROTOCOL * | This | ) |
Stops the current address configuration.
The Stop() function is used to stop the DHCP configuration process. After this function is called successfully, the EFI DHCPv4 Protocol driver is transferred into the Dhcp4Stopped state. EFI_DHCP4_PROTOCOL.Configure() needs to be called before DHCP configuration process can be started again. This function can be called when the EFI DHCPv4 Protocol driver is in any state.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
EFI_SUCCESS | The EFI DHCPv4 Protocol driver is now in the Dhcp4Stopped phase. |
EFI_INVALID_PARAMETER | This is NULL. |
Definition at line 1062 of file Dhcp4Impl.c.
EFI_STATUS EFIAPI EfiDhcp4TransmitReceive | ( | IN EFI_DHCP4_PROTOCOL * | This, |
IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN * | Token | ||
) |
Transmits a DHCP formatted packet and optionally waits for responses.
The TransmitReceive() function is used to transmit a DHCP packet and optionally wait for the response from servers. This function does not change the state of the EFI DHCPv4 Protocol driver and thus can be used at any time.
[in] | This | Pointer to the EFI_DHCP4_PROTOCOL instance. |
[in] | Token | Pointer to the EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN structure. |
EFI_SUCCESS | The packet was successfully queued for transmission. |
EFI_INVALID_PARAMETER | Some parameter is NULL. |
EFI_NOT_READY | The previous call to this function has not finished yet. Try to call this function after collection process completes. |
EFI_NO_MAPPING | The default station address is not available yet. |
EFI_OUT_OF_RESOURCES | Required system resources could not be allocated. |
Others | Some other unexpected error occurred. |
Definition at line 1487 of file Dhcp4Impl.c.
VOID PxeDhcpDone | ( | IN DHCP_PROTOCOL * | Instance | ) |
Complete a Dhcp4 transaction and signal the upper layer.
Instance | Dhcp4 instance. |
Definition at line 1419 of file Dhcp4Impl.c.
VOID EFIAPI PxeDhcpInput | ( | NET_BUF * | UdpPacket, |
UDP_END_POINT * | EndPoint, | ||
EFI_STATUS | IoStatus, | ||
VOID * | Context | ||
) |
Callback of UdpIoRecvDatagram() that handles a Dhcp4 packet.
Only BOOTP responses will be handled that correspond to the Xid of the request sent out. The packet will be queued to the response queue.
UdpPacket | The Dhcp4 packet. |
EndPoint | Udp4 address pair. |
IoStatus | Status of the input. |
Context | Extra info for the input. |
Definition at line 1316 of file Dhcp4Impl.c.
VOID SetElapsedTime | ( | IN UINT16 * | Elapsed, |
IN DHCP_PROTOCOL * | Instance | ||
) |
Set the elapsed time based on the given instance and the pointer to the elapsed time option.
[in] | Elapsed | The pointer to the position to append. |
[in] | Instance | The pointer to the Dhcp4 instance. |
Definition at line 1783 of file Dhcp4Impl.c.
EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate |
Definition at line 322 of file Dhcp4Impl.c.