summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-14 01:43:29 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-09-14 01:43:29 +0000
commit18aa9a0316f4b496fc009018434db424c7cced5f (patch)
treedbe36e501b17c07a08d3d112377e9cbe5495b2ec
parent2481fa19834126489c9b627caa8f3bf137e57191 (diff)
downloadedk2-18aa9a0316f4b496fc009018434db424c7cced5f.zip
edk2-18aa9a0316f4b496fc009018434db424c7cced5f.tar.gz
edk2-18aa9a0316f4b496fc009018434db424c7cced5f.tar.bz2
Merge the bind routines.
Eliminate the network specific initialization and shutdown routines. Signed-off by: Lee Leahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK@12344 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--StdLib/EfiSocketLib/Ip4.c275
-rw-r--r--StdLib/EfiSocketLib/Service.c68
-rw-r--r--StdLib/EfiSocketLib/Socket.c167
-rw-r--r--StdLib/EfiSocketLib/Socket.h264
-rw-r--r--StdLib/EfiSocketLib/Tcp4.c260
-rw-r--r--StdLib/EfiSocketLib/Udp4.c322
-rw-r--r--StdLib/Include/Efi/EfiSocketLib.h21
7 files changed, 230 insertions, 1147 deletions
diff --git a/StdLib/EfiSocketLib/Ip4.c b/StdLib/EfiSocketLib/Ip4.c
index 780127e..2d8a161 100644
--- a/StdLib/EfiSocketLib/Ip4.c
+++ b/StdLib/EfiSocketLib/Ip4.c
@@ -52,8 +52,9 @@
**/
CONST ESL_PROTOCOL_API cEslIp4Api = {
IPPROTO_IP,
+ OFFSET_OF ( ESL_LAYER, pIp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
NULL, // Accept
- EslIp4Bind,
EslIp4Connect,
NULL, // ConnectPoll
EslIp4GetLocalAddress,
@@ -76,141 +77,6 @@ CONST ESL_PROTOCOL_API cEslIp4Api = {
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address) to the IPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the IPv4 specific
- protocol bind operations for SOCK_RAW sockets.
-
- The configure call to the IP4 driver occurs on the first poll, recv, recvfrom,
- send or sentto call. Until then, all changes are made in the local IP context
- structure.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslIp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- )
-{
- EFI_HANDLE ChildHandle;
- CONST struct sockaddr_in * pIp4Address;
- EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pService;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Assume success
- //
- pSocket->errno = 0;
- Status = EFI_SUCCESS;
-
- //
- // Validate the address length
- //
- pIp4Address = (CONST struct sockaddr_in *) pSockAddr;
- if ( SockAddrLength >= ( sizeof ( *pIp4Address )
- - sizeof ( pIp4Address->sin_zero ))) {
-
- //
- // Walk the list of services
- //
- pLayer = &mEslLayer;
- pService = pLayer->pIp4List;
- while ( NULL != pService ) {
-
- //
- // Create the IP port
- //
- pServiceBinding = pService->pServiceBinding;
- ChildHandle = NULL;
- Status = pServiceBinding->CreateChild ( pServiceBinding,
- &ChildHandle );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "0x%08x: Ip4 port handle created\r\n",
- ChildHandle ));
-
- //
- // Open the port
- //
- Status = EslSocketPortAllocate ( pSocket,
- pService,
- ChildHandle,
- (UINT8 *) &pIp4Address->sin_addr.s_addr,
- 0,
- DEBUG_BIND,
- &pPort );
- }
- else {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "ERROR - Failed to open Ip4 port handle, Status: %r\r\n",
- Status ));
- }
-
- //
- // Set the next service
- //
- pService = pService->pNext;
- }
-
- //
- // Verify that at least one network connection was found
- //
- if ( NULL == pSocket->pPortList ) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
- "Socket address %d.%d.%d.%d (0x%08x) is not available!\r\n",
- ( pIp4Address->sin_addr.s_addr >> 24 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 16 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 8 ) & 0xff,
- pIp4Address->sin_addr.s_addr & 0xff,
- pIp4Address->sin_addr.s_addr ));
- pSocket->errno = EADDRNOTAVAIL;
- Status = EFI_INVALID_PARAMETER;
- }
- }
- else {
- DEBUG (( DEBUG_BIND,
- "ERROR - Invalid Ip4 address length: %d\r\n",
- SockAddrLength ));
- Status = EFI_INVALID_PARAMETER;
- pSocket->errno = EINVAL;
- }
-
- //
- // Return the operation status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Set the default remote system address.
This routine sets the default remote address for a SOCK_RAW
@@ -483,52 +349,6 @@ EslIp4GetRemoteAddress (
/**
- Initialize the IP4 service.
-
- This routine initializes the IP4 service which is used by the
- sockets layer to support SOCK_RAW sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running IPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslIp4Initialize (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Connect this service to the service list
- //
- pLayer = &mEslLayer;
- pService->pNext = pLayer->pIp4List;
- pLayer->pIp4List = pService;
-
- //
- // Assume the list is empty
- //
- Status = EFI_SUCCESS;
-
- //
- // Return the initialization status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Get the option value
This routine handles the IPv4 level options.
@@ -1619,91 +1439,13 @@ EslIp4RxStart (
/**
- Shutdown the IP4 service.
-
- This routine undoes the work performed by ::EslIp4Initialize to
- shutdown the IP4 service which is used by the sockets layer to
- support SOCK_RAW sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- IPv4.
-
- @param [in] pService The address of an ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslIp4Shutdown (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pPreviousService;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Walk the list of ports
- //
- do {
- pPort = pService->pPortList;
- if ( NULL != pPort ) {
- //
- // Remove the port from the port list
- //
- pService->pPortList = pPort->pLinkService;
-
- //
- // Close the port
- // TODO: Fix this
- //
-// pPort->pfnClosePort ( pPort, 0 );
- }
- } while ( NULL != pPort );
-
- //
- // Remove the service from the service list
- //
- pLayer = &mEslLayer;
- pPreviousService = pLayer->pIp4List;
- if ( pService == pPreviousService ) {
- //
- // Remove the service from the beginning of the list
- //
- pLayer->pIp4List = pService->pNext;
- }
- else {
- //
- // Remove the service from the middle of the list
- //
- while ( NULL != pPreviousService ) {
- if ( pService == pPreviousService->pNext ) {
- pPreviousService->pNext = pService->pNext;
- break;
- }
- pPreviousService = pPreviousService->pNext;
- }
- }
-
- DBG_EXIT ( );
-}
-
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
if the network layer's configuration routine has been called.
- This routine calls the bind and configuration routines if they
- were not already called. After the port is configured, the
- \ref Ip4ReceiveEngine is started.
+ This routine calls the ::EslSocketBind and configuration routines
+ if they were not already called. After the port is configured,
+ the \ref Ip4ReceiveEngine is started.
This routine is called by EslSocketIsConfigured to verify
that the socket is configured.
@@ -1746,9 +1488,10 @@ EslIp4Shutdown (
LocalAddress.sin_family = AF_INET;
LocalAddress.sin_addr.s_addr = 0;
LocalAddress.sin_port = 0;
- Status = EslIp4Bind ( pSocket,
- (struct sockaddr *)&LocalAddress,
- LocalAddress.sin_len );
+ Status = EslSocketBind ( &pSocket->SocketProtocol,
+ (struct sockaddr *)&LocalAddress,
+ LocalAddress.sin_len,
+ &pSocket->errno );
}
//
diff --git a/StdLib/EfiSocketLib/Service.c b/StdLib/EfiSocketLib/Service.c
index 21cdce4..927f0e4 100644
--- a/StdLib/EfiSocketLib/Service.c
+++ b/StdLib/EfiSocketLib/Service.c
@@ -41,8 +41,10 @@ EslServiceConnect (
{
BOOLEAN bInUse;
UINTN LengthInBytes;
+ UINT8 * pBuffer;
CONST ESL_SOCKET_BINDING * pEnd;
VOID * pJunk;
+ ESL_SERVICE ** ppServiceListHead;
ESL_SERVICE * pService;
CONST ESL_SOCKET_BINDING * pSocketBinding;
EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
@@ -155,9 +157,13 @@ EslServiceConnect (
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
//
- // Initialize the service
+ // Connect the service to the list
//
- Status = pSocketBinding->pfnInitialize ( pService );
+ pBuffer = (UINT8 *)&mEslLayer;
+ pBuffer = &pBuffer[ pSocketBinding->ServiceListOffset ];
+ ppServiceListHead = (ESL_SERVICE **)pBuffer;
+ pService->pNext = *ppServiceListHead;
+ *ppServiceListHead = pService;
//
// Release the socket layer synchronization
@@ -256,9 +262,8 @@ EslServiceConnect (
/**
Shutdown the connections to the network layer by locating the
tags on the network interfaces established by ::EslServiceConnect.
- This routine calls ESL_SOCKET_BINDING::pfnShutdown to shutdown the any
- activity on the network interface and then free the ::ESL_SERVICE
- structures.
+ This routine shutdowns any activity on the network interface and
+ then frees the ::ESL_SERVICE structures.
@param [in] BindingHandle Handle for protocol binding.
@param [in] Controller Handle of device to stop driver on.
@@ -275,8 +280,12 @@ EslServiceDisconnect (
IN EFI_HANDLE Controller
)
{
+ UINT8 * pBuffer;
CONST ESL_SOCKET_BINDING * pEnd;
+ ESL_PORT * pPort;
+ ESL_SERVICE * pPreviousService;
ESL_SERVICE * pService;
+ ESL_SERVICE ** ppServiceListHead;
CONST ESL_SOCKET_BINDING * pSocketBinding;
EFI_STATUS Status;
EFI_TPL TplPrevious;
@@ -313,9 +322,54 @@ EslServiceDisconnect (
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
//
- // Shutdown the service
+ // Walk the list of ports
//
- pSocketBinding->pfnShutdown ( pService );
+ pPort = pService->pPortList;
+ while ( NULL != pPort ) {
+ //
+ // Remove the port from the port list
+ //
+ pPort->pService = NULL;
+ pService->pPortList = pPort->pLinkService;
+
+ //
+ // Close the port
+ //
+ EslSocketPortCloseStart ( pPort,
+ TRUE,
+ DEBUG_POOL | DEBUG_INIT );
+
+ //
+ // Set the next port
+ //
+ pPort = pService->pPortList;
+ }
+
+ //
+ // Remove the service from the service list
+ //
+ pBuffer = (UINT8 *)&mEslLayer;
+ pBuffer = &pBuffer[ pService->pSocketBinding->ServiceListOffset ];
+ ppServiceListHead = (ESL_SERVICE **)pBuffer;
+ pPreviousService = *ppServiceListHead;
+ if ( pService == pPreviousService ) {
+ //
+ // Remove the service from the beginning of the list
+ //
+ *ppServiceListHead = pService->pNext;
+ }
+ else {
+ //
+ // Remove the service from the middle of the list
+ //
+ while ( NULL != pPreviousService ) {
+ if ( pService == pPreviousService->pNext ) {
+ pPreviousService->pNext = pService->pNext;
+ break;
+ }
+ pPreviousService = pPreviousService->pNext;
+ }
+ }
//
// Release the socket layer synchronization
diff --git a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c
index 2c367fc..3f7040d 100644
--- a/StdLib/EfiSocketLib/Socket.c
+++ b/StdLib/EfiSocketLib/Socket.c
@@ -96,24 +96,21 @@ CONST ESL_SOCKET_BINDING cEslSocketBinding[] = {
&gEfiIp4ServiceBindingProtocolGuid,
&gEfiIp4ProtocolGuid,
&mEslIp4ServiceGuid,
- EslIp4Initialize,
- EslIp4Shutdown,
+ OFFSET_OF ( ESL_LAYER, pIp4List ),
4,
0 },
{ L"Tcp4",
&gEfiTcp4ServiceBindingProtocolGuid,
&gEfiTcp4ProtocolGuid,
&mEslTcp4ServiceGuid,
- EslTcp4Initialize,
- EslTcp4Shutdown,
+ OFFSET_OF ( ESL_LAYER, pTcp4List ),
4,
4 },
{ L"Udp4",
&gEfiUdp4ServiceBindingProtocolGuid,
&gEfiUdp4ProtocolGuid,
&mEslUdp4ServiceGuid,
- EslUdp4Initialize,
- EslUdp4Shutdown,
+ OFFSET_OF ( ESL_LAYER, pUdp4List ),
4,
0 }
};
@@ -696,7 +693,14 @@ EslSocketBind (
OUT int * pErrno
)
{
+ EFI_HANDLE ChildHandle;
+ UINT8 * pBuffer;
+ CONST struct sockaddr_in * pIp4Address;
+ ESL_PORT * pPort;
+ ESL_SERVICE ** ppServiceListHead;
ESL_SOCKET * pSocket;
+ ESL_SERVICE * pService;
+ EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
EFI_STATUS Status;
EFI_TPL TplPrevious;
@@ -717,6 +721,7 @@ EslSocketBind (
//
// Validate the structure pointer
//
+ pSocket->errno = 0;
if ( NULL == pSockAddr ) {
DEBUG (( DEBUG_BIND,
"ERROR - pSockAddr is NULL!\r\n" ));
@@ -745,37 +750,94 @@ EslSocketBind (
}
//
- // Verify the API
+ // Synchronize with the socket layer
//
- if ( NULL == pSocket->pApi->pfnBind ) {
- Status = EFI_UNSUPPORTED;
- pSocket->errno = ENOTSUP;
- }
- else {
- //
- // Synchronize with the socket layer
- //
- RAISE_TPL ( TplPrevious, TPL_SOCKETS );
+ RAISE_TPL ( TplPrevious, TPL_SOCKETS );
+ //
+ // Validate the address length
+ //
+ pIp4Address = (CONST struct sockaddr_in *) pSockAddr;
+ if ( SockAddrLength >= pSocket->pApi->MinimumAddressLength ) {
//
- // Bind the socket
+ // Walk the list of services
//
- Status = pSocket->pApi->pfnBind ( pSocket,
- pSockAddr,
- SockAddrLength );
-
+ pBuffer = (UINT8 *)&mEslLayer;
+ pBuffer = &pBuffer[ pSocket->pApi->ServiceListOffset ];
+ ppServiceListHead = (ESL_SERVICE **)pBuffer;
+ pService = *ppServiceListHead;
+ while ( NULL != pService ) {
+ //
+ // Create the port
+ //
+ pServiceBinding = pService->pServiceBinding;
+ ChildHandle = NULL;
+ Status = pServiceBinding->CreateChild ( pServiceBinding,
+ &ChildHandle );
+ if ( !EFI_ERROR ( Status )) {
+ DEBUG (( DEBUG_BIND | DEBUG_POOL,
+ "0x%08x: %s port handle created\r\n",
+ ChildHandle,
+ pService->pSocketBinding->pName ));
+
+ //
+ // Open the port
+ //
+ Status = EslSocketPortAllocate ( pSocket,
+ pService,
+ ChildHandle,
+ (UINT8 *) &pIp4Address->sin_addr.s_addr,
+ SwapBytes16 ( pIp4Address->sin_port ),
+ DEBUG_BIND,
+ &pPort );
+ }
+ else {
+ DEBUG (( DEBUG_BIND | DEBUG_POOL,
+ "ERROR - Failed to open %s port handle, Status: %r\r\n",
+ pService->pSocketBinding->pName,
+ Status ));
+ }
+
+ //
+ // Set the next service
+ //
+ pService = pService->pNext;
+ }
+
//
- // Mark this socket as bound if successful
+ // Verify that at least one network connection was found
//
- if ( !EFI_ERROR ( Status )) {
- pSocket->State = SOCKET_STATE_BOUND;
+ if ( NULL == pSocket->pPortList ) {
+ DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
+ "Socket address %d.%d.%d.%d (0x%08x) is not available!\r\n",
+ ( pIp4Address->sin_addr.s_addr >> 24 ) & 0xff,
+ ( pIp4Address->sin_addr.s_addr >> 16 ) & 0xff,
+ ( pIp4Address->sin_addr.s_addr >> 8 ) & 0xff,
+ pIp4Address->sin_addr.s_addr & 0xff,
+ pIp4Address->sin_addr.s_addr ));
+ pSocket->errno = EADDRNOTAVAIL;
+ Status = EFI_INVALID_PARAMETER;
}
+ }
+ else {
+ DEBUG (( DEBUG_BIND,
+ "ERROR - Invalid address length: %d\r\n",
+ SockAddrLength ));
+ Status = EFI_INVALID_PARAMETER;
+ pSocket->errno = EINVAL;
+ }
- //
- // Release the socket layer synchronization
- //
- RESTORE_TPL ( TplPrevious );
+ //
+ // Mark this socket as bound if successful
+ //
+ if ( !EFI_ERROR ( Status )) {
+ pSocket->State = SOCKET_STATE_BOUND;
}
+
+ //
+ // Release the socket layer synchronization
+ //
+ RESTORE_TPL ( TplPrevious );
}
}
}
@@ -2544,10 +2606,9 @@ EslSocketPoll (
This support routine is called by:
<ul>
- <li>::EslIp4Bind</li>
- <li>::EslTcp4Bind</li>
+ <li>::EslSocketBind</li>
<li>::EslTcp4ListenComplete</li>
- <li>::EslUdp4Bind::</li>
+ </ul>
to connect the socket with the underlying network adapter
to the socket.
@@ -2626,7 +2687,9 @@ EslSocketPortAllocate (
pPort->DebugFlags = DebugFlags;
pPort->Handle = ChildHandle;
pPort->pService = pService;
+ pPort->pServiceBinding = pService->pServiceBinding;
pPort->pSocket = pSocket;
+ pPort->pSocketBinding = pService->pSocketBinding;
pPort->Signature = PORT_SIGNATURE;
//
@@ -2839,28 +2902,32 @@ EslSocketPortClose (
//
// Locate the port in the service list
+ // Note that the port may not be in the service list
+ // if the service has been shutdown.
//
pService = pPort->pService;
- pPreviousPort = pService->pPortList;
- if ( pPreviousPort == pPort ) {
- //
- // Remove this port from the head of the service list
- //
- pService->pPortList = pPort->pLinkService;
- }
- else {
- //
- // Locate the port in the middle of the service list
- //
- while (( NULL != pPreviousPort )
- && ( pPreviousPort->pLinkService != pPort )) {
- pPreviousPort = pPreviousPort->pLinkService;
+ if ( NULL != pService ) {
+ pPreviousPort = pService->pPortList;
+ if ( pPreviousPort == pPort ) {
+ //
+ // Remove this port from the head of the service list
+ //
+ pService->pPortList = pPort->pLinkService;
}
- if ( NULL != pPreviousPort ) {
+ else {
//
- // Remove the port from the middle of the service list
+ // Locate the port in the middle of the service list
//
- pPreviousPort->pLinkService = pPort->pLinkService;
+ while (( NULL != pPreviousPort )
+ && ( pPreviousPort->pLinkService != pPort )) {
+ pPreviousPort = pPreviousPort->pLinkService;
+ }
+ if ( NULL != pPreviousPort ) {
+ //
+ // Remove the port from the middle of the service list
+ //
+ pPreviousPort->pLinkService = pPort->pLinkService;
+ }
}
}
@@ -2922,7 +2989,7 @@ EslSocketPortClose (
//
// Done with the lower layer network protocol
//
- pSocketBinding = pService->pSocketBinding;
+ pSocketBinding = pPort->pSocketBinding;
if ( NULL != pPort->pProtocol.v ) {
Status = gBS->CloseProtocol ( pPort->Handle,
pSocketBinding->pNetworkProtocolGuid,
@@ -2946,7 +3013,7 @@ EslSocketPortClose (
//
// Done with the network port
//
- pServiceBinding = pService->pServiceBinding;
+ pServiceBinding = pPort->pServiceBinding;
if ( NULL != pPort->Handle ) {
Status = pServiceBinding->DestroyChild ( pServiceBinding,
pPort->Handle );
diff --git a/StdLib/EfiSocketLib/Socket.h b/StdLib/EfiSocketLib/Socket.h
index 5a99370..504dee7 100644
--- a/StdLib/EfiSocketLib/Socket.h
+++ b/StdLib/EfiSocketLib/Socket.h
@@ -316,6 +316,12 @@ typedef struct _ESL_PORT {
ESL_SOCKET * pSocket; ///< Socket for this port
//
+ // Eliminate the pService references during port close
+ //
+ EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding; ///< Service binding for network layer
+ CONST ESL_SOCKET_BINDING * pSocketBinding; ///< Socket binding for network layer
+
+ //
// Port management
//
EFI_HANDLE Handle; ///< Network port handle
@@ -380,34 +386,6 @@ EFI_STATUS
);
/**
- Bind a name to a socket.
-
- @param [in] pSocket Address of the socket structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLen Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-typedef
-EFI_STATUS
-(* PFN_API_BIND) (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
Connect to a remote system via the network.
@param [in] pSocket Address of the socket structure.
@@ -764,8 +742,9 @@ VOID
**/
typedef struct {
int DefaultProtocol; ///< Default protocol
+ UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services
+ UINTN MinimumAddressLength; ///< Minimum address length in bytes
PFN_API_ACCEPT pfnAccept; ///< Accept a network connection
- PFN_API_BIND pfnBind; ///< Bind API for the protocol
PFN_API_CONNECT_START pfnConnectStart; ///< Start the connection to a remote system
PFN_API_CONNECT_POLL pfnConnectPoll; ///< Poll for connection complete
PFN_API_GET_LOCAL_ADDR pfnGetLocalAddr; ///< Get local address
@@ -1317,40 +1296,6 @@ EslSocketTxStart (
//------------------------------------------------------------------------------
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address) to the IPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the IPv4 specific
- protocol bind operations for SOCK_RAW sockets.
-
- The configure call to the IP4 driver occurs on the first poll, recv, recvfrom,
- send or sentto call. Until then, all changes are made in the local IP context
- structure.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslIp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
Set the default remote system address.
This routine sets the default remote address for a SOCK_RAW
@@ -1431,27 +1376,6 @@ EslIp4GetRemoteAddress (
);
/**
- Initialize the IP4 service.
-
- This routine initializes the IP4 service which is used by the
- sockets layer to support SOCK_RAW sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running IPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslIp4Initialize (
- IN ESL_SERVICE * pService
- );
-
-/**
Get the option value
This routine handles the IPv4 level options.
@@ -1695,26 +1619,6 @@ EslIp4RxStart (
);
/**
- Shutdown the IP4 service.
-
- This routine undoes the work performed by ::EslIp4Initialize to
- shutdown the IP4 service which is used by the sockets layer to
- support SOCK_RAW sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- IPv4.
-
- @param [in] pService The address of an ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslIp4Shutdown (
- IN ESL_SERVICE * pService
- );
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
@@ -1840,39 +1744,6 @@ EslTcp4Accept (
);
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address and port number) to the TCPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the TCPv4 specific
- protocol bind operations for SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslTcp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
Poll for completion of the connection attempt.
This routine polls the ESL_SOCKET::bConnected flag to determine
@@ -1977,27 +1848,6 @@ EslTcp4GetRemoteAddress (
);
/**
- Initialize the TCP4 service.
-
- This routine initializes the TCP4 service which is used by the
- sockets layer to support SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running TCPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure.
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslTcp4Initialize (
- IN ESL_SERVICE * pService
- );
-
-/**
Establish the known port to listen for network connections.
This routine places the port into a state that enables connection
@@ -2235,26 +2085,6 @@ EslTcp4RxStart (
);
/**
- Shutdown the TCP4 service.
-
- This routine undoes the work performed by ::EslTcp4Initialize to
- shutdown the TCP4 service which is used by the sockets layer to
- support SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- TCPv4.
-
- @param [in] pService Adress of a ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslTcp4Shutdown (
- IN ESL_SERVICE * pService
- );
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
@@ -2365,43 +2195,6 @@ EslTcp4TxOobComplete (
//------------------------------------------------------------------------------
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address and port number) to the UDPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the UDPv4 specific
- protocol bind operations for SOCK_DGRAM sockets.
-
- The configure call to the UDP4 driver occurs on the first poll, recv, recvfrom,
- send or sentto call. Until then, all changes are made in the local UDP context
- structure.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslUdp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- );
-
-/**
Set the default remote system address.
This routine sets the default remote address for a SOCK_DGRAM
@@ -2482,27 +2275,6 @@ EslUdp4GetRemoteAddress (
);
/**
- Initialize the UDP4 service.
-
- This routine initializes the UDP4 service which is used by the
- sockets layer to support SOCK_DGRAM sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running UDPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslUdp4Initialize (
- IN ESL_SERVICE * pService
- );
-
-/**
Initialize the network specific portions of an ::ESL_PORT structure.
This routine initializes the network specific portions of an
@@ -2694,26 +2466,6 @@ EslUdp4RxStart (
);
/**
- Shutdown the UDP4 service.
-
- This routine undoes the work performed by ::EslUdp4Initialize to
- shutdown the UDP4 service which is used by the sockets layer to
- support SOCK_DGRAM sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- UDPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslUdp4Shutdown (
- IN ESL_SERVICE * pService
- );
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
diff --git a/StdLib/EfiSocketLib/Tcp4.c b/StdLib/EfiSocketLib/Tcp4.c
index 6b75423..4b6ae4e 100644
--- a/StdLib/EfiSocketLib/Tcp4.c
+++ b/StdLib/EfiSocketLib/Tcp4.c
@@ -64,8 +64,9 @@
**/
CONST ESL_PROTOCOL_API cEslTcp4Api = {
IPPROTO_TCP,
+ OFFSET_OF ( ESL_LAYER, pTcp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
EslTcp4Accept,
- EslTcp4Bind,
EslTcp4ConnectStart,
EslTcp4ConnectPoll,
EslTcp4GetLocalAddress,
@@ -177,139 +178,6 @@ EslTcp4Accept (
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address and port number) to the TCPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the TCPv4 specific
- protocol bind operations for SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslTcp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- )
-{
- EFI_HANDLE ChildHandle;
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pService;
- CONST struct sockaddr_in * pIp4Address;
- EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Assume success
- //
- pSocket->errno = 0;
- Status = EFI_SUCCESS;
-
- //
- // Validate the address length
- //
- pIp4Address = (CONST struct sockaddr_in *) pSockAddr;
- if ( SockAddrLength >= ( sizeof ( *pIp4Address )
- - sizeof ( pIp4Address->sin_zero ))) {
-
- //
- // Walk the list of services
- //
- pLayer = &mEslLayer;
- pService = pLayer->pTcp4List;
- while ( NULL != pService ) {
- //
- // Create the TCP port
- //
- pServiceBinding = pService->pServiceBinding;
- ChildHandle = NULL;
- Status = pServiceBinding->CreateChild ( pServiceBinding,
- &ChildHandle );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "0x%08x: Tcp4 port handle created\r\n",
- ChildHandle ));
-
- //
- // Open the port
- //
- Status = EslSocketPortAllocate ( pSocket,
- pService,
- ChildHandle,
- (UINT8 *) &pIp4Address->sin_addr.s_addr,
- SwapBytes16 ( pIp4Address->sin_port ),
- DEBUG_BIND,
- &pPort );
- }
- else {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "ERROR - Failed to open Tcp4 port handle, Status: %r\r\n",
- Status ));
- }
-
- //
- // Set the next service
- //
- pService = pService->pNext;
- }
-
- //
- // Verify that at least one network connection was found
- //
- if ( NULL == pSocket->pPortList ) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
- "Socket address %d.%d.%d.%d (0x%08x) is not available!\r\n",
- ( pIp4Address->sin_addr.s_addr >> 24 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 16 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 8 ) & 0xff,
- pIp4Address->sin_addr.s_addr & 0xff,
- pIp4Address->sin_addr.s_addr ));
- pSocket->errno = EADDRNOTAVAIL;
- Status = EFI_INVALID_PARAMETER;
- }
- }
- else {
- DEBUG (( DEBUG_BIND,
- "ERROR - Invalid TCP4 address length: %d\r\n",
- SockAddrLength ));
- Status = EFI_INVALID_PARAMETER;
- pSocket->errno = EINVAL;
- }
-
- //
- // Return the operation status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Attempt to connect to a remote TCP port
This routine configures the local TCPv4 connection point and
@@ -955,52 +823,6 @@ EslTcp4GetRemoteAddress (
/**
- Initialize the TCP4 service.
-
- This routine initializes the TCP4 service which is used by the
- sockets layer to support SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running TCPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure.
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslTcp4Initialize (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Connect this service to the service list
- //
- pLayer = &mEslLayer;
- pService->pNext = pLayer->pTcp4List;
- pLayer->pTcp4List = pService;
-
- //
- // Assume the list is empty
- //
- Status = EFI_SUCCESS;
-
- //
- // Return the initialization status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Establish the known port to listen for network connections.
This routine places the port into a state that enables connection
@@ -2425,84 +2247,6 @@ EslTcp4RxStart (
/**
- Shutdown the TCP4 service.
-
- This routine undoes the work performed by ::EslTcp4Initialize to
- shutdown the TCP4 service which is used by the sockets layer to
- support SOCK_STREAM and SOCK_SEQPACKET sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- TCPv4.
-
- @param [in] pService Adress of a ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslTcp4Shutdown (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pPreviousService;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Walk the list of ports
- //
- do {
- pPort = pService->pPortList;
- if ( NULL != pPort ) {
- //
- // Remove the port from the port list
- //
- pService->pPortList = pPort->pLinkService;
-
- //
- // Close the port
- // TODO: Fix this
- //
-// pPort->pfnClosePort ( pPort, DEBUG_LISTEN | DEBUG_CONNECTION );
- }
- } while ( NULL != pPort );
-
- //
- // Remove the service from the service list
- //
- pLayer = &mEslLayer;
- pPreviousService = pLayer->pTcp4List;
- if ( pService == pPreviousService ) {
- //
- // Remove the service from the beginning of the list
- //
- pLayer->pTcp4List = pService->pNext;
- }
- else {
- //
- // Remove the service from the middle of the list
- //
- while ( NULL != pPreviousService ) {
- if ( pService == pPreviousService->pNext ) {
- pPreviousService->pNext = pService->pNext;
- break;
- }
- pPreviousService = pPreviousService->pNext;
- }
- }
-
- DBG_EXIT ( );
-}
-
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
diff --git a/StdLib/EfiSocketLib/Udp4.c b/StdLib/EfiSocketLib/Udp4.c
index 916086e..c032bfc 100644
--- a/StdLib/EfiSocketLib/Udp4.c
+++ b/StdLib/EfiSocketLib/Udp4.c
@@ -52,8 +52,9 @@
**/
CONST ESL_PROTOCOL_API cEslUdp4Api = {
IPPROTO_UDP,
+ OFFSET_OF ( ESL_LAYER, pUdp4List ),
+ OFFSET_OF ( struct sockaddr_in, sin_zero ),
NULL, // Accept
- EslUdp4Bind,
EslUdp4Connect,
NULL, // ConnectPoll
EslUdp4GetLocalAddress,
@@ -76,144 +77,6 @@ CONST ESL_PROTOCOL_API cEslUdp4Api = {
/**
- Bind a name to a socket.
-
- This routine connects a name (IPv4 address and port number) to the UDPv4 stack
- on the local machine.
-
- This routine is called by ::EslSocketBind to handle the UDPv4 specific
- protocol bind operations for SOCK_DGRAM sockets.
-
- The configure call to the UDP4 driver occurs on the first poll, recv, recvfrom,
- send or sentto call. Until then, all changes are made in the local UDP context
- structure.
-
- @param [in] pSocket Address of an ::ESL_SOCKET structure.
-
- @param [in] pSockAddr Address of a sockaddr structure that contains the
- connection point on the local machine. An IPv4 address
- of INADDR_ANY specifies that the connection is made to
- all of the network stacks on the platform. Specifying a
- specific IPv4 address restricts the connection to the
- network stack supporting that address. Specifying zero
- for the port causes the network layer to assign a port
- number from the dynamic range. Specifying a specific
- port number causes the network layer to use that port.
-
- @param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
-
- @retval EFI_SUCCESS - Socket successfully created
-
- **/
-EFI_STATUS
-EslUdp4Bind (
- IN ESL_SOCKET * pSocket,
- IN const struct sockaddr * pSockAddr,
- IN socklen_t SockAddrLength
- )
-{
- EFI_HANDLE ChildHandle;
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pService;
- CONST struct sockaddr_in * pIp4Address;
- EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Assume success
- //
- pSocket->errno = 0;
- Status = EFI_SUCCESS;
-
- //
- // Validate the address length
- //
- pIp4Address = (CONST struct sockaddr_in *) pSockAddr;
- if ( SockAddrLength >= ( sizeof ( *pIp4Address )
- - sizeof ( pIp4Address->sin_zero ))) {
-
- //
- // Walk the list of services
- //
- pLayer = &mEslLayer;
- pService = pLayer->pUdp4List;
- while ( NULL != pService ) {
-
- //
- // Create the UDP port
- //
- pServiceBinding = pService->pServiceBinding;
- ChildHandle = NULL;
- Status = pServiceBinding->CreateChild ( pServiceBinding,
- &ChildHandle );
- if ( !EFI_ERROR ( Status )) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "0x%08x: Udp4 port handle created\r\n",
- ChildHandle ));
-
- //
- // Open the port
- //
- Status = EslSocketPortAllocate ( pSocket,
- pService,
- ChildHandle,
- (UINT8 *) &pIp4Address->sin_addr.s_addr,
- SwapBytes16 ( pIp4Address->sin_port ),
- DEBUG_BIND,
- &pPort );
- }
- else {
- DEBUG (( DEBUG_BIND | DEBUG_POOL,
- "ERROR - Failed to open Udp4 port handle, Status: %r\r\n",
- Status ));
- }
-
- //
- // Set the next service
- //
- pService = pService->pNext;
- }
-
- //
- // Verify that at least one network connection was found
- //
- if ( NULL == pSocket->pPortList ) {
- DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
- "Socket address %d.%d.%d.%d (0x%08x) is not available!\r\n",
- ( pIp4Address->sin_addr.s_addr >> 24 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 16 ) & 0xff,
- ( pIp4Address->sin_addr.s_addr >> 8 ) & 0xff,
- pIp4Address->sin_addr.s_addr & 0xff,
- pIp4Address->sin_addr.s_addr ));
- pSocket->errno = EADDRNOTAVAIL;
- Status = EFI_INVALID_PARAMETER;
- }
- }
- else {
- DEBUG (( DEBUG_BIND,
- "ERROR - Invalid Udp4 address length: %d\r\n",
- SockAddrLength ));
- Status = EFI_INVALID_PARAMETER;
- pSocket->errno = EINVAL;
- }
-
- //
- // Return the operation status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Set the default remote system address.
This routine sets the default remote address for a SOCK_DGRAM
@@ -489,52 +352,6 @@ EslUdp4GetRemoteAddress (
/**
- Initialize the UDP4 service.
-
- This routine initializes the UDP4 service which is used by the
- sockets layer to support SOCK_DGRAM sockets.
-
- This routine is called by ::EslServiceConnect after initializing an
- ::ESL_SERVICE structure for an adapter running UDPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
- @retval EFI_SUCCESS The service was properly initialized
- @retval other A failure occurred during the service initialization
-
-**/
-EFI_STATUS
-EFIAPI
-EslUdp4Initialize (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Connect this service to the service list
- //
- pLayer = &mEslLayer;
- pService->pNext = pLayer->pUdp4List;
- pLayer->pUdp4List = pService;
-
- //
- // Assume the list is empty
- //
- Status = EFI_SUCCESS;
-
- //
- // Return the initialization status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
-
-
-/**
Initialize the network specific portions of an ::ESL_PORT structure.
This routine initializes the network specific portions of an
@@ -1408,84 +1225,6 @@ EslUdp4RxStart (
/**
- Shutdown the UDP4 service.
-
- This routine undoes the work performed by ::EslUdp4Initialize to
- shutdown the UDP4 service which is used by the sockets layer to
- support SOCK_DGRAM sockets.
-
- This routine is called by ::EslServiceDisconnect prior to freeing
- the ::ESL_SERVICE structure associated with the adapter running
- UDPv4.
-
- @param [in] pService Address of an ::ESL_SERVICE structure
-
-**/
-VOID
-EFIAPI
-EslUdp4Shutdown (
- IN ESL_SERVICE * pService
- )
-{
- ESL_LAYER * pLayer;
- ESL_PORT * pPort;
- ESL_SERVICE * pPreviousService;
-
- DBG_ENTER ( );
-
- //
- // Verify the socket layer synchronization
- //
- VERIFY_TPL ( TPL_SOCKETS );
-
- //
- // Walk the list of ports
- //
- do {
- pPort = pService->pPortList;
- if ( NULL != pPort ) {
- //
- // Remove the port from the port list
- //
- pService->pPortList = pPort->pLinkService;
-
- //
- // Close the port
- // TODO: Fix this
- //
-// pPort->pfnClosePort ( pPort, 0 );
- }
- } while ( NULL != pPort );
-
- //
- // Remove the service from the service list
- //
- pLayer = &mEslLayer;
- pPreviousService = pLayer->pUdp4List;
- if ( pService == pPreviousService ) {
- //
- // Remove the service from the beginning of the list
- //
- pLayer->pUdp4List = pService->pNext;
- }
- else {
- //
- // Remove the service from the middle of the list
- //
- while ( NULL != pPreviousService ) {
- if ( pService == pPreviousService->pNext ) {
- pPreviousService->pNext = pService->pNext;
- break;
- }
- pPreviousService = pPreviousService->pNext;
- }
- }
-
- DBG_EXIT ( );
-}
-
-
-/**
Determine if the socket is configured.
This routine uses the flag ESL_SOCKET::bConfigured to determine
@@ -1508,6 +1247,7 @@ EslUdp4Shutdown (
IN ESL_SOCKET * pSocket
)
{
+ EFI_UDP4_CONFIG_DATA * pConfigData;
ESL_PORT * pPort;
ESL_PORT * pNextPort;
ESL_UDP4_CONTEXT * pUdp4;
@@ -1534,9 +1274,10 @@ EslUdp4Shutdown (
LocalAddress.sin_family = AF_INET;
LocalAddress.sin_addr.s_addr = 0;
LocalAddress.sin_port = 0;
- Status = EslUdp4Bind ( pSocket,
- (struct sockaddr *)&LocalAddress,
- LocalAddress.sin_len );
+ Status = EslSocketBind ( &pSocket->SocketProtocol,
+ (struct sockaddr *)&LocalAddress,
+ LocalAddress.sin_len,
+ &pSocket->errno );
}
//
@@ -1550,27 +1291,28 @@ EslUdp4Shutdown (
pNextPort = pPort->pLinkSocket;
pUdp4 = &pPort->Context.Udp4;
pUdp4Protocol = pPort->pProtocol.UDPv4;
+ pConfigData = &pUdp4->ConfigData;
DEBUG (( DEBUG_TX,
"0x%08x: pPort Configuring for %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d\r\n",
- pPort,
- pUdp4->ConfigData.StationAddress.Addr[0],
- pUdp4->ConfigData.StationAddress.Addr[1],
- pUdp4->ConfigData.StationAddress.Addr[2],
- pUdp4->ConfigData.StationAddress.Addr[3],
- pUdp4->ConfigData.StationPort,
- pUdp4->ConfigData.RemoteAddress.Addr[0],
- pUdp4->ConfigData.RemoteAddress.Addr[1],
- pUdp4->ConfigData.RemoteAddress.Addr[2],
- pUdp4->ConfigData.RemoteAddress.Addr[3],
- pUdp4->ConfigData.RemotePort ));
+ pPort,
+ pConfigData->StationAddress.Addr[0],
+ pConfigData->StationAddress.Addr[1],
+ pConfigData->StationAddress.Addr[2],
+ pConfigData->StationAddress.Addr[3],
+ pConfigData->StationPort,
+ pConfigData->RemoteAddress.Addr[0],
+ pConfigData->RemoteAddress.Addr[1],
+ pConfigData->RemoteAddress.Addr[2],
+ pConfigData->RemoteAddress.Addr[3],
+ pConfigData->RemotePort ));
Status = pUdp4Protocol->Configure ( pUdp4Protocol,
- &pUdp4->ConfigData );
+ pConfigData );
if ( !EFI_ERROR ( Status )) {
//
// Update the configuration data
//
Status = pUdp4Protocol->GetModeData ( pUdp4Protocol,
- &pUdp4->ConfigData,
+ pConfigData,
NULL,
NULL,
NULL );
@@ -1609,17 +1351,17 @@ EslUdp4Shutdown (
else {
DEBUG (( DEBUG_TX,
"0x%08x: pPort Configured for %d.%d.%d.%d:%d --> %d.%d.%d.%d:%d\r\n",
- pPort,
- pUdp4->ConfigData.StationAddress.Addr[0],
- pUdp4->ConfigData.StationAddress.Addr[1],
- pUdp4->ConfigData.StationAddress.Addr[2],
- pUdp4->ConfigData.StationAddress.Addr[3],
- pUdp4->ConfigData.StationPort,
- pUdp4->ConfigData.RemoteAddress.Addr[0],
- pUdp4->ConfigData.RemoteAddress.Addr[1],
- pUdp4->ConfigData.RemoteAddress.Addr[2],
- pUdp4->ConfigData.RemoteAddress.Addr[3],
- pUdp4->ConfigData.RemotePort ));
+ pPort,
+ pConfigData->StationAddress.Addr[0],
+ pConfigData->StationAddress.Addr[1],
+ pConfigData->StationAddress.Addr[2],
+ pConfigData->StationAddress.Addr[3],
+ pConfigData->StationPort,
+ pConfigData->RemoteAddress.Addr[0],
+ pConfigData->RemoteAddress.Addr[1],
+ pConfigData->RemoteAddress.Addr[2],
+ pConfigData->RemoteAddress.Addr[3],
+ pConfigData->RemotePort ));
pPort->bConfigured = TRUE;
//
diff --git a/StdLib/Include/Efi/EfiSocketLib.h b/StdLib/Include/Efi/EfiSocketLib.h
index 4a44693..463db19 100644
--- a/StdLib/Include/Efi/EfiSocketLib.h
+++ b/StdLib/Include/Efi/EfiSocketLib.h
@@ -120,24 +120,6 @@
typedef struct _ESL_SERVICE ESL_SERVICE; ///< Forward delcaration
/**
- Initialize the network layer
-**/
-typedef
-EFI_STATUS
-(EFIAPI * PFN_SB_INITIALIZE) (
- IN ESL_SERVICE * pService
- );
-
-/**
- Shutdown the network layer
-**/
-typedef
-VOID
-(EFIAPI * PFN_SB_SHUTDOWN) (
- IN ESL_SERVICE * pService
- );
-
-/**
Protocol binding and installation control structure
The driver uses this structure to simplify the driver binding processing.
@@ -147,8 +129,7 @@ typedef struct {
EFI_GUID * pNetworkBinding; ///< Network service binding protocol for socket support
EFI_GUID * pNetworkProtocolGuid;///< Network protocol GUID
CONST EFI_GUID * pTagGuid; ///< Tag to mark protocol in use
- PFN_SB_INITIALIZE pfnInitialize;///< Routine to initialize the service
- PFN_SB_SHUTDOWN pfnShutdown; ///< Routine to shutdown the service
+ UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services
UINTN TxIoNormal; ///< Number of transmit ESL_IO_MGMT structures for normal data
UINTN TxIoUrgent; ///< Number of transmit ESL_IO_MGMT structures for urgent data
} ESL_SOCKET_BINDING;