Code clean up in NetLib:
1. Add GLOBAL_REMOVE_IF_UNREFERENCED to all globals 2. Update NTOHL and NTOHS to be BaseLib func SwapBytes32/SwapBytes16 3. Remove duplicate NET_SWAP_SHORT (to use NTOHS instead) git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9648 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9ae650ef6c
commit
1204fe8319
@ -1,5 +1,5 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Ihis library is only intended to be used by UEFI network stack modules.
|
This library is only intended to be used by UEFI network stack modules.
|
||||||
It provides basic functions for the UEFI network stack.
|
It provides basic functions for the UEFI network stack.
|
||||||
|
|
||||||
Copyright (c) 2005 - 2009, Intel Corporation
|
Copyright (c) 2005 - 2009, Intel Corporation
|
||||||
@ -18,6 +18,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
#include <Protocol/Ip6.h>
|
#include <Protocol/Ip6.h>
|
||||||
|
|
||||||
|
#include <Library/BaseLib.h>
|
||||||
|
|
||||||
typedef UINT32 IP4_ADDR;
|
typedef UINT32 IP4_ADDR;
|
||||||
typedef UINT32 TCP_SEQNO;
|
typedef UINT32 TCP_SEQNO;
|
||||||
typedef UINT16 TCP_PORTNO;
|
typedef UINT16 TCP_PORTNO;
|
||||||
@ -160,15 +162,11 @@ typedef struct {
|
|||||||
#define NET_MAC_IS_MULTICAST(Mac, BMac, Len) \
|
#define NET_MAC_IS_MULTICAST(Mac, BMac, Len) \
|
||||||
(((*((UINT8 *) Mac) & 0x01) == 0x01) && (!NET_MAC_EQUAL (Mac, BMac, Len)))
|
(((*((UINT8 *) Mac) & 0x01) == 0x01) && (!NET_MAC_EQUAL (Mac, BMac, Len)))
|
||||||
|
|
||||||
#define NTOHL(x) (UINT32)((((UINT32) (x) & 0xff) << 24) | \
|
#define NTOHL(x) SwapBytes32 (x)
|
||||||
(((UINT32) (x) & 0xff00) << 8) | \
|
|
||||||
(((UINT32) (x) & 0xff0000) >> 8) | \
|
|
||||||
(((UINT32) (x) & 0xff000000) >> 24))
|
|
||||||
|
|
||||||
#define HTONL(x) NTOHL(x)
|
#define HTONL(x) NTOHL(x)
|
||||||
|
|
||||||
#define NTOHS(x) (UINT16)((((UINT16) (x) & 0xff) << 8) | \
|
#define NTOHS(x) SwapBytes16 (x)
|
||||||
(((UINT16) (x) & 0xff00) >> 8))
|
|
||||||
|
|
||||||
#define HTONS(x) NTOHS(x)
|
#define HTONS(x) NTOHS(x)
|
||||||
#define NTOHLL(x) SwapBytes64 (x)
|
#define NTOHLL(x) SwapBytes64 (x)
|
||||||
@ -199,24 +197,24 @@ typedef struct {
|
|||||||
#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))
|
#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)))
|
||||||
|
|
||||||
//
|
//
|
||||||
// The debug level definition. This value is also used as the
|
// The debug level definition. This value is also used as the
|
||||||
// syslog's servity level. Don't change it.
|
// syslog's servity level. Don't change it.
|
||||||
//
|
//
|
||||||
#define NETDEBUG_LEVEL_TRACE 5
|
#define NETDEBUG_LEVEL_TRACE 5
|
||||||
#define NETDEBUG_LEVEL_WARNING 4
|
#define NETDEBUG_LEVEL_WARNING 4
|
||||||
#define NETDEBUG_LEVEL_ERROR 3
|
#define NETDEBUG_LEVEL_ERROR 3
|
||||||
|
|
||||||
//
|
//
|
||||||
// Network debug message is sent out as syslog packet.
|
// Network debug message is sent out as syslog packet.
|
||||||
//
|
//
|
||||||
#define NET_SYSLOG_FACILITY 16 // Syslog local facility local use
|
#define NET_SYSLOG_FACILITY 16 // Syslog local facility local use
|
||||||
#define NET_SYSLOG_PACKET_LEN 512
|
#define NET_SYSLOG_PACKET_LEN 512
|
||||||
#define NET_SYSLOG_TX_TIMEOUT 500 *1000 *10 // 500ms
|
#define NET_SYSLOG_TX_TIMEOUT (500 * 1000 * 10) // 500ms
|
||||||
#define NET_DEBUG_MSG_LEN 470 // 512 - (ether+ip4+udp4 head length)
|
#define NET_DEBUG_MSG_LEN 470 // 512 - (ether+ip4+udp4 head length)
|
||||||
|
|
||||||
//
|
//
|
||||||
// The debug output expects the ASCII format string, Use %a to print ASCII
|
// The debug output expects the ASCII format string, Use %a to print ASCII
|
||||||
// string, and %s to print UNICODE string. PrintArg must be enclosed in ().
|
// string, and %s to print UNICODE string. PrintArg must be enclosed in ().
|
||||||
// For example: NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name));
|
// For example: NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name));
|
||||||
//
|
//
|
||||||
#define NET_DEBUG_TRACE(Module, PrintArg) \
|
#define NET_DEBUG_TRACE(Module, PrintArg) \
|
||||||
@ -247,23 +245,23 @@ typedef struct {
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate a buffer, then format the message to it. This is a
|
Allocate a buffer, then format the message to it. This is a
|
||||||
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
||||||
these macros treats the variable length print parameters as a
|
these macros treats the variable length print parameters as a
|
||||||
single parameter, and pass it to the NetDebugASPrint. For
|
single parameter, and pass it to the NetDebugASPrint. For
|
||||||
example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
|
example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
|
||||||
if extracted to:
|
if extracted to:
|
||||||
|
|
||||||
NetDebugOutput (
|
NetDebugOutput (
|
||||||
NETDEBUG_LEVEL_TRACE,
|
NETDEBUG_LEVEL_TRACE,
|
||||||
"Tcp",
|
"Tcp",
|
||||||
__FILE__,
|
__FILE__,
|
||||||
__LINE__,
|
__LINE__,
|
||||||
NetDebugASPrint ("State transit to %a\n", Name)
|
NetDebugASPrint ("State transit to %a\n", Name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@param Format The ASCII format string.
|
@param Format The ASCII format string.
|
||||||
@param ... The variable length parameter whose format is determined
|
@param ... The variable length parameter whose format is determined
|
||||||
by the Format string.
|
by the Format string.
|
||||||
|
|
||||||
@return The buffer containing the formatted message,
|
@return The buffer containing the formatted message,
|
||||||
@ -290,12 +288,12 @@ NetDebugASPrint (
|
|||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet
|
||||||
@retval EFI_SUCCESS The log is discard because that it is more verbose
|
@retval EFI_SUCCESS The log is discard because that it is more verbose
|
||||||
than the mNetDebugLevelMax. Or, it has been sent out.
|
than the mNetDebugLevelMax. Or, it has been sent out.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
NetDebugOutput (
|
NetDebugOutput (
|
||||||
IN UINT32 Level,
|
IN UINT32 Level,
|
||||||
IN UINT8 *Module,
|
IN UINT8 *Module,
|
||||||
IN UINT8 *File,
|
IN UINT8 *File,
|
||||||
IN UINT32 Line,
|
IN UINT32 Line,
|
||||||
@ -304,8 +302,8 @@ NetDebugOutput (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return the length of the mask.
|
Return the length of the mask.
|
||||||
|
|
||||||
Return the length of the mask. Valid values are 0 to 32.
|
Return the length of the mask. Valid values are 0 to 32.
|
||||||
If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.
|
If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.
|
||||||
NetMask is in the host byte order.
|
NetMask is in the host byte order.
|
||||||
@ -313,7 +311,7 @@ NetDebugOutput (
|
|||||||
@param[in] NetMask The netmask to get the length from.
|
@param[in] NetMask The netmask to get the length from.
|
||||||
|
|
||||||
@return The length of the netmask, or IP4_MASK_NUM (33) if the mask is invalid.
|
@return The length of the netmask, or IP4_MASK_NUM (33) if the mask is invalid.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
INTN
|
INTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -324,19 +322,19 @@ NetGetMaskLength (
|
|||||||
/**
|
/**
|
||||||
Return the class of the IP address, such as class A, B, C.
|
Return the class of the IP address, such as class A, B, C.
|
||||||
Addr is in host byte order.
|
Addr is in host byte order.
|
||||||
|
|
||||||
The address of class A starts with 0.
|
The address of class A starts with 0.
|
||||||
If the address belong to class A, return IP4_ADDR_CLASSA.
|
If the address belong to class A, return IP4_ADDR_CLASSA.
|
||||||
The address of class B starts with 10.
|
The address of class B starts with 10.
|
||||||
If the address belong to class B, return IP4_ADDR_CLASSB.
|
If the address belong to class B, return IP4_ADDR_CLASSB.
|
||||||
The address of class C starts with 110.
|
The address of class C starts with 110.
|
||||||
If the address belong to class C, return IP4_ADDR_CLASSC.
|
If the address belong to class C, return IP4_ADDR_CLASSC.
|
||||||
The address of class D starts with 1110.
|
The address of class D starts with 1110.
|
||||||
If the address belong to class D, return IP4_ADDR_CLASSD.
|
If the address belong to class D, return IP4_ADDR_CLASSD.
|
||||||
The address of class E starts with 1111.
|
The address of class E starts with 1111.
|
||||||
If the address belong to class E, return IP4_ADDR_CLASSE.
|
If the address belong to class E, return IP4_ADDR_CLASSE.
|
||||||
|
|
||||||
|
|
||||||
@param[in] Addr The address to get the class from.
|
@param[in] Addr The address to get the class from.
|
||||||
|
|
||||||
@return IP address class, such as IP4_ADDR_CLASSA.
|
@return IP address class, such as IP4_ADDR_CLASSA.
|
||||||
@ -351,10 +349,10 @@ NetGetIpClass (
|
|||||||
/**
|
/**
|
||||||
Check whether the IP is a valid unicast address according to
|
Check whether the IP is a valid unicast address according to
|
||||||
the netmask. If NetMask is zero, use the IP address's class to get the default mask.
|
the netmask. If NetMask is zero, use the IP address's class to get the default mask.
|
||||||
|
|
||||||
If Ip is 0, IP is not a valid unicast address.
|
If Ip is 0, IP is not a valid unicast address.
|
||||||
Class D address is used for multicasting and class E address is reserved for future. If Ip
|
Class D address is used for multicasting and class E address is reserved for future. If Ip
|
||||||
belongs to class D or class E, Ip is not a valid unicast address.
|
belongs to class D or class E, Ip is not a valid unicast address.
|
||||||
If all bits of the host address of Ip are 0 or 1, Ip is not a valid unicast address.
|
If all bits of the host address of Ip are 0 or 1, Ip is not a valid unicast address.
|
||||||
|
|
||||||
@param[in] Ip The IP to check against.
|
@param[in] Ip The IP to check against.
|
||||||
@ -377,13 +375,13 @@ NetIp4IsUnicast (
|
|||||||
a valid unicast address. If the address is unspecified ::, it is not a valid
|
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
|
unicast address to be assigned to any node. If the address is loopback address
|
||||||
::1, it is also not a valid unicast address to be assigned to any physical
|
::1, it is also not a valid unicast address to be assigned to any physical
|
||||||
interface.
|
interface.
|
||||||
|
|
||||||
@param[in] Ip6 The IPv6 address to check against.
|
@param[in] Ip6 The IPv6 address to check against.
|
||||||
|
|
||||||
@return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.
|
@return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsValidUnicast (
|
NetIp6IsValidUnicast (
|
||||||
IN EFI_IPv6_ADDRESS *Ip6
|
IN EFI_IPv6_ADDRESS *Ip6
|
||||||
@ -397,7 +395,7 @@ NetIp6IsValidUnicast (
|
|||||||
|
|
||||||
@retval TRUE - Yes, unspecified
|
@retval TRUE - Yes, unspecified
|
||||||
@retval FALSE - No
|
@retval FALSE - No
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsUnspecifiedAddr (
|
NetIp6IsUnspecifiedAddr (
|
||||||
@ -411,7 +409,7 @@ NetIp6IsUnspecifiedAddr (
|
|||||||
|
|
||||||
@retval TRUE - Yes, link-local address
|
@retval TRUE - Yes, link-local address
|
||||||
@retval FALSE - No
|
@retval FALSE - No
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsLinkLocalAddr (
|
NetIp6IsLinkLocalAddr (
|
||||||
@ -427,7 +425,7 @@ NetIp6IsLinkLocalAddr (
|
|||||||
|
|
||||||
@retval TRUE - Yes, connected.
|
@retval TRUE - Yes, connected.
|
||||||
@retval FALSE - No.
|
@retval FALSE - No.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsNetEqual (
|
NetIp6IsNetEqual (
|
||||||
@ -470,8 +468,8 @@ extern EFI_IPv4_ADDRESS mZeroIp4Addr;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Extract a UINT32 from a byte stream.
|
Extract a UINT32 from a byte stream.
|
||||||
|
|
||||||
This function copies a UINT32 from a byte stream, and then converts it from Network
|
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.
|
byte order to host byte order. Use this function to avoid alignment error.
|
||||||
|
|
||||||
@param[in] Buf The buffer to extract the UINT32.
|
@param[in] Buf The buffer to extract the UINT32.
|
||||||
@ -486,14 +484,14 @@ NetGetUint32 (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Puts a UINT32 into the byte stream in network byte order.
|
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, and then copies it to the
|
||||||
byte stream.
|
byte stream.
|
||||||
|
|
||||||
@param[in, out] Buf The buffer to put the UINT32.
|
@param[in, out] Buf The buffer to put the UINT32.
|
||||||
@param[in] Data The data to put.
|
@param[in] Data The data to put.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -504,11 +502,11 @@ NetPutUint32 (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize a random seed using current time.
|
Initialize a random seed using current time.
|
||||||
|
|
||||||
Get current time first. Then initialize a random seed based on some basic
|
Get current time first. Then initialize a random seed based on some basic
|
||||||
mathematical operations on the hour, day, minute, second, nanosecond and year
|
mathematical operations on the hour, day, minute, second, nanosecond and year
|
||||||
of the current time.
|
of the current time.
|
||||||
|
|
||||||
@return The random seed, initialized with current time.
|
@return The random seed, initialized with current time.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -555,16 +553,16 @@ NetRandomInitSeed (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Remove the first node entry on the list, and return the removed node entry.
|
Remove the first node entry on the list, and return the removed node entry.
|
||||||
|
|
||||||
Removes the first node entry from a doubly linked list. It is up to the caller of
|
Removes the first node entry from a doubly linked list. It is up to the caller of
|
||||||
this function to release the memory used by the first node, if that is required. On
|
this function to release the memory used by the first node, if that is required. On
|
||||||
exit, the removed node is returned.
|
exit, the removed node is returned.
|
||||||
|
|
||||||
If Head is NULL, then ASSERT().
|
If Head is NULL, then ASSERT().
|
||||||
If Head was not initialized, then ASSERT().
|
If Head was not initialized, then ASSERT().
|
||||||
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
||||||
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
||||||
then ASSERT().
|
then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Head The list header.
|
@param[in, out] Head The list header.
|
||||||
|
|
||||||
@ -582,14 +580,14 @@ NetListRemoveHead (
|
|||||||
|
|
||||||
Removes the last node entry from a doubly linked list. It is up to the caller of
|
Removes the last node entry from a doubly linked list. It is up to the caller of
|
||||||
this function to release the memory used by the first node, if that is required. On
|
this function to release the memory used by the first node, if that is required. On
|
||||||
exit, the removed node is returned.
|
exit, the removed node is returned.
|
||||||
|
|
||||||
If Head is NULL, then ASSERT().
|
If Head is NULL, then ASSERT().
|
||||||
If Head was not initialized, then ASSERT().
|
If Head was not initialized, then ASSERT().
|
||||||
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
||||||
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
||||||
then ASSERT().
|
then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Head The list head.
|
@param[in, out] Head The list head.
|
||||||
|
|
||||||
@return The last node entry that is removed from the list, NULL if the list is empty.
|
@return The last node entry that is removed from the list, NULL if the list is empty.
|
||||||
@ -603,11 +601,11 @@ NetListRemoveTail (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Insert a new node entry after a designated node entry of a doubly linked list.
|
Insert a new node entry after a designated node entry of a doubly linked list.
|
||||||
|
|
||||||
Inserts a new node entry designated by NewEntry after the node entry designated by PrevEntry
|
Inserts a new node entry designated by NewEntry after the node entry designated by PrevEntry
|
||||||
of the doubly linked list.
|
of the doubly linked list.
|
||||||
|
|
||||||
@param[in, out] PrevEntry The entry after which to insert.
|
@param[in, out] PrevEntry The entry after which to insert.
|
||||||
@param[in, out] NewEntry The new entry to insert.
|
@param[in, out] NewEntry The new entry to insert.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -620,10 +618,10 @@ NetListInsertAfter (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Insert a new node entry before a designated node entry of a doubly linked list.
|
Insert a new node entry before a designated node entry of a doubly linked list.
|
||||||
|
|
||||||
Inserts a new node entry designated by NewEntry before the node entry designated by PostEntry
|
Inserts a new node entry designated by NewEntry before the node entry designated by PostEntry
|
||||||
of the doubly linked list.
|
of the doubly linked list.
|
||||||
|
|
||||||
@param[in, out] PostEntry The entry to insert before.
|
@param[in, out] PostEntry The entry to insert before.
|
||||||
@param[in, out] NewEntry The new entry to insert.
|
@param[in, out] NewEntry The new entry to insert.
|
||||||
|
|
||||||
@ -656,15 +654,15 @@ typedef struct {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
|
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
|
||||||
|
|
||||||
Initialize the forward and backward links of two head nodes donated by Map->Used
|
Initialize the forward and backward links of two head nodes donated by Map->Used
|
||||||
and Map->Recycled of two doubly linked lists.
|
and Map->Recycled of two doubly linked lists.
|
||||||
Initializes the count of the <Key, Value> pairs in the netmap to zero.
|
Initializes the count of the <Key, Value> pairs in the netmap to zero.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the address of Map->Used is NULL, then ASSERT().
|
If the address of Map->Used is NULL, then ASSERT().
|
||||||
If the address of Map->Recycled is NULl, then ASSERT().
|
If the address of Map->Recycled is NULl, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to initialize.
|
@param[in, out] Map The netmap to initialize.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -676,13 +674,13 @@ NetMapInit (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
To clean up the netmap, that is, release allocated memories.
|
To clean up the netmap, that is, release allocated memories.
|
||||||
|
|
||||||
Removes all nodes of the Used doubly linked list and frees memory of all related netmap items.
|
Removes all nodes of the Used doubly linked list and frees memory of all related netmap items.
|
||||||
Removes all nodes of the Recycled doubly linked list and free memory of all related netmap items.
|
Removes all nodes of the Recycled doubly linked list and free memory of all related netmap items.
|
||||||
The number of the <Key, Value> pairs in the netmap is set to zero.
|
The number of the <Key, Value> pairs in the netmap is set to zero.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to clean up.
|
@param[in, out] Map The netmap to clean up.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -694,12 +692,12 @@ NetMapClean (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Test whether the netmap is empty and return true if it is.
|
Test whether the netmap is empty and return true if it is.
|
||||||
|
|
||||||
If the number of the <Key, Value> pairs in the netmap is zero, return TRUE.
|
If the number of the <Key, Value> pairs in the netmap is zero, return TRUE.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
|
|
||||||
@param[in] Map The net map to test.
|
@param[in] Map The net map to test.
|
||||||
|
|
||||||
@return TRUE if the netmap is empty, otherwise FALSE.
|
@return TRUE if the netmap is empty, otherwise FALSE.
|
||||||
@ -727,13 +725,13 @@ NetMapGetCount (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate an item to save the <Key, Value> pair to the head of the netmap.
|
Allocate an item to save the <Key, Value> pair to the head of the netmap.
|
||||||
|
|
||||||
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
||||||
to the beginning of the Used doubly linked list. The number of the <Key, Value>
|
to the beginning of the Used doubly linked list. The number of the <Key, Value>
|
||||||
pairs in the netmap increase by 1.
|
pairs in the netmap increase by 1.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to insert into.
|
@param[in, out] Map The netmap to insert into.
|
||||||
@param[in] Key The user's key.
|
@param[in] Key The user's key.
|
||||||
@param[in] Value The user's value for the key.
|
@param[in] Value The user's value for the key.
|
||||||
@ -754,11 +752,11 @@ NetMapInsertHead (
|
|||||||
Allocate an item to save the <Key, Value> pair to the tail of the netmap.
|
Allocate an item to save the <Key, Value> pair to the tail of the netmap.
|
||||||
|
|
||||||
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
||||||
to the tail of the Used doubly linked list. The number of the <Key, Value>
|
to the tail of the Used doubly linked list. The number of the <Key, Value>
|
||||||
pairs in the netmap increase by 1.
|
pairs in the netmap increase by 1.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to insert into.
|
@param[in, out] Map The netmap to insert into.
|
||||||
@param[in] Key The user's key.
|
@param[in] Key The user's key.
|
||||||
@param[in] Value The user's value for the key.
|
@param[in] Value The user's value for the key.
|
||||||
@ -777,12 +775,12 @@ NetMapInsertTail (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Finds the key in the netmap and returns the point to the item containing the Key.
|
Finds the key in the netmap and returns the point to the item containing the Key.
|
||||||
|
|
||||||
Iterate the Used doubly linked list of the netmap to get every item. Compare the key of every
|
Iterate the Used doubly linked list of the netmap to get every item. Compare the key of every
|
||||||
item with the key to search. It returns the point to the item contains the Key if found.
|
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 Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Map The netmap to search within.
|
@param[in] Map The netmap to search within.
|
||||||
@param[in] Key The key to search.
|
@param[in] Key The key to search.
|
||||||
|
|
||||||
@ -798,16 +796,16 @@ NetMapFindKey (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Remove the node entry of the item from the netmap and return the key of the removed item.
|
Remove the node entry of the item from the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the node entry of the item from the Used doubly linked list of the netmap.
|
Remove the node entry of the item from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry of the item to the Recycled doubly linked list of the netmap. If Value is not NULL,
|
entry of the item to the Recycled doubly linked list of the netmap. If Value is not NULL,
|
||||||
Value will point to the value of the item. It returns the key of the removed item.
|
Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If Item is NULL, then ASSERT().
|
If Item is NULL, then ASSERT().
|
||||||
if item in not in the netmap, then ASSERT().
|
if item in not in the netmap, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the item from.
|
@param[in, out] Map The netmap to remove the item from.
|
||||||
@param[in, out] Item The item to remove.
|
@param[in, out] Item The item to remove.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
@ -826,14 +824,14 @@ NetMapRemoveItem (
|
|||||||
/**
|
/**
|
||||||
Remove the first node entry on the netmap and return the key of the removed item.
|
Remove the first node entry on the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the first node entry from the Used doubly linked list of the netmap.
|
Remove the first node entry from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
||||||
parameter Value will point to the value of the item. It returns the key of the removed item.
|
parameter Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the Used doubly linked list is empty, then ASSERT().
|
If the Used doubly linked list is empty, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the head from.
|
@param[in, out] Map The netmap to remove the head from.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
|
|
||||||
@ -850,14 +848,14 @@ NetMapRemoveHead (
|
|||||||
/**
|
/**
|
||||||
Remove the last node entry on the netmap and return the key of the removed item.
|
Remove the last node entry on the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the last node entry from the Used doubly linked list of the netmap.
|
Remove the last node entry from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
||||||
parameter Value will point to the value of the item. It returns the key of the removed item.
|
parameter Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the Used doubly linked list is empty, then ASSERT().
|
If the Used doubly linked list is empty, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the tail from.
|
@param[in, out] Map The netmap to remove the tail from.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
|
|
||||||
@ -881,14 +879,14 @@ EFI_STATUS
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Iterate through the netmap and call CallBack for each item.
|
Iterate through the netmap and call CallBack for each item.
|
||||||
|
|
||||||
It will contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
|
It will contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
|
||||||
from the loop. It returns the CallBack's last return value. This function is
|
from the loop. It returns the CallBack's last return value. This function is
|
||||||
delete safe for the current item.
|
delete safe for the current item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If CallBack is NULL, then ASSERT().
|
If CallBack is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Map The Map to iterate through.
|
@param[in] Map The Map to iterate through.
|
||||||
@param[in] CallBack The callback function to call for each item.
|
@param[in] CallBack The callback function to call for each item.
|
||||||
@param[in] Arg The opaque parameter to the callback.
|
@param[in] Arg The opaque parameter to the callback.
|
||||||
@ -912,12 +910,12 @@ NetMapIterate (
|
|||||||
//
|
//
|
||||||
/**
|
/**
|
||||||
Create a child of the service that is identified by ServiceBindingGuid.
|
Create a child of the service that is identified by ServiceBindingGuid.
|
||||||
|
|
||||||
Get the ServiceBinding Protocol first, then use it to create a child.
|
Get the ServiceBinding Protocol first, then use it to create a child.
|
||||||
|
|
||||||
If ServiceBindingGuid is NULL, then ASSERT().
|
If ServiceBindingGuid is NULL, then ASSERT().
|
||||||
If ChildHandle is NULL, then ASSERT().
|
If ChildHandle is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Controller The controller which has the service installed.
|
@param[in] Controller The controller which has the service installed.
|
||||||
@param[in] Image The image handle used to open service.
|
@param[in] Image The image handle used to open service.
|
||||||
@param[in] ServiceBindingGuid The service's Guid.
|
@param[in] ServiceBindingGuid The service's Guid.
|
||||||
@ -938,11 +936,11 @@ NetLibCreateServiceChild (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Destroy a child of the service that is identified by ServiceBindingGuid.
|
Destroy a child of the service that is identified by ServiceBindingGuid.
|
||||||
|
|
||||||
Get the ServiceBinding Protocol first, then use it to destroy a child.
|
Get the ServiceBinding Protocol first, then use it to destroy a child.
|
||||||
|
|
||||||
If ServiceBindingGuid is NULL, then ASSERT().
|
If ServiceBindingGuid is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Controller The controller which has the service installed.
|
@param[in] Controller The controller which has the service installed.
|
||||||
@param[in] Image The image handle used to open service.
|
@param[in] Image The image handle used to open service.
|
||||||
@param[in] ServiceBindingGuid The service's Guid.
|
@param[in] ServiceBindingGuid The service's Guid.
|
||||||
@ -977,9 +975,9 @@ NetLibDestroyServiceChild (
|
|||||||
get the simple network protocol.
|
get the simple network protocol.
|
||||||
@param[out] MacString The pointer to store the address of the string
|
@param[out] MacString The pointer to store the address of the string
|
||||||
representation of the mac address.
|
representation of the mac address.
|
||||||
|
|
||||||
@retval EFI_SUCCESS Converted the mac address a unicode string successfully.
|
@retval EFI_SUCCESS Convert the mac address a unicode string successfully.
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough memory resources.
|
@retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
|
||||||
@retval Others Failed to open the simple network protocol.
|
@retval Others Failed to open the simple network protocol.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -993,7 +991,7 @@ NetLibGetMacString (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Create an IPv4 device path node.
|
Create an IPv4 device path node.
|
||||||
|
|
||||||
The header type of IPv4 device path node is MESSAGING_DEVICE_PATH.
|
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 header subtype of IPv4 device path node is MSG_IPv4_DP.
|
||||||
The length of the IPv4 device path node in bytes is 19.
|
The length of the IPv4 device path node in bytes is 19.
|
||||||
@ -1024,7 +1022,7 @@ NetLibCreateIPv4DPathNode (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Create an IPv6 device path node.
|
Create an IPv6 device path node.
|
||||||
|
|
||||||
The header type of IPv6 device path node is MESSAGING_DEVICE_PATH.
|
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 header subtype of IPv6 device path node is MSG_IPv6_DP.
|
||||||
The length of the IPv6 device path node in bytes is 43.
|
The length of the IPv6 device path node in bytes is 43.
|
||||||
@ -1054,7 +1052,7 @@ NetLibCreateIPv6DPathNode (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Find the UNDI/SNP handle from controller and protocol GUID.
|
Find the UNDI/SNP handle from controller and protocol GUID.
|
||||||
|
|
||||||
For example, IP will open an MNP child to transmit/receive
|
For example, IP will open an MNP child to transmit/receive
|
||||||
packets. When MNP is stopped, IP should also be stopped. IP
|
packets. When MNP is stopped, IP should also be stopped. IP
|
||||||
needs to find its own private data which is related the IP's
|
needs to find its own private data which is related the IP's
|
||||||
@ -1081,7 +1079,7 @@ NetLibGetNicHandle (
|
|||||||
|
|
||||||
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
|
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
|
||||||
Uninstall all the protocols installed in the driver entry point.
|
Uninstall all the protocols installed in the driver entry point.
|
||||||
|
|
||||||
@param[in] ImageHandle The drivers' driver image.
|
@param[in] ImageHandle The drivers' driver image.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The image is unloaded.
|
@retval EFI_SUCCESS The image is unloaded.
|
||||||
@ -1111,9 +1109,6 @@ NetLibDefaultUnload (
|
|||||||
#define NET_CHECK_SIGNATURE(PData, SIGNATURE) \
|
#define NET_CHECK_SIGNATURE(PData, SIGNATURE) \
|
||||||
ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE)))
|
ASSERT (((PData) != NULL) && ((PData)->Signature == (SIGNATURE)))
|
||||||
|
|
||||||
#define NET_SWAP_SHORT(Value) \
|
|
||||||
((((Value) & 0xff) << 8) | (((Value) >> 8) & 0xff))
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Single memory block in the vector.
|
// Single memory block in the vector.
|
||||||
//
|
//
|
||||||
@ -1255,7 +1250,7 @@ typedef struct {
|
|||||||
|
|
||||||
@param[in] Len The length of the block.
|
@param[in] Len The length of the block.
|
||||||
|
|
||||||
@return Pointer to the allocated NET_BUF, or NULL if the
|
@return Pointer to the allocated NET_BUF, or NULL if the
|
||||||
allocation failed due to resource limit.
|
allocation failed due to resource limit.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1267,13 +1262,13 @@ NetbufAlloc (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Free the net buffer and its associated NET_VECTOR.
|
Free the net buffer and its associated NET_VECTOR.
|
||||||
|
|
||||||
Decrease the reference count of the net buffer by one. Free the associated net
|
Decrease the reference count of the net buffer by one. Free the associated net
|
||||||
vector and itself if the reference count of the net buffer is decreased to 0.
|
vector and itself if the reference count of the net buffer is decreased to 0.
|
||||||
The net vector free operation decreases the reference count of the net
|
The net vector free operation decreases the reference count of the net
|
||||||
vector by one, and performs the resource free operation when the reference count
|
vector by one, and performs the resource free operation when the reference count
|
||||||
of the net vector is 0.
|
of the net vector is 0.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the NET_BUF to be freed.
|
@param[in] Nbuf Pointer to the NET_BUF to be freed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1284,16 +1279,16 @@ NetbufFree (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the index of NET_BLOCK_OP that contains the byte at Offset in the net
|
Get the index of NET_BLOCK_OP that contains the byte at Offset in the net
|
||||||
buffer.
|
buffer.
|
||||||
|
|
||||||
For example, this function can be used to retrieve the IP header in the packet. It
|
For example, this function can be used to retrieve the IP header in the packet. It
|
||||||
also can be used to get the fragment that contains the byte used
|
also can be used to get the fragment that contains the byte used
|
||||||
mainly by the library implementation itself.
|
mainly by the library implementation itself.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer.
|
@param[in] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Offset The offset of the byte.
|
@param[in] Offset The offset of the byte.
|
||||||
@param[out] Index Index of the NET_BLOCK_OP that contains the byte at
|
@param[out] Index Index of the NET_BLOCK_OP that contains the byte at
|
||||||
Offset.
|
Offset.
|
||||||
|
|
||||||
@return Pointer to the Offset'th byte of data in the net buffer, or NULL
|
@return Pointer to the Offset'th byte of data in the net buffer, or NULL
|
||||||
@ -1309,10 +1304,10 @@ NetbufGetByte (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a copy of the net buffer that shares the associated net vector.
|
Create a copy of the net buffer that shares the associated net vector.
|
||||||
|
|
||||||
The reference count of the newly created net buffer is set to 1. The reference
|
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.
|
count of the associated net vector is increased by one.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be cloned.
|
@param[in] Nbuf Pointer to the net buffer to be cloned.
|
||||||
|
|
||||||
@ -1329,12 +1324,12 @@ NetbufClone (
|
|||||||
/**
|
/**
|
||||||
Create a duplicated copy of the net buffer with data copied and HeadSpace
|
Create a duplicated copy of the net buffer with data copied and HeadSpace
|
||||||
bytes of head space reserved.
|
bytes of head space reserved.
|
||||||
|
|
||||||
The duplicated net buffer will allocate its own memory to hold the data of the
|
The duplicated net buffer will allocate its own memory to hold the data of the
|
||||||
source net buffer.
|
source net buffer.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be duplicated from.
|
@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
|
@param[in, out] Duplicate Pointer to the net buffer to duplicate to, if
|
||||||
NULL a new net buffer is allocated.
|
NULL a new net buffer is allocated.
|
||||||
@param[in] HeadSpace Length of the head space to reserve.
|
@param[in] HeadSpace Length of the head space to reserve.
|
||||||
|
|
||||||
@ -1351,19 +1346,19 @@ NetbufDuplicate (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a NET_BUF structure which contains Len byte data of Nbuf starting from
|
Create a NET_BUF structure which contains Len byte data of Nbuf starting from
|
||||||
Offset.
|
Offset.
|
||||||
|
|
||||||
A new NET_BUF structure will be created but the associated data in NET_VECTOR
|
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 do IP packet fragmentation.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be extracted.
|
@param[in] Nbuf Pointer to the net buffer to be extracted.
|
||||||
@param[in] Offset Starting point of the data to be included in the new
|
@param[in] Offset Starting point of the data to be included in the new
|
||||||
net buffer.
|
net buffer.
|
||||||
@param[in] Len Bytes of 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] HeadSpace Bytes of head space to reserve for protocol header.
|
||||||
|
|
||||||
@return Pointer to the cloned net buffer, or NULL if the
|
@return Pointer to the cloned net buffer, or NULL if the
|
||||||
allocation failed due to resource limit.
|
allocation failed due to resource limit.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1379,10 +1374,10 @@ NetbufGetFragment (
|
|||||||
/**
|
/**
|
||||||
Reserve some space in the header room of the net buffer.
|
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
|
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 some 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
|
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. But it should be enough for the network stack.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Len The length of buffer to be reserved from the header.
|
@param[in] Len The length of buffer to be reserved from the header.
|
||||||
@ -1396,14 +1391,14 @@ NetbufReserve (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate Len bytes of space from the header or tail of the buffer.
|
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 Pointer to the net buffer.
|
||||||
@param[in] Len The length of the buffer to be allocated.
|
@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 reserve the data
|
||||||
from head (TRUE) or tail (FALSE).
|
from head (TRUE) or tail (FALSE).
|
||||||
|
|
||||||
@return Pointer to the first byte of the allocated buffer,
|
@return Pointer to the first byte of the allocated buffer,
|
||||||
or NULL if there is no sufficient space.
|
or NULL if there is no sufficient space.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1416,14 +1411,14 @@ NetbufAllocSpace (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trim Len bytes from the header or tail of the net buffer.
|
Trim Len bytes from the header or tail of the net buffer.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Len The length of the data to be trimmed.
|
@param[in] Len The length of the data to be trimmed.
|
||||||
@param[in] FromHead The flag to indicate whether trim data from head
|
@param[in] FromHead The flag to indicate whether trim data from head
|
||||||
(TRUE) or tail (FALSE).
|
(TRUE) or tail (FALSE).
|
||||||
|
|
||||||
@return Length of the actually trimmed data, which may be less
|
@return Length of the actually trimmed data, which may be less
|
||||||
than Len if the TotalSize of Nbuf is less than Len.
|
than Len if the TotalSize of Nbuf is less than Len.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1436,11 +1431,11 @@ NetbufTrim (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copy Len bytes of data from the specific offset of the net buffer to the
|
Copy Len bytes of data from the specific offset of the net buffer to the
|
||||||
destination memory.
|
destination memory.
|
||||||
|
|
||||||
The Len bytes of data may cross several fragments of the net buffer.
|
The Len bytes of data may cross several fragments of the net buffer.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer.
|
@param[in] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Offset The sequence number of the first byte to copy.
|
@param[in] Offset The sequence number of the first byte to copy.
|
||||||
@param[in] Len Length of the data to copy.
|
@param[in] Len Length of the data to copy.
|
||||||
@ -1460,8 +1455,8 @@ NetbufCopy (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a NET_BUF from external blocks.
|
Build a NET_BUF from external blocks.
|
||||||
|
|
||||||
A new NET_BUF structure will be created from external blocks. An additional block
|
A new NET_BUF structure will be created from external blocks. An additional block
|
||||||
of memory will be allocated to hold reserved HeadSpace bytes of header room
|
of memory will be allocated to hold reserved HeadSpace bytes of header room
|
||||||
and existing HeadLen bytes of header, but the external blocks are shared by the
|
and existing HeadLen bytes of header, but the external blocks are shared by the
|
||||||
@ -1476,7 +1471,7 @@ NetbufCopy (
|
|||||||
@param[in] Arg The argument passed to ExtFree when ExtFree is
|
@param[in] Arg The argument passed to ExtFree when ExtFree is
|
||||||
called.
|
called.
|
||||||
|
|
||||||
@return Pointer to the net buffer built from the data blocks,
|
@return Pointer to the net buffer built from the data blocks,
|
||||||
or NULL if the allocation failed due to resource
|
or NULL if the allocation failed due to resource
|
||||||
limit.
|
limit.
|
||||||
|
|
||||||
@ -1494,13 +1489,13 @@ NetbufFromExt (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Build a fragment table to contain the fragments in the net buffer. This is the
|
Build a fragment table to contain the fragments in the net buffer. This is the
|
||||||
opposite operation of the NetbufFromExt.
|
opposite operation of the NetbufFromExt.
|
||||||
|
|
||||||
@param[in] Nbuf Point to the net buffer.
|
@param[in] Nbuf Point to the net buffer.
|
||||||
@param[in, out] ExtFragment Pointer to the data block.
|
@param[in, out] ExtFragment Pointer to the data block.
|
||||||
@param[in, out] ExtNum The number of the data blocks.
|
@param[in, out] ExtNum The number of the data blocks.
|
||||||
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than
|
@retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than
|
||||||
ExtNum.
|
ExtNum.
|
||||||
@retval EFI_SUCCESS Fragment table is built successfully.
|
@retval EFI_SUCCESS Fragment table is built successfully.
|
||||||
|
|
||||||
@ -1515,10 +1510,10 @@ NetbufBuildExt (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Build a net buffer from a list of net buffers.
|
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.
|
net buffer will be created through NetbufFromExt.
|
||||||
|
|
||||||
@param[in] BufList A List of the net buffer.
|
@param[in] BufList A List of the net buffer.
|
||||||
@param[in] HeadSpace The head space to be reserved.
|
@param[in] HeadSpace The head space to be reserved.
|
||||||
@param[in] HeaderLen The length of the protocol header. The function
|
@param[in] HeaderLen The length of the protocol header. The function
|
||||||
@ -1526,7 +1521,7 @@ NetbufBuildExt (
|
|||||||
@param[in] ExtFree Pointer to the caller provided free function.
|
@param[in] ExtFree Pointer to the caller provided free function.
|
||||||
@param[in] Arg The argument passed to ExtFree when ExtFree is called.
|
@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 Pointer to the net buffer built from the list of net
|
||||||
buffers.
|
buffers.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1578,10 +1573,10 @@ NetbufQueAlloc (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free a net buffer queue.
|
Free a net buffer queue.
|
||||||
|
|
||||||
Decrease the reference count of the net buffer queue by one. The real resource
|
Decrease the reference count of the net buffer queue by one. The real resource
|
||||||
free operation isn't performed until the reference count of the net buffer
|
free operation isn't performed until the reference count of the net buffer
|
||||||
queue is decreased to 0.
|
queue is decreased to 0.
|
||||||
|
|
||||||
@param[in] NbufQue Pointer to the net buffer queue to be freed.
|
@param[in] NbufQue Pointer to the net buffer queue to be freed.
|
||||||
@ -1598,7 +1593,7 @@ NetbufQueFree (
|
|||||||
|
|
||||||
@param[in, out] NbufQue Pointer to the net buffer queue.
|
@param[in, out] NbufQue Pointer to the net buffer queue.
|
||||||
|
|
||||||
@return Pointer to the net buffer removed from the specific queue,
|
@return Pointer to the net buffer removed from the specific queue,
|
||||||
or NULL if there is no net buffer in the specific queue.
|
or NULL if there is no net buffer in the specific queue.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1625,16 +1620,16 @@ NetbufQueAppend (
|
|||||||
/**
|
/**
|
||||||
Copy Len bytes of data from the net buffer queue at the specific offset to the
|
Copy Len bytes of data from the net buffer queue at the specific offset to the
|
||||||
destination memory.
|
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.
|
queue instead of the net buffer.
|
||||||
|
|
||||||
@param[in] NbufQue Pointer to the net buffer queue.
|
@param[in] NbufQue Pointer to the net buffer queue.
|
||||||
@param[in] Offset The sequence number of the first byte to copy.
|
@param[in] Offset The sequence number of the first byte to copy.
|
||||||
@param[in] Len Length of the data to copy.
|
@param[in] Len Length of the data to copy.
|
||||||
@param[out] Dest The destination of the data to copy to.
|
@param[out] Dest The destination of the data to copy to.
|
||||||
|
|
||||||
@return The length of the actual copied data, or 0 if the offset
|
@return The length of the actual copied data, or 0 if the offset
|
||||||
specified exceeds the total size of net buffer queue.
|
specified exceeds the total size of net buffer queue.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1648,9 +1643,9 @@ NetbufQueCopy (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trim Len bytes of data from the queue header and release any net buffer
|
Trim Len bytes of data from the queue header and release any net buffer
|
||||||
that is trimmed wholely.
|
that is trimmed wholely.
|
||||||
|
|
||||||
The trimming operation is the same as NetbufTrim but applies to the net buffer
|
The trimming operation is the same as NetbufTrim but applies to the net buffer
|
||||||
queue instead of the net buffer.
|
queue instead of the net buffer.
|
||||||
|
|
||||||
@ -1727,8 +1722,8 @@ NetbufChecksum (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Compute the checksum for TCP/UDP pseudo header.
|
Compute the checksum for TCP/UDP pseudo header.
|
||||||
|
|
||||||
Src and Dst are in network byte order, and Len is in host byte order.
|
Src and Dst are in network byte order, and Len is in host byte order.
|
||||||
|
|
||||||
@param[in] Src The source address of the packet.
|
@param[in] Src The source address of the packet.
|
||||||
@ -1749,8 +1744,8 @@ NetPseudoHeadChecksum (
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Compute the checksum for TCP6/UDP6 pseudo header.
|
Compute the checksum for TCP6/UDP6 pseudo header.
|
||||||
|
|
||||||
Src and Dst are in network byte order, and Len is in host byte order.
|
Src and Dst are in network byte order, and Len is in host byte order.
|
||||||
|
|
||||||
@param[in] Src The source address of the packet.
|
@param[in] Src The source address of the packet.
|
||||||
|
@ -24,12 +24,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Library/DpcLib.h>
|
#include <Library/DpcLib.h>
|
||||||
|
|
||||||
|
|
||||||
LIST_ENTRY mActiveIpIoList = {
|
GLOBAL_REMOVE_IF_UNREFERENCED LIST_ENTRY mActiveIpIoList = {
|
||||||
&mActiveIpIoList,
|
&mActiveIpIoList,
|
||||||
&mActiveIpIoList
|
&mActiveIpIoList
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData = {
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData = {
|
||||||
EFI_IP_PROTO_UDP,
|
EFI_IP_PROTO_UDP,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
@ -46,7 +46,7 @@ EFI_IP4_CONFIG_DATA mIp4IoDefaultIpConfigData = {
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData = {
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData = {
|
||||||
EFI_IP_PROTO_UDP,
|
EFI_IP_PROTO_UDP,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
@ -60,7 +60,7 @@ EFI_IP6_CONFIG_DATA mIp6IoDefaultIpConfigData = {
|
|||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
ICMP_ERROR_INFO mIcmpErrMap[10] = {
|
GLOBAL_REMOVE_IF_UNREFERENCED ICMP_ERROR_INFO mIcmpErrMap[10] = {
|
||||||
{FALSE, TRUE }, // ICMP_ERR_UNREACH_NET
|
{FALSE, TRUE }, // ICMP_ERR_UNREACH_NET
|
||||||
{FALSE, TRUE }, // ICMP_ERR_UNREACH_HOST
|
{FALSE, TRUE }, // ICMP_ERR_UNREACH_HOST
|
||||||
{TRUE, TRUE }, // ICMP_ERR_UNREACH_PROTOCOL
|
{TRUE, TRUE }, // ICMP_ERR_UNREACH_PROTOCOL
|
||||||
@ -73,7 +73,7 @@ ICMP_ERROR_INFO mIcmpErrMap[10] = {
|
|||||||
{FALSE, TRUE } // ICMP_ERR_PARAMPROB
|
{FALSE, TRUE } // ICMP_ERR_PARAMPROB
|
||||||
};
|
};
|
||||||
|
|
||||||
ICMP_ERROR_INFO mIcmp6ErrMap[10] = {
|
GLOBAL_REMOVE_IF_UNREFERENCED ICMP_ERROR_INFO mIcmp6ErrMap[10] = {
|
||||||
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_NET
|
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_NET
|
||||||
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_HOST
|
{FALSE, TRUE}, // ICMP6_ERR_UNREACH_HOST
|
||||||
{TRUE, TRUE}, // ICMP6_ERR_UNREACH_PROTOCOL
|
{TRUE, TRUE}, // ICMP6_ERR_UNREACH_PROTOCOL
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Network library.
|
Network library.
|
||||||
|
|
||||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Protocol/DriverBinding.h>
|
#include <Protocol/DriverBinding.h>
|
||||||
#include <Protocol/ServiceBinding.h>
|
#include <Protocol/ServiceBinding.h>
|
||||||
#include <Protocol/SimpleNetwork.h>
|
#include <Protocol/SimpleNetwork.h>
|
||||||
|
#include <Protocol/ManagedNetwork.h>
|
||||||
#include <Protocol/HiiConfigRouting.h>
|
#include <Protocol/HiiConfigRouting.h>
|
||||||
#include <Protocol/ComponentName.h>
|
#include <Protocol/ComponentName.h>
|
||||||
#include <Protocol/ComponentName2.h>
|
#include <Protocol/ComponentName2.h>
|
||||||
@ -33,14 +34,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
#include <Library/HiiLib.h>
|
#include <Library/HiiLib.h>
|
||||||
#include <Library/PrintLib.h>
|
#include <Library/PrintLib.h>
|
||||||
|
|
||||||
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mNetLibHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
|
||||||
|
|
||||||
#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE
|
#define NIC_ITEM_CONFIG_SIZE sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * MAX_IP4_CONFIG_IN_VARIABLE
|
||||||
|
|
||||||
//
|
//
|
||||||
// All the supported IP4 maskes in host byte order.
|
// All the supported IP4 maskes in host byte order.
|
||||||
//
|
//
|
||||||
IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = {
|
GLOBAL_REMOVE_IF_UNREFERENCED IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = {
|
||||||
0x00000000,
|
0x00000000,
|
||||||
0x80000000,
|
0x80000000,
|
||||||
0xC0000000,
|
0xC0000000,
|
||||||
@ -79,26 +78,25 @@ IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = {
|
|||||||
0xFFFFFFFF,
|
0xFFFFFFFF,
|
||||||
};
|
};
|
||||||
|
|
||||||
EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}};
|
GLOBAL_REMOVE_IF_UNREFERENCED EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Any error level digitally larger than mNetDebugLevelMax
|
// Any error level digitally larger than mNetDebugLevelMax
|
||||||
// will be silently discarded.
|
// will be silently discarded.
|
||||||
//
|
//
|
||||||
UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
|
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
|
||||||
UINT32 mSyslogPacketSeq = 0xDEADBEEF;
|
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogPacketSeq = 0xDEADBEEF;
|
||||||
|
|
||||||
//
|
|
||||||
// You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp
|
|
||||||
// here to direct the syslog packets to the syslog deamon. The
|
|
||||||
// default is broadcast to both the ethernet and IP.
|
|
||||||
//
|
//
|
||||||
UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
// You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp
|
||||||
UINT32 mSyslogDstIp = 0xffffffff;
|
// here to direct the syslog packets to the syslog deamon. The
|
||||||
UINT32 mSyslogSrcIp = 0;
|
// default is broadcast to both the ethernet and IP.
|
||||||
|
//
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogDstIp = 0xffffffff;
|
||||||
|
GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mSyslogSrcIp = 0;
|
||||||
|
|
||||||
CHAR8 *
|
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = {
|
||||||
mMonthName[] = {
|
|
||||||
"Jan",
|
"Jan",
|
||||||
"Feb",
|
"Feb",
|
||||||
"Mar",
|
"Mar",
|
||||||
@ -114,7 +112,7 @@ mMonthName[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Locate the handles that support SNP, then open one of them
|
Locate the handles that support SNP, then open one of them
|
||||||
to send the syslog packets. The caller isn't required to close
|
to send the syslog packets. The caller isn't required to close
|
||||||
the SNP after use because the SNP is opened by HandleProtocol.
|
the SNP after use because the SNP is opened by HandleProtocol.
|
||||||
|
|
||||||
@ -147,12 +145,12 @@ SyslogLocateSnp (
|
|||||||
if (EFI_ERROR (Status) || (HandleCount == 0)) {
|
if (EFI_ERROR (Status) || (HandleCount == 0)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Try to open one of the ethernet SNP protocol to send packet
|
// Try to open one of the ethernet SNP protocol to send packet
|
||||||
//
|
//
|
||||||
Snp = NULL;
|
Snp = NULL;
|
||||||
|
|
||||||
for (Index = 0; Index < HandleCount; Index++) {
|
for (Index = 0; Index < HandleCount; Index++) {
|
||||||
Status = gBS->HandleProtocol (
|
Status = gBS->HandleProtocol (
|
||||||
Handles[Index],
|
Handles[Index],
|
||||||
@ -160,10 +158,10 @@ SyslogLocateSnp (
|
|||||||
(VOID **) &Snp
|
(VOID **) &Snp
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
|
if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
|
||||||
(Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
|
(Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
|
||||||
(Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) {
|
(Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,18 +174,18 @@ SyslogLocateSnp (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Transmit a syslog packet synchronously through SNP. The Packet
|
Transmit a syslog packet synchronously through SNP. The Packet
|
||||||
already has the ethernet header prepended. This function should
|
already has the ethernet header prepended. This function should
|
||||||
fill in the source MAC because it will try to locate a SNP each
|
fill in the source MAC because it will try to locate a SNP each
|
||||||
time it is called to avoid the problem if SNP is unloaded.
|
time it is called to avoid the problem if SNP is unloaded.
|
||||||
This code snip is copied from MNP.
|
This code snip is copied from MNP.
|
||||||
|
|
||||||
@param[in] Packet - The Syslog packet
|
@param[in] Packet The Syslog packet
|
||||||
@param[in] Length - The length of the packet
|
@param[in] Length The length of the packet
|
||||||
|
|
||||||
|
@retval EFI_DEVICE_ERROR Failed to locate a usable SNP protocol
|
||||||
|
@retval EFI_TIMEOUT Timeout happened to send the packet.
|
||||||
|
@retval EFI_SUCCESS Packet is sent.
|
||||||
|
|
||||||
@retval EFI_DEVICE_ERROR - Failed to locate a usable SNP protocol
|
|
||||||
@retval EFI_TIMEOUT - Timeout happened to send the packet.
|
|
||||||
@retval EFI_SUCCESS - Packet is sent.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
SyslogSendPacket (
|
SyslogSendPacket (
|
||||||
@ -241,7 +239,7 @@ SyslogSendPacket (
|
|||||||
Status = EFI_DEVICE_ERROR;
|
Status = EFI_DEVICE_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// If Status is EFI_SUCCESS, the packet is put in the transmit queue.
|
// If Status is EFI_SUCCESS, the packet is put in the transmit queue.
|
||||||
// if Status is EFI_NOT_READY, the transmit engine of the network
|
// if Status is EFI_NOT_READY, the transmit engine of the network
|
||||||
@ -265,7 +263,7 @@ SyslogSendPacket (
|
|||||||
if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
|
if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Status is EFI_NOT_READY. Restart the timer event and
|
// Status is EFI_NOT_READY. Restart the timer event and
|
||||||
// call Snp->Transmit again.
|
// call Snp->Transmit again.
|
||||||
@ -281,20 +279,18 @@ ON_EXIT:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a syslog packet, including the Ethernet/Ip/Udp headers
|
Build a syslog packet, including the Ethernet/Ip/Udp headers
|
||||||
and user's message.
|
and user's message.
|
||||||
|
|
||||||
@param[in] Level - Syslog servity level
|
|
||||||
@param[in] Module - The module that generates the log
|
|
||||||
@param[in] File - The file that contains the current log
|
|
||||||
@param[in] Line - The line of code in the File that contains the current log
|
|
||||||
@param[in] Message - The log message
|
|
||||||
@param[in] BufLen - The lenght of the Buf
|
|
||||||
@param[out] Buf - The buffer to put the packet data
|
|
||||||
|
|
||||||
Returns:
|
@param[in] Level Syslog servity level
|
||||||
|
@param[in] Module The module that generates the log
|
||||||
|
@param[in] File The file that contains the current log
|
||||||
|
@param[in] Line The line of code in the File that contains the current log
|
||||||
|
@param[in] Message The log message
|
||||||
|
@param[in] BufLen The lenght of the Buf
|
||||||
|
@param[out] Buf The buffer to put the packet data
|
||||||
|
|
||||||
The length of the syslog packet built.
|
@return The length of the syslog packet built.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
UINT32
|
UINT32
|
||||||
@ -305,7 +301,7 @@ SyslogBuildPacket (
|
|||||||
IN UINT32 Line,
|
IN UINT32 Line,
|
||||||
IN UINT8 *Message,
|
IN UINT8 *Message,
|
||||||
IN UINT32 BufLen,
|
IN UINT32 BufLen,
|
||||||
OUT CHAR8 *Buf
|
OUT CHAR8 *Buf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ETHER_HEAD *Ether;
|
ETHER_HEAD *Ether;
|
||||||
@ -316,7 +312,7 @@ SyslogBuildPacket (
|
|||||||
UINT32 Len;
|
UINT32 Len;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Fill in the Ethernet header. Leave alone the source MAC.
|
// Fill in the Ethernet header. Leave alone the source MAC.
|
||||||
// SyslogSendPacket will fill in the address for us.
|
// SyslogSendPacket will fill in the address for us.
|
||||||
//
|
//
|
||||||
Ether = (ETHER_HEAD *) Buf;
|
Ether = (ETHER_HEAD *) Buf;
|
||||||
@ -374,7 +370,7 @@ SyslogBuildPacket (
|
|||||||
BufLen,
|
BufLen,
|
||||||
"<%d> %a %d %d:%d:%d ",
|
"<%d> %a %d %d:%d:%d ",
|
||||||
Pri,
|
Pri,
|
||||||
mMonthName [Time.Month-1],
|
mMonthName [Time.Month-1],
|
||||||
Time.Day,
|
Time.Day,
|
||||||
Time.Hour,
|
Time.Hour,
|
||||||
Time.Minute,
|
Time.Minute,
|
||||||
@ -383,9 +379,9 @@ SyslogBuildPacket (
|
|||||||
Len--;
|
Len--;
|
||||||
|
|
||||||
Len += (UINT32) AsciiSPrint (
|
Len += (UINT32) AsciiSPrint (
|
||||||
Buf + Len,
|
Buf + Len,
|
||||||
BufLen - Len,
|
BufLen - Len,
|
||||||
"Tiano %a: %a (Line: %d File: %a)",
|
"Tiano %a: %a (Line: %d File: %a)",
|
||||||
Module,
|
Module,
|
||||||
Message,
|
Message,
|
||||||
Line,
|
Line,
|
||||||
@ -407,23 +403,23 @@ SyslogBuildPacket (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate a buffer, then format the message to it. This is a
|
Allocate a buffer, then format the message to it. This is a
|
||||||
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
||||||
these macros treats the variable length print parameters as a
|
these macros treats the variable length print parameters as a
|
||||||
single parameter, and pass it to the NetDebugASPrint. For
|
single parameter, and pass it to the NetDebugASPrint. For
|
||||||
example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
|
example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
|
||||||
if extracted to:
|
if extracted to:
|
||||||
|
|
||||||
NetDebugOutput (
|
NetDebugOutput (
|
||||||
NETDEBUG_LEVEL_TRACE,
|
NETDEBUG_LEVEL_TRACE,
|
||||||
"Tcp",
|
"Tcp",
|
||||||
__FILE__,
|
__FILE__,
|
||||||
__LINE__,
|
__LINE__,
|
||||||
NetDebugASPrint ("State transit to %a\n", Name)
|
NetDebugASPrint ("State transit to %a\n", Name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@param Format The ASCII format string.
|
@param Format The ASCII format string.
|
||||||
@param ... The variable length parameter whose format is determined
|
@param ... The variable length parameter whose format is determined
|
||||||
by the Format string.
|
by the Format string.
|
||||||
|
|
||||||
@return The buffer containing the formatted message,
|
@return The buffer containing the formatted message,
|
||||||
@ -466,12 +462,12 @@ NetDebugASPrint (
|
|||||||
|
|
||||||
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
||||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet
|
@retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet
|
||||||
@retval EFI_SUCCESS The log is discard because that it is more verbose
|
@retval EFI_SUCCESS The log is discard because that it is more verbose
|
||||||
than the mNetDebugLevelMax. Or, it has been sent out.
|
than the mNetDebugLevelMax. Or, it has been sent out.
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
NetDebugOutput (
|
NetDebugOutput (
|
||||||
IN UINT32 Level,
|
IN UINT32 Level,
|
||||||
IN UINT8 *Module,
|
IN UINT8 *Module,
|
||||||
IN UINT8 *File,
|
IN UINT8 *File,
|
||||||
IN UINT32 Line,
|
IN UINT32 Line,
|
||||||
@ -493,7 +489,7 @@ NetDebugOutput (
|
|||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Allocate a maxium of 1024 bytes, the caller should ensure
|
// Allocate a maxium of 1024 bytes, the caller should ensure
|
||||||
// that the message plus the ethernet/ip/udp header is shorter
|
// that the message plus the ethernet/ip/udp header is shorter
|
||||||
@ -505,7 +501,7 @@ NetDebugOutput (
|
|||||||
Status = EFI_OUT_OF_RESOURCES;
|
Status = EFI_OUT_OF_RESOURCES;
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Build the message: Ethernet header + IP header + Udp Header + user data
|
// Build the message: Ethernet header + IP header + Udp Header + user data
|
||||||
//
|
//
|
||||||
@ -528,8 +524,8 @@ ON_EXIT:
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
Return the length of the mask.
|
Return the length of the mask.
|
||||||
|
|
||||||
Return the length of the mask, the correct value is from 0 to 32.
|
Return the length of the mask, the correct value is from 0 to 32.
|
||||||
If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.
|
If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.
|
||||||
NetMask is in the host byte order.
|
NetMask is in the host byte order.
|
||||||
@ -537,7 +533,7 @@ ON_EXIT:
|
|||||||
@param[in] NetMask The netmask to get the length from.
|
@param[in] NetMask The netmask to get the length from.
|
||||||
|
|
||||||
@return The length of the netmask, IP4_MASK_NUM if the mask is invalid.
|
@return The length of the netmask, IP4_MASK_NUM if the mask is invalid.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
INTN
|
INTN
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -561,19 +557,19 @@ NetGetMaskLength (
|
|||||||
/**
|
/**
|
||||||
Return the class of the IP address, such as class A, B, C.
|
Return the class of the IP address, such as class A, B, C.
|
||||||
Addr is in host byte order.
|
Addr is in host byte order.
|
||||||
|
|
||||||
The address of class A starts with 0.
|
The address of class A starts with 0.
|
||||||
If the address belong to class A, return IP4_ADDR_CLASSA.
|
If the address belong to class A, return IP4_ADDR_CLASSA.
|
||||||
The address of class B starts with 10.
|
The address of class B starts with 10.
|
||||||
If the address belong to class B, return IP4_ADDR_CLASSB.
|
If the address belong to class B, return IP4_ADDR_CLASSB.
|
||||||
The address of class C starts with 110.
|
The address of class C starts with 110.
|
||||||
If the address belong to class C, return IP4_ADDR_CLASSC.
|
If the address belong to class C, return IP4_ADDR_CLASSC.
|
||||||
The address of class D starts with 1110.
|
The address of class D starts with 1110.
|
||||||
If the address belong to class D, return IP4_ADDR_CLASSD.
|
If the address belong to class D, return IP4_ADDR_CLASSD.
|
||||||
The address of class E starts with 1111.
|
The address of class E starts with 1111.
|
||||||
If the address belong to class E, return IP4_ADDR_CLASSE.
|
If the address belong to class E, return IP4_ADDR_CLASSE.
|
||||||
|
|
||||||
|
|
||||||
@param[in] Addr The address to get the class from.
|
@param[in] Addr The address to get the class from.
|
||||||
|
|
||||||
@return IP address class, such as IP4_ADDR_CLASSA.
|
@return IP address class, such as IP4_ADDR_CLASSA.
|
||||||
@ -611,10 +607,10 @@ NetGetIpClass (
|
|||||||
/**
|
/**
|
||||||
Check whether the IP is a valid unicast address according to
|
Check whether the IP is a valid unicast address according to
|
||||||
the netmask. If NetMask is zero, use the IP address's class to get the default mask.
|
the netmask. If NetMask is zero, use the IP address's class to get the default mask.
|
||||||
|
|
||||||
If Ip is 0, IP is not a valid unicast address.
|
If Ip is 0, IP is not a valid unicast address.
|
||||||
Class D address is used for multicasting and class E address is reserved for future. If Ip
|
Class D address is used for multicasting and class E address is reserved for future. If Ip
|
||||||
belongs to class D or class E, IP is not a valid unicast address.
|
belongs to class D or class E, IP is 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.
|
If all bits of the host address of IP are 0 or 1, IP is also not a valid unicast address.
|
||||||
|
|
||||||
@param[in] Ip The IP to check against.
|
@param[in] Ip The IP to check against.
|
||||||
@ -656,21 +652,21 @@ NetIp4IsUnicast (
|
|||||||
a valid unicast address. If the address is unspecified ::, it is not a valid
|
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
|
unicast address to be assigned to any node. If the address is loopback address
|
||||||
::1, it is also not a valid unicast address to be assigned to any physical
|
::1, it is also not a valid unicast address to be assigned to any physical
|
||||||
interface.
|
interface.
|
||||||
|
|
||||||
@param[in] Ip6 The IPv6 address to check against.
|
@param[in] Ip6 The IPv6 address to check against.
|
||||||
|
|
||||||
@return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.
|
@return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsValidUnicast (
|
NetIp6IsValidUnicast (
|
||||||
IN EFI_IPv6_ADDRESS *Ip6
|
IN EFI_IPv6_ADDRESS *Ip6
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 Byte;
|
UINT8 Byte;
|
||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
|
|
||||||
if (Ip6->Addr[0] == 0xFF) {
|
if (Ip6->Addr[0] == 0xFF) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -687,7 +683,7 @@ NetIp6IsValidUnicast (
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -697,7 +693,7 @@ NetIp6IsValidUnicast (
|
|||||||
|
|
||||||
@retval TRUE - Yes, unspecified
|
@retval TRUE - Yes, unspecified
|
||||||
@retval FALSE - No
|
@retval FALSE - No
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsUnspecifiedAddr (
|
NetIp6IsUnspecifiedAddr (
|
||||||
@ -722,7 +718,7 @@ NetIp6IsUnspecifiedAddr (
|
|||||||
|
|
||||||
@retval TRUE - Yes, link-local address
|
@retval TRUE - Yes, link-local address
|
||||||
@retval FALSE - No
|
@retval FALSE - No
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsLinkLocalAddr (
|
NetIp6IsLinkLocalAddr (
|
||||||
@ -730,13 +726,13 @@ NetIp6IsLinkLocalAddr (
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINT8 Index;
|
UINT8 Index;
|
||||||
|
|
||||||
ASSERT (Ip6 != NULL);
|
ASSERT (Ip6 != NULL);
|
||||||
|
|
||||||
if (Ip6->Addr[0] != 0xFE) {
|
if (Ip6->Addr[0] != 0xFE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ip6->Addr[1] != 0x80) {
|
if (Ip6->Addr[1] != 0x80) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -759,7 +755,7 @@ NetIp6IsLinkLocalAddr (
|
|||||||
|
|
||||||
@retval TRUE - Yes, connected.
|
@retval TRUE - Yes, connected.
|
||||||
@retval FALSE - No.
|
@retval FALSE - No.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
NetIp6IsNetEqual (
|
NetIp6IsNetEqual (
|
||||||
@ -773,14 +769,14 @@ NetIp6IsNetEqual (
|
|||||||
UINT8 Mask;
|
UINT8 Mask;
|
||||||
|
|
||||||
ASSERT (Ip1 != NULL && Ip2 != NULL);
|
ASSERT (Ip1 != NULL && Ip2 != NULL);
|
||||||
|
|
||||||
if (PrefixLength == 0) {
|
if (PrefixLength == 0) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte = (UINT8) (PrefixLength / 8);
|
Byte = (UINT8) (PrefixLength / 8);
|
||||||
Bit = (UINT8) (PrefixLength % 8);
|
Bit = (UINT8) (PrefixLength % 8);
|
||||||
|
|
||||||
if (CompareMem (Ip1, Ip2, Byte) != 0) {
|
if (CompareMem (Ip1, Ip2, Byte) != 0) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -790,9 +786,9 @@ NetIp6IsNetEqual (
|
|||||||
|
|
||||||
if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
|
if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -831,11 +827,11 @@ Ip6Swap128 (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize a random seed using current time.
|
Initialize a random seed using current time.
|
||||||
|
|
||||||
Get current time first. Then initialize a random seed based on some basic
|
Get current time first. Then initialize a random seed based on some basic
|
||||||
mathematics operation on the hour, day, minute, second, nanosecond and year
|
mathematics operation on the hour, day, minute, second, nanosecond and year
|
||||||
of the current time.
|
of the current time.
|
||||||
|
|
||||||
@return The random seed initialized with current time.
|
@return The random seed initialized with current time.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -859,8 +855,8 @@ NetRandomInitSeed (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Extract a UINT32 from a byte stream.
|
Extract a UINT32 from a byte stream.
|
||||||
|
|
||||||
Copy a UINT32 from a byte stream, then converts it from Network
|
Copy a UINT32 from a byte stream, then converts it from Network
|
||||||
byte order to host byte order. Use this function to avoid alignment error.
|
byte order to host byte order. Use this function to avoid alignment error.
|
||||||
|
|
||||||
@param[in] Buf The buffer to extract the UINT32.
|
@param[in] Buf The buffer to extract the UINT32.
|
||||||
@ -882,14 +878,14 @@ NetGetUint32 (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Put a UINT32 to the byte stream in network byte order.
|
Put a UINT32 to the byte stream in network byte order.
|
||||||
|
|
||||||
Converts a UINT32 from host byte order to network byte order. Then copy it to the
|
Converts a UINT32 from host byte order to network byte order. Then copy it to the
|
||||||
byte stream.
|
byte stream.
|
||||||
|
|
||||||
@param[in, out] Buf The buffer to put the UINT32.
|
@param[in, out] Buf The buffer to put the UINT32.
|
||||||
@param[in] Data The data to put.
|
@param[in] Data The data to put.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -905,16 +901,16 @@ NetPutUint32 (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Remove the first node entry on the list, and return the removed node entry.
|
Remove the first node entry on the list, and return the removed node entry.
|
||||||
|
|
||||||
Removes the first node Entry from a doubly linked list. It is up to the caller of
|
Removes the first node Entry from a doubly linked list. It is up to the caller of
|
||||||
this function to release the memory used by the first node if that is required. On
|
this function to release the memory used by the first node if that is required. On
|
||||||
exit, the removed node is returned.
|
exit, the removed node is returned.
|
||||||
|
|
||||||
If Head is NULL, then ASSERT().
|
If Head is NULL, then ASSERT().
|
||||||
If Head was not initialized, then ASSERT().
|
If Head was not initialized, then ASSERT().
|
||||||
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
||||||
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
||||||
then ASSERT().
|
then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Head The list header.
|
@param[in, out] Head The list header.
|
||||||
|
|
||||||
@ -953,14 +949,14 @@ NetListRemoveHead (
|
|||||||
|
|
||||||
Removes the last node entry from a doubly linked list. It is up to the caller of
|
Removes the last node entry from a doubly linked list. It is up to the caller of
|
||||||
this function to release the memory used by the first node if that is required. On
|
this function to release the memory used by the first node if that is required. On
|
||||||
exit, the removed node is returned.
|
exit, the removed node is returned.
|
||||||
|
|
||||||
If Head is NULL, then ASSERT().
|
If Head is NULL, then ASSERT().
|
||||||
If Head was not initialized, then ASSERT().
|
If Head was not initialized, then ASSERT().
|
||||||
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
|
||||||
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
linked list including the head node is greater than or equal to PcdMaximumLinkedListLength,
|
||||||
then ASSERT().
|
then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Head The list head.
|
@param[in, out] Head The list head.
|
||||||
|
|
||||||
@return The last node entry that is removed from the list, NULL if the list is empty.
|
@return The last node entry that is removed from the list, NULL if the list is empty.
|
||||||
@ -995,10 +991,10 @@ NetListRemoveTail (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Insert a new node entry after a designated node entry of a doubly linked list.
|
Insert a new node entry after a designated node entry of a doubly linked list.
|
||||||
|
|
||||||
Inserts a new node entry donated by NewEntry after the node entry donated by PrevEntry
|
Inserts a new node entry donated by NewEntry after the node entry donated by PrevEntry
|
||||||
of the doubly linked list.
|
of the doubly linked list.
|
||||||
|
|
||||||
@param[in, out] PrevEntry The previous entry to insert after.
|
@param[in, out] PrevEntry The previous entry to insert after.
|
||||||
@param[in, out] NewEntry The new entry to insert.
|
@param[in, out] NewEntry The new entry to insert.
|
||||||
|
|
||||||
@ -1019,10 +1015,10 @@ NetListInsertAfter (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Insert a new node entry before a designated node entry of a doubly linked list.
|
Insert a new node entry before a designated node entry of a doubly linked list.
|
||||||
|
|
||||||
Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry
|
Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry
|
||||||
of the doubly linked list.
|
of the doubly linked list.
|
||||||
|
|
||||||
@param[in, out] PostEntry The entry to insert before.
|
@param[in, out] PostEntry The entry to insert before.
|
||||||
@param[in, out] NewEntry The new entry to insert.
|
@param[in, out] NewEntry The new entry to insert.
|
||||||
|
|
||||||
@ -1043,15 +1039,15 @@ NetListInsertBefore (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
|
Initialize the netmap. Netmap is a reposity to keep the <Key, Value> pairs.
|
||||||
|
|
||||||
Initialize the forward and backward links of two head nodes donated by Map->Used
|
Initialize the forward and backward links of two head nodes donated by Map->Used
|
||||||
and Map->Recycled of two doubly linked lists.
|
and Map->Recycled of two doubly linked lists.
|
||||||
Initializes the count of the <Key, Value> pairs in the netmap to zero.
|
Initializes the count of the <Key, Value> pairs in the netmap to zero.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the address of Map->Used is NULL, then ASSERT().
|
If the address of Map->Used is NULL, then ASSERT().
|
||||||
If the address of Map->Recycled is NULl, then ASSERT().
|
If the address of Map->Recycled is NULl, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to initialize.
|
@param[in, out] Map The netmap to initialize.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1071,13 +1067,13 @@ NetMapInit (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
To clean up the netmap, that is, release allocated memories.
|
To clean up the netmap, that is, release allocated memories.
|
||||||
|
|
||||||
Removes all nodes of the Used doubly linked list and free memory of all related netmap items.
|
Removes all nodes of the Used doubly linked list and free memory of all related netmap items.
|
||||||
Removes all nodes of the Recycled doubly linked list and free memory of all related netmap items.
|
Removes all nodes of the Recycled doubly linked list and free memory of all related netmap items.
|
||||||
The number of the <Key, Value> pairs in the netmap is set to be zero.
|
The number of the <Key, Value> pairs in the netmap is set to be zero.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to clean up.
|
@param[in, out] Map The netmap to clean up.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1117,12 +1113,12 @@ NetMapClean (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Test whether the netmap is empty and return true if it is.
|
Test whether the netmap is empty and return true if it is.
|
||||||
|
|
||||||
If the number of the <Key, Value> pairs in the netmap is zero, return TRUE.
|
If the number of the <Key, Value> pairs in the netmap is zero, return TRUE.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
|
|
||||||
@param[in] Map The net map to test.
|
@param[in] Map The net map to test.
|
||||||
|
|
||||||
@return TRUE if the netmap is empty, otherwise FALSE.
|
@return TRUE if the netmap is empty, otherwise FALSE.
|
||||||
@ -1158,15 +1154,15 @@ NetMapGetCount (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return one allocated item.
|
Return one allocated item.
|
||||||
|
|
||||||
If the Recycled doubly linked list of the netmap is empty, it will try to allocate
|
If the Recycled doubly linked list of the netmap is empty, it will try to allocate
|
||||||
a batch of items if there are enough resources and add corresponding nodes to the begining
|
a batch of items if there are enough resources and add corresponding nodes to the begining
|
||||||
of the Recycled doubly linked list of the netmap. Otherwise, it will directly remove
|
of the Recycled doubly linked list of the netmap. Otherwise, it will directly remove
|
||||||
the fist node entry of the Recycled doubly linked list and return the corresponding item.
|
the fist node entry of the Recycled doubly linked list and return the corresponding item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to allocate item for.
|
@param[in, out] Map The netmap to allocate item for.
|
||||||
|
|
||||||
@return The allocated item. If NULL, the
|
@return The allocated item. If NULL, the
|
||||||
@ -1211,13 +1207,13 @@ NetMapAllocItem (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate an item to save the <Key, Value> pair to the head of the netmap.
|
Allocate an item to save the <Key, Value> pair to the head of the netmap.
|
||||||
|
|
||||||
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
||||||
to the beginning of the Used doubly linked list. The number of the <Key, Value>
|
to the beginning of the Used doubly linked list. The number of the <Key, Value>
|
||||||
pairs in the netmap increase by 1.
|
pairs in the netmap increase by 1.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to insert into.
|
@param[in, out] Map The netmap to insert into.
|
||||||
@param[in] Key The user's key.
|
@param[in] Key The user's key.
|
||||||
@param[in] Value The user's value for the key.
|
@param[in] Value The user's value for the key.
|
||||||
@ -1257,11 +1253,11 @@ NetMapInsertHead (
|
|||||||
Allocate an item to save the <Key, Value> pair to the tail of the netmap.
|
Allocate an item to save the <Key, Value> pair to the tail of the netmap.
|
||||||
|
|
||||||
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
Allocate an item to save the <Key, Value> pair and add corresponding node entry
|
||||||
to the tail of the Used doubly linked list. The number of the <Key, Value>
|
to the tail of the Used doubly linked list. The number of the <Key, Value>
|
||||||
pairs in the netmap increase by 1.
|
pairs in the netmap increase by 1.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to insert into.
|
@param[in, out] Map The netmap to insert into.
|
||||||
@param[in] Key The user's key.
|
@param[in] Key The user's key.
|
||||||
@param[in] Value The user's value for the key.
|
@param[in] Value The user's value for the key.
|
||||||
@ -1327,12 +1323,12 @@ NetItemInMap (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Find the key in the netmap and returns the point to the item contains the Key.
|
Find the key in the netmap and returns the point to the item contains the Key.
|
||||||
|
|
||||||
Iterate the Used doubly linked list of the netmap to get every item. Compare the key of every
|
Iterate the Used doubly linked list of the netmap to get every item. Compare the key of every
|
||||||
item with the key to search. It returns the point to the item contains the Key if found.
|
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 Map is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Map The netmap to search within.
|
@param[in] Map The netmap to search within.
|
||||||
@param[in] Key The key to search.
|
@param[in] Key The key to search.
|
||||||
|
|
||||||
@ -1365,16 +1361,16 @@ NetMapFindKey (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Remove the node entry of the item from the netmap and return the key of the removed item.
|
Remove the node entry of the item from the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the node entry of the item from the Used doubly linked list of the netmap.
|
Remove the node entry of the item from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry of the item to the Recycled doubly linked list of the netmap. If Value is not NULL,
|
entry of the item to the Recycled doubly linked list of the netmap. If Value is not NULL,
|
||||||
Value will point to the value of the item. It returns the key of the removed item.
|
Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If Item is NULL, then ASSERT().
|
If Item is NULL, then ASSERT().
|
||||||
if item in not in the netmap, then ASSERT().
|
if item in not in the netmap, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the item from.
|
@param[in, out] Map The netmap to remove the item from.
|
||||||
@param[in, out] Item The item to remove.
|
@param[in, out] Item The item to remove.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
@ -1408,14 +1404,14 @@ NetMapRemoveItem (
|
|||||||
/**
|
/**
|
||||||
Remove the first node entry on the netmap and return the key of the removed item.
|
Remove the first node entry on the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the first node entry from the Used doubly linked list of the netmap.
|
Remove the first node entry from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
||||||
parameter Value will point to the value of the item. It returns the key of the removed item.
|
parameter Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the Used doubly linked list is empty, then ASSERT().
|
If the Used doubly linked list is empty, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the head from.
|
@param[in, out] Map The netmap to remove the head from.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
|
|
||||||
@ -1453,14 +1449,14 @@ NetMapRemoveHead (
|
|||||||
/**
|
/**
|
||||||
Remove the last node entry on the netmap and return the key of the removed item.
|
Remove the last node entry on the netmap and return the key of the removed item.
|
||||||
|
|
||||||
Remove the last node entry from the Used doubly linked list of the netmap.
|
Remove the last node entry from the Used doubly linked list of the netmap.
|
||||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||||
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
entry to the Recycled doubly linked list of the netmap. If parameter Value is not NULL,
|
||||||
parameter Value will point to the value of the item. It returns the key of the removed item.
|
parameter Value will point to the value of the item. It returns the key of the removed item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If the Used doubly linked list is empty, then ASSERT().
|
If the Used doubly linked list is empty, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] Map The netmap to remove the tail from.
|
@param[in, out] Map The netmap to remove the tail from.
|
||||||
@param[out] Value The variable to receive the value if not NULL.
|
@param[out] Value The variable to receive the value if not NULL.
|
||||||
|
|
||||||
@ -1497,14 +1493,14 @@ NetMapRemoveTail (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Iterate through the netmap and call CallBack for each item.
|
Iterate through the netmap and call CallBack for each item.
|
||||||
|
|
||||||
It will contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
|
It will contiue the traverse if CallBack returns EFI_SUCCESS, otherwise, break
|
||||||
from the loop. It returns the CallBack's last return value. This function is
|
from the loop. It returns the CallBack's last return value. This function is
|
||||||
delete safe for the current item.
|
delete safe for the current item.
|
||||||
|
|
||||||
If Map is NULL, then ASSERT().
|
If Map is NULL, then ASSERT().
|
||||||
If CallBack is NULL, then ASSERT().
|
If CallBack is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Map The Map to iterate through.
|
@param[in] Map The Map to iterate through.
|
||||||
@param[in] CallBack The callback function to call for each item.
|
@param[in] CallBack The callback function to call for each item.
|
||||||
@param[in] Arg The opaque parameter to the callback.
|
@param[in] Arg The opaque parameter to the callback.
|
||||||
@ -1555,7 +1551,7 @@ NetMapIterate (
|
|||||||
|
|
||||||
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
|
Disconnect the driver specified by ImageHandle from all the devices in the handle database.
|
||||||
Uninstall all the protocols installed in the driver entry point.
|
Uninstall all the protocols installed in the driver entry point.
|
||||||
|
|
||||||
@param[in] ImageHandle The drivers' driver image.
|
@param[in] ImageHandle The drivers' driver image.
|
||||||
|
|
||||||
@retval EFI_SUCCESS The image is unloaded.
|
@retval EFI_SUCCESS The image is unloaded.
|
||||||
@ -1669,12 +1665,12 @@ NetLibDefaultUnload (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Create a child of the service that is identified by ServiceBindingGuid.
|
Create a child of the service that is identified by ServiceBindingGuid.
|
||||||
|
|
||||||
Get the ServiceBinding Protocol first, then use it to create a child.
|
Get the ServiceBinding Protocol first, then use it to create a child.
|
||||||
|
|
||||||
If ServiceBindingGuid is NULL, then ASSERT().
|
If ServiceBindingGuid is NULL, then ASSERT().
|
||||||
If ChildHandle is NULL, then ASSERT().
|
If ChildHandle is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Controller The controller which has the service installed.
|
@param[in] Controller The controller which has the service installed.
|
||||||
@param[in] Image The image handle used to open service.
|
@param[in] Image The image handle used to open service.
|
||||||
@param[in] ServiceBindingGuid The service's Guid.
|
@param[in] ServiceBindingGuid The service's Guid.
|
||||||
@ -1725,11 +1721,11 @@ NetLibCreateServiceChild (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Destory a child of the service that is identified by ServiceBindingGuid.
|
Destory a child of the service that is identified by ServiceBindingGuid.
|
||||||
|
|
||||||
Get the ServiceBinding Protocol first, then use it to destroy a child.
|
Get the ServiceBinding Protocol first, then use it to destroy a child.
|
||||||
|
|
||||||
If ServiceBindingGuid is NULL, then ASSERT().
|
If ServiceBindingGuid is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] Controller The controller which has the service installed.
|
@param[in] Controller The controller which has the service installed.
|
||||||
@param[in] Image The image handle used to open service.
|
@param[in] Image The image handle used to open service.
|
||||||
@param[in] ServiceBindingGuid The service's Guid.
|
@param[in] ServiceBindingGuid The service's Guid.
|
||||||
@ -1793,7 +1789,7 @@ NetLibDestroyServiceChild (
|
|||||||
get the simple network protocol.
|
get the simple network protocol.
|
||||||
@param[out] MacString The pointer to store the address of the string
|
@param[out] MacString The pointer to store the address of the string
|
||||||
representation of the mac address.
|
representation of the mac address.
|
||||||
|
|
||||||
@retval EFI_SUCCESS Convert the mac address a unicode string successfully.
|
@retval EFI_SUCCESS Convert the mac address a unicode string successfully.
|
||||||
@retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
|
@retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
|
||||||
@retval Others Failed to open the simple network protocol.
|
@retval Others Failed to open the simple network protocol.
|
||||||
@ -1811,6 +1807,7 @@ NetLibGetMacString (
|
|||||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||||
EFI_SIMPLE_NETWORK_MODE *Mode;
|
EFI_SIMPLE_NETWORK_MODE *Mode;
|
||||||
CHAR16 *MacAddress;
|
CHAR16 *MacAddress;
|
||||||
|
UINT8 *HwAddress;
|
||||||
UINTN Index;
|
UINTN Index;
|
||||||
|
|
||||||
*MacString = NULL;
|
*MacString = NULL;
|
||||||
@ -1840,18 +1837,18 @@ NetLibGetMacString (
|
|||||||
if (MacAddress == NULL) {
|
if (MacAddress == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
*MacString = MacAddress;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Convert the mac address into a unicode string.
|
// Convert the mac address into a unicode string.
|
||||||
//
|
//
|
||||||
|
HwAddress = Mode->CurrentAddress.Addr;
|
||||||
for (Index = 0; Index < Mode->HwAddressSize; Index++) {
|
for (Index = 0; Index < Mode->HwAddressSize; Index++) {
|
||||||
MacAddress[Index * 2] = (CHAR16) mNetLibHexStr[(Mode->CurrentAddress.Addr[Index] >> 4) & 0x0F];
|
MacAddress += UnicodeValueToString (MacAddress, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
|
||||||
MacAddress[Index * 2 + 1] = (CHAR16) mNetLibHexStr[Mode->CurrentAddress.Addr[Index] & 0x0F];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MacAddress[Mode->HwAddressSize * 2] = L'\0';
|
MacAddress[Mode->HwAddressSize * 2] = L'\0';
|
||||||
|
|
||||||
*MacString = MacAddress;
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1860,11 +1857,11 @@ NetLibGetMacString (
|
|||||||
Check the default address used by the IPv4 driver is static or dynamic (acquired
|
Check the default address used by the IPv4 driver is static or dynamic (acquired
|
||||||
from DHCP).
|
from DHCP).
|
||||||
|
|
||||||
If the controller handle does not have the NIC Ip4 Config Protocol installed, the
|
If the controller handle does not have the NIC Ip4 Config Protocol installed, the
|
||||||
default address is static. If the EFI variable to save the configuration is not found,
|
default address is static. If the EFI variable to save the configuration is not found,
|
||||||
the default address is static. Otherwise, get the result from the EFI variable which
|
the default address is static. Otherwise, get the result from the EFI variable which
|
||||||
saving the configuration.
|
saving the configuration.
|
||||||
|
|
||||||
@param[in] Controller The controller handle which has the NIC Ip4 Config Protocol
|
@param[in] Controller The controller handle which has the NIC Ip4 Config Protocol
|
||||||
relative with the default address to judge.
|
relative with the default address to judge.
|
||||||
|
|
||||||
@ -1911,7 +1908,7 @@ NetLibDefaultAddressIsStatic (
|
|||||||
if (ConfigHdr == NULL) {
|
if (ConfigHdr == NULL) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Len = StrLen (ConfigHdr);
|
Len = StrLen (ConfigHdr);
|
||||||
ConfigResp = AllocateZeroPool ((Len + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
|
ConfigResp = AllocateZeroPool ((Len + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
|
||||||
if (ConfigResp == NULL) {
|
if (ConfigResp == NULL) {
|
||||||
@ -1921,10 +1918,10 @@ NetLibDefaultAddressIsStatic (
|
|||||||
|
|
||||||
String = ConfigResp + Len;
|
String = ConfigResp + Len;
|
||||||
UnicodeSPrint (
|
UnicodeSPrint (
|
||||||
String,
|
String,
|
||||||
(8 + 4 + 7 + 4 + 1) * sizeof (CHAR16),
|
(8 + 4 + 7 + 4 + 1) * sizeof (CHAR16),
|
||||||
L"&OFFSET=%04X&WIDTH=%04X",
|
L"&OFFSET=%04X&WIDTH=%04X",
|
||||||
OFFSET_OF (NIC_IP4_CONFIG_INFO, Source),
|
OFFSET_OF (NIC_IP4_CONFIG_INFO, Source),
|
||||||
sizeof (UINT32)
|
sizeof (UINT32)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -1957,7 +1954,7 @@ NetLibDefaultAddressIsStatic (
|
|||||||
}
|
}
|
||||||
|
|
||||||
IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC);
|
IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC);
|
||||||
|
|
||||||
ON_EXIT:
|
ON_EXIT:
|
||||||
|
|
||||||
if (AccessResults != NULL) {
|
if (AccessResults != NULL) {
|
||||||
@ -1978,7 +1975,7 @@ ON_EXIT:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Create an IPv4 device path node.
|
Create an IPv4 device path node.
|
||||||
|
|
||||||
The header type of IPv4 device path node is MESSAGING_DEVICE_PATH.
|
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 header subtype of IPv4 device path node is MSG_IPv4_DP.
|
||||||
The length of the IPv4 device path node in bytes is 19.
|
The length of the IPv4 device path node in bytes is 19.
|
||||||
@ -2028,7 +2025,7 @@ NetLibCreateIPv4DPathNode (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Create an IPv6 device path node.
|
Create an IPv6 device path node.
|
||||||
|
|
||||||
The header type of IPv6 device path node is MESSAGING_DEVICE_PATH.
|
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 header subtype of IPv6 device path node is MSG_IPv6_DP.
|
||||||
Get other info from parameters to make up the whole IPv6 device path node.
|
Get other info from parameters to make up the whole IPv6 device path node.
|
||||||
@ -2070,7 +2067,7 @@ NetLibCreateIPv6DPathNode (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Find the UNDI/SNP handle from controller and protocol GUID.
|
Find the UNDI/SNP handle from controller and protocol GUID.
|
||||||
|
|
||||||
For example, IP will open a MNP child to transmit/receive
|
For example, IP will open a MNP child to transmit/receive
|
||||||
packets, when MNP is stopped, IP should also be stopped. IP
|
packets, when MNP is stopped, IP should also be stopped. IP
|
||||||
needs to find its own private data which is related the IP's
|
needs to find its own private data which is related the IP's
|
||||||
|
@ -54,6 +54,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiSimpleNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
gEfiManagedNetworkProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
gEfiManagedNetworkServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiComponentNameProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiComponentName2ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
gEfiHiiConfigRoutingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
Network library functions providing net buffer operation support.
|
Network library functions providing net buffer operation support.
|
||||||
|
|
||||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||||
All rights reserved. This program and the accompanying materials
|
All rights reserved. This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
@ -22,16 +22,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate and build up the sketch for a NET_BUF.
|
Allocate and build up the sketch for a NET_BUF.
|
||||||
|
|
||||||
The net buffer allocated has the BlockOpNum's NET_BLOCK_OP, and its associated
|
The net buffer allocated has the BlockOpNum's NET_BLOCK_OP, and its associated
|
||||||
NET_VECTOR has the BlockNum's NET_BLOCK. But all the NET_BLOCK_OP and
|
NET_VECTOR has the BlockNum's NET_BLOCK. But all the NET_BLOCK_OP and
|
||||||
NET_BLOCK remain un-initialized.
|
NET_BLOCK remain un-initialized.
|
||||||
|
|
||||||
@param[in] BlockNum The number of NET_BLOCK in the vector of net buffer
|
@param[in] BlockNum The number of NET_BLOCK in the vector of net buffer
|
||||||
@param[in] BlockOpNum The number of NET_BLOCK_OP in the net buffer
|
@param[in] BlockOpNum The number of NET_BLOCK_OP in the net buffer
|
||||||
|
|
||||||
@return Pointer to the allocated NET_BUF, or NULL if the
|
@return Pointer to the allocated NET_BUF, or NULL if the
|
||||||
allocation failed due to resource limit.
|
allocation failed due to resource limit.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -88,7 +88,7 @@ FreeNbuf:
|
|||||||
|
|
||||||
@param[in] Len The length of the block.
|
@param[in] Len The length of the block.
|
||||||
|
|
||||||
@return Pointer to the allocated NET_BUF, or NULL if the
|
@return Pointer to the allocated NET_BUF, or NULL if the
|
||||||
allocation failed due to resource limit.
|
allocation failed due to resource limit.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -137,11 +137,11 @@ FreeNBuf:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free the net vector.
|
Free the net vector.
|
||||||
|
|
||||||
Decrease the reference count of the net vector by one. The real resource free
|
Decrease the reference count of the net vector by one. The real resource free
|
||||||
operation isn't performed until the reference count of the net vector is
|
operation isn't performed until the reference count of the net vector is
|
||||||
decreased to 0.
|
decreased to 0.
|
||||||
|
|
||||||
@param[in] Vector Pointer to the NET_VECTOR to be freed.
|
@param[in] Vector Pointer to the NET_VECTOR to be freed.
|
||||||
|
|
||||||
@ -190,13 +190,13 @@ NetbufFreeVector (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Free the net buffer and its associated NET_VECTOR.
|
Free the net buffer and its associated NET_VECTOR.
|
||||||
|
|
||||||
Decrease the reference count of the net buffer by one. Free the associated net
|
Decrease the reference count of the net buffer by one. Free the associated net
|
||||||
vector and itself if the reference count of the net buffer is decreased to 0.
|
vector and itself if the reference count of the net buffer is decreased to 0.
|
||||||
The net vector free operation just decrease the reference count of the net
|
The net vector free operation just decrease the reference count of the net
|
||||||
vector by one and do the real resource free operation when the reference count
|
vector by one and do the real resource free operation when the reference count
|
||||||
of the net vector is 0.
|
of the net vector is 0.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the NET_BUF to be freed.
|
@param[in] Nbuf Pointer to the NET_BUF to be freed.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -224,10 +224,10 @@ NetbufFree (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a copy of the net buffer that shares the associated net vector.
|
Create a copy of the net buffer that shares the associated net vector.
|
||||||
|
|
||||||
The reference count of the newly created net buffer is set to 1. The reference
|
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.
|
count of the associated net vector is increased by one.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be cloned.
|
@param[in] Nbuf Pointer to the net buffer to be cloned.
|
||||||
|
|
||||||
@ -274,12 +274,12 @@ NetbufClone (
|
|||||||
/**
|
/**
|
||||||
Create a duplicated copy of the net buffer with data copied and HeadSpace
|
Create a duplicated copy of the net buffer with data copied and HeadSpace
|
||||||
bytes of head space reserved.
|
bytes of head space reserved.
|
||||||
|
|
||||||
The duplicated net buffer will allocate its own memory to hold the data of the
|
The duplicated net buffer will allocate its own memory to hold the data of the
|
||||||
source net buffer.
|
source net buffer.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be duplicated from.
|
@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
|
@param[in, out] Duplicate Pointer to the net buffer to duplicate to, if
|
||||||
NULL a new net buffer is allocated.
|
NULL a new net buffer is allocated.
|
||||||
@param[in] HeadSpace Length of the head space to reserve.
|
@param[in] HeadSpace Length of the head space to reserve.
|
||||||
|
|
||||||
@ -352,16 +352,16 @@ NetbufFreeList (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the index of NET_BLOCK_OP that contains the byte at Offset in the net
|
Get the index of NET_BLOCK_OP that contains the byte at Offset in the net
|
||||||
buffer.
|
buffer.
|
||||||
|
|
||||||
This can be used to, for example, retrieve the IP header in the packet. It
|
This can be used to, for example, retrieve the IP header in the packet. It
|
||||||
also can be used to get the fragment that contains the byte which is used
|
also can be used to get the fragment that contains the byte which is used
|
||||||
mainly by the library implementation itself.
|
mainly by the library implementation itself.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer.
|
@param[in] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Offset The offset of the byte.
|
@param[in] Offset The offset of the byte.
|
||||||
@param[out] Index Index of the NET_BLOCK_OP that contains the byte at
|
@param[out] Index Index of the NET_BLOCK_OP that contains the byte at
|
||||||
Offset.
|
Offset.
|
||||||
|
|
||||||
@return Pointer to the Offset'th byte of data in the net buffer, or NULL
|
@return Pointer to the Offset'th byte of data in the net buffer, or NULL
|
||||||
@ -409,12 +409,12 @@ NetbufGetByte (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Set the NET_BLOCK and corresponding NET_BLOCK_OP in the net buffer and
|
Set the NET_BLOCK and corresponding NET_BLOCK_OP in the net buffer and
|
||||||
corresponding net vector according to the bulk pointer and bulk length.
|
corresponding net vector according to the bulk pointer and bulk length.
|
||||||
|
|
||||||
All the pointers in the Index'th NET_BLOCK and NET_BLOCK_OP are set to the
|
All the pointers in the Index'th NET_BLOCK and NET_BLOCK_OP are set to the
|
||||||
bulk's head and tail respectively. So, this function alone can't be used by
|
bulk's head and tail respectively. So, this function alone can't be used by
|
||||||
NetbufAlloc.
|
NetbufAlloc.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Bulk Pointer to the data.
|
@param[in] Bulk Pointer to the data.
|
||||||
@ -453,15 +453,15 @@ NetbufSetBlock (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Set the NET_BLOCK_OP in the net buffer. The corresponding NET_BLOCK
|
Set the NET_BLOCK_OP in the net buffer. The corresponding NET_BLOCK
|
||||||
structure is left untouched.
|
structure is left untouched.
|
||||||
|
|
||||||
Some times, there is no 1:1 relationship between NET_BLOCK and NET_BLOCK_OP.
|
Some times, there is no 1:1 relationship between NET_BLOCK and NET_BLOCK_OP.
|
||||||
For example, that in NetbufGetFragment.
|
For example, that in NetbufGetFragment.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Bulk Pointer to the data.
|
@param[in] Bulk Pointer to the data.
|
||||||
@param[in] Len Length of the bulk data.
|
@param[in] Len Length of the bulk data.
|
||||||
@param[in] Index The data block index in the net buffer the bulk
|
@param[in] Index The data block index in the net buffer the bulk
|
||||||
data should belong to.
|
data should belong to.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -488,10 +488,10 @@ NetbufSetBlockOp (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper function for NetbufGetFragment. NetbufGetFragment may allocate the
|
Helper function for NetbufGetFragment. NetbufGetFragment may allocate the
|
||||||
first block to reserve HeadSpace bytes header space. So it needs to create a
|
first block to reserve HeadSpace bytes header space. So it needs to create a
|
||||||
new net vector for the first block and can avoid copy for the remaining data
|
new net vector for the first block and can avoid copy for the remaining data
|
||||||
by sharing the old net vector.
|
by sharing the old net vector.
|
||||||
|
|
||||||
@param[in] Arg Point to the old NET_VECTOR.
|
@param[in] Arg Point to the old NET_VECTOR.
|
||||||
|
|
||||||
@ -510,19 +510,19 @@ NetbufGetFragmentFree (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a NET_BUF structure which contains Len byte data of Nbuf starting from
|
Create a NET_BUF structure which contains Len byte data of Nbuf starting from
|
||||||
Offset.
|
Offset.
|
||||||
|
|
||||||
A new NET_BUF structure will be created but the associated data in NET_VECTOR
|
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 do IP packet fragmentation.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer to be extracted.
|
@param[in] Nbuf Pointer to the net buffer to be extracted.
|
||||||
@param[in] Offset Starting point of the data to be included in the new
|
@param[in] Offset Starting point of the data to be included in the new
|
||||||
net buffer.
|
net buffer.
|
||||||
@param[in] Len Bytes of 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] HeadSpace Bytes of head space to reserve for protocol header.
|
||||||
|
|
||||||
@return Pointer to the cloned net buffer, or NULL if the
|
@return Pointer to the cloned net buffer, or NULL if the
|
||||||
allocation failed due to resource limit.
|
allocation failed due to resource limit.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -694,8 +694,8 @@ FreeChild:
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a NET_BUF from external blocks.
|
Build a NET_BUF from external blocks.
|
||||||
|
|
||||||
A new NET_BUF structure will be created from external blocks. Additional block
|
A new NET_BUF structure will be created from external blocks. Additional block
|
||||||
of memory will be allocated to hold reserved HeadSpace bytes of header room
|
of memory will be allocated to hold reserved HeadSpace bytes of header room
|
||||||
and existing HeadLen bytes of header but the external blocks are shared by the
|
and existing HeadLen bytes of header but the external blocks are shared by the
|
||||||
@ -710,7 +710,7 @@ FreeChild:
|
|||||||
@param[in] Arg The argument passed to ExtFree when ExtFree is
|
@param[in] Arg The argument passed to ExtFree when ExtFree is
|
||||||
called.
|
called.
|
||||||
|
|
||||||
@return Pointer to the net buffer built from the data blocks,
|
@return Pointer to the net buffer built from the data blocks,
|
||||||
or NULL if the allocation failed due to resource
|
or NULL if the allocation failed due to resource
|
||||||
limit.
|
limit.
|
||||||
|
|
||||||
@ -878,13 +878,13 @@ FreeFirstBlock:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Build a fragment table to contain the fragments in the net buffer. This is the
|
Build a fragment table to contain the fragments in the net buffer. This is the
|
||||||
opposite operation of the NetbufFromExt.
|
opposite operation of the NetbufFromExt.
|
||||||
|
|
||||||
@param[in] Nbuf Point to the net buffer.
|
@param[in] Nbuf Point to the net buffer.
|
||||||
@param[in, out] ExtFragment Pointer to the data block.
|
@param[in, out] ExtFragment Pointer to the data block.
|
||||||
@param[in, out] ExtNum The number of the data blocks.
|
@param[in, out] ExtNum The number of the data blocks.
|
||||||
|
|
||||||
@retval EFI_BUFFER_TOO_SMALL The number of non-empty block is bigger than
|
@retval EFI_BUFFER_TOO_SMALL The number of non-empty block is bigger than
|
||||||
ExtNum.
|
ExtNum.
|
||||||
@retval EFI_SUCCESS Fragment table is built successfully.
|
@retval EFI_SUCCESS Fragment table is built successfully.
|
||||||
|
|
||||||
@ -923,10 +923,10 @@ NetbufBuildExt (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Build a net buffer from a list of net buffers.
|
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.
|
net buffer will be created through NetbufFromExt.
|
||||||
|
|
||||||
@param[in] BufList A List of the net buffer.
|
@param[in] BufList A List of the net buffer.
|
||||||
@param[in] HeadSpace The head space to be reserved.
|
@param[in] HeadSpace The head space to be reserved.
|
||||||
@param[in] HeaderLen The length of the protocol header, This function
|
@param[in] HeaderLen The length of the protocol header, This function
|
||||||
@ -934,7 +934,7 @@ NetbufBuildExt (
|
|||||||
@param[in] ExtFree Pointer to the caller provided free function.
|
@param[in] ExtFree Pointer to the caller provided free function.
|
||||||
@param[in] Arg The argument passed to ExtFree when ExtFree is called.
|
@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 Pointer to the net buffer built from the list of net
|
||||||
buffers.
|
buffers.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1000,10 +1000,10 @@ NetbufFromBufList (
|
|||||||
/**
|
/**
|
||||||
Reserve some space in the header room of the net buffer.
|
Reserve some space in the header room of the net buffer.
|
||||||
|
|
||||||
Upon allocation, all the space are in the tail room of the buffer. Call this
|
Upon allocation, all the space are 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 some 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
|
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. But it should be enough for the network stack.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Len The length of buffer to be reserved from the header.
|
@param[in] Len The length of buffer to be reserved from the header.
|
||||||
@ -1030,14 +1030,14 @@ NetbufReserve (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Allocate Len bytes of space from the header or tail of the buffer.
|
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 Pointer to the net buffer.
|
||||||
@param[in] Len The length of the buffer to be allocated.
|
@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 reserve the data
|
||||||
from head (TRUE) or tail (FALSE).
|
from head (TRUE) or tail (FALSE).
|
||||||
|
|
||||||
@return Pointer to the first byte of the allocated buffer,
|
@return Pointer to the first byte of the allocated buffer,
|
||||||
or NULL if there is no sufficient space.
|
or NULL if there is no sufficient space.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1126,7 +1126,7 @@ NetbufAllocSpace (
|
|||||||
|
|
||||||
@param[in, out] BlockOp Pointer to the NET_BLOCK.
|
@param[in, out] BlockOp Pointer to the NET_BLOCK.
|
||||||
@param[in] Len The length of the data to be trimmed.
|
@param[in] Len The length of the data to be trimmed.
|
||||||
@param[in] FromHead The flag to indicate whether trim data from head
|
@param[in] FromHead The flag to indicate whether trim data from head
|
||||||
(TRUE) or tail (FALSE).
|
(TRUE) or tail (FALSE).
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1150,14 +1150,14 @@ NetblockTrim (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trim Len bytes from the header or tail of the net buffer.
|
Trim Len bytes from the header or tail of the net buffer.
|
||||||
|
|
||||||
@param[in, out] Nbuf Pointer to the net buffer.
|
@param[in, out] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Len The length of the data to be trimmed.
|
@param[in] Len The length of the data to be trimmed.
|
||||||
@param[in] FromHead The flag to indicate whether trim data from head
|
@param[in] FromHead The flag to indicate whether trim data from head
|
||||||
(TRUE) or tail (FALSE).
|
(TRUE) or tail (FALSE).
|
||||||
|
|
||||||
@return Length of the actually trimmed data, which is possible to be less
|
@return Length of the actually trimmed data, which is possible to be less
|
||||||
than Len because the TotalSize of Nbuf is less than Len.
|
than Len because the TotalSize of Nbuf is less than Len.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1216,11 +1216,11 @@ NetbufTrim (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copy Len bytes of data from the specific offset of the net buffer to the
|
Copy Len bytes of data from the specific offset of the net buffer to the
|
||||||
destination memory.
|
destination memory.
|
||||||
|
|
||||||
The Len bytes of data may cross the several fragments of the net buffer.
|
The Len bytes of data may cross the several fragments of the net buffer.
|
||||||
|
|
||||||
@param[in] Nbuf Pointer to the net buffer.
|
@param[in] Nbuf Pointer to the net buffer.
|
||||||
@param[in] Offset The sequence number of the first byte to copy.
|
@param[in] Offset The sequence number of the first byte to copy.
|
||||||
@param[in] Len Length of the data to copy.
|
@param[in] Len Length of the data to copy.
|
||||||
@ -1368,10 +1368,10 @@ NetbufQueAlloc (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Free a net buffer queue.
|
Free a net buffer queue.
|
||||||
|
|
||||||
Decrease the reference count of the net buffer queue by one. The real resource
|
Decrease the reference count of the net buffer queue by one. The real resource
|
||||||
free operation isn't performed until the reference count of the net buffer
|
free operation isn't performed until the reference count of the net buffer
|
||||||
queue is decreased to 0.
|
queue is decreased to 0.
|
||||||
|
|
||||||
@param[in] NbufQue Pointer to the net buffer queue to be freed.
|
@param[in] NbufQue Pointer to the net buffer queue to be freed.
|
||||||
@ -1424,7 +1424,7 @@ NetbufQueAppend (
|
|||||||
|
|
||||||
@param[in, out] NbufQue Pointer to the net buffer queue.
|
@param[in, out] NbufQue Pointer to the net buffer queue.
|
||||||
|
|
||||||
@return Pointer to the net buffer removed from the specific queue,
|
@return Pointer to the net buffer removed from the specific queue,
|
||||||
or NULL if there is no net buffer in the specific queue.
|
or NULL if there is no net buffer in the specific queue.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1455,16 +1455,16 @@ NetbufQueRemove (
|
|||||||
/**
|
/**
|
||||||
Copy Len bytes of data from the net buffer queue at the specific offset to the
|
Copy Len bytes of data from the net buffer queue at the specific offset to the
|
||||||
destination memory.
|
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.
|
queue instead of the net buffer.
|
||||||
|
|
||||||
@param[in] NbufQue Pointer to the net buffer queue.
|
@param[in] NbufQue Pointer to the net buffer queue.
|
||||||
@param[in] Offset The sequence number of the first byte to copy.
|
@param[in] Offset The sequence number of the first byte to copy.
|
||||||
@param[in] Len Length of the data to copy.
|
@param[in] Len Length of the data to copy.
|
||||||
@param[out] Dest The destination of the data to copy to.
|
@param[out] Dest The destination of the data to copy to.
|
||||||
|
|
||||||
@return The length of the actual copied data, or 0 if the offset
|
@return The length of the actual copied data, or 0 if the offset
|
||||||
specified exceeds the total size of net buffer queue.
|
specified exceeds the total size of net buffer queue.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
@ -1557,9 +1557,9 @@ NetbufQueCopy (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Trim Len bytes of data from the queue header, release any of the net buffer
|
Trim Len bytes of data from the queue header, release any of the net buffer
|
||||||
whom is trimmed wholely.
|
whom is trimmed wholely.
|
||||||
|
|
||||||
The trimming operation is the same as NetbufTrim but applies to the net buffer
|
The trimming operation is the same as NetbufTrim but applies to the net buffer
|
||||||
queue instead of the net buffer.
|
queue instead of the net buffer.
|
||||||
|
|
||||||
@ -1756,7 +1756,7 @@ NetbufChecksum (
|
|||||||
// The checksum starts with an odd byte, swap
|
// The checksum starts with an odd byte, swap
|
||||||
// the checksum before added to total checksum
|
// the checksum before added to total checksum
|
||||||
//
|
//
|
||||||
BlockSum = (UINT16) NET_SWAP_SHORT (BlockSum);
|
BlockSum = SwapBytes16 (BlockSum);
|
||||||
}
|
}
|
||||||
|
|
||||||
TotalSum = NetAddChecksum (BlockSum, TotalSum);
|
TotalSum = NetAddChecksum (BlockSum, TotalSum);
|
||||||
@ -1768,8 +1768,8 @@ NetbufChecksum (
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Compute the checksum for TCP/UDP pseudo header.
|
Compute the checksum for TCP/UDP pseudo header.
|
||||||
|
|
||||||
Src and Dst are in network byte order, and Len is in host byte order.
|
Src and Dst are in network byte order, and Len is in host byte order.
|
||||||
|
|
||||||
@param[in] Src The source address of the packet.
|
@param[in] Src The source address of the packet.
|
||||||
@ -1805,8 +1805,8 @@ NetPseudoHeadChecksum (
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Compute the checksum for TCP6/UDP6 pseudo header.
|
Compute the checksum for TCP6/UDP6 pseudo header.
|
||||||
|
|
||||||
Src and Dst are in network byte order, and Len is in host byte order.
|
Src and Dst are in network byte order, and Len is in host byte order.
|
||||||
|
|
||||||
@param[in] Src The source address of the packet.
|
@param[in] Src The source address of the packet.
|
||||||
@ -1836,7 +1836,7 @@ NetIp6PseudoHeadChecksum (
|
|||||||
IP6_COPY_ADDRESS (&Hdr.DstIp, Dst);
|
IP6_COPY_ADDRESS (&Hdr.DstIp, Dst);
|
||||||
|
|
||||||
Hdr.NextHeader = NextHeader;
|
Hdr.NextHeader = NextHeader;
|
||||||
Hdr.Len = HTONL (Len);
|
Hdr.Len = HTONL (Len);
|
||||||
|
|
||||||
return NetblockChecksum ((UINT8 *) &Hdr, sizeof (Hdr));
|
return NetblockChecksum ((UINT8 *) &Hdr, sizeof (Hdr));
|
||||||
}
|
}
|
||||||
|
@ -1857,7 +1857,7 @@ IScsiNewScsiCmdPdu (
|
|||||||
CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
|
CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb));
|
||||||
|
|
||||||
if (Packet->CdbLength > 16) {
|
if (Packet->CdbLength > 16) {
|
||||||
Header->Length = NTOHS (Packet->CdbLength - 15);
|
Header->Length = NTOHS ((UINT16) (Packet->CdbLength - 15));
|
||||||
Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
|
Header->Type = ISCSI_AHS_TYPE_EXT_CDB;
|
||||||
|
|
||||||
CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);
|
CopyMem (Header + 1, (UINT8 *) Packet->Cdb + 16, Packet->CdbLength - 16);
|
||||||
|
@ -105,6 +105,8 @@ Ip4ProcessIcmpRedirect (
|
|||||||
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
IP4_ROUTE_CACHE_ENTRY *CacheEntry;
|
||||||
IP4_INTERFACE *IpIf;
|
IP4_INTERFACE *IpIf;
|
||||||
IP4_ADDR Gateway;
|
IP4_ADDR Gateway;
|
||||||
|
IP4_ADDR Src;
|
||||||
|
IP4_ADDR Dst;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find the interface whose IP address is the source of the
|
// Find the interface whose IP address is the source of the
|
||||||
@ -133,11 +135,9 @@ Ip4ProcessIcmpRedirect (
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheEntry = Ip4FindRouteCache (
|
Dst = NTOHL (Icmp->IpHead.Dst);
|
||||||
Ip4Instance->RouteTable,
|
Src = NTOHL (Icmp->IpHead.Src);
|
||||||
NTOHL (Icmp->IpHead.Dst),
|
CacheEntry = Ip4FindRouteCache (Ip4Instance->RouteTable, Dst, Src);
|
||||||
NTOHL (Icmp->IpHead.Src)
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Only update the route cache's gateway if the source of the
|
// Only update the route cache's gateway if the source of the
|
||||||
|
@ -561,6 +561,10 @@ Ip4AutoConfigCallBackDpc (
|
|||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
UINTN Len;
|
UINTN Len;
|
||||||
UINT32 Index;
|
UINT32 Index;
|
||||||
|
IP4_ADDR StationAddress;
|
||||||
|
IP4_ADDR SubnetMask;
|
||||||
|
IP4_ADDR SubnetAddress;
|
||||||
|
IP4_ADDR GatewayAddress;
|
||||||
|
|
||||||
IpSb = (IP4_SERVICE *) Context;
|
IpSb = (IP4_SERVICE *) Context;
|
||||||
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);
|
||||||
@ -646,11 +650,9 @@ Ip4AutoConfigCallBackDpc (
|
|||||||
// Set the default interface's address, then add a directed
|
// Set the default interface's address, then add a directed
|
||||||
// route for it, that is, the route whose nexthop is zero.
|
// route for it, that is, the route whose nexthop is zero.
|
||||||
//
|
//
|
||||||
Status = Ip4SetAddress (
|
StationAddress = EFI_NTOHL (Data->StationAddress);
|
||||||
IpIf,
|
SubnetMask = EFI_NTOHL (Data->SubnetMask);
|
||||||
EFI_NTOHL (Data->StationAddress),
|
Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask);
|
||||||
EFI_NTOHL (Data->SubnetMask)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto ON_EXIT;
|
goto ON_EXIT;
|
||||||
@ -658,8 +660,8 @@ Ip4AutoConfigCallBackDpc (
|
|||||||
|
|
||||||
Ip4AddRoute (
|
Ip4AddRoute (
|
||||||
IpSb->DefaultRouteTable,
|
IpSb->DefaultRouteTable,
|
||||||
EFI_NTOHL (Data->StationAddress),
|
StationAddress,
|
||||||
EFI_NTOHL (Data->SubnetMask),
|
SubnetMask,
|
||||||
IP4_ALLZERO_ADDRESS
|
IP4_ALLZERO_ADDRESS
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -669,12 +671,10 @@ Ip4AutoConfigCallBackDpc (
|
|||||||
for (Index = 0; Index < Data->RouteTableSize; Index++) {
|
for (Index = 0; Index < Data->RouteTableSize; Index++) {
|
||||||
RouteEntry = &Data->RouteTable[Index];
|
RouteEntry = &Data->RouteTable[Index];
|
||||||
|
|
||||||
Ip4AddRoute (
|
SubnetAddress = EFI_NTOHL (RouteEntry->SubnetAddress);
|
||||||
IpSb->DefaultRouteTable,
|
SubnetMask = EFI_NTOHL (RouteEntry->SubnetMask);
|
||||||
EFI_NTOHL (RouteEntry->SubnetAddress),
|
GatewayAddress = EFI_NTOHL (RouteEntry->GatewayAddress);
|
||||||
EFI_NTOHL (RouteEntry->SubnetMask),
|
Ip4AddRoute (IpSb->DefaultRouteTable, SubnetAddress, SubnetMask, GatewayAddress);
|
||||||
EFI_NTOHL (RouteEntry->GatewayAddress)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IpSb->State = IP4_SERVICE_CONFIGED;
|
IpSb->State = IP4_SERVICE_CONFIGED;
|
||||||
|
@ -73,7 +73,7 @@ Ip4PrependHead (
|
|||||||
PacketHead->Ver = 4;
|
PacketHead->Ver = 4;
|
||||||
PacketHead->HeadLen = (UINT8) (HeadLen >> 2);
|
PacketHead->HeadLen = (UINT8) (HeadLen >> 2);
|
||||||
PacketHead->Tos = Head->Tos;
|
PacketHead->Tos = Head->Tos;
|
||||||
PacketHead->TotalLen = HTONS (Packet->TotalSize);
|
PacketHead->TotalLen = HTONS ((UINT16) Packet->TotalSize);
|
||||||
PacketHead->Id = HTONS (Head->Id);
|
PacketHead->Id = HTONS (Head->Id);
|
||||||
PacketHead->Fragment = HTONS (Head->Fragment);
|
PacketHead->Fragment = HTONS (Head->Fragment);
|
||||||
PacketHead->Checksum = 0;
|
PacketHead->Checksum = 0;
|
||||||
|
@ -799,7 +799,7 @@ TcpInput (
|
|||||||
Tcb = TcpCloneTcb (Parent);
|
Tcb = TcpCloneTcb (Parent);
|
||||||
if (Tcb == NULL) {
|
if (Tcb == NULL) {
|
||||||
DEBUG ((EFI_D_ERROR, "TcpInput: discard a segment because"
|
DEBUG ((EFI_D_ERROR, "TcpInput: discard a segment because"
|
||||||
"failed to clone a child for TCB%x\n", Tcb));
|
" failed to clone a child for TCB%x\n", Tcb));
|
||||||
|
|
||||||
goto DISCARD;
|
goto DISCARD;
|
||||||
}
|
}
|
||||||
|
@ -1090,18 +1090,22 @@ TcpInstallDevicePath (
|
|||||||
TCP_CB *Tcb;
|
TCP_CB *Tcb;
|
||||||
IPv4_DEVICE_PATH Ip4DPathNode;
|
IPv4_DEVICE_PATH Ip4DPathNode;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
TCP_PORTNO LocalPort;
|
||||||
|
TCP_PORTNO RemotePort;
|
||||||
|
|
||||||
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
|
TcpProto = (TCP4_PROTO_DATA *) Sock->ProtoReserved;
|
||||||
TcpService = TcpProto->TcpService;
|
TcpService = TcpProto->TcpService;
|
||||||
Tcb = TcpProto->TcpPcb;
|
Tcb = TcpProto->TcpPcb;
|
||||||
|
|
||||||
|
LocalPort = NTOHS (Tcb->LocalEnd.Port);
|
||||||
|
RemotePort = NTOHS (Tcb->RemoteEnd.Port);
|
||||||
NetLibCreateIPv4DPathNode (
|
NetLibCreateIPv4DPathNode (
|
||||||
&Ip4DPathNode,
|
&Ip4DPathNode,
|
||||||
TcpService->ControllerHandle,
|
TcpService->ControllerHandle,
|
||||||
Tcb->LocalEnd.Ip,
|
Tcb->LocalEnd.Ip,
|
||||||
NTOHS (Tcb->LocalEnd.Port),
|
LocalPort,
|
||||||
Tcb->RemoteEnd.Ip,
|
Tcb->RemoteEnd.Ip,
|
||||||
NTOHS (Tcb->RemoteEnd.Port),
|
RemotePort,
|
||||||
EFI_IP_PROTO_TCP,
|
EFI_IP_PROTO_TCP,
|
||||||
Tcb->UseDefaultAddr
|
Tcb->UseDefaultAddr
|
||||||
);
|
);
|
||||||
|
@ -586,7 +586,7 @@ Udp4Transmit (
|
|||||||
//
|
//
|
||||||
Udp4Header->SrcPort = HTONS (ConfigData->StationPort);
|
Udp4Header->SrcPort = HTONS (ConfigData->StationPort);
|
||||||
Udp4Header->DstPort = HTONS (ConfigData->RemotePort);
|
Udp4Header->DstPort = HTONS (ConfigData->RemotePort);
|
||||||
Udp4Header->Length = HTONS (Packet->TotalSize);
|
Udp4Header->Length = HTONS ((UINT16) Packet->TotalSize);
|
||||||
Udp4Header->Checksum = 0;
|
Udp4Header->Checksum = 0;
|
||||||
|
|
||||||
UdpSessionData = TxData->UdpSessionData;
|
UdpSessionData = TxData->UdpSessionData;
|
||||||
|
@ -1182,7 +1182,7 @@ PxeBcDiscvBootService (
|
|||||||
|
|
||||||
Xid = NET_RANDOM (NetRandomInitSeed ());
|
Xid = NET_RANDOM (NetRandomInitSeed ());
|
||||||
Token.Packet->Dhcp4.Header.Xid = HTONL(Xid);
|
Token.Packet->Dhcp4.Header.Xid = HTONL(Xid);
|
||||||
Token.Packet->Dhcp4.Header.Reserved = HTONS((IsBCast) ? 0x8000 : 0);
|
Token.Packet->Dhcp4.Header.Reserved = HTONS((UINT16) ((IsBCast) ? 0x8000 : 0));
|
||||||
CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
|
CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS));
|
||||||
|
|
||||||
Token.RemotePort = Sport;
|
Token.RemotePort = Sport;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user