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