]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/NetLib.h
MdeModulePkg: Add DNS QType and QClass values definition
[mirror_edk2.git] / MdeModulePkg / Include / Library / NetLib.h
index 71680a42b2ce79369fc1e96906a364abfd6ea77b..e4456fa6c2715697809e3e1b01da19e78466955d 100644 (file)
@@ -2,8 +2,8 @@
   This library is only intended to be used by UEFI network stack modules.\r
   It provides basic functions for the UEFI network stack.\r
 \r
-Copyright (c) 2005 - 2010, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2016, 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<BR>\r
 http://opensource.org/licenses/bsd-license.php\r
@@ -19,6 +19,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/Ip6.h>\r
 \r
 #include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
 \r
 typedef UINT32          IP4_ADDR;\r
 typedef UINT32          TCP_SEQNO;\r
@@ -51,6 +52,7 @@ typedef UINT16          TCP_PORTNO;
 \r
 #define  IP6_HOP_BY_HOP        0\r
 #define  IP6_DESTINATION       60\r
+#define  IP6_ROUTING           43\r
 #define  IP6_FRAGMENT          44\r
 #define  IP6_AH                51\r
 #define  IP6_ESP               50\r
@@ -59,6 +61,35 @@ typedef UINT16          TCP_PORTNO;
 #define  IP_VERSION_4          4\r
 #define  IP_VERSION_6          6\r
 \r
+#define  IP6_PREFIX_LENGTH     64\r
+\r
+//\r
+// DNS QTYPE values\r
+//\r
+#define  DNS_TYPE_A            1\r
+#define  DNS_TYPE_NS           2\r
+#define  DNS_TYPE_CNAME        5\r
+#define  DNS_TYPE_SOA          6\r
+#define  DNS_TYPE_WKS          11\r
+#define  DNS_TYPE_PTR          12\r
+#define  DNS_TYPE_HINFO        13\r
+#define  DNS_TYPE_MINFO        14\r
+#define  DNS_TYPE_MX           15\r
+#define  DNS_TYPE_TXT          16\r
+#define  DNS_TYPE_AAAA         28\r
+#define  DNS_TYPE_SRV_RR       33\r
+#define  DNS_TYPE_AXFR         252\r
+#define  DNS_TYPE_MAILB        253\r
+#define  DNS_TYPE_ANY          255\r
+\r
+//\r
+// DNS QCLASS values\r
+//\r
+#define  DNS_CLASS_INET        1\r
+#define  DNS_CLASS_CH          3\r
+#define  DNS_CLASS_HS          4\r
+#define  DNS_CLASS_ANY         255\r
+\r
 #pragma pack(1)\r
 \r
 //\r
