Update the sockets library code

* Passes conformance and functional tests.
* Builds with GCC 4.4 compiler.

Signed-off by: lpleahy


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12497 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lpleahy
2011-09-30 23:02:35 +00:00
parent df7499fcc1
commit a88c31639b
40 changed files with 8998 additions and 6826 deletions

View File

@ -15,14 +15,30 @@
#include "Socket.h"
CONST EFI_GUID mEslRawServiceGuid = {
0xc31bf4a5, 0x2c7, 0x49d2, { 0xa5, 0x58, 0xfe, 0x62, 0x6f, 0x7e, 0xd4, 0x77 }
/**
The following GUID values are only used when an application links
against EfiSocketLib. An alternative set of values exists in
SocketDxe\EntryUnload.c which the SocketDxe driver uses to coexist
with socket applications.
Tag GUID - IPv4 in use by an application using EfiSocketLib
**/
CONST EFI_GUID mEslIp4ServiceGuid = {
0x9c756011, 0x5d44, 0x4ee0, { 0xbc, 0xe7, 0xc3, 0x82, 0x18, 0xfe, 0x39, 0x8d }
};
/**
Tag GUID - TCPv4 in use by an application using EfiSocketLib
**/
CONST EFI_GUID mEslTcp4ServiceGuid = {
0xffc659c2, 0x4ef2, 0x4532, { 0xb8, 0x75, 0xcd, 0x9a, 0xa4, 0x27, 0x4c, 0xde }
};
/**
Tag GUID - UDPv4 in use by an application using EfiSocketLib
**/
CONST EFI_GUID mEslUdp4ServiceGuid = {
0x44e03a55, 0x8d97, 0x4511, { 0xbf, 0xef, 0xa, 0x8b, 0xc6, 0x2c, 0x25, 0xae }
};
@ -31,10 +47,20 @@ CONST EFI_GUID mEslUdp4ServiceGuid = {
/**
Connect to the EFI socket library
@param [in] ppSocketProtocol Address to receive the socket protocol address
This routine creates the ::ESL_SOCKET structure and returns
the API (::EFI_SOCKET_PROTOCOL address) to the socket file
system layer in BsdSocketLib.
This routine is called from the ::socket routine in BsdSocketLib
to create the data structure and initialize the API for a socket.
Note that this implementation is only used by socket applications
that link directly to EslSocketLib.
@param [in] ppSocketProtocol Address to receive the ::EFI_SOCKET_PROTOCOL
structure address
@return Value for ::errno, zero (0) indicates success.
@retval 0 Successfully returned the socket protocol
@retval other Value for errno
**/
int
EslServiceGetProtocol (
@ -42,7 +68,7 @@ EslServiceGetProtocol (
)
{
EFI_HANDLE ChildHandle;
DT_SOCKET * pSocket;
ESL_SOCKET * pSocket;
int RetVal;
EFI_STATUS Status;
@ -81,6 +107,16 @@ EslServiceGetProtocol (
/**
Connect to the network layer
This routine is the constructor for the EfiSocketLib when the
library is linked directly to an application. This routine
walks the ::cEslSocketBinding table to create ::ESL_SERVICE
structures, associated with the network adapters, which this
routine links to the ::ESL_LAYER structure.
This routine is called from ::EslConstructor as a result of the
constructor redirection in ::mpfnEslConstructor at the end of this
file.
@retval EFI_SUCCESS Successfully connected to the network layer
**/
@ -89,11 +125,12 @@ EslServiceNetworkConnect (
VOID
)
{
BOOLEAN bSomethingFound;
UINTN HandleCount;
EFI_HANDLE * pHandles;
UINTN Index;
CONST DT_SOCKET_BINDING * pSocketBinding;
CONST DT_SOCKET_BINDING * pEnd;
CONST ESL_SOCKET_BINDING * pEnd;
EFI_HANDLE * pHandles;
CONST ESL_SOCKET_BINDING * pSocketBinding;
EFI_STATUS Status;
DBG_ENTER ( );
@ -102,13 +139,14 @@ EslServiceNetworkConnect (
// Initialize the socket layer
//
Status = EFI_SUCCESS;
bSomethingFound = FALSE;
EslServiceLoad ( gImageHandle );
//
// Connect the network devices
//
pSocketBinding = &cEslSocketBinding [0];
pEnd = &pSocketBinding [ cEslSocketBindingEntries ];
pSocketBinding = &cEslSocketBinding[0];
pEnd = &pSocketBinding[ cEslSocketBindingEntries ];
while ( pEnd > pSocketBinding ) {
//
// Attempt to locate the network adapters
@ -121,24 +159,30 @@ EslServiceNetworkConnect (
&HandleCount,
&pHandles );
if ( EFI_ERROR ( Status )) {
break;
DEBUG (( DEBUG_ERROR,
"ERROR with %s layer, Status: %r\r\n",
pSocketBinding->pName,
Status ));
}
if ( NULL != pHandles ) {
//
// Attempt to connect to this network adapter
//
for ( Index = 0; HandleCount > Index; Index++ ) {
Status = EslServiceConnect ( gImageHandle,
pHandles [ Index ]);
if ( EFI_ERROR ( Status )) {
break;
else {
if ( NULL != pHandles ) {
//
// Attempt to connect to this network adapter
//
for ( Index = 0; HandleCount > Index; Index++ ) {
Status = EslServiceConnect ( gImageHandle,
pHandles[ Index ]);
if ( EFI_ERROR ( Status )) {
break;
}
bSomethingFound = TRUE;
}
}
//
// Done with the handles
//
gBS->FreePool ( pHandles );
//
// Done with the handles
//
gBS->FreePool ( pHandles );
}
}
//
@ -150,6 +194,9 @@ EslServiceNetworkConnect (
//
// Return the network connection status
//
if ( bSomethingFound ) {
Status = EFI_SUCCESS;
}
DBG_EXIT_STATUS ( Status );
return Status;
}
@ -158,6 +205,15 @@ EslServiceNetworkConnect (
/**
Disconnect from the network layer
Destructor for the EfiSocketLib when the library is linked
directly to an application. This routine walks the
::cEslSocketBinding table to remove the ::ESL_SERVICE
structures (network connections) from the ::ESL_LAYER structure.
This routine is called from ::EslDestructor as a result of the
destructor redirection in ::mpfnEslDestructor at the end of this
file.
@retval EFI_SUCCESS Successfully disconnected from the network layer
**/
@ -167,10 +223,10 @@ EslServiceNetworkDisconnect (
)
{
UINTN HandleCount;
EFI_HANDLE * pHandles;
UINTN Index;
CONST DT_SOCKET_BINDING * pSocketBinding;
CONST DT_SOCKET_BINDING * pEnd;
CONST ESL_SOCKET_BINDING * pEnd;
EFI_HANDLE * pHandles;
CONST ESL_SOCKET_BINDING * pSocketBinding;
EFI_STATUS Status;
DBG_ENTER ( );
@ -183,8 +239,8 @@ EslServiceNetworkDisconnect (
//
// Disconnect the network devices
//
pSocketBinding = &cEslSocketBinding [0];
pEnd = &pSocketBinding [ cEslSocketBindingEntries ];
pSocketBinding = &cEslSocketBinding[0];
pEnd = &pSocketBinding[ cEslSocketBindingEntries ];
while ( pEnd > pSocketBinding ) {
//
// Attempt to locate the network adapters
@ -205,7 +261,7 @@ EslServiceNetworkDisconnect (
//
for ( Index = 0; HandleCount > Index; Index++ ) {
Status = EslServiceDisconnect ( gImageHandle,
pHandles [ Index ]);
pHandles[ Index ]);
if ( EFI_ERROR ( Status )) {
break;
}
@ -238,5 +294,19 @@ EslServiceNetworkDisconnect (
}
PFN_ESL_xSTRUCTOR mpfnEslConstructor = EslServiceNetworkConnect;
PFN_ESL_xSTRUCTOR mpfnEslDestructor = EslServiceNetworkDisconnect;
/**
Socket layer's service binding protocol delcaration.
**/
CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {
NULL,
NULL
};
/**
The following entries redirect the constructor and destructor
for any socket application that links against the EfiSocketLib.
Note that the SocketDxe driver uses different redirection.
**/
PFN_ESL_xSTRUCTOR mpfnEslConstructor = EslServiceNetworkConnect; ///< Constructor for EfiSocketLib
PFN_ESL_xSTRUCTOR mpfnEslDestructor = EslServiceNetworkDisconnect; ///< Destructor for EfiSocketLib