TianoCore EDK2 master
|
#include "Dhcp4Impl.h"
Go to the source code of this file.
Functions | |
DHCP_OPTION_FORMAT * | DhcpFindOptionFormat (IN UINT8 Tag) |
BOOLEAN | DhcpOptionIsValid (IN DHCP_OPTION_FORMAT *Format, IN UINT8 *OptValue, IN INTN Len) |
EFI_STATUS | DhcpGetParameter (IN UINT8 Tag, IN INTN Len, IN UINT8 *Data, OUT DHCP_PARAMETER *Para) |
EFI_STATUS | DhcpIterateBufferOptions (IN UINT8 *Buffer, IN INTN BufLen, IN DHCP_CHECK_OPTION Check OPTIONAL, IN VOID *Context, OUT UINT8 *Overload OPTIONAL) |
EFI_STATUS | DhcpIterateOptions (IN EFI_DHCP4_PACKET *Packet, IN DHCP_CHECK_OPTION Check OPTIONAL, IN VOID *Context) |
EFI_STATUS | DhcpGetOptionLen (IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context) |
EFI_STATUS | DhcpFillOption (IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context) |
EFI_STATUS | DhcpParseOption (IN EFI_DHCP4_PACKET *Packet, OUT INTN *Count, OUT DHCP_OPTION **OptionPoint) |
EFI_STATUS | DhcpValidateOptions (IN EFI_DHCP4_PACKET *Packet, OUT DHCP_PARAMETER **Para OPTIONAL) |
UINT8 * | DhcpAppendOption (OUT UINT8 *Buf, IN UINT8 Tag, IN UINT16 DataLen, IN UINT8 *Data) |
EFI_STATUS | DhcpBuild (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) |
Variables | |
DHCP_OPTION_FORMAT | DhcpOptionFormats [] |
Function to validate, parse, process the DHCP options.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dhcp4Option.c.
Append an option to the memory, if the option is longer than 255 bytes, splits it into several options.
[out] | Buf | The buffer to append the option to |
[in] | Tag | The option's tag |
[in] | DataLen | The length of the option's data |
[in] | Data | The option's data |
Definition at line 727 of file Dhcp4Option.c.
EFI_STATUS DhcpBuild | ( | 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 | ||
) |
Build a new DHCP packet from a seed packet. Options may be deleted or appended. The caller should free the NewPacket when finished using it.
[in] | SeedPacket | The seed packet to start with |
[in] | DeleteCount | The number of options to delete |
[in] | DeleteList | The options to delete from the packet |
[in] | AppendCount | The number of options to append |
[in] | AppendList | The options to append to the packet |
[out] | NewPacket | The new packet, allocated and built by this function. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory |
EFI_INVALID_PARAMETER | The options in SeekPacket are mal-formatted |
EFI_SUCCESS | The packet is build. |
Definition at line 770 of file Dhcp4Option.c.
EFI_STATUS DhcpFillOption | ( | IN UINT8 | Tag, |
IN UINT8 | Len, | ||
IN UINT8 * | Data, | ||
IN VOID * | Context | ||
) |
Call back function to DhcpIterateOptions to consolidate each option's data. There are maybe several occurrence of the same option.
[in] | Tag | The option to consolidate its data |
[in] | Len | The length of option data |
[in] | Data | The data of the option's current occurrence |
[in] | Context | The context, which is DHCP_OPTION_CONTEXT. This array is just a wrap to pass THREE parameters. |
EFI_SUCCESS | It always returns EFI_SUCCESS |
Definition at line 480 of file Dhcp4Option.c.
DHCP_OPTION_FORMAT * DhcpFindOptionFormat | ( | IN UINT8 | Tag | ) |
Binary search the DhcpOptionFormats array to find the format information about a specific option.
[in] | Tag | The option's tag. |
Definition at line 114 of file Dhcp4Option.c.
EFI_STATUS DhcpGetOptionLen | ( | IN UINT8 | Tag, |
IN UINT8 | Len, | ||
IN UINT8 * | Data, | ||
IN VOID * | Context | ||
) |
Call back function to DhcpIterateOptions to compute each option's length. It just adds the data length of all the occurrences of this Tag. Context is an array of 256 DHCP_OPTION_COUNT.
[in] | Tag | The current option to check |
[in] | Len | The length of the option data |
[in] | Data | The option data |
[in] | Context | The context, which is a array of 256 DHCP_OPTION_COUNT. |
EFI_SUCCESS | It always returns EFI_SUCCESS. |
Definition at line 451 of file Dhcp4Option.c.
EFI_STATUS DhcpGetParameter | ( | IN UINT8 | Tag, |
IN INTN | Len, | ||
IN UINT8 * | Data, | ||
OUT DHCP_PARAMETER * | Para | ||
) |
Extract the client interested options, all the parameters are converted to host byte order.
[in] | Tag | The DHCP option tag |
[in] | Len | The length of the option |
[in] | Data | The value of the DHCP option |
[out] | Para | The variable to save the interested parameter |
EFI_SUCCESS | The DHCP option is successfully extracted. |
EFI_INVALID_PARAMETER | The DHCP option is mal-formatted |
Definition at line 235 of file Dhcp4Option.c.
EFI_STATUS DhcpIterateBufferOptions | ( | IN UINT8 * | Buffer, |
IN INTN | BufLen, | ||
IN DHCP_CHECK_OPTION Check | OPTIONAL, | ||
IN VOID * | Context, | ||
OUT UINT8 *Overload | OPTIONAL | ||
) |
Inspect all the options in a single buffer. DHCP options may be contained in several buffers, such as the BOOTP options filed, boot file or server name. Each option buffer is required to end with DHCP4_TAG_EOP.
[in] | Buffer | The buffer which contains DHCP options |
[in] | BufLen | The length of the buffer |
[in] | Check | The callback function for each option found |
[in] | Context | The opaque parameter for the Check |
[out] | Overload | Variable to save the value of DHCP4_TAG_OVERLOAD option. |
EFI_SUCCESS | All the options are valid |
EFI_INVALID_PARAMETER | The options are mal-formatted. |
Definition at line 309 of file Dhcp4Option.c.
EFI_STATUS DhcpIterateOptions | ( | IN EFI_DHCP4_PACKET * | Packet, |
IN DHCP_CHECK_OPTION Check | OPTIONAL, | ||
IN VOID * | Context | ||
) |
Iterate through a DHCP message to visit each option. First inspect all the options in the OPTION field. Then if overloaded, inspect the options in FILENAME and SERVERNAME fields. One option may be encoded in several places. See RFC 3396 Encoding Long Options in DHCP
[in] | Packet | The DHCP packet to check the options for |
[in] | Check | The callback function to be called for each option found |
[in] | Context | The opaque parameter for Check |
EFI_SUCCESS | The DHCP packet's options are well formatted |
EFI_INVALID_PARAMETER | The DHCP packet's options are not well formatted |
Definition at line 382 of file Dhcp4Option.c.
BOOLEAN DhcpOptionIsValid | ( | IN DHCP_OPTION_FORMAT * | Format, |
IN UINT8 * | OptValue, | ||
IN INTN | Len | ||
) |
Validate whether a single DHCP option is valid according to its format.
[in] | Format | The option's format |
[in] | OptValue | The value of the option |
[in] | Len | The length of the option value |
TRUE | The option is valid. |
FALSE | Otherwise. |
Definition at line 154 of file Dhcp4Option.c.
EFI_STATUS DhcpParseOption | ( | IN EFI_DHCP4_PACKET * | Packet, |
OUT INTN * | Count, | ||
OUT DHCP_OPTION ** | OptionPoint | ||
) |
Parse the options of a DHCP packet. It supports RFC 3396: Encoding Long Options in DHCP. That is, it will combine all the option value of all the occurrences of each option. A little bit of implementation: It adopts the "Key indexed counting" algorithm. First, it allocates an array of 256 DHCP_OPTION_COUNTs because DHCP option tag is encoded as a UINT8. It then iterates the DHCP packet to get data length of each option by calling DhcpIterOptions with DhcpGetOptionLen. Now, it knows the number of present options and their length. It allocates a array of DHCP_OPTION and a continuous buffer after the array to put all the options' data. Each option's data is pointed to by the Data field in DHCP_OPTION structure. At last, it call DhcpIterateOptions with DhcpFillOption to fill each option's data to its position in the buffer.
[in] | Packet | The DHCP packet to parse the options |
[out] | Count | The number of valid dhcp options present in the packet |
[out] | OptionPoint | The array that contains the DHCP options. Caller should free it. |
EFI_NOT_FOUND | Cannot find any option. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory to parse the packet. |
EFI_INVALID_PARAMETER | The options are mal-formatted |
EFI_SUCCESS | The options are parsed into OptionPoint |
Definition at line 541 of file Dhcp4Option.c.
EFI_STATUS DhcpValidateOptions | ( | IN EFI_DHCP4_PACKET * | Packet, |
OUT DHCP_PARAMETER **Para | OPTIONAL | ||
) |
Validate the packet's options. If necessary, allocate and fill in the interested parameters.
[in] | Packet | The packet to validate the options |
[out] | Para | The variable to save the DHCP parameters. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory to validate the packet. |
EFI_INVALID_PARAMETER | The options are mal-formatted |
EFI_SUCCESS | The options are parsed into OptionPoint |
Definition at line 641 of file Dhcp4Option.c.
DHCP_OPTION_FORMAT DhcpOptionFormats[] |
A list of the format of DHCP Options sorted by option tag to validate a dhcp message. Refere the comments of the DHCP_OPTION_FORMAT structure.
Definition at line 16 of file Dhcp4Option.c.