]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h
BaseTools:Change the path of the file that Binary Cache
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Option.h
index d3c596c9793944e861ec1bd2a5a127d71642a117..9e25386507edb4ffe81a035e5294f38424b992d1 100644 (file)
 /** @file\r
+  To validate, parse and process the DHCP options.\r
 \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-\r
-Module Name:\r
-\r
-  Dhcp4Option.h\r
-\r
-Abstract:\r
-\r
-  To validate, parse and process the DHCP options\r
-\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #ifndef __EFI_DHCP4_OPTION_H__\r
 #define __EFI_DHCP4_OPTION_H__\r
 \r
-//\r
-// DHCP option tags (types)\r
-//\r
-typedef enum {\r
-  //\r
-  // RFC1497 vendor extensions\r
-  //\r
-  DHCP_TAG_PAD             = 0,    // Pad Option\r
-  DHCP_TAG_EOP             = 255,  // End Option\r
-  DHCP_TAG_NETMASK         = 1,    // Subnet Mask\r
-  DHCP_TAG_TIME_OFFSET     = 2,    // Time Offset from UTC\r
-  DHCP_TAG_ROUTER          = 3,    // Router option,\r
-  DHCP_TAG_TIME_SERVER     = 4,    // Time Server\r
-  DHCP_TAG_NAME_SERVER     = 5,    // Name Server\r
-  DHCP_TAG_DNS_SERVER      = 6,    // Domain Name Server\r
-  DHCP_TAG_LOG_SERVER      = 7,    // Log Server\r
-  DHCP_TAG_COOKIE_SERVER   = 8,    // Cookie Server\r
-  DHCP_TAG_LPR_SERVER      = 9,    // LPR Print Server\r
-  DHCP_TAG_IMPRESS_SERVER  = 10,   // Impress Server\r
-  DHCP_TAG_RL_SERVER       = 11,   // Resource Location Server\r
-  DHCP_TAG_HOSTNAME        = 12,   // Host Name\r
-  DHCP_TAG_BOOTFILE_LEN    = 13,   // Boot File Size\r
-  DHCP_TAG_DUMP            = 14,   // Merit Dump File\r
-  DHCP_TAG_DOMAINNAME      = 15,   // Domain Name\r
-  DHCP_TAG_SWAP_SERVER     = 16,   // Swap Server\r
-  DHCP_TAG_ROOTPATH        = 17,   // Root path\r
-  DHCP_TAG_EXTEND_PATH     = 18,   // Extensions Path\r
-\r
-  //\r
-  // IP Layer Parameters per Host\r
-  //\r
-  DHCP_TAG_IPFORWARD       = 19, // IP Forwarding Enable/Disable\r
-  DHCP_TAG_NONLOCAL_SRR    = 20, // on-Local Source Routing Enable/Disable\r
-  DHCP_TAG_POLICY_SRR      = 21, // Policy Filter\r
-  DHCP_TAG_EMTU            = 22, // Maximum Datagram Reassembly Size\r
-  DHCP_TAG_TTL             = 23, // Default IP Time-to-live\r
-  DHCP_TAG_PATHMTU_AGE     = 24, // Path MTU Aging Timeout\r
-  DHCP_TAG_PATHMTU_PLATEAU = 25, // Path MTU Plateau Table\r
+///\r
+/// DHCP option tags (types)\r
+///\r
 \r
-  //\r
-  // IP Layer Parameters per Interface\r
-  //\r
-  DHCP_TAG_IFMTU           = 26, // Interface MTU\r
-  DHCP_TAG_SUBNET_LOCAL    = 27, // All Subnets are Local\r
-  DHCP_TAG_BROADCAST       = 28, // Broadcast Address\r
-  DHCP_TAG_DISCOVER_MASK   = 29, // Perform Mask Discovery\r
-  DHCP_TAG_SUPPLY_MASK     = 30, // Mask Supplier\r
-  DHCP_TAG_DISCOVER_ROUTE  = 31, // Perform Router Discovery\r
-  DHCP_TAG_ROUTER_SOLICIT  = 32, // Router Solicitation Address\r
-  DHCP_TAG_STATIC_ROUTE    = 33, // Static Route\r
+#define DHCP_OPTION_MAGIC         0x63538263 // Network byte order\r
+#define DHCP_MAX_OPTIONS          256\r
 \r
-  //\r
-  // Link Layer Parameters per Interface\r
-  //\r
-  DHCP_TAG_TRAILER         = 34, // Trailer Encapsulation\r
-  DHCP_TAG_ARPAGE          = 35, // ARP Cache Timeout\r
-  DHCP_TAG_ETHER_ENCAP     = 36, // Ethernet Encapsulation\r
 \r
-  //\r
-  // TCP Parameters\r
-  //\r
-  DHCP_TAG_TCP_TTL         = 37, // TCP Default TTL\r
-  DHCP_TAG_KEEP_INTERVAL   = 38, // TCP Keepalive Interval\r
-  DHCP_TAG_KEEP_GARBAGE    = 39, // TCP Keepalive Garbage\r
-\r
-  //\r
-  // Application and Service Parameters\r
-  //\r
-  DHCP_TAG_NIS_DOMAIN      = 40,   // Network Information Service Domain\r
-  DHCP_TAG_NIS_SERVER      = 41,   // Network Information Servers\r
-  DHCP_TAG_NTP_SERVER      = 42,   // Network Time Protocol Servers\r
-  DHCP_TAG_VENDOR          = 43,   // Vendor Specific Information\r
-  DHCP_TAG_NBNS            = 44,   // NetBIOS over TCP/IP Name Server\r
-  DHCP_TAG_NBDD            = 45,   // NetBIOS Datagram Distribution Server\r
-  DHCP_TAG_NBTYPE          = 46,   // NetBIOS over TCP/IP Node Type\r
-  DHCP_TAG_NBSCOPE         = 47,   // NetBIOS over TCP/IP Scope\r
-  DHCP_TAG_XFONT           = 48,   // X Window System Font Server\r
-  DHCP_TAG_XDM             = 49,   // X Window System Display Manager\r
-  DHCP_TAG_NISPLUS         = 64,   // Network Information Service+ Domain\r
-  DHCP_TAG_NISPLUS_SERVER  = 65,   // Network Information Service+ Servers\r
-  DHCP_TAG_MOBILEIP        = 68,   // Mobile IP Home Agent\r
-  DHCP_TAG_SMTP            = 69,   // Simple Mail Transport Protocol Server\r
-  DHCP_TAG_POP3            = 70,   // Post Office Protocol (POP3) Server\r
-  DHCP_TAG_NNTP            = 71,   // Network News Transport Protocol Server\r
-  DHCP_TAG_WWW             = 72,   // Default World Wide Web (WWW) Server\r
-  DHCP_TAG_FINGER          = 73,   // Default Finger Server\r
-  DHCP_TAG_IRC             = 74,   // Default Internet Relay Chat (IRC) Server\r
-  DHCP_TAG_STTALK          = 75,   // StreetTalk Server\r
-  DHCP_TAG_STDA            = 76,   // StreetTalk Directory Assistance Server\r
-  DHCP_TAG_CLASSLESS_ROUTE = 121,  // Classless Route\r
-\r
-  //\r
-  // DHCP Extensions\r
-  //\r
-  DHCP_TAG_REQUEST_IP      = 50,         // Requested IP Address\r
-  DHCP_TAG_LEASE           = 51,         // IP Address Lease Time\r
-  DHCP_TAG_OVERLOAD        = 52,         // Option Overload\r
-  DHCP_TAG_TFTP            = 66,         // TFTP server name\r
-  DHCP_TAG_BOOTFILE        = 67,         // Bootfile name\r
-  DHCP_TAG_TYPE            = 53,         // DHCP Message Type\r
-  DHCP_TAG_SERVER_ID       = 54,         // Server Identifier\r
-  DHCP_TAG_PARA_LIST       = 55,         // Parameter Request List\r
-  DHCP_TAG_MESSAGE         = 56,         // Message\r
-  DHCP_TAG_MAXMSG          = 57,         // Maximum DHCP Message Size\r
-  DHCP_TAG_T1              = 58,         // Renewal (T1) Time Value\r
-  DHCP_TAG_T2              = 59,         // Rebinding (T2) Time Value\r
-  DHCP_TAG_VENDOR_CLASS    = 60,         // Vendor class identifier\r
-  DHCP_TAG_CLIENT_ID       = 61          // Client-identifier\r
-} DHCP_TAGS;\r
-\r
-#define DHCP_OPTION_MAGIC      0x63538263 // Network byte order\r
-#define DHCP_MAX_OPTIONS              256\r
-\r
-typedef enum {\r
-  //\r
-  // DHCP option types, this is used to validate the DHCP options.\r
-  //\r
-  DHCP_OPTION_SWITCH       = 1,\r
-  DHCP_OPTION_INT8,\r
-  DHCP_OPTION_INT16,\r
-  DHCP_OPTION_INT32,\r
-  DHCP_OPTION_IP,\r
-  DHCP_OPTION_IPPAIR\r
-} DHCP_OPTION_TYPE; \r
-\r
-typedef enum {\r
-  //\r
-  // Value of DHCP overload option\r
-  //\r
-  DHCP_OVERLOAD_FILENAME   = 1,\r
-  DHCP_OVERLOAD_SVRNAME    = 2,\r
-  DHCP_OVERLOAD_BOTH       = 3\r
-} DHCP_OVERLOAD_TYPE;\r
+//\r
+// DHCP option types, this is used to validate the DHCP options.\r
+//\r
+#define DHCP_OPTION_SWITCH        1\r
+#define DHCP_OPTION_INT8          2\r
+#define DHCP_OPTION_INT16         3\r
+#define DHCP_OPTION_INT32         4\r
+#define DHCP_OPTION_IP            5\r
+#define DHCP_OPTION_IPPAIR        6\r
 \r
 //\r
-// The DHCP option structure. This structure extends the EFI_DHCP_OPTION\r
-// structure to support options longer than 255 bytes, such as classless route.\r
+// Value of DHCP overload option\r
 //\r
+#define DHCP_OVERLOAD_FILENAME    1\r
+#define DHCP_OVERLOAD_SVRNAME     2\r
+#define DHCP_OVERLOAD_BOTH        3\r
+\r
+///\r
+/// The DHCP option structure. This structure extends the EFI_DHCP_OPTION\r
+/// structure to support options longer than 255 bytes, such as classless route.\r
+///\r
 typedef struct {\r
   UINT8                     Tag;\r
   UINT16                    Len;\r
   UINT8                     *Data;\r
 } DHCP_OPTION;\r
 \r
-//\r
-// Structures used to parse the DHCP options with RFC3396 support.\r
-//\r
+///\r
+/// Structures used to parse the DHCP options with RFC3396 support.\r
+///\r
 typedef struct {\r
   UINT8                     Index;\r
   UINT16                    Offset;\r
@@ -182,34 +58,34 @@ typedef struct {
   UINT8                     *Buf;\r
 } DHCP_OPTION_CONTEXT;\r
 \r
-//\r
-// The options that matters to DHCP driver itself. The user of\r
-// DHCP clients may be interested in other options, such as\r
-// classless route, who can parse the DHCP offer to get them.\r
-//\r
+///\r
+/// The options that matters to DHCP driver itself. The user of\r
+/// DHCP clients may be interested in other options, such as\r
+/// classless route, who can parse the DHCP offer to get them.\r
+///\r
 typedef struct {\r
-  IP4_ADDR                  NetMask;  // DHCP_TAG_NETMASK\r
-  IP4_ADDR                  Router;   // DHCP_TAG_ROUTER, only the first router is used\r
+  IP4_ADDR                  NetMask;  // DHCP4_TAG_NETMASK\r
+  IP4_ADDR                  Router;   // DHCP4_TAG_ROUTER, only the first router is used\r
 \r
   //\r
   // DHCP specific options\r
   //\r
-  UINT8                     DhcpType; // DHCP_TAG_TYPE\r
-  UINT8                     Overload; // DHCP_TAG_OVERLOAD\r
-  IP4_ADDR                  ServerId; // DHCP_TAG_SERVER_ID\r
-  UINT32                    Lease;    // DHCP_TAG_LEASE\r
-  UINT32                    T1;       // DHCP_TAG_T1\r
-  UINT32                    T2;       // DHCP_TAG_T2\r
+  UINT8                     DhcpType; // DHCP4_TAG_MSG_TYPE\r
+  UINT8                     Overload; // DHCP4_TAG_OVERLOAD\r
+  IP4_ADDR                  ServerId; // DHCP4_TAG_SERVER_ID\r
+  UINT32                    Lease;    // DHCP4_TAG_LEASE\r
+  UINT32                    T1;       // DHCP4_TAG_T1\r
+  UINT32                    T2;       // DHCP4_TAG_T2\r
 } DHCP_PARAMETER;\r
 \r
-//\r
-// Structure used to describe and validate the format of DHCP options.\r
-// Type is the options' data type, such as DHCP_OPTION_INT8. MinOccur\r
-// is the minium occurance of this data type. MaxOccur is defined\r
-// similarly. If MaxOccur is -1, it means that there is no limit on the\r
-// maximum occurance. Alert tells whether DHCP client should further\r
-// inspect the option to parse DHCP_PARAMETER.\r
-//\r
+///\r
+/// Structure used to describe and validate the format of DHCP options.\r
+/// Type is the options' data type, such as DHCP_OPTION_INT8. MinOccur\r
+/// is the minium occurance of this data type. MaxOccur is defined\r
+/// similarly. If MaxOccur is -1, it means that there is no limit on the\r
+/// maximum occurance. Alert tells whether DHCP client should further\r
+/// inspect the option to parse DHCP_PARAMETER.\r
+///\r
 typedef struct {\r
   UINT8                     Tag;\r
   INTN                      Type;\r
@@ -233,19 +109,19 @@ EFI_STATUS
   the options in FILENAME and SERVERNAME fields. One option may be\r
   encoded in several places. See RFC 3396 Encoding Long Options in DHCP\r
 \r
-  @param  Packet                 The DHCP packet to check the options for\r
-  @param  Check                  The callback function to be called for each option\r
-                                 found\r
-  @param  Context                The opaque parameter for Check\r
+  @param[in]  Packet                 The DHCP packet to check the options for\r
+  @param[in]  Check                  The callback function to be called for each option\r
+                                     found\r
+  @param[in]  Context                The opaque parameter for Check\r
 \r
   @retval EFI_SUCCESS            The DHCP packet's options are well formated\r
-  @retval Others                 The DHCP packet's options are not well formated\r
+  @retval EFI_INVALID_PARAMETER  The DHCP packet's options are not well formated\r
 \r
 **/\r
 EFI_STATUS\r
 DhcpIterateOptions (\r
   IN  EFI_DHCP4_PACKET      *Packet,\r
-  IN  DHCP_CHECK_OPTION     Check,          OPTIONAL\r
+  IN  DHCP_CHECK_OPTION     Check         OPTIONAL,\r
   IN  VOID                  *Context\r
   );\r
 \r