@@ -210,6 +241,7 @@ typedef struct {
 \r
 #define EFI_IP6_EQUAL(Ip1, Ip2)  (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv6_ADDRESS)) == 0)\r
 \r
+#define IP4_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv4_ADDRESS)))\r
 #define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS)))\r
 #define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))\r
 \r
@@ -286,6 +318,7 @@ typedef struct {
 \r
 **/\r
 CHAR8 *\r
+EFIAPI\r
 NetDebugASPrint (\r
   IN CHAR8                  *Format,\r
   ...\r
@@ -309,6 +342,7 @@ NetDebugASPrint (
                                 than the mNetDebugLevelMax. Or, it has been sent out.\r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetDebugOutput (\r
   IN UINT32                    Level,\r
   IN UINT8                     *Module,\r
@@ -400,6 +434,7 @@ NetIp4IsUnicast (
 \r
 **/\r
 BOOLEAN\r
+EFIAPI\r
 NetIp6IsValidUnicast (\r
   IN EFI_IPv6_ADDRESS       *Ip6\r
   );\r
@@ -415,6 +450,7 @@ NetIp6IsValidUnicast (
 \r
 **/\r
 BOOLEAN\r
+EFIAPI\r
 NetIp6IsUnspecifiedAddr (\r
   IN EFI_IPv6_ADDRESS       *Ip6\r
   );\r
@@ -429,6 +465,7 @@ NetIp6IsUnspecifiedAddr (
 \r
 **/\r
 BOOLEAN\r
+EFIAPI\r
 NetIp6IsLinkLocalAddr (\r
   IN EFI_IPv6_ADDRESS *Ip6\r
   );\r
@@ -445,6 +482,7 @@ NetIp6IsLinkLocalAddr (
 \r
 **/\r
 BOOLEAN\r
+EFIAPI\r
 NetIp6IsNetEqual (\r
   EFI_IPv6_ADDRESS *Ip1,\r
   EFI_IPv6_ADDRESS *Ip2,\r
@@ -464,6 +502,7 @@ NetIp6IsNetEqual (
 \r
 **/\r
 EFI_IPv6_ADDRESS *\r
+EFIAPI\r
 Ip6Swap128 (\r
   EFI_IPv6_ADDRESS *Ip6\r
   );\r
@@ -518,13 +557,13 @@ NetPutUint32 (
   );\r
 \r
 /**\r
-  Initialize a random seed using current time.\r
+  Initialize a random seed using current time and monotonic count.\r
 \r
-  Get current time first. Then initialize a random seed based on some basic\r
-  mathematical operations on the hour, day, minute, second, nanosecond and year\r
-  of the current time.\r
+  Get current time and monotonic count first. Then initialize a random seed \r
+  based on some basic mathematics operation on the hour, day, minute, second,\r
+  nanosecond and year of the current time and the monotonic count value.\r
 \r
-  @return The random seed, initialized with current time.\r
+  @return The random seed initialized with current time.\r
 \r
 **/\r
 UINT32\r
@@ -650,6 +689,73 @@ NetListInsertBefore (
   IN OUT LIST_ENTRY     *NewEntry\r
   );\r
 \r
+/**\r
+  Callback function which provided by user to remove one node in NetDestroyLinkList process.\r
+  \r
+  @param[in]    Entry           The entry to be removed.\r
+  @param[in]    Context         Pointer to the callback context corresponds to the Context in NetDestroyLinkList.\r
+\r
+  @retval EFI_SUCCESS           The entry has been removed successfully.\r
+  @retval Others                Fail to remove the entry.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *NET_DESTROY_LINK_LIST_CALLBACK) (\r
+  IN LIST_ENTRY         *Entry,\r
+  IN VOID               *Context   OPTIONAL\r
+  );\r
+\r
+/**\r
+  Safe destroy nodes in a linked list, and return the length of the list after all possible operations finished.\r
+\r
+  Destroy network children list by list traversals is not safe due to graph dependencies between nodes.\r
+  This function performs a safe traversal to destroy these nodes by checking to see if the node being destroyed\r
+  has been removed from the list or not.\r
+  If it has been removed, then restart the traversal from the head.\r
+  If it hasn't been removed, then continue with the next node directly.\r
+  This function will end the iterate and return the CallBack's last return value if error happens,\r
+  or retrun EFI_SUCCESS if 2 complete passes are made with no changes in the number of children in the list.  \r
+\r
+  @param[in]    List             The head of the list.\r
+  @param[in]    CallBack         Pointer to the callback function to destroy one node in the list.\r
+  @param[in]    Context          Pointer to the callback function's context: corresponds to the\r
+                                 parameter Context in NET_DESTROY_LINK_LIST_CALLBACK.\r
+  @param[out]   ListLength       The length of the link list if the function returns successfully.\r
+\r
+  @retval EFI_SUCCESS            Two complete passes are made with no changes in the number of children.\r
+  @retval EFI_INVALID_PARAMETER  The input parameter is invalid.\r
+  @retval Others                 Return the CallBack's last return value.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NetDestroyLinkList (\r
+  IN   LIST_ENTRY                       *List,\r
+  IN   NET_DESTROY_LINK_LIST_CALLBACK   CallBack,\r
+  IN   VOID                             *Context,    OPTIONAL\r
+  OUT  UINTN                            *ListLength  OPTIONAL\r
+  );\r
+\r
+/**\r
+  This function checks the input Handle to see if it's one of these handles in ChildHandleBuffer.\r
+\r
+  @param[in]  Handle             Handle to be checked.\r
+  @param[in]  NumberOfChildren   Number of Handles in ChildHandleBuffer.\r
+  @param[in]  ChildHandleBuffer  An array of child handles to be freed. May be NULL\r
+                                 if NumberOfChildren is 0.\r
+\r
+  @retval TURE                   Found the input Handle in ChildHandleBuffer.\r
+  @retval FALSE                  Can't find the input Handle in ChildHandleBuffer.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+NetIsInHandleBuffer (\r
+  IN  EFI_HANDLE          Handle,\r
+  IN  UINTN               NumberOfChildren,\r
+  IN  EFI_HANDLE          *ChildHandleBuffer OPTIONAL\r
+  );\r
 \r
 //\r
 // Object container: EFI network stack spec defines various kinds of\r
@@ -888,7 +994,7 @@ NetMapRemoveTail (
 \r
 typedef\r
 EFI_STATUS\r
-(*NET_MAP_CALLBACK) (\r
+(EFIAPI *NET_MAP_CALLBACK) (\r
   IN NET_MAP                *Map,\r
   IN NET_MAP_ITEM           *Item,\r
   IN VOID                   *Arg\r
@@ -1075,7 +1181,8 @@ NetLibGetMacAddress (
   @param[in]   ServiceHandle         The handle where network service binding protocol is\r
                                      installed.\r
   @param[in]   ImageHandle           The image handle used to act as the agent handle to\r
-                                     get the simple network protocol.\r
+                                     get the simple network protocol. This parameter is\r
+                                     optional and may be NULL.\r
   @param[out]  MacString             The pointer to store the address of the string\r
                                      representation of  the mac address.\r
 \r
@@ -1088,7 +1195,7 @@ EFI_STATUS
 EFIAPI\r
 NetLibGetMacString (\r
   IN  EFI_HANDLE            ServiceHandle,\r
-  IN  EFI_HANDLE            ImageHandle,\r
+  IN  EFI_HANDLE            ImageHandle, OPTIONAL\r
   OUT CHAR16                **MacString\r
   );\r
 \r
@@ -1241,6 +1348,7 @@ NetLibDefaultUnload (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetLibAsciiStrToIp4 (\r
   IN CONST CHAR8                 *String,\r
   OUT      EFI_IPv4_ADDRESS      *Ip4Address\r
@@ -1258,6 +1366,7 @@ NetLibAsciiStrToIp4 (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetLibAsciiStrToIp6 (\r
   IN CONST CHAR8                 *String,\r
   OUT      EFI_IPv6_ADDRESS      *Ip6Address\r
@@ -1275,6 +1384,7 @@ NetLibAsciiStrToIp6 (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetLibStrToIp4 (\r
   IN CONST CHAR16                *String,\r
   OUT      EFI_IPv4_ADDRESS      *Ip4Address\r
@@ -1293,6 +1403,7 @@ NetLibStrToIp4 (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetLibStrToIp6 (\r
   IN CONST CHAR16                *String,\r
   OUT      EFI_IPv6_ADDRESS      *Ip6Address\r
@@ -1313,12 +1424,35 @@ NetLibStrToIp6 (
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 NetLibStrToIp6andPrefix (\r
   IN CONST CHAR16                *String,\r
   OUT      EFI_IPv6_ADDRESS      *Ip6Address,\r
   OUT      UINT8                 *PrefixLength\r
   );\r
 \r
+/**\r
+\r
+  Convert one EFI_IPv6_ADDRESS to Null-terminated Unicode string.\r
+  The text representation of address is defined in RFC 4291.\r
+  \r
+  @param[in]       Ip6Address     The pointer to the IPv6 address.\r
+  @param[out]      String         The buffer to return the converted string.\r
+  @param[in]       StringSize     The length in bytes of the input String.\r
+                                  \r
+  @retval EFI_SUCCESS             Convert to string successfully.\r
+  @retval EFI_INVALID_PARAMETER   The input parameter is invalid.\r
+  @retval EFI_BUFFER_TOO_SMALL    The BufferSize is too small for the result. BufferSize has been \r
+                                  updated with the size needed to complete the request.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NetLibIp6ToStr (\r
+  IN         EFI_IPv6_ADDRESS      *Ip6Address,\r
+  OUT        CHAR16                *String,\r
+  IN         UINTN                 StringSize\r
+  );\r
+\r
 //\r
 // Various signatures\r
 //\r
@@ -1343,7 +1477,7 @@ typedef struct {
   UINT8               *Bulk;      // The block's Data\r
 } NET_BLOCK;\r
 \r
-typedef VOID (*NET_VECTOR_EXT_FREE) (VOID *Arg);\r
+typedef VOID (EFIAPI *NET_VECTOR_EXT_FREE) (VOID *Arg);\r
 \r
 //\r
 //NET_VECTOR contains several blocks to hold all packet's\r
@@ -1983,10 +2117,43 @@ NetPseudoHeadChecksum (
 \r
 **/\r
 UINT16\r
+EFIAPI\r
 NetIp6PseudoHeadChecksum (\r
   IN EFI_IPv6_ADDRESS       *Src,\r
   IN EFI_IPv6_ADDRESS       *Dst,\r
   IN UINT8                  NextHeader,\r
   IN UINT32                 Len\r
   );\r
+\r
+/**\r
+  The function frees the net buffer which allocated by the IP protocol. It releases \r
+  only the net buffer and doesn't call the external free function. \r
+\r
+  This function should be called after finishing the process of mIpSec->ProcessExt() \r
+  for outbound traffic. The (EFI_IPSEC2_PROTOCOL)->ProcessExt() allocates a new \r
+  buffer for the ESP, so there needs a function to free the old net buffer.\r
+\r
+  @param[in]  Nbuf       The network buffer to be freed.\r
+\r
+**/\r
+VOID\r
+NetIpSecNetbufFree (\r
+  NET_BUF   *Nbuf\r
+  );\r
+\r
+/**\r
+  This function obtains the system guid from the smbios table.\r
+\r
+  @param[out]  SystemGuid     The pointer of the returned system guid.\r
+\r
+  @retval EFI_SUCCESS         Successfully obtained the system guid.\r
+  @retval EFI_NOT_FOUND       Did not find the SMBIOS table.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+NetLibGetSystemGuid (\r
+  OUT EFI_GUID              *SystemGuid\r
+  );\r
+\r
 #endif\r