X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FInclude%2FLibrary%2FNetLib.h;h=102d7f1413844ef52bad68eb35e8d36fb9fa6507;hp=d19e3ac9b186b0390e460278b4af7d2211f824de;hb=0677cc4925d580f7016ac092dc591be0ebe03495;hpb=1204fe8319e5e6f77df68c375ef403e9ffa9227e
diff --git a/MdeModulePkg/Include/Library/NetLib.h b/MdeModulePkg/Include/Library/NetLib.h
index d19e3ac9b1..102d7f1413 100644
--- a/MdeModulePkg/Include/Library/NetLib.h
+++ b/MdeModulePkg/Include/Library/NetLib.h
@@ -2,10 +2,10 @@
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 - 2009, Intel Corporation
-All rights reserved. This program and the accompanying materials
+Copyright (c) 2005 - 2010, 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
+which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -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;
@@ -28,6 +29,9 @@ typedef UINT16 TCP_PORTNO;
#define NET_ETHER_ADDR_LEN 6
#define NET_IFTYPE_ETHERNET 0x01
+#define NET_VLAN_TAG_LEN 4
+#define ETHER_TYPE_VLAN 0x8100
+
#define EFI_IP_PROTO_UDP 0x11
#define EFI_IP_PROTO_TCP 0x06
#define EFI_IP_PROTO_ICMP 0x01
@@ -48,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
@@ -67,6 +72,20 @@ typedef struct {
UINT16 EtherType;
} ETHER_HEAD;
+//
+// 802.1Q VLAN Tag Control Information
+//
+typedef union {
+ struct {
+ UINT16 Vid : 12; // Unique VLAN identifier (0 to 4094)
+ UINT16 Cfi : 1; // Canonical Format Indicator
+ UINT16 Priority : 3; // 802.1Q priority level (0 to 7)
+ } Bits;
+ UINT16 Uint16;
+} VLAN_TCI;
+
+#define VLAN_TCI_CFI_CANONICAL_MAC 0
+#define VLAN_TCI_CFI_NON_CANONICAL_MAC 1
//
// The EFI_IP4_HEADER is hard to use because the source and
@@ -265,10 +284,11 @@ typedef struct {
by the Format string.
@return The buffer containing the formatted message,
- or NULL if failed to allocate memory.
+ or NULL if memory allocation failed.
**/
CHAR8 *
+EFIAPI
NetDebugASPrint (
IN CHAR8 *Format,
...
@@ -292,6 +312,7 @@ NetDebugASPrint (
than the mNetDebugLevelMax. Or, it has been sent out.
**/
EFI_STATUS
+EFIAPI
NetDebugOutput (
IN UINT32 Level,
IN UINT8 *Module,
@@ -383,6 +404,7 @@ NetIp4IsUnicast (
**/
BOOLEAN
+EFIAPI
NetIp6IsValidUnicast (
IN EFI_IPv6_ADDRESS *Ip6
);
@@ -393,11 +415,12 @@ NetIp6IsValidUnicast (
@param[in] Ip6 - Ip6 address, in network order.
- @retval TRUE - Yes, unspecified
- @retval FALSE - No
+ @retval TRUE - Yes, incoming Ipv6 address is the unspecified address.
+ @retval FALSE - The incoming Ipv6 address is not the unspecified address
**/
BOOLEAN
+EFIAPI
NetIp6IsUnspecifiedAddr (
IN EFI_IPv6_ADDRESS *Ip6
);
@@ -407,11 +430,12 @@ NetIp6IsUnspecifiedAddr (
@param[in] Ip6 - Ip6 address, in network order.
- @retval TRUE - Yes, link-local address
- @retval FALSE - No
+ @retval TRUE - The incoming Ipv6 address is a link-local address.
+ @retval FALSE - The incoming Ipv6 address is not a link-local address.
**/
BOOLEAN
+EFIAPI
NetIp6IsLinkLocalAddr (
IN EFI_IPv6_ADDRESS *Ip6
);
@@ -423,11 +447,12 @@ NetIp6IsLinkLocalAddr (
@param[in] Ip2 - Ip6 address2, in network order.
@param[in] PrefixLength - The prefix length of the checking net.
- @retval TRUE - Yes, connected.
- @retval FALSE - No.
+ @retval TRUE - Yes, the Ipv6 address1 and address2 are connected.
+ @retval FALSE - No the Ipv6 address1 and address2 are not connected.
**/
BOOLEAN
+EFIAPI
NetIp6IsNetEqual (
EFI_IPv6_ADDRESS *Ip1,
EFI_IPv6_ADDRESS *Ip2,
@@ -435,18 +460,19 @@ NetIp6IsNetEqual (
);
/**
- Switches the endianess of an IPv6 address
+ Switches the endianess of an IPv6 address.
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.
- @param Ip6 Points to an IPv6 address
+ @param Ip6 Points to an IPv6 address.
@return The byte swapped IPv6 address.
**/
EFI_IPv6_ADDRESS *
+EFIAPI
Ip6Swap128 (
EFI_IPv6_ADDRESS *Ip6
);
@@ -486,11 +512,11 @@ NetGetUint32 (
/**
Puts a UINT32 into the byte stream in network byte order.
- Converts a UINT32 from host byte order to network byte order, and then copies it to the
+ Converts a UINT32 from host byte order to network byte order, then copies it to the
byte stream.
- @param[in, out] Buf The buffer to put the UINT32.
- @param[in] Data The data to put.
+ @param[in, out] Buf The buffer in which to put the UINT32.
+ @param[in] Data The data to be converted and put into the byte stream.
**/
VOID
@@ -871,7 +897,7 @@ NetMapRemoveTail (
typedef
EFI_STATUS
-(*NET_MAP_CALLBACK) (
+(EFIAPI *NET_MAP_CALLBACK) (
IN NET_MAP *Map,
IN NET_MAP_ITEM *Item,
IN VOID *Arg
@@ -891,8 +917,8 @@ EFI_STATUS
@param[in] CallBack The callback function to call for each item.
@param[in] Arg The opaque parameter to the callback.
- @retval EFI_SUCCESS There is no item in the netmap or CallBack for each item
- return EFI_SUCCESS.
+ @retval EFI_SUCCESS There is no item in the netmap, or CallBack for each item
+ returns EFI_SUCCESS.
@retval Others It returns the CallBack's last return value.
**/
@@ -946,7 +972,7 @@ NetLibCreateServiceChild (
@param[in] ServiceBindingGuid The service's Guid.
@param[in] ChildHandle The child to destroy.
- @retval EFI_SUCCESS The child is successfully destroyed.
+ @retval EFI_SUCCESS The child was destroyed.
@retval Others Failed to destroy the child.
**/
@@ -960,44 +986,165 @@ NetLibDestroyServiceChild (
);
/**
- Convert the mac address of the simple network protocol installed on
- SnpHandle to a unicode string. Callers are responsible for freeing the
- string storage.
+ Get handle with Simple Network Protocol installed on it.
+
+ There should be MNP Service Binding Protocol installed on the input ServiceHandle.
+ If Simple Network Protocol is already installed on the ServiceHandle, the
+ ServiceHandle will be returned. If SNP is not installed on the ServiceHandle,
+ try to find its parent handle with SNP installed.
+
+ @param[in] ServiceHandle The handle where network service binding protocols are
+ installed on.
+ @param[out] Snp The pointer to store the address of the SNP instance.
+ This is an optional parameter that may be NULL.
+
+ @return The SNP handle, or NULL if not found.
+
+**/
+EFI_HANDLE
+EFIAPI
+NetLibGetSnpHandle (
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_SIMPLE_NETWORK_PROTOCOL **Snp OPTIONAL
+ );
+
+/**
+ Retrieve VLAN ID of a VLAN device handle.
+
+ Search VLAN device path node in Device Path of specified ServiceHandle and
+ return its VLAN ID. If no VLAN device path node found, then this ServiceHandle
+ is not a VLAN device handle, and 0 will be returned.
+
+ @param[in] ServiceHandle The handle where network service binding protocols are
+ installed on.
+
+ @return VLAN ID of the device handle, or 0 if not a VLAN device.
+
+**/
+UINT16
+EFIAPI
+NetLibGetVlanId (
+ IN EFI_HANDLE ServiceHandle
+ );
+
+/**
+ Find VLAN device handle with specified VLAN ID.
+
+ The VLAN child device handle is created by VLAN Config Protocol on ControllerHandle.
+ This function will append VLAN device path node to the parent device path,
+ and then use LocateDevicePath() to find the correct VLAN device handle.
+
+ @param[in] ControllerHandle The handle where network service binding protocols are
+ installed on.
+ @param[in] VlanId The configured VLAN ID for the VLAN device.
+
+ @return The VLAN device handle, or NULL if not found.
+
+**/
+EFI_HANDLE
+EFIAPI
+NetLibGetVlanHandle (
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT16 VlanId
+ );
+
+/**
+ Get MAC address associated with the network service handle.
- Get the mac address of the Simple Network protocol from the SnpHandle. Then convert
- the mac address into a unicode string. It takes 2 unicode characters to represent
- a 1 byte binary buffer, plus one unicode character for the null terminator.
+ 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.
+ @param[in] ServiceHandle The handle where network service binding protocols are
+ installed on.
+ @param[out] MacAddress The pointer to store the returned MAC address.
+ @param[out] AddressSize The length of returned MAC address.
- @param[in] SnpHandle The handle on which the simple network protocol is
+ @retval EFI_SUCCESS MAC address was returned successfully.
+ @retval Others Failed to get SNP mode data.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibGetMacAddress (
+ IN EFI_HANDLE ServiceHandle,
+ OUT EFI_MAC_ADDRESS *MacAddress,
+ OUT UINTN *AddressSize
+ );
+
+/**
+ Convert MAC address of the NIC associated with specified Service Binding Handle
+ to a unicode string. Callers are responsible for freeing the string storage.
+
+ 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.
+ Plus one unicode character for the null-terminator.
+
+ @param[in] ServiceHandle The handle where network service binding protocol is
installed.
- @param[in] ImageHandle The image handle to act as the agent handle to
+ @param[in] ImageHandle The image handle used to act as the agent handle to
get the simple network protocol.
@param[out] MacString The pointer to store the address of the string
representation of the mac address.
- @retval EFI_SUCCESS Convert the mac address a unicode string successfully.
- @retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
+ @retval EFI_SUCCESS Converted the mac address a unicode string successfully.
+ @retval EFI_OUT_OF_RESOURCES There are not enough memory resources.
@retval Others Failed to open the simple network protocol.
**/
EFI_STATUS
EFIAPI
NetLibGetMacString (
- IN EFI_HANDLE SnpHandle,
+ IN EFI_HANDLE ServiceHandle,
IN EFI_HANDLE ImageHandle,
OUT CHAR16 **MacString
);
+/**
+ Detect media status for specified network device.
+
+ 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
+ present, it returns directly. If media is not present, it will stop SNP and then
+ restart SNP to get the latest media status. This provides an opportunity to get
+ the correct media status for old UNDI driver, which doesn't support reporting
+ media status from GET_STATUS command.
+ Note: there are two limitations for the current algorithm:
+ 1) For UNDI with this capability, when the cable is not attached, there will
+ be an redundant Stop/Start() process.
+ 2) for UNDI without this capability, in case that network cable is attached when
+ Snp->Initialize() is invoked while network cable is unattached later,
+ NetLibDetectMedia() will report MediaPresent as TRUE, causing upper layer
+ apps to wait for timeout time.
+
+ @param[in] ServiceHandle The handle where network service binding protocols are
+ installed.
+ @param[out] MediaPresent The pointer to store the media status.
+
+ @retval EFI_SUCCESS Media detection success.
+ @retval EFI_INVALID_PARAMETER ServiceHandle is not a valid network device handle.
+ @retval EFI_UNSUPPORTED The network device does not support media detection.
+ @retval EFI_DEVICE_ERROR SNP is in an unknown state.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibDetectMedia (
+ IN EFI_HANDLE ServiceHandle,
+ OUT BOOLEAN *MediaPresent
+ );
+
/**
Create an IPv4 device path node.
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.
- Get other info from parameters to make up the whole IPv4 device path node.
+ Get other information from parameters to make up the whole IPv4 device path node.
- @param[in, out] Node Pointer to the IPv4 device path node.
+ @param[in, out] Node The pointer to the IPv4 device path node.
@param[in] Controller The controller handle.
@param[in] LocalIp The local IPv4 address.
@param[in] LocalPort The local port.
@@ -1026,9 +1173,9 @@ NetLibCreateIPv4DPathNode (
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.
- Get other info from parameters to make up the whole IPv6 device path node.
+ Get other information from parameters to make up the whole IPv6 device path node.
- @param[in, out] Node Pointer to the IPv6 device path node.
+ @param[in, out] Node The pointer to the IPv6 device path node.
@param[in] Controller The controller handle.
@param[in] LocalIp The local IPv6 address.
@param[in] LocalPort The local port.
@@ -1055,13 +1202,13 @@ NetLibCreateIPv6DPathNode (
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 which is related the IP's
- service binding instance that is install on UNDI/SNP handle.
- Now, the controller is either a MNP or ARP child handle. But
- IP opens these handle BY_DRIVER, use that info, we can get the
+ needs to find its own private data that is related the IP's
+ service binding instance that is installed on the UNDI/SNP handle.
+ The controller is then either an MNP or an ARP child handle. Note that
+ IP opens these handles using BY_DRIVER. Use that infomation to get the
UNDI/SNP handle.
- @param[in] Controller Then protocol handle to check.
+ @param[in] Controller The protocol handle to check.
@param[in] ProtocolGuid The protocol that is related with the handle.
@return The UNDI/SNP handle or NULL for errors.
@@ -1092,9 +1239,102 @@ NetLibDefaultUnload (
IN EFI_HANDLE ImageHandle
);
+/**
+ Convert one Null-terminated ASCII string (decimal dotted) to EFI_IPv4_ADDRESS.
+
+ @param[in] String The pointer to the Ascii string.
+ @param[out] Ip4Address The pointer to the converted IPv4 address.
+
+ @retval EFI_SUCCESS Converted to an IPv4 address successfully.
+ @retval EFI_INVALID_PARAMETER The string is malformated, or Ip4Address is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibAsciiStrToIp4 (
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
+ );
+
+/**
+ Convert one Null-terminated ASCII string to EFI_IPv6_ADDRESS. The format of the
+ string is defined in RFC 4291 - Text Pepresentation of Addresses.
+
+ @param[in] String The pointer to the Ascii string.
+ @param[out] Ip6Address The pointer to the converted IPv6 address.
+
+ @retval EFI_SUCCESS Converted to an IPv6 address successfully.
+ @retval EFI_INVALID_PARAMETER The string is malformated, or Ip6Address is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibAsciiStrToIp6 (
+ IN CONST CHAR8 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
+ );
+
+/**
+ Convert one Null-terminated Unicode string (decimal dotted) to EFI_IPv4_ADDRESS.
+
+ @param[in] String The pointer to the Ascii string.
+ @param[out] Ip4Address The pointer to the converted IPv4 address.
+
+ @retval EFI_SUCCESS Converted to an IPv4 address successfully.
+ @retval EFI_INVALID_PARAMETER The string is mal-formated or Ip4Address is NULL.
+ @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to lack of resources.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibStrToIp4 (
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv4_ADDRESS *Ip4Address
+ );
+
+/**
+ Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS. The format of
+ the string is defined in RFC 4291 - Text Pepresentation of Addresses.
+
+ @param[in] String The pointer to the Ascii string.
+ @param[out] Ip6Address The pointer to the converted IPv6 address.
+
+ @retval EFI_SUCCESS Converted to an IPv6 address successfully.
+ @retval EFI_INVALID_PARAMETER The string is malformated or Ip6Address is NULL.
+ @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to a lack of resources.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibStrToIp6 (
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address
+ );
+
+/**
+ Convert one Null-terminated Unicode string to EFI_IPv6_ADDRESS and prefix length.
+ The format of the string is defined in RFC 4291 - Text Pepresentation of Addresses
+ Prefixes: ipv6-address/prefix-length.
+
+ @param[in] String The pointer to the Ascii string.
+ @param[out] Ip6Address The pointer to the converted IPv6 address.
+ @param[out] PrefixLength The pointer to the converted prefix length.
+
+ @retval EFI_SUCCESS Converted to an IPv6 address successfully.
+ @retval EFI_INVALID_PARAMETER The string is malformated, or Ip6Address is NULL.
+ @retval EFI_OUT_OF_RESOURCES Failed to perform the operation due to a lack of resources.
+
+**/
+EFI_STATUS
+EFIAPI
+NetLibStrToIp6andPrefix (
+ IN CONST CHAR16 *String,
+ OUT EFI_IPv6_ADDRESS *Ip6Address,
+ OUT UINT8 *PrefixLength
+ );
//
-//Various signatures
+// Various signatures
//
#define NET_BUF_SIGNATURE SIGNATURE_32 ('n', 'b', 'u', 'f')
#define NET_VECTOR_SIGNATURE SIGNATURE_32 ('n', 'v', 'e', 'c')
@@ -1117,7 +1357,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
@@ -1250,8 +1490,8 @@ typedef struct {
@param[in] Len The length of the block.
- @return Pointer to the allocated NET_BUF, or NULL if the
- allocation failed due to resource limit.
+ @return The pointer to the allocated NET_BUF, or NULL if the
+ allocation failed due to resource limitations.
**/
NET_BUF *
@@ -1269,7 +1509,7 @@ NetbufAlloc (
vector by one, and performs the resource free operation when the reference count
of the net vector is 0.
- @param[in] Nbuf Pointer to the NET_BUF to be freed.
+ @param[in] Nbuf The pointer to the NET_BUF to be freed.
**/
VOID
@@ -1286,12 +1526,12 @@ NetbufFree (
also can be used to get the fragment that contains the byte used
mainly by the library implementation itself.
- @param[in] Nbuf Pointer to the net buffer.
+ @param[in] Nbuf The pointer to the net buffer.
@param[in] Offset The offset of the byte.
@param[out] Index Index of the NET_BLOCK_OP that contains the byte at
Offset.
- @return Pointer to the Offset'th byte of data in the net buffer, or NULL
+ @return The pointer to the Offset'th byte of data in the net buffer, or NULL
if there is no such data in the net buffer.
**/
@@ -1309,10 +1549,10 @@ NetbufGetByte (
The reference count of the newly created net buffer is set to 1. The reference
count of the associated net vector is increased by one.
- @param[in] Nbuf Pointer to the net buffer to be cloned.
+ @param[in] Nbuf The pointer to the net buffer to be cloned.
- @return Pointer to the cloned net buffer, or NULL if the
- allocation failed due to resource limit.
+ @return The pointer to the cloned net buffer, or NULL if the
+ allocation failed due to resource limitations.
**/
NET_BUF *
@@ -1328,13 +1568,13 @@ NetbufClone (
The duplicated net buffer will allocate its own memory to hold the data of the
source net buffer.
- @param[in] Nbuf Pointer to the net buffer to be duplicated from.
- @param[in, out] Duplicate Pointer to the net buffer to duplicate to, if
- NULL a new net buffer is allocated.
- @param[in] HeadSpace Length of the head space to reserve.
+ @param[in] Nbuf The pointer to the net buffer to be duplicated from.
+ @param[in, out] Duplicate The pointer to the net buffer to duplicate to. If
+ NULL, a new net buffer is allocated.
+ @param[in] HeadSpace The length of the head space to reserve.
- @return Pointer to the duplicated net buffer, or NULL if
- the allocation failed due to resource limit.
+ @return The pointer to the duplicated net buffer, or NULL if
+ the allocation failed due to resource limitations.
**/
NET_BUF *
@@ -1350,16 +1590,16 @@ NetbufDuplicate (
Offset.
A new NET_BUF structure will be created but the associated data in NET_VECTOR
- is shared. This function exists to do IP packet fragmentation.
+ is shared. This function exists to perform IP packet fragmentation.
- @param[in] Nbuf Pointer to the net buffer to be extracted.
+ @param[in] Nbuf The pointer to the net buffer to be extracted.
@param[in] Offset Starting point of the data to be included in the new
net buffer.
- @param[in] Len Bytes of data to be included in the new net buffer.
- @param[in] HeadSpace Bytes of head space to reserve for protocol header.
+ @param[in] Len The bytes of data to be included in the new net buffer.
+ @param[in] HeadSpace The bytes of the head space to reserve for the protocol header.
- @return Pointer to the cloned net buffer, or NULL if the
- allocation failed due to resource limit.
+ @return The pointer to the cloned net buffer, or NULL if the
+ allocation failed due to resource limitations.
**/
NET_BUF *
@@ -1375,11 +1615,11 @@ NetbufGetFragment (
Reserve some space in the header room of the net buffer.
Upon allocation, all the space is in the tail room of the buffer. Call this
- function to move some space to the header room. This function is quite limited
+ function to move space to the header room. This function is quite limited
in that it can only reserve space from the first block of an empty NET_BUF not
- built from the external. But it should be enough for the network stack.
+ built from the external. However, it should be enough for the network stack.
- @param[in, out] Nbuf Pointer to the net buffer.
+ @param[in, out] Nbuf The pointer to the net buffer.
@param[in] Len The length of buffer to be reserved from the header.
**/
@@ -1393,13 +1633,13 @@ NetbufReserve (
/**
Allocate Len bytes of space from the header or tail of the buffer.
- @param[in, out] Nbuf Pointer to the net buffer.
+ @param[in, out] Nbuf The pointer to the net buffer.
@param[in] Len The length of the buffer to be allocated.
- @param[in] FromHead The flag to indicate whether reserve the data
+ @param[in] FromHead The flag to indicate whether to reserve the data
from head (TRUE) or tail (FALSE).
- @return Pointer to the first byte of the allocated buffer,
- or NULL if there is no sufficient space.
+ @return The pointer to the first byte of the allocated buffer,
+ or NULL, if there is no sufficient space.
**/
UINT8*
@@ -1411,14 +1651,14 @@ NetbufAllocSpace (
);
/**
- Trim Len bytes from the header or tail of the net buffer.
+ Trim Len bytes from the header or the tail of the net buffer.
- @param[in, out] Nbuf Pointer to the net buffer.
+ @param[in, out] Nbuf The pointer to the net buffer.
@param[in] Len The length of the data to be trimmed.
- @param[in] FromHead The flag to indicate whether trim data from head
- (TRUE) or tail (FALSE).
+ @param[in] FromHead The flag to indicate whether trim data is from the
+ head (TRUE) or the tail (FALSE).
- @return Length of the actually trimmed data, which may be less
+ @return The length of the actual trimmed data, which may be less
than Len if the TotalSize of Nbuf is less than Len.
**/
@@ -1436,9 +1676,9 @@ NetbufTrim (
The Len bytes of data may cross several fragments of the net buffer.
- @param[in] Nbuf Pointer to the net buffer.
+ @param[in] Nbuf The pointer to the net buffer.
@param[in] Offset The sequence number of the first byte to copy.
- @param[in] Len Length of the data to copy.
+ @param[in] Len The length of the data to copy.
@param[in] Dest The destination of the data to copy to.
@return The length of the actual copied data, or 0 if the offset
@@ -1462,16 +1702,16 @@ NetbufCopy (
and existing HeadLen bytes of header, but the external blocks are shared by the
net buffer to avoid data copying.
- @param[in] ExtFragment Pointer to the data block.
+ @param[in] ExtFragment The pointer to the data block.
@param[in] ExtNum The number of the data blocks.
@param[in] HeadSpace The head space to be reserved.
@param[in] HeadLen The length of the protocol header. The function
pulls this amount of data into a linear block.
- @param[in] ExtFree Pointer to the caller-provided free function.
+ @param[in] ExtFree The pointer to the caller-provided free function.
@param[in] Arg The argument passed to ExtFree when ExtFree is
called.
- @return Pointer to the net buffer built from the data blocks,
+ @return The pointer to the net buffer built from the data blocks,
or NULL if the allocation failed due to resource
limit.
@@ -1491,13 +1731,13 @@ NetbufFromExt (
Build a fragment table to contain the fragments in the net buffer. This is the
opposite operation of the NetbufFromExt.
- @param[in] Nbuf Point to the net buffer.
- @param[in, out] ExtFragment Pointer to the data block.
+ @param[in] Nbuf Points to the net buffer.
+ @param[in, out] ExtFragment The pointer to the data block.
@param[in, out] ExtNum The number of the data blocks.
@retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than
ExtNum.
- @retval EFI_SUCCESS Fragment table is built successfully.
+ @retval EFI_SUCCESS The fragment table was built successfully.
**/
EFI_STATUS
@@ -1511,17 +1751,17 @@ NetbufBuildExt (
/**
Build a net buffer from a list of net buffers.
- All the fragments will be collected from the list of NEW_BUF and then a new
+ All the fragments will be collected from the list of NEW_BUF, and then a new
net buffer will be created through NetbufFromExt.
@param[in] BufList A List of the net buffer.
@param[in] HeadSpace The head space to be reserved.
@param[in] HeaderLen The length of the protocol header. The function
pulls this amount of data into a linear block.
- @param[in] ExtFree Pointer to the caller provided free function.
+ @param[in] ExtFree The pointer to the caller provided free function.
@param[in] Arg The argument passed to ExtFree when ExtFree is called.
- @return Pointer to the net buffer built from the list of net
+ @return The pointer to the net buffer built from the list of net
buffers.
**/
@@ -1538,7 +1778,7 @@ NetbufFromBufList (
/**
Free a list of net buffers.
- @param[in, out] Head Pointer to the head of linked net buffers.
+ @param[in, out] Head The pointer to the head of linked net buffers.
**/
VOID
@@ -1550,7 +1790,7 @@ NetbufFreeList (
/**
Initiate the net buffer queue.
- @param[in, out] NbufQue Pointer to the net buffer queue to be initialized.
+ @param[in, out] NbufQue The pointer to the net buffer queue to be initialized.
**/
VOID
@@ -1562,7 +1802,7 @@ NetbufQueInit (
/**
Allocate and initialize a net buffer queue.
- @return Pointer to the allocated net buffer queue, or NULL if the
+ @return The pointer to the allocated net buffer queue, or NULL if the
allocation failed due to resource limit.
**/
@@ -1579,7 +1819,7 @@ NetbufQueAlloc (
free operation isn't performed until the reference count of the net buffer
queue is decreased to 0.
- @param[in] NbufQue Pointer to the net buffer queue to be freed.
+ @param[in] NbufQue The pointer to the net buffer queue to be freed.
**/
VOID
@@ -1591,9 +1831,9 @@ NetbufQueFree (
/**
Remove a net buffer from the head in the specific queue and return it.
- @param[in, out] NbufQue Pointer to the net buffer queue.
+ @param[in, out] NbufQue The pointer to the net buffer queue.
- @return Pointer to the net buffer removed from the specific queue,
+ @return The pointer to the net buffer removed from the specific queue,
or NULL if there is no net buffer in the specific queue.
**/
@@ -1606,8 +1846,8 @@ NetbufQueRemove (
/**
Append a net buffer to the net buffer queue.
- @param[in, out] NbufQue Pointer to the net buffer queue.
- @param[in, out] Nbuf Pointer to the net buffer to be appended.
+ @param[in, out] NbufQue The pointer to the net buffer queue.
+ @param[in, out] Nbuf The pointer to the net buffer to be appended.
**/
VOID
@@ -1621,12 +1861,12 @@ NetbufQueAppend (
Copy Len bytes of data from the net buffer queue at the specific offset to the
destination memory.
- The copying operation is the same as NetbufCopy but applies to the net buffer
+ The copying operation is the same as NetbufCopy, but applies to the net buffer
queue instead of the net buffer.
- @param[in] NbufQue Pointer to the net buffer queue.
+ @param[in] NbufQue The pointer to the net buffer queue.
@param[in] Offset The sequence number of the first byte to copy.
- @param[in] Len Length of the data to copy.
+ @param[in] Len The length of the data to copy.
@param[out] Dest The destination of the data to copy to.
@return The length of the actual copied data, or 0 if the offset
@@ -1643,14 +1883,14 @@ NetbufQueCopy (
);
/**
- Trim Len bytes of data from the queue header and release any net buffer
- that is trimmed wholely.
+ Trim Len bytes of data from the buffer queue and free any net buffer
+ that is completely trimmed.
The trimming operation is the same as NetbufTrim but applies to the net buffer
queue instead of the net buffer.
- @param[in, out] NbufQue Pointer to the net buffer queue.
- @param[in] Len Length of the data to trim.
+ @param[in, out] NbufQue The pointer to the net buffer queue.
+ @param[in] Len The length of the data to trim.
@return The actual length of the data trimmed.
@@ -1666,7 +1906,7 @@ NetbufQueTrim (
/**
Flush the net buffer queue.
- @param[in, out] NbufQue Pointer to the queue to be flushed.
+ @param[in, out] NbufQue The pointer to the queue to be flushed.
**/
VOID
@@ -1678,8 +1918,8 @@ NetbufQueFlush (
/**
Compute the checksum for a bulk of data.
- @param[in] Bulk Pointer to the data.
- @param[in] Len Length of the data, in bytes.
+ @param[in] Bulk The pointer to the data.
+ @param[in] Len The length of the data, in bytes.
@return The computed checksum.
@@ -1710,7 +1950,7 @@ NetAddChecksum (
/**
Compute the checksum for a NET_BUF.
- @param[in] Nbuf Pointer to the net buffer.
+ @param[in] Nbuf The pointer to the net buffer.
@return The computed checksum.
@@ -1744,7 +1984,7 @@ NetPseudoHeadChecksum (
);
/**
- Compute the checksum for TCP6/UDP6 pseudo header.
+ Compute the checksum for the TCP6/UDP6 pseudo header.
Src and Dst are in network byte order, and Len is in host byte order.
@@ -1757,10 +1997,27 @@ 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
+ );
#endif