@@ -253,8 +129,8 @@ DhcpIterateOptions (
   Validate the packet's options. If necessary, allocate\r
   and fill in the interested parameters.\r
 \r
-  @param  Packet                 The packet to validate the options\r
-  @param  Para                   The variable to save the DHCP parameters.\r
+  @param[in]  Packet                 The packet to validate the options\r
+  @param[out] Para                   The variable to save the DHCP parameters.\r
 \r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to validate the packet.\r
   @retval EFI_INVALID_PARAMETER  The options are mal-formated\r
@@ -264,7 +140,7 @@ DhcpIterateOptions (
 EFI_STATUS\r
 DhcpValidateOptions (\r
   IN  EFI_DHCP4_PACKET      *Packet,\r
-  OUT DHCP_PARAMETER        **Para          OPTIONAL\r
+  OUT DHCP_PARAMETER        **Para       OPTIONAL\r
   );\r
 \r
 /**\r
@@ -277,18 +153,19 @@ DhcpValidateOptions (
   as a UINT8. It then iterates the DHCP packet to get data length of\r
   each option by calling DhcpIterOptions with DhcpGetOptionLen. Now, it\r
   knows the number of present options and their length. It allocates a\r
-  array of DHCP_OPTION and a continous buffer after the array to put\r
+  array of DHCP_OPTION and a continuous buffer after the array to put\r
   all the options' data. Each option's data is pointed to by the Data\r
   field in DHCP_OPTION structure. At last, it call DhcpIterateOptions\r
   with DhcpFillOption to fill each option's data to its position in the\r
   buffer.\r
 \r
-  @param  Packet                 The DHCP packet to parse the options\r
-  @param  Count                  The number of valid dhcp options present in the\r
-                                 packet\r
-  @param  OptionPoint            The array that contains the DHCP options. Caller\r
-                                 should free it.\r
+  @param[in]  Packet                 The DHCP packet to parse the options\r
+  @param[out] Count                  The number of valid dhcp options present in the\r
+                                     packet\r
+  @param[out] OptionPoint            The array that contains the DHCP options. Caller\r
+                                     should free it.\r
 \r
+  @retval EFI_NOT_FOUND          Cannot find any option.\r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory to parse the packet.\r
   @retval EFI_INVALID_PARAMETER  The options are mal-formated\r
   @retval EFI_SUCCESS            The options are parsed into OptionPoint\r
@@ -305,46 +182,47 @@ DhcpParseOption (
   Append an option to the memory, if the option is longer than\r
   255 bytes, splits it into several options.\r
 \r
-  @param  Buf                    The buffer to append the option to\r
-  @param  Tag                    The option's tag\r
-  @param  DataLen                The length of the option's data\r
-  @param  Data                   The option's data\r
+  @param[out] Buf                    The buffer to append the option to\r
+  @param[in]  Tag                    The option's tag\r
+  @param[in]  DataLen                The length of the option's data\r
+  @param[in]  Data                   The option's data\r
 \r
   @return The position to append the next option\r
 \r
 **/\r
 UINT8 *\r
 DhcpAppendOption (\r
-  IN UINT8                  *Buf,\r
-  IN UINT8                  Tag,\r
-  IN UINT16                 DataLen,\r
-  IN UINT8                  *Data\r
+  OUT UINT8                  *Buf,\r
+  IN  UINT8                  Tag,\r
+  IN  UINT16                 DataLen,\r
+  IN  UINT8                  *Data\r
   );\r
 \r
 /**\r
   Build a new DHCP packet from a seed packet. Options may be deleted or\r
   appended. The caller should free the NewPacket when finished using it.\r
 \r
-  @param  SeedPacket             The seed packet to start with\r
-  @param  DeleteCount            The number of options to delete\r
-  @param  DeleteList             The options to delete from the packet\r
-  @param  AppendCount            The number of options to append\r
-  @param  AppendList             The options to append to the packet\r
-  @param  NewPacket              The new packet, allocated and built by this\r
-                                 function.\r
+  @param[in]  SeedPacket             The seed packet to start with\r
+  @param[in]  DeleteCount            The number of options to delete\r
+  @param[in]  DeleteList             The options to delete from the packet\r
+  @param[in]  AppendCount            The number of options to append\r
+  @param[in]  AppendList             The options to append to the packet\r
+  @param[out] NewPacket              The new packet, allocated and built by this\r
+                                     function.\r
 \r
   @retval EFI_OUT_OF_RESOURCES   Failed to allocate memory\r
+  @retval EFI_INVALID_PARAMETER  The options in SeekPacket are mal-formated\r
   @retval EFI_SUCCESS            The packet is build.\r
 \r
 **/\r
 EFI_STATUS\r
 DhcpBuild (\r
-  IN  EFI_DHCP4_PACKET         *SeedPacket,\r
-  IN  UINT32                   DeleteCount,\r
-  IN  UINT8                    *DeleteList OPTIONAL,\r
-  IN  UINT32                   AppendCount,\r
-  IN  EFI_DHCP4_PACKET_OPTION  *AppendList[] OPTIONAL,\r
-  OUT EFI_DHCP4_PACKET         **NewPacket\r
+  IN  EFI_DHCP4_PACKET        *SeedPacket,\r
+  IN  UINT32                  DeleteCount,\r
+  IN  UINT8                   *DeleteList     OPTIONAL,\r
+  IN  UINT32                  AppendCount,\r
+  IN  EFI_DHCP4_PACKET_OPTION *AppendList[]   OPTIONAL,\r
+  OUT EFI_DHCP4_PACKET        **NewPacket\r
   );\r
 \r
 #endif\r