PxeBcDhcp.h revision 4fd606d1f5abe38e1f42c38de1d2e895166bd0f4
/** @file
Dhcp and Discover routines for PxeBc.
Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_DHCP_H__
#define __EFI_PXEBC_DHCP_H__
#define PXEBC_DHCP4_MAX_OPTION_NUM 16
#define PXEBC_DHCP4_MAX_OPTION_SIZE 312
#define PXEBC_DHCP4_MAX_PACKET_SIZE 1472
#define PXEBC_DHCP4_S_PORT 67
#define PXEBC_DHCP4_C_PORT 68
#define PXEBC_BS_DOWNLOAD_PORT 69
#define PXEBC_BS_DISCOVER_PORT 4011
#define PXEBC_DHCP4_OPCODE_REQUEST 1
#define PXEBC_DHCP4_OPCODE_REPLY 2
#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
//
// Dhcp Options
//
#define PXEBC_DHCP4_TAG_PAD 0 // Pad Option
#define PXEBC_PXE_DHCP4_TAG_ARCH 93
#define PXEBC_PXE_DHCP4_TAG_UNDI 94
#define PXEBC_PXE_DHCP4_TAG_UUID 97
//
// Sub-Options in Dhcp Vendor Option
//
#define PXEBC_VENDOR_TAG_MTFTP_IP 1
#define PXEBC_VENDOR_TAG_MTFTP_CPORT 2
#define PXEBC_VENDOR_TAG_MTFTP_SPORT 3
#define PXEBC_VENDOR_TAG_MTFTP_TIMEOUT 4
#define PXEBC_VENDOR_TAG_MTFTP_DELAY 5
#define PXEBC_VENDOR_TAG_DISCOVER_CTRL 6
#define PXEBC_VENDOR_TAG_DISCOVER_MCAST 7
#define PXEBC_VENDOR_TAG_BOOT_SERVERS 8
#define PXEBC_VENDOR_TAG_BOOT_MENU 9
#define PXEBC_VENDOR_TAG_MENU_PROMPT 10
#define PXEBC_VENDOR_TAG_MCAST_ALLOC 11
#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12
#define PXEBC_VENDOR_TAG_BOOT_ITEM 71
#define PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT 4
#define PXEBC_DHCP4_DISCOVER_RETRIES 4
#define PXEBC_MAX_MENU_NUM 24
#define PXEBC_MAX_OFFER_NUM 16
#define PXEBC_BOOT_REQUEST_TIMEOUT 1
#define PXEBC_BOOT_REQUEST_RETRIES 4
#define PXEBC_DHCP4_OVERLOAD_FILE 1
#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
//
// The array index of the DHCP4 option tag interested
//
#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
#define PXEBC_DHCP4_TAG_INDEX_MAX 7
//
// The type of DHCP OFFER, arranged by priority, PXE10 has the highest priority.
//
#define DHCP4_PACKET_TYPE_PXE10 0
#define DHCP4_PACKET_TYPE_WFM11A 1
#define DHCP4_PACKET_TYPE_BINL 2
#define DHCP4_PACKET_TYPE_DHCP_ONLY 3
#define DHCP4_PACKET_TYPE_BOOTP 4
#define DHCP4_PACKET_TYPE_MAX 5
#define BIT(x) (1 << x)
#define CTRL(x) (0x1F & (x))
//
// WfM11a options
//
//
// Discoverty options
//
#define IS_VALID_BOOT_PROMPT(x) \
#define IS_VALID_BOOT_MENU(x) \
#define IS_VALID_MTFTP_VENDOR_OPTION(x) \
#define IS_VALID_DISCOVER_VENDOR_OPTION(x) (((UINT32) ((x)[0]) & DISCOVER_VENDOR_OPTION_BIT_MAP) != 0)
#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) == BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES))
#define IS_VALID_BOOTITEM_VENDOR_OPTION(x) \
#define SET_VENDOR_OPTION_BIT_MAP(x, y) (((x)[(y) / 32]) = (UINT32) ((x)[(y) / 32]) | BIT ((y) % 32))
#pragma pack(1)
typedef struct {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
#define DEFAULT_UNDI_TYPE 1
#define DEFAULT_UNDI_MAJOR 3
#define DEFAULT_UNDI_MINOR 0
typedef struct {
typedef struct {
typedef struct {
#pragma pack()
typedef union {
typedef struct {
typedef struct {
typedef struct {
typedef struct {
#define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_MAX_PACKET_SIZE)
typedef union {
typedef struct {
#define GET_NEXT_DHCP_OPTION(Opt) \
(EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
#define GET_NEXT_BOOT_SVR_ENTRY(Ent) \
(PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + ((Ent)->IpCnt - 1) * sizeof (EFI_IPv4_ADDRESS))
/**
This function initialize the DHCP4 message instance.
This function will pad each item of dhcp4 message packet.
@param Seed Pointer to the message instance of the DHCP4 packet.
@param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance.
**/
);
/**
Parse the cached dhcp packet.
@param CachedPacket Pointer to cached dhcp packet.
@retval TRUE Succeed to parse and validation.
@retval FALSE Fail to parse or validation.
**/
);
/**
This function is to check the selected proxy offer (include BINL dhcp offer and
DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe base code
mode structure.
@param Private Pointer to PxeBc private data.
@retval EFI_SUCCESS Operational successful.
@retval EFI_NO_RESPONSE Offer dhcp service failed.
**/
);
/**
Callback routine.
EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver
to intercept events that occurred in the configuration process. This structure
provides advanced control of each state transition of the DHCP process. The
returned status code determines the behavior of the EFI DHCPv4 Protocol driver.
There are three possible returned values, which are described in the following
table.
@param This Pointer to the EFI DHCPv4 Protocol instance that is used to
configure this callback function.
@param Context Pointer to the context that is initialized by
EFI_DHCP4_PROTOCOL.Configure().
@param CurrentState The current operational state of the EFI DHCPv4 Protocol
driver.
@param Dhcp4Event The event that occurs in the current state, which usually means a
state transition.
@param Packet The DHCP packet that is going to be sent or already received.
@param NewPacket The packet that is used to replace the above Packet.
@retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process.
@retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol
driver will continue to wait for more DHCPOFFER packets until the retry
timeout expires.
@retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and
return to the Dhcp4Init or Dhcp4InitReboot state.
**/
);
/**
Discover the boot of service and initialize the vendor option if exists.
@param Private Pointer to PxeBc private data.
@param Type PxeBc option boot item type
@param Layer PxeBc option boot item layer
@param UseBis Use BIS or not
@param DestIp Ip address for server
@param IpCount The total count of the server ip address
@param SrvList Server list
@param IsDiscv Discover the vendor or not
@param Reply The dhcp4 packet of Pxe reply
@retval EFI_SUCCESS Operation succeeds.
@retval EFI_OUT_OF_RESOURCES Allocate memory pool failed.
@retval EFI_NOT_FOUND There is no vendor option exists.
@retval EFI_TIMEOUT Send Pxe Discover time out.
**/
);
/**
Initialize the DHCP options and build the option list.
@param Private Pointer to PxeBc private data.
@param OptList Pointer to a DHCP option list.
@param IsDhcpDiscover Discover dhcp option or not.
@return The index item number of the option list.
**/
);
/**
Create the boot options.
@param OptList Pointer to the list of the options
@param Type the type of option
@param Layer the layer of the boot options
@param OptLen length of opotion
**/
);
/**
Parse interested dhcp options.
@param Buffer Pointer to the dhcp options packet.
@param Length The length of the dhcp options.
@param OptTag The option OpCode.
@return NULL if the buffer length is 0 and OpCode is not
PXEBC_DHCP4_TAG_EOP, or the pointer to the buffer.
**/
);
/**
This function is to parse and check vendor options.
@param Dhcp4Option Pointer to dhcp options
@param VendorOption Pointer to vendor options
@return TRUE if valid for vendor options, or FALSE.
**/
);
/**
Choose the boot prompt.
@param Private Pointer to PxeBc private data.
@retval EFI_SUCCESS Select boot prompt done.
@retval EFI_TIMEOUT Select boot prompt time out.
@retval EFI_NOT_FOUND The proxy offer is not Pxe10.
@retval EFI_ABORTED User cancel the operation.
@retval EFI_NOT_READY Read the input key from the keybroad has not finish.
**/
);
/**
Select the boot menu.
@param Private Pointer to PxeBc private data.
@param Type The type of the menu.
@param UseDefaultItem Use default item or not.
@retval EFI_ABORTED User cancel operation.
@retval EFI_SUCCESS Select the boot menu success.
@retval EFI_NOT_READY Read the input key from the keybroad has not finish.
**/
);
#endif