MedmodulePkg: Refine codes related to Dhcpv4 and Dhcpv6 configuration.
Add a new head file Dhcp.h in Mde/Include/IndustryStandard, normalize the universal option numbers and other network number tags. Cc: Sriram Subramanian <sriram-s@hpe.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Cc: Wu Jiaxin <jiaxin.wu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Zhang Lubo <lubo.zhang@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
This commit is contained in:
@@ -20,13 +20,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
// This is a map from the interested DHCP4 option tags' index to the tag value.
|
||||
//
|
||||
UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
|
||||
PXEBC_DHCP4_TAG_BOOTFILE_LEN,
|
||||
PXEBC_DHCP4_TAG_VENDOR,
|
||||
PXEBC_DHCP4_TAG_OVERLOAD,
|
||||
PXEBC_DHCP4_TAG_MSG_TYPE,
|
||||
PXEBC_DHCP4_TAG_SERVER_ID,
|
||||
PXEBC_DHCP4_TAG_CLASS_ID,
|
||||
PXEBC_DHCP4_TAG_BOOTFILE
|
||||
DHCP4_TAG_BOOTFILE_LEN,
|
||||
DHCP4_TAG_VENDOR,
|
||||
DHCP4_TAG_OVERLOAD,
|
||||
DHCP4_TAG_MSG_TYPE,
|
||||
DHCP4_TAG_SERVER_ID,
|
||||
DHCP4_TAG_VENDOR_CLASS_ID,
|
||||
DHCP4_TAG_BOOTFILE
|
||||
};
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ PxeBcInitSeedPacket (
|
||||
CopyMem (Header->ClientHwAddr, &Mode.CurrentAddress, Header->HwAddrLen);
|
||||
|
||||
Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC;
|
||||
Seed->Dhcp4.Option[0] = PXEBC_DHCP4_TAG_EOP;
|
||||
Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
|
||||
}
|
||||
|
||||
|
||||
@@ -885,7 +885,7 @@ PxeBcDhcpCallBack (
|
||||
MaxMsgSize = PxeBcParseExtendOptions (
|
||||
Packet->Dhcp4.Option,
|
||||
GET_OPTION_BUFFER_LEN (Packet),
|
||||
PXEBC_DHCP4_TAG_MAXMSG
|
||||
DHCP4_TAG_MAXMSG
|
||||
);
|
||||
if (MaxMsgSize != NULL) {
|
||||
Value = HTONS (PXEBC_DHCP4_MAX_PACKET_SIZE);
|
||||
@@ -1012,7 +1012,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append message type.
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_DHCP4_TAG_MSG_TYPE;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE;
|
||||
OptList[Index]->Length = 1;
|
||||
OptEnt.Mesg = (PXEBC_DHCP4_OPTION_MESG *) OptList[Index]->Data;
|
||||
OptEnt.Mesg->Type = PXEBC_DHCP4_MSG_TYPE_REQUEST;
|
||||
@@ -1022,7 +1022,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append max message size.
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_DHCP4_TAG_MAXMSG;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_MAXMSG;
|
||||
OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);
|
||||
OptEnt.MaxMesgSize = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) OptList[Index]->Data;
|
||||
Value = NTOHS (PXEBC_DHCP4_MAX_PACKET_SIZE);
|
||||
@@ -1033,36 +1033,36 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Parameter request list option.
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_DHCP4_TAG_PARA_LIST;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
|
||||
OptList[Index]->Length = 35;
|
||||
OptEnt.Para = (PXEBC_DHCP4_OPTION_PARA *) OptList[Index]->Data;
|
||||
OptEnt.Para->ParaList[0] = PXEBC_DHCP4_TAG_NETMASK;
|
||||
OptEnt.Para->ParaList[1] = PXEBC_DHCP4_TAG_TIME_OFFSET;
|
||||
OptEnt.Para->ParaList[2] = PXEBC_DHCP4_TAG_ROUTER;
|
||||
OptEnt.Para->ParaList[3] = PXEBC_DHCP4_TAG_TIME_SERVER;
|
||||
OptEnt.Para->ParaList[4] = PXEBC_DHCP4_TAG_NAME_SERVER;
|
||||
OptEnt.Para->ParaList[5] = PXEBC_DHCP4_TAG_DNS_SERVER;
|
||||
OptEnt.Para->ParaList[6] = PXEBC_DHCP4_TAG_HOSTNAME;
|
||||
OptEnt.Para->ParaList[7] = PXEBC_DHCP4_TAG_BOOTFILE_LEN;
|
||||
OptEnt.Para->ParaList[8] = PXEBC_DHCP4_TAG_DOMAINNAME;
|
||||
OptEnt.Para->ParaList[9] = PXEBC_DHCP4_TAG_ROOTPATH;
|
||||
OptEnt.Para->ParaList[10] = PXEBC_DHCP4_TAG_EXTEND_PATH;
|
||||
OptEnt.Para->ParaList[11] = PXEBC_DHCP4_TAG_EMTU;
|
||||
OptEnt.Para->ParaList[12] = PXEBC_DHCP4_TAG_TTL;
|
||||
OptEnt.Para->ParaList[13] = PXEBC_DHCP4_TAG_BROADCAST;
|
||||
OptEnt.Para->ParaList[14] = PXEBC_DHCP4_TAG_NIS_DOMAIN;
|
||||
OptEnt.Para->ParaList[15] = PXEBC_DHCP4_TAG_NIS_SERVER;
|
||||
OptEnt.Para->ParaList[16] = PXEBC_DHCP4_TAG_NTP_SERVER;
|
||||
OptEnt.Para->ParaList[17] = PXEBC_DHCP4_TAG_VENDOR;
|
||||
OptEnt.Para->ParaList[18] = PXEBC_DHCP4_TAG_REQUEST_IP;
|
||||
OptEnt.Para->ParaList[19] = PXEBC_DHCP4_TAG_LEASE;
|
||||
OptEnt.Para->ParaList[20] = PXEBC_DHCP4_TAG_SERVER_ID;
|
||||
OptEnt.Para->ParaList[21] = PXEBC_DHCP4_TAG_T1;
|
||||
OptEnt.Para->ParaList[22] = PXEBC_DHCP4_TAG_T2;
|
||||
OptEnt.Para->ParaList[23] = PXEBC_DHCP4_TAG_CLASS_ID;
|
||||
OptEnt.Para->ParaList[24] = PXEBC_DHCP4_TAG_TFTP;
|
||||
OptEnt.Para->ParaList[25] = PXEBC_DHCP4_TAG_BOOTFILE;
|
||||
OptEnt.Para->ParaList[26] = PXEBC_PXE_DHCP4_TAG_UUID;
|
||||
OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
|
||||
OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
|
||||
OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
|
||||
OptEnt.Para->ParaList[3] = DHCP4_TAG_TIME_SERVER;
|
||||
OptEnt.Para->ParaList[4] = DHCP4_TAG_NAME_SERVER;
|
||||
OptEnt.Para->ParaList[5] = DHCP4_TAG_DNS_SERVER;
|
||||
OptEnt.Para->ParaList[6] = DHCP4_TAG_HOSTNAME;
|
||||
OptEnt.Para->ParaList[7] = DHCP4_TAG_BOOTFILE_LEN;
|
||||
OptEnt.Para->ParaList[8] = DHCP4_TAG_DOMAINNAME;
|
||||
OptEnt.Para->ParaList[9] = DHCP4_TAG_ROOTPATH;
|
||||
OptEnt.Para->ParaList[10] = DHCP4_TAG_EXTEND_PATH;
|
||||
OptEnt.Para->ParaList[11] = DHCP4_TAG_EMTU;
|
||||
OptEnt.Para->ParaList[12] = DHCP4_TAG_TTL;
|
||||
OptEnt.Para->ParaList[13] = DHCP4_TAG_BROADCAST;
|
||||
OptEnt.Para->ParaList[14] = DHCP4_TAG_NIS_DOMAIN;
|
||||
OptEnt.Para->ParaList[15] = DHCP4_TAG_NIS_SERVER;
|
||||
OptEnt.Para->ParaList[16] = DHCP4_TAG_NTP_SERVER;
|
||||
OptEnt.Para->ParaList[17] = DHCP4_TAG_VENDOR;
|
||||
OptEnt.Para->ParaList[18] = DHCP4_TAG_REQUEST_IP;
|
||||
OptEnt.Para->ParaList[19] = DHCP4_TAG_LEASE;
|
||||
OptEnt.Para->ParaList[20] = DHCP4_TAG_SERVER_ID;
|
||||
OptEnt.Para->ParaList[21] = DHCP4_TAG_T1;
|
||||
OptEnt.Para->ParaList[22] = DHCP4_TAG_T2;
|
||||
OptEnt.Para->ParaList[23] = DHCP4_TAG_VENDOR_CLASS_ID;
|
||||
OptEnt.Para->ParaList[24] = DHCP4_TAG_TFTP;
|
||||
OptEnt.Para->ParaList[25] = DHCP4_TAG_BOOTFILE;
|
||||
OptEnt.Para->ParaList[26] = DHCP4_TAG_UUID;
|
||||
OptEnt.Para->ParaList[27] = 0x80;
|
||||
OptEnt.Para->ParaList[28] = 0x81;
|
||||
OptEnt.Para->ParaList[29] = 0x82;
|
||||
@@ -1077,7 +1077,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append UUID/Guid-based client identifier option
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_UUID;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_UUID;
|
||||
OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID);
|
||||
OptEnt.Uuid = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data;
|
||||
OptEnt.Uuid->Type = 0;
|
||||
@@ -1096,7 +1096,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append client network device interface option
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_UNDI;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_UNDI;
|
||||
OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI);
|
||||
OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data;
|
||||
if (Private->Nii != NULL) {
|
||||
@@ -1115,7 +1115,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append client system architecture option
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_PXE_DHCP4_TAG_ARCH;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_ARCH;
|
||||
OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH);
|
||||
OptEnt.Arch = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;
|
||||
Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
|
||||
@@ -1126,7 +1126,7 @@ PxeBcBuildDhcpOptions (
|
||||
//
|
||||
// Append client system architecture option
|
||||
//
|
||||
OptList[Index]->OpCode = PXEBC_DHCP4_TAG_CLASS_ID;
|
||||
OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
|
||||
OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID);
|
||||
OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data;
|
||||
CopyMem (OptEnt.Clid, DEFAULT_CLASS_ID_DATA, sizeof (PXEBC_DHCP4_OPTION_CLID));
|
||||
@@ -1229,7 +1229,7 @@ PxeBcDiscvBootService (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
OptList[OptCount]->OpCode = PXEBC_DHCP4_TAG_VENDOR;
|
||||
OptList[OptCount]->OpCode = DHCP4_TAG_VENDOR;
|
||||
OptList[OptCount]->Length = (UINT8) (VendorOptLen - 2);
|
||||
PxeOpt = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]->Data;
|
||||
PxeOpt->OpCode = PXEBC_VENDOR_TAG_BOOT_ITEM;
|
||||
@@ -1237,7 +1237,7 @@ PxeBcDiscvBootService (
|
||||
PxeBootItem = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data;
|
||||
PxeBootItem->Type = HTONS (Type);
|
||||
PxeBootItem->Layer = HTONS (*Layer);
|
||||
PxeOpt->Data[PxeOpt->Length] = PXEBC_DHCP4_TAG_EOP;
|
||||
PxeOpt->Data[PxeOpt->Length] = DHCP4_TAG_EOP;
|
||||
|
||||
OptCount++;
|
||||
}
|
||||
@@ -1382,7 +1382,7 @@ PxeBcDiscvBootService (
|
||||
@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.
|
||||
DHCP4_TAG_EOP, or the pointer to the buffer.
|
||||
|
||||
**/
|
||||
EFI_DHCP4_PACKET_OPTION *
|
||||
@@ -1398,14 +1398,14 @@ PxeBcParseExtendOptions (
|
||||
Option = (EFI_DHCP4_PACKET_OPTION *) Buffer;
|
||||
Offset = 0;
|
||||
|
||||
while (Offset < Length && Option->OpCode != PXEBC_DHCP4_TAG_EOP) {
|
||||
while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
|
||||
|
||||
if (Option->OpCode == OptTag) {
|
||||
|
||||
return Option;
|
||||
}
|
||||
|
||||
if (Option->OpCode == PXEBC_DHCP4_TAG_PAD) {
|
||||
if (Option->OpCode == DHCP4_TAG_PAD) {
|
||||
Offset++;
|
||||
} else {
|
||||
Offset += Option->Length + 2;
|
||||
@@ -1443,7 +1443,7 @@ PxeBcParseVendorOptions (
|
||||
PxeOption = (EFI_DHCP4_PACKET_OPTION *) &Dhcp4Option->Data[0];
|
||||
Offset = 0;
|
||||
|
||||
while ((Offset < VendorOptionLen) && (PxeOption->OpCode != PXEBC_DHCP4_TAG_EOP)) {
|
||||
while ((Offset < VendorOptionLen) && (PxeOption->OpCode != DHCP4_TAG_EOP)) {
|
||||
//
|
||||
// Parse every Vendor Option and set its BitMap
|
||||
//
|
||||
@@ -1524,7 +1524,7 @@ PxeBcParseVendorOptions (
|
||||
|
||||
SET_VENDOR_OPTION_BIT_MAP (BitMap, PxeOption->OpCode);
|
||||
|
||||
if (PxeOption->OpCode == PXEBC_DHCP4_TAG_PAD) {
|
||||
if (PxeOption->OpCode == DHCP4_TAG_PAD) {
|
||||
Offset++;
|
||||
} else {
|
||||
Offset = (UINT8) (Offset + PxeOption->Length + 2);
|
||||
|
@@ -2,7 +2,7 @@
|
||||
Dhcp and Discover routines for PxeBc.
|
||||
|
||||
Copyright (c) 2013, Red Hat, Inc.
|
||||
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2007 - 2016, 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
|
||||
@@ -29,46 +29,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#define PXEBC_DHCP4_OPCODE_REPLY 2
|
||||
#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
|
||||
#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
|
||||
//
|
||||
// Dhcp Options
|
||||
//
|
||||
#define PXEBC_DHCP4_TAG_PAD 0 // Pad Option
|
||||
#define PXEBC_DHCP4_TAG_EOP 255 // End Option
|
||||
#define PXEBC_DHCP4_TAG_NETMASK 1 // Subnet Mask
|
||||
#define PXEBC_DHCP4_TAG_TIME_OFFSET 2 // Time Offset from UTC
|
||||
#define PXEBC_DHCP4_TAG_ROUTER 3 // Router option,
|
||||
#define PXEBC_DHCP4_TAG_TIME_SERVER 4 // Time Server
|
||||
#define PXEBC_DHCP4_TAG_NAME_SERVER 5 // Name Server
|
||||
#define PXEBC_DHCP4_TAG_DNS_SERVER 6 // Domain Name Server
|
||||
#define PXEBC_DHCP4_TAG_HOSTNAME 12 // Host Name
|
||||
#define PXEBC_DHCP4_TAG_BOOTFILE_LEN 13 // Boot File Size
|
||||
#define PXEBC_DHCP4_TAG_DUMP 14 // Merit Dump File
|
||||
#define PXEBC_DHCP4_TAG_DOMAINNAME 15 // Domain Name
|
||||
#define PXEBC_DHCP4_TAG_ROOTPATH 17 // Root path
|
||||
#define PXEBC_DHCP4_TAG_EXTEND_PATH 18 // Extensions Path
|
||||
#define PXEBC_DHCP4_TAG_EMTU 22 // Maximum Datagram Reassembly Size
|
||||
#define PXEBC_DHCP4_TAG_TTL 23 // Default IP Time-to-live
|
||||
#define PXEBC_DHCP4_TAG_BROADCAST 28 // Broadcast Address
|
||||
#define PXEBC_DHCP4_TAG_NIS_DOMAIN 40 // Network Information Service Domain
|
||||
#define PXEBC_DHCP4_TAG_NIS_SERVER 41 // Network Information Servers
|
||||
#define PXEBC_DHCP4_TAG_NTP_SERVER 42 // Network Time Protocol Servers
|
||||
#define PXEBC_DHCP4_TAG_VENDOR 43 // Vendor Specific Information
|
||||
#define PXEBC_DHCP4_TAG_REQUEST_IP 50 // Requested IP Address
|
||||
#define PXEBC_DHCP4_TAG_LEASE 51 // IP Address Lease Time
|
||||
#define PXEBC_DHCP4_TAG_OVERLOAD 52 // Option Overload
|
||||
#define PXEBC_DHCP4_TAG_MSG_TYPE 53 // DHCP Message Type
|
||||
#define PXEBC_DHCP4_TAG_SERVER_ID 54 // Server Identifier
|
||||
#define PXEBC_DHCP4_TAG_PARA_LIST 55 // Parameter Request List
|
||||
#define PXEBC_DHCP4_TAG_MAXMSG 57 // Maximum DHCP Message Size
|
||||
#define PXEBC_DHCP4_TAG_T1 58 // Renewal (T1) Time Value
|
||||
#define PXEBC_DHCP4_TAG_T2 59 // Rebinding (T2) Time Value
|
||||
#define PXEBC_DHCP4_TAG_CLASS_ID 60 // Vendor class identifier
|
||||
#define PXEBC_DHCP4_TAG_CLIENT_ID 61 // Client-identifier
|
||||
#define PXEBC_DHCP4_TAG_TFTP 66 // TFTP server name
|
||||
#define PXEBC_DHCP4_TAG_BOOTFILE 67 // Bootfile name
|
||||
#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
|
||||
//
|
||||
@@ -472,7 +433,7 @@ PxeBcCreateBootOptions (
|
||||
@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.
|
||||
DHCP4_TAG_EOP, or the pointer to the buffer.
|
||||
|
||||
**/
|
||||
EFI_DHCP4_PACKET_OPTION *
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
|
||||
Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
|
||||
Copyright (c) 2007 - 2016, 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
|
||||
@@ -21,6 +21,7 @@ typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
|
||||
|
||||
#include <Guid/SmBios.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
#include <IndustryStandard/Dhcp.h>
|
||||
#include <Protocol/Dhcp4.h>
|
||||
#include <Protocol/PxeBaseCode.h>
|
||||
#include <Protocol/Mtftp4.h>
|
||||
|
Reference in New Issue
Block a user