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:
@ -1,6 +1,6 @@
|
||||
/** @file
|
||||
Network library.
|
||||
|
||||
|
||||
Copyright (c) 2005 - 2009, Intel Corporation.<BR>
|
||||
All rights reserved. This program and the accompanying materials
|
||||
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/ServiceBinding.h>
|
||||
#include <Protocol/SimpleNetwork.h>
|
||||
#include <Protocol/ManagedNetwork.h>
|
||||
#include <Protocol/HiiConfigRouting.h>
|
||||
#include <Protocol/ComponentName.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/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
|
||||
|
||||
//
|
||||
// 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,
|
||||
0x80000000,
|
||||
0xC0000000,
|
||||
@ -79,26 +78,25 @@ IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = {
|
||||
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.
|
||||
//
|
||||
UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
|
||||
UINT32 mSyslogPacketSeq = 0xDEADBEEF;
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR;
|
||||
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};
|
||||
UINT32 mSyslogDstIp = 0xffffffff;
|
||||
UINT32 mSyslogSrcIp = 0;
|
||||
// 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.
|
||||
//
|
||||
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 *
|
||||
mMonthName[] = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED CHAR8 *mMonthName[] = {
|
||||
"Jan",
|
||||
"Feb",
|
||||
"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
|
||||
the SNP after use because the SNP is opened by HandleProtocol.
|
||||
|
||||
@ -147,12 +145,12 @@ SyslogLocateSnp (
|
||||
if (EFI_ERROR (Status) || (HandleCount == 0)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Try to open one of the ethernet SNP protocol to send packet
|
||||
//
|
||||
Snp = NULL;
|
||||
|
||||
|
||||
for (Index = 0; Index < HandleCount; Index++) {
|
||||
Status = gBS->HandleProtocol (
|
||||
Handles[Index],
|
||||
@ -160,10 +158,10 @@ SyslogLocateSnp (
|
||||
(VOID **) &Snp
|
||||
);
|
||||
|
||||
if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
|
||||
if ((Status == EFI_SUCCESS) && (Snp != NULL) &&
|
||||
(Snp->Mode->IfType == NET_IFTYPE_ETHERNET) &&
|
||||
(Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) {
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -176,18 +174,18 @@ SyslogLocateSnp (
|
||||
|
||||
/**
|
||||
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
|
||||
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] Length - The length of the packet
|
||||
@param[in] Packet The Syslog 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
|
||||
SyslogSendPacket (
|
||||
@ -241,7 +239,7 @@ SyslogSendPacket (
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 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
|
||||
@ -265,7 +263,7 @@ SyslogSendPacket (
|
||||
if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Status is EFI_NOT_READY. Restart the timer event and
|
||||
// call Snp->Transmit again.
|
||||
@ -281,20 +279,18 @@ ON_EXIT:
|
||||
}
|
||||
|
||||
/**
|
||||
Build a syslog packet, including the Ethernet/Ip/Udp headers
|
||||
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
|
||||
Build a syslog packet, including the Ethernet/Ip/Udp headers
|
||||
and user's message.
|
||||
|
||||
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
|
||||
@ -305,7 +301,7 @@ SyslogBuildPacket (
|
||||
IN UINT32 Line,
|
||||
IN UINT8 *Message,
|
||||
IN UINT32 BufLen,
|
||||
OUT CHAR8 *Buf
|
||||
OUT CHAR8 *Buf
|
||||
)
|
||||
{
|
||||
ETHER_HEAD *Ether;
|
||||
@ -316,7 +312,7 @@ SyslogBuildPacket (
|
||||
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.
|
||||
//
|
||||
Ether = (ETHER_HEAD *) Buf;
|
||||
@ -374,7 +370,7 @@ SyslogBuildPacket (
|
||||
BufLen,
|
||||
"<%d> %a %d %d:%d:%d ",
|
||||
Pri,
|
||||
mMonthName [Time.Month-1],
|
||||
mMonthName [Time.Month-1],
|
||||
Time.Day,
|
||||
Time.Hour,
|
||||
Time.Minute,
|
||||
@ -383,9 +379,9 @@ SyslogBuildPacket (
|
||||
Len--;
|
||||
|
||||
Len += (UINT32) AsciiSPrint (
|
||||
Buf + Len,
|
||||
BufLen - Len,
|
||||
"Tiano %a: %a (Line: %d File: %a)",
|
||||
Buf + Len,
|
||||
BufLen - Len,
|
||||
"Tiano %a: %a (Line: %d File: %a)",
|
||||
Module,
|
||||
Message,
|
||||
Line,
|
||||
@ -407,23 +403,23 @@ SyslogBuildPacket (
|
||||
}
|
||||
|
||||
/**
|
||||
Allocate a buffer, then format the message to it. This is a
|
||||
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
||||
these macros treats the variable length print parameters as a
|
||||
Allocate a buffer, then format the message to it. This is a
|
||||
help function for the NET_DEBUG_XXX macros. The PrintArg of
|
||||
these macros treats the variable length print parameters as a
|
||||
single parameter, and pass it to the NetDebugASPrint. For
|
||||
example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name))
|
||||
if extracted to:
|
||||
|
||||
if extracted to:
|
||||
|
||||
NetDebugOutput (
|
||||
NETDEBUG_LEVEL_TRACE,
|
||||
"Tcp",
|
||||
NETDEBUG_LEVEL_TRACE,
|
||||
"Tcp",
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
NetDebugASPrint ("State transit to %a\n", Name)
|
||||
)
|
||||
|
||||
NetDebugASPrint ("State transit to %a\n", Name)
|
||||
)
|
||||
|
||||
@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.
|
||||
|
||||
@return The buffer containing the formatted message,
|
||||
@ -466,12 +462,12 @@ NetDebugASPrint (
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Any input parameter is invalid.
|
||||
@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.
|
||||
**/
|
||||
**/
|
||||
EFI_STATUS
|
||||
NetDebugOutput (
|
||||
IN UINT32 Level,
|
||||
IN UINT32 Level,
|
||||
IN UINT8 *Module,
|
||||
IN UINT8 *File,
|
||||
IN UINT32 Line,
|
||||
@ -493,7 +489,7 @@ NetDebugOutput (
|
||||
Status = EFI_SUCCESS;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Allocate a maxium of 1024 bytes, the caller should ensure
|
||||
// that the message plus the ethernet/ip/udp header is shorter
|
||||
@ -505,7 +501,7 @@ NetDebugOutput (
|
||||
Status = EFI_OUT_OF_RESOURCES;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Build the message: Ethernet header + IP header + Udp Header + user data
|
||||
//
|
||||
@ -528,8 +524,8 @@ ON_EXIT:
|
||||
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.
|
||||
If the mask is invalid, return the invalid length 33, which is IP4_MASK_NUM.
|
||||
NetMask is in the host byte order.
|
||||
@ -537,7 +533,7 @@ ON_EXIT:
|
||||
@param[in] NetMask The netmask to get the length from.
|
||||
|
||||
@return The length of the netmask, IP4_MASK_NUM if the mask is invalid.
|
||||
|
||||
|
||||
**/
|
||||
INTN
|
||||
EFIAPI
|
||||
@ -561,19 +557,19 @@ NetGetMaskLength (
|
||||
/**
|
||||
Return the class of the IP address, such as class A, B, C.
|
||||
Addr is in host byte order.
|
||||
|
||||
|
||||
The address of class A starts with 0.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
The address of class E starts with 1111.
|
||||
If the address belong to class E, return IP4_ADDR_CLASSE.
|
||||
|
||||
|
||||
|
||||
@param[in] Addr The address to get the class from.
|
||||
|
||||
@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
|
||||
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.
|
||||
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.
|
||||
|
||||
@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
|
||||
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
|
||||
interface.
|
||||
interface.
|
||||
|
||||
@param[in] Ip6 The IPv6 address to check against.
|
||||
|
||||
@return TRUE if Ip6 is a valid unicast address on the network, otherwise FALSE.
|
||||
|
||||
**/
|
||||
**/
|
||||
BOOLEAN
|
||||
NetIp6IsValidUnicast (
|
||||
IN EFI_IPv6_ADDRESS *Ip6
|
||||
)
|
||||
)
|
||||
{
|
||||
UINT8 Byte;
|
||||
UINT8 Index;
|
||||
|
||||
|
||||
if (Ip6->Addr[0] == 0xFF) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -687,7 +683,7 @@ NetIp6IsValidUnicast (
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -697,7 +693,7 @@ NetIp6IsValidUnicast (
|
||||
|
||||
@retval TRUE - Yes, unspecified
|
||||
@retval FALSE - No
|
||||
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
NetIp6IsUnspecifiedAddr (
|
||||
@ -722,7 +718,7 @@ NetIp6IsUnspecifiedAddr (
|
||||
|
||||
@retval TRUE - Yes, link-local address
|
||||
@retval FALSE - No
|
||||
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
NetIp6IsLinkLocalAddr (
|
||||
@ -730,13 +726,13 @@ NetIp6IsLinkLocalAddr (
|
||||
)
|
||||
{
|
||||
UINT8 Index;
|
||||
|
||||
|
||||
ASSERT (Ip6 != NULL);
|
||||
|
||||
if (Ip6->Addr[0] != 0xFE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
if (Ip6->Addr[1] != 0x80) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -759,7 +755,7 @@ NetIp6IsLinkLocalAddr (
|
||||
|
||||
@retval TRUE - Yes, connected.
|
||||
@retval FALSE - No.
|
||||
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
NetIp6IsNetEqual (
|
||||
@ -773,14 +769,14 @@ NetIp6IsNetEqual (
|
||||
UINT8 Mask;
|
||||
|
||||
ASSERT (Ip1 != NULL && Ip2 != NULL);
|
||||
|
||||
|
||||
if (PrefixLength == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Byte = (UINT8) (PrefixLength / 8);
|
||||
Bit = (UINT8) (PrefixLength % 8);
|
||||
|
||||
|
||||
if (CompareMem (Ip1, Ip2, Byte) != 0) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -790,9 +786,9 @@ NetIp6IsNetEqual (
|
||||
|
||||
if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -831,11 +827,11 @@ Ip6Swap128 (
|
||||
|
||||
/**
|
||||
Initialize a random seed using current time.
|
||||
|
||||
Get current time first. Then initialize a random seed based on some basic
|
||||
mathematics operation on the hour, day, minute, second, nanosecond and year
|
||||
|
||||
Get current time first. Then initialize a random seed based on some basic
|
||||
mathematics operation on the hour, day, minute, second, nanosecond and year
|
||||
of the current time.
|
||||
|
||||
|
||||
@return The random seed initialized with current time.
|
||||
|
||||
**/
|
||||
@ -859,8 +855,8 @@ NetRandomInitSeed (
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
@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.
|
||||
|
||||
Converts a UINT32 from host byte order to network byte order. Then copy it to the
|
||||
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
|
||||
byte stream.
|
||||
|
||||
@param[in, out] Buf The buffer to put the UINT32.
|
||||
@param[in] Data The data to put.
|
||||
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
@ -905,16 +901,16 @@ NetPutUint32 (
|
||||
|
||||
/**
|
||||
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
|
||||
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 was not initialized, then ASSERT().
|
||||
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,
|
||||
then ASSERT().
|
||||
then ASSERT().
|
||||
|
||||
@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
|
||||
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 was not initialized, then ASSERT().
|
||||
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,
|
||||
then ASSERT().
|
||||
|
||||
then ASSERT().
|
||||
|
||||
@param[in, out] Head The list head.
|
||||
|
||||
@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.
|
||||
|
||||
|
||||
Inserts a new node entry donated by NewEntry after the node entry donated by PrevEntry
|
||||
of the doubly linked list.
|
||||
|
||||
|
||||
@param[in, out] PrevEntry The previous entry to insert after.
|
||||
@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.
|
||||
|
||||
|
||||
Inserts a new node entry donated by NewEntry after the node entry donated by PostEntry
|
||||
of the doubly linked list.
|
||||
|
||||
|
||||
@param[in, out] PostEntry The entry to insert before.
|
||||
@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 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.
|
||||
Initializes the count of the <Key, Value> pairs in the netmap to zero.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
If the address of Map->Used is NULL, then ASSERT().
|
||||
If the address of Map->Recycled is NULl, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to initialize.
|
||||
|
||||
**/
|
||||
@ -1071,13 +1067,13 @@ NetMapInit (
|
||||
|
||||
/**
|
||||
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 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.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
|
||||
If the number of the <Key, Value> pairs in the netmap is zero, return TRUE.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
|
||||
|
||||
@param[in] Map The net map to test.
|
||||
|
||||
@return TRUE if the netmap is empty, otherwise FALSE.
|
||||
@ -1158,15 +1154,15 @@ NetMapGetCount (
|
||||
|
||||
|
||||
/**
|
||||
Return one allocated item.
|
||||
|
||||
If the Recycled doubly linked list of the netmap is empty, it will try to allocate
|
||||
Return one allocated item.
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to allocate item for.
|
||||
|
||||
@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 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.
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to insert into.
|
||||
@param[in] Key The user's 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 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.
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to insert into.
|
||||
@param[in] Key The user's 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.
|
||||
|
||||
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.
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in] Map The netmap to search within.
|
||||
@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 Used doubly linked list of the netmap.
|
||||
The number of the <Key, Value> pairs in the netmap decrease by 1. Then add the node
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
If Item is NULL, 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] Item The item to remove.
|
||||
@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 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
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
If the Used doubly linked list is empty, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to remove the head from.
|
||||
@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 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
|
||||
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
|
||||
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.
|
||||
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
If the Used doubly linked list is empty, then ASSERT().
|
||||
|
||||
|
||||
@param[in, out] Map The netmap to remove the tail from.
|
||||
@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.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
If Map is NULL, then ASSERT().
|
||||
If CallBack is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in] Map The Map to iterate through.
|
||||
@param[in] CallBack The callback function to call for each item.
|
||||
@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.
|
||||
Uninstall all the protocols installed in the driver entry point.
|
||||
|
||||
|
||||
@param[in] ImageHandle The drivers' driver image.
|
||||
|
||||
@retval EFI_SUCCESS The image is unloaded.
|
||||
@ -1669,12 +1665,12 @@ NetLibDefaultUnload (
|
||||
|
||||
/**
|
||||
Create a child of the service that is identified by ServiceBindingGuid.
|
||||
|
||||
|
||||
Get the ServiceBinding Protocol first, then use it to create a child.
|
||||
|
||||
If ServiceBindingGuid is NULL, then ASSERT().
|
||||
If ChildHandle is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in] Controller The controller which has the service installed.
|
||||
@param[in] Image The image handle used to open service.
|
||||
@param[in] ServiceBindingGuid The service's Guid.
|
||||
@ -1725,11 +1721,11 @@ NetLibCreateServiceChild (
|
||||
|
||||
/**
|
||||
Destory a child of the service that is identified by ServiceBindingGuid.
|
||||
|
||||
|
||||
Get the ServiceBinding Protocol first, then use it to destroy a child.
|
||||
|
||||
|
||||
If ServiceBindingGuid is NULL, then ASSERT().
|
||||
|
||||
|
||||
@param[in] Controller The controller which has the service installed.
|
||||
@param[in] Image The image handle used to open service.
|
||||
@param[in] ServiceBindingGuid The service's Guid.
|
||||
@ -1793,7 +1789,7 @@ NetLibDestroyServiceChild (
|
||||
get the simple network protocol.
|
||||
@param[out] MacString The pointer to store the address of the string
|
||||
representation of the mac address.
|
||||
|
||||
|
||||
@retval EFI_SUCCESS Convert the mac address a unicode string successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough memory resource.
|
||||
@retval Others Failed to open the simple network protocol.
|
||||
@ -1811,6 +1807,7 @@ NetLibGetMacString (
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
EFI_SIMPLE_NETWORK_MODE *Mode;
|
||||
CHAR16 *MacAddress;
|
||||
UINT8 *HwAddress;
|
||||
UINTN Index;
|
||||
|
||||
*MacString = NULL;
|
||||
@ -1840,18 +1837,18 @@ NetLibGetMacString (
|
||||
if (MacAddress == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
*MacString = MacAddress;
|
||||
|
||||
//
|
||||
// Convert the mac address into a unicode string.
|
||||
//
|
||||
HwAddress = Mode->CurrentAddress.Addr;
|
||||
for (Index = 0; Index < Mode->HwAddressSize; Index++) {
|
||||
MacAddress[Index * 2] = (CHAR16) mNetLibHexStr[(Mode->CurrentAddress.Addr[Index] >> 4) & 0x0F];
|
||||
MacAddress[Index * 2 + 1] = (CHAR16) mNetLibHexStr[Mode->CurrentAddress.Addr[Index] & 0x0F];
|
||||
MacAddress += UnicodeValueToString (MacAddress, PREFIX_ZERO | RADIX_HEX, *(HwAddress++), 2);
|
||||
}
|
||||
|
||||
MacAddress[Mode->HwAddressSize * 2] = L'\0';
|
||||
|
||||
*MacString = MacAddress;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1860,11 +1857,11 @@ NetLibGetMacString (
|
||||
Check the default address used by the IPv4 driver is static or dynamic (acquired
|
||||
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,
|
||||
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.
|
||||
|
||||
|
||||
@param[in] Controller The controller handle which has the NIC Ip4 Config Protocol
|
||||
relative with the default address to judge.
|
||||
|
||||
@ -1911,7 +1908,7 @@ NetLibDefaultAddressIsStatic (
|
||||
if (ConfigHdr == NULL) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Len = StrLen (ConfigHdr);
|
||||
ConfigResp = AllocateZeroPool ((Len + NIC_ITEM_CONFIG_SIZE * 2 + 100) * sizeof (CHAR16));
|
||||
if (ConfigResp == NULL) {
|
||||
@ -1921,10 +1918,10 @@ NetLibDefaultAddressIsStatic (
|
||||
|
||||
String = ConfigResp + Len;
|
||||
UnicodeSPrint (
|
||||
String,
|
||||
(8 + 4 + 7 + 4 + 1) * sizeof (CHAR16),
|
||||
L"&OFFSET=%04X&WIDTH=%04X",
|
||||
OFFSET_OF (NIC_IP4_CONFIG_INFO, Source),
|
||||
String,
|
||||
(8 + 4 + 7 + 4 + 1) * sizeof (CHAR16),
|
||||
L"&OFFSET=%04X&WIDTH=%04X",
|
||||
OFFSET_OF (NIC_IP4_CONFIG_INFO, Source),
|
||||
sizeof (UINT32)
|
||||
);
|
||||
|
||||
@ -1957,7 +1954,7 @@ NetLibDefaultAddressIsStatic (
|
||||
}
|
||||
|
||||
IsStatic = (BOOLEAN) (ConfigInfo->Source == IP4_CONFIG_SOURCE_STATIC);
|
||||
|
||||
|
||||
ON_EXIT:
|
||||
|
||||
if (AccessResults != NULL) {
|
||||
@ -1978,7 +1975,7 @@ ON_EXIT:
|
||||
|
||||
/**
|
||||
Create an IPv4 device path node.
|
||||
|
||||
|
||||
The header type of IPv4 device path node is MESSAGING_DEVICE_PATH.
|
||||
The header subtype of IPv4 device path node is MSG_IPv4_DP.
|
||||
The length of the IPv4 device path node in bytes is 19.
|
||||
@ -2028,7 +2025,7 @@ NetLibCreateIPv4DPathNode (
|
||||
|
||||
/**
|
||||
Create an IPv6 device path node.
|
||||
|
||||
|
||||
The header type of IPv6 device path node is MESSAGING_DEVICE_PATH.
|
||||
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.
|
||||
@ -2070,7 +2067,7 @@ NetLibCreateIPv6DPathNode (
|
||||
|
||||
/**
|
||||
Find the UNDI/SNP handle from controller and protocol GUID.
|
||||
|
||||
|
||||
For example, IP will open a MNP child to transmit/receive
|
||||
packets, when MNP is stopped, IP should also be stopped. IP
|
||||
needs to find its own private data which is related the IP's
|
||||
|
Reference in New Issue
Block a user