X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FInclude%2FLibrary%2FNetLib.h;h=b0bbaf22a7732896878c059e2183a6978b97fec8;hb=e0e26f9c1ffa596f700101027b9346b10d78b191;hp=09ead094977ab9f6768dc0300dec3886d9ae0b94;hpb=418373a1cd97abc0c0e3557f7a00105291829e6f;p=mirror_edk2.git diff --git a/MdeModulePkg/Include/Library/NetLib.h b/MdeModulePkg/Include/Library/NetLib.h index 09ead09497..b0bbaf22a7 100644 --- a/MdeModulePkg/Include/Library/NetLib.h +++ b/MdeModulePkg/Include/Library/NetLib.h @@ -2,7 +2,7 @@ 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 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2018, 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
@@ -95,6 +95,12 @@ typedef UINT16 TCP_PORTNO; #define DNS_CLASS_HS 4 #define DNS_CLASS_ANY 255 +// +// Number of 100ns units time Interval for network media state detect +// +#define MEDIA_STATE_DETECT_TIME_INTERVAL 1000000U + + #pragma pack(1) // @@ -414,8 +420,10 @@ NetGetIpClass ( ASSERT if NetMask is zero. - If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address. - + If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address, + except when the originator is one of the endpoints of a point-to-point link with a 31-bit + mask (RFC3021). + @param[in] Ip The IP to check against. @param[in] NetMask The mask of the IP. @@ -432,6 +440,8 @@ NetIp4IsUnicast ( /** Check whether the incoming IPv6 address is a valid unicast address. + ASSERT if Ip6 is NULL. + If the address is a multicast address has binary 0xFF at the start, it is not a valid unicast address. If the address is unspecified ::, it is not a valid unicast address to be assigned to any node. If the address is loopback address @@ -453,6 +463,8 @@ NetIp6IsValidUnicast ( /** Check whether the incoming Ipv6 address is the unspecified address or not. + ASSERT if Ip6 is NULL. + @param[in] Ip6 - Ip6 address, in network order. @retval TRUE - Yes, incoming Ipv6 address is the unspecified address. @@ -468,6 +480,8 @@ NetIp6IsUnspecifiedAddr ( /** Check whether the incoming Ipv6 address is a link-local address. + ASSERT if Ip6 is NULL. + @param[in] Ip6 - Ip6 address, in network order. @retval TRUE - The incoming Ipv6 address is a link-local address. @@ -483,6 +497,9 @@ NetIp6IsLinkLocalAddr ( /** Check whether the Ipv6 address1 and address2 are on the connected network. + ASSERT if Ip1 or Ip2 is NULL. + ASSERT if PrefixLength exceeds or equals to IP6_PREFIX_MAX. + @param[in] Ip1 - Ip6 address1, in network order. @param[in] Ip2 - Ip6 address2, in network order. @param[in] PrefixLength - The prefix length of the checking net. @@ -502,6 +519,8 @@ NetIp6IsNetEqual ( /** Switches the endianess of an IPv6 address. + ASSERT if Ip6 is NULL. + This function swaps the bytes in a 128-bit IPv6 address to switch the value from little endian to big endian or vice versa. The byte swapped value is returned. @@ -536,6 +555,8 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr; /** Extract a UINT32 from a byte stream. + ASSERT if Buf is NULL. + This function copies a UINT32 from a byte stream, and then converts it from Network byte order to host byte order. Use this function to avoid alignment error. @@ -553,6 +574,8 @@ NetGetUint32 ( /** Puts a UINT32 into the byte stream in network byte order. + ASSERT if Buf is NULL. + Converts a UINT32 from host byte order to network byte order, then copies it to the byte stream. @@ -669,6 +692,8 @@ NetListRemoveTail ( /** Insert a new node entry after a designated node entry of a doubly linked list. + ASSERT if PrevEntry or NewEntry is NULL. + Inserts a new node entry designated by NewEntry after the node entry designated by PrevEntry of the doubly linked list. @@ -686,6 +711,8 @@ NetListInsertAfter ( /** Insert a new node entry before a designated node entry of a doubly linked list. + ASSERT if PostEntry or NewEntry is NULL. + Inserts a new node entry designated by NewEntry before the node entry designated by PostEntry of the doubly linked list. @@ -831,7 +858,6 @@ NetMapClean ( If Map is NULL, then ASSERT(). - @param[in] Map The net map to test. @return TRUE if the netmap is empty, otherwise FALSE. @@ -846,6 +872,8 @@ NetMapIsEmpty ( /** Return the number of the pairs in the netmap. + If Map is NULL, then ASSERT(). + @param[in] Map The netmap to get the entry number. @return The entry number in the netmap. @@ -865,6 +893,7 @@ NetMapGetCount ( pairs in the netmap increase by 1. If Map is NULL, then ASSERT(). + If Key is NULL, then ASSERT(). @param[in, out] Map The netmap to insert into. @param[in] Key The user's key. @@ -890,6 +919,7 @@ NetMapInsertHead ( pairs in the netmap increase by 1. If Map is NULL, then ASSERT(). + If Key is NULL, then ASSERT(). @param[in, out] Map The netmap to insert into. @param[in] Key The user's key. @@ -914,6 +944,7 @@ NetMapInsertTail ( item with the key to search. It returns the point to the item contains the Key if found. If Map is NULL, then ASSERT(). + If Key is NULL, then ASSERT(). @param[in] Map The netmap to search within. @param[in] Key The key to search. @@ -1159,6 +1190,9 @@ NetLibGetVlanHandle ( /** Get MAC address associated with the network service handle. + If MacAddress is NULL, then ASSERT(). + If AddressSize is NULL, then ASSERT(). + There should be MNP Service Binding Protocol installed on the input ServiceHandle. If SNP is installed on the ServiceHandle or its parent handle, MAC address will be retrieved from SNP. If no SNP found, try to get SNP mode data use MNP. @@ -1184,6 +1218,8 @@ NetLibGetMacAddress ( Convert MAC address of the NIC associated with specified Service Binding Handle to a unicode string. Callers are responsible for freeing the string storage. + If MacString is NULL, then ASSERT(). + Locate simple network protocol associated with the Service Binding Handle and get the mac address from SNP. Then convert the mac address into a unicode string. It takes 2 unicode characters to represent a 1 byte binary buffer. @@ -1213,6 +1249,8 @@ NetLibGetMacString ( /** Detect media status for specified network device. + If MediaPresent is NULL, then ASSERT(). + The underlying UNDI driver may or may not support reporting media status from GET_STATUS command (PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED). This routine will try to invoke Snp->GetStatus() to get the media status. If media is already @@ -1245,9 +1283,44 @@ NetLibDetectMedia ( OUT BOOLEAN *MediaPresent ); +/** + Detect media state for a network device. This routine will wait for a period of time at + a specified checking interval when a certain network is under connecting until connection + process finishes or timeout. If Aip protocol is supported by low layer drivers, three kinds + of media states can be detected: EFI_SUCCESS, EFI_NOT_READY and EFI_NO_MEDIA, represents + connected state, connecting state and no media state respectively. When function detects + the current state is EFI_NOT_READY, it will loop to wait for next time's check until state + turns to be EFI_SUCCESS or EFI_NO_MEDIA. If Aip protocol is not supported, function will + call NetLibDetectMedia() and return state directly. + + @param[in] ServiceHandle The handle where network service binding protocols are + installed on. + @param[in] Timeout The maximum number of 100ns units to wait when network + is connecting. Zero value means detect once and return + immediately. + @param[out] MediaState The pointer to the detected media state. + + @retval EFI_SUCCESS Media detection success. + @retval EFI_INVALID_PARAMETER ServiceHandle is not a valid network device handle or + MediaState pointer is NULL. + @retval EFI_DEVICE_ERROR A device error occurred. + @retval EFI_TIMEOUT Network is connecting but timeout. + +**/ +EFI_STATUS +EFIAPI +NetLibDetectMediaWaitTimeout ( + IN EFI_HANDLE ServiceHandle, + IN UINT64 Timeout, + OUT EFI_STATUS *MediaState + ); + + /** Create an IPv4 device path node. + If Node is NULL, then ASSERT(). + The header type of IPv4 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv4 device path node is MSG_IPv4_DP. The length of the IPv4 device path node in bytes is 19. @@ -1279,6 +1352,10 @@ NetLibCreateIPv4DPathNode ( /** Create an IPv6 device path node. + If Node is NULL, then ASSERT(). + If LocalIp is NULL, then ASSERT(). + If RemoteIp is NULL, then ASSERT(). + The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. The header subtype of IPv6 device path node is MSG_IPv6_DP. The length of the IPv6 device path node in bytes is 43. @@ -1309,6 +1386,8 @@ NetLibCreateIPv6DPathNode ( /** Find the UNDI/SNP handle from controller and protocol GUID. + If ProtocolGuid is NULL, then ASSERT(). + For example, IP will open an MNP child to transmit/receive packets. When MNP is stopped, IP should also be stopped. IP needs to find its own private data that is related the IP's @@ -1391,7 +1470,6 @@ NetLibAsciiStrToIp6 ( @retval EFI_SUCCESS Converted to an IPv4 address successfully. @retval EFI_INVALID_PARAMETER The string is mal-formatted or Ip4Address is NULL. - @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to lack of resources. **/ EFI_STATUS @@ -1410,7 +1488,6 @@ NetLibStrToIp4 ( @retval EFI_SUCCESS Converted to an IPv6 address successfully. @retval EFI_INVALID_PARAMETER The string is malformatted or Ip6Address is NULL. - @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to a lack of resources. **/ EFI_STATUS @@ -1431,7 +1508,6 @@ NetLibStrToIp6 ( @retval EFI_SUCCESS Converted to an IPv6 address successfully. @retval EFI_INVALID_PARAMETER The string is malformatted, or Ip6Address is NULL. - @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to a lack of resources. **/ EFI_STATUS @@ -1610,10 +1686,10 @@ typedef struct { (sizeof (NET_BUF) + ((BlockOpNum) - 1) * sizeof (NET_BLOCK_OP)) #define NET_HEADSPACE(BlockOp) \ - (UINTN)((BlockOp)->Head - (BlockOp)->BlockHead) + ((UINTN)((BlockOp)->Head) - (UINTN)((BlockOp)->BlockHead)) #define NET_TAILSPACE(BlockOp) \ - (UINTN)((BlockOp)->BlockTail - (BlockOp)->Tail) + ((UINTN)((BlockOp)->BlockTail) - (UINTN)((BlockOp)->Tail)) /** Allocate a single block NET_BUF. Upon allocation, all the @@ -2155,6 +2231,8 @@ NetIpSecNetbufFree ( /** This function obtains the system guid from the smbios table. + If SystemGuid is NULL, then ASSERT(). + @param[out] SystemGuid The pointer of the returned system guid. @retval EFI_SUCCESS Successfully obtained the system guid. @@ -2168,7 +2246,10 @@ NetLibGetSystemGuid ( ); /** - Create Dns QName according the queried domain name. + Create Dns QName according the queried domain name. + + If DomainName is NULL, then ASSERT(). + QName is a domain name represented as a sequence of labels, where each label consists of a length octet followed by that number of octets. The QName terminates with the zero