TianoCore EDK2 master
|
Go to the source code of this file.
Data Structures | |
struct | DHCP_OPTION |
struct | DHCP_OPTION_COUNT |
struct | DHCP_OPTION_CONTEXT |
struct | DHCP_PARAMETER |
struct | DHCP_OPTION_FORMAT |
Macros | |
#define | DHCP_OPTION_MAGIC 0x63538263 |
#define | DHCP_MAX_OPTIONS 256 |
#define | DHCP_OPTION_SWITCH 1 |
#define | DHCP_OPTION_INT8 2 |
#define | DHCP_OPTION_INT16 3 |
#define | DHCP_OPTION_INT32 4 |
#define | DHCP_OPTION_IP 5 |
#define | DHCP_OPTION_IPPAIR 6 |
#define | DHCP_OVERLOAD_FILENAME 1 |
#define | DHCP_OVERLOAD_SVRNAME 2 |
#define | DHCP_OVERLOAD_BOTH 3 |
Typedefs | |
typedef EFI_STATUS(* | DHCP_CHECK_OPTION) (IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context) |
Functions | |
EFI_STATUS | DhcpIterateOptions (IN EFI_DHCP4_PACKET *Packet, IN DHCP_CHECK_OPTION Check OPTIONAL, IN VOID *Context) |
EFI_STATUS | DhcpValidateOptions (IN EFI_DHCP4_PACKET *Packet, OUT DHCP_PARAMETER **Para OPTIONAL) |
EFI_STATUS | DhcpParseOption (IN EFI_DHCP4_PACKET *Packet, OUT INTN *Count, OUT DHCP_OPTION **OptionPoint) |
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) |
To validate, parse and process the DHCP options.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Dhcp4Option.h.
#define DHCP_MAX_OPTIONS 256 |
Definition at line 17 of file Dhcp4Option.h.
#define DHCP_OPTION_INT16 3 |
Definition at line 24 of file Dhcp4Option.h.
#define DHCP_OPTION_INT32 4 |
Definition at line 25 of file Dhcp4Option.h.
#define DHCP_OPTION_INT8 2 |
Definition at line 23 of file Dhcp4Option.h.
#define DHCP_OPTION_IP 5 |
Definition at line 26 of file Dhcp4Option.h.
#define DHCP_OPTION_IPPAIR 6 |
Definition at line 27 of file Dhcp4Option.h.
#define DHCP_OPTION_MAGIC 0x63538263 |
DHCP option tags (types)
Definition at line 16 of file Dhcp4Option.h.
#define DHCP_OPTION_SWITCH 1 |
Definition at line 22 of file Dhcp4Option.h.
#define DHCP_OVERLOAD_BOTH 3 |
Definition at line 34 of file Dhcp4Option.h.
#define DHCP_OVERLOAD_FILENAME 1 |
Definition at line 32 of file Dhcp4Option.h.
#define DHCP_OVERLOAD_SVRNAME 2 |
Definition at line 33 of file Dhcp4Option.h.
typedef EFI_STATUS(* DHCP_CHECK_OPTION) (IN UINT8 Tag, IN UINT8 Len, IN UINT8 *Data, IN VOID *Context) |
Definition at line 97 of file Dhcp4Option.h.
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 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.
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.