]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/DnsDxe/DnsDhcp.h
NetworkPkg: Add DNS feature support over IPv4 and IPv6.
[mirror_edk2.git] / NetworkPkg / DnsDxe / DnsDhcp.h
diff --git a/NetworkPkg/DnsDxe/DnsDhcp.h b/NetworkPkg/DnsDxe/DnsDhcp.h
new file mode 100644 (file)
index 0000000..62bf717
--- /dev/null
@@ -0,0 +1,145 @@
+/** @file\r
+Functions implementation related with DHCPv4/v6 for DNS driver.\r
+\r
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+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
+\r
+#ifndef _DNS_DHCP_H_\r
+#define _DNS_DHCP_H_\r
+\r
+//\r
+// DHCP DNS related\r
+//\r
+#pragma pack(1)\r
+\r
+#define IP4_ETHER_PROTO       0x0800\r
+\r
+#define DHCP4_OPCODE_REQUEST         1\r
+#define DHCP4_MAGIC                  0x63538263 /// network byte order\r
+#define DHCP4_TAG_EOP                255  /// End Option\r
+\r
+#define DHCP4_TAG_TYPE               53\r
+#define DHCP4_MSG_REQUEST            3\r
+#define DHCP4_MSG_INFORM             8\r
+\r
+#define DHCP4_TAG_PARA_LIST          55\r
+#define DHCP4_TAG_DNS_SERVER         6\r
+\r
+\r
+#define DHCP6_TAG_DNS_REQUEST        6\r
+#define DHCP6_TAG_DNS_SERVER         23\r
+\r
+//\r
+// The required Dns4 server information.\r
+//\r
+typedef struct {\r
+  UINT32                     *ServerCount;\r
+  EFI_IPv4_ADDRESS           *ServerList;\r
+} DNS4_SERVER_INFOR;\r
+\r
+//\r
+// The required Dns6 server information.\r
+//\r
+typedef struct {\r
+  UINT32                     *ServerCount;\r
+  EFI_IPv6_ADDRESS           *ServerList;\r
+} DNS6_SERVER_INFOR;\r
+\r
+#pragma pack()\r
+\r
+/**\r
+  Parse the ACK to get required information\r
+\r
+  @param  Dhcp4            The DHCP4 protocol.\r
+  @param  Packet           Packet waiting for parse.\r
+  @param  DnsServerInfor   The required Dns4 server information.\r
+\r
+  @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
+  @retval EFI_NO_MAPPING        DHCP failed to acquire address and other information.\r
+  @retval EFI_DEVICE_ERROR      Other errors as indicated.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+\r
+**/\r
+EFI_STATUS\r
+ParseDhcp4Ack (\r
+  IN EFI_DHCP4_PROTOCOL         *Dhcp4,\r
+  IN EFI_DHCP4_PACKET           *Packet,\r
+  IN DNS4_SERVER_INFOR          *DnsServerInfor\r
+  );\r
+\r
+/**\r
+  EFI_DHCP6_INFO_CALLBACK is provided by the consumer of the EFI DHCPv6 Protocol \r
+  instance to intercept events that occurs in the DHCPv6 Information Request\r
+  exchange process.\r
+\r
+  @param  This                  Pointer to the EFI_DHCP6_PROTOCOL instance that \r
+                                is used to configure this  callback function.\r
+  @param  Context               Pointer to the context that is initialized in\r
+                                the EFI_DHCP6_PROTOCOL.InfoRequest().\r
+  @param  Packet                Pointer to Reply packet that has been received.\r
+                                The EFI DHCPv6 Protocol instance is responsible\r
+                                for freeing the buffer.\r
+\r
+  @retval EFI_SUCCESS           The DNS information is got from the DHCP ACK.\r
+  @retval EFI_DEVICE_ERROR      Other errors as indicated.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ParseDhcp6Ack (\r
+  IN EFI_DHCP6_PROTOCOL          *This,\r
+  IN VOID                        *Context,\r
+  IN EFI_DHCP6_PACKET            *Packet\r
+  );\r
+\r
+/**\r
+  Parse the DHCP ACK to get Dns4 server information.\r
+\r
+  @param  Instance         The DNS instance.\r
+  @param  DnsServerCount   Retrieved Dns4 server Ip count.\r
+  @param  DnsServerList    Retrieved Dns4 server Ip list.\r
+\r
+  @retval EFI_SUCCESS           The Dns4 information is got from the DHCP ACK.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+  @retval EFI_NO_MEDIA          There was a media error.\r
+  @retval Others                Other errors as indicated.\r
+\r
+**/\r
+EFI_STATUS\r
+GetDns4ServerFromDhcp4 (\r
+  IN  DNS_INSTANCE               *Instance,\r
+  OUT UINT32                     *DnsServerCount,\r
+  OUT EFI_IPv4_ADDRESS           **DnsServerList\r
+  );\r
+\r
+/**\r
+  Parse the DHCP ACK to get Dns6 server information.\r
+\r
+  @param  Image            The handle of the driver image.\r
+  @param  Controller       The handle of the controller.\r
+  @param  DnsServerCount   Retrieved Dns6 server Ip count.\r
+  @param  DnsServerList    Retrieved Dns6 server Ip list.\r
+\r
+  @retval EFI_SUCCESS           The Dns6 information is got from the DHCP ACK.\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate memory.\r
+  @retval EFI_NO_MEDIA          There was a media error.\r
+  @retval Others                Other errors as indicated.\r
+\r
+**/\r
+EFI_STATUS\r
+GetDns6ServerFromDhcp6 (\r
+  IN  EFI_HANDLE                 Image,\r
+  IN  EFI_HANDLE                 Controller,\r
+  OUT UINT32                     *DnsServerCount,\r
+  OUT EFI_IPv6_ADDRESS           **DnsServerList\r
+  );\r
+  \r
+#endif
\ No newline at end of file