/** @file
Interface function of the Socket.
Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "SockImpl.h"
/**
Check whether the Event is in the List.
@param List Pointer to the token list to be searched.
@param Event The event to be checked.
@retval TRUE The specific Event exists in the List.
@retval FALSE The specific Event is not in the List.
**/
)
{
);
return TRUE;
}
}
return FALSE;
}
/**
Call SockTokenExistedInList() to check whether the Event is
in the related socket's lists.
@param Sock Pointer to the instance's socket.
@param Event The event to be checked.
@retval TRUE The Event exists in related socket's lists.
@retval FALSE The Event is not in related socket's lists.
**/
)
{
return TRUE;
}
return TRUE;
}
return TRUE;
}
return FALSE;
}
/**
Buffer a token into the specific list of socket Sock.
@param Sock Pointer to the instance's socket.
@param List Pointer to the list to store the token.
@param Token Pointer to the token to be buffered.
@param DataLen The data length of the buffer contained in Token.
@return Pointer to the token that wraps Token. If NULL, error condition occurred.
**/
)
{
"to allocate SockToken\n"));
return NULL;
}
return SockToken;
}
/**
Destory the socket Sock and its associated protocol control block.
@param Sock The socket to be destroyed.
@retval EFI_SUCCESS The socket Sock is destroyed successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
**/
)
{
if (Sock->IsDestroyed) {
return EFI_SUCCESS;
}
"access socket failed with %r\n", Status));
return EFI_ACCESS_DENIED;
}
//
// force protocol layer to detach the PCB
//
" failed with %r\n", Status));
} else if (SOCK_IS_CONFIGURED (Sock)) {
}
return Status;
}
SockDestroy (Sock);
return EFI_SUCCESS;
}
/**
Create a socket and its associated protocol control block
with the intial data SockInitData and protocol specific
data ProtoData.
@param SockInitData Inital data to setting the socket.
@return Pointer to the newly created socket. If NULL, error condition occured.
**/
SOCKET *
)
{
//
// create a new socket
//
"create a new socket\n"));
return NULL;
}
"access socket failed with %r\n", Status));
SockDestroy (Sock);
return NULL;
}
//
// inform the protocol layer to attach the socket
// with a new protocol control block
//
" attach a socket with %r\n", Status));
SockDestroy (Sock);
}
return Sock;
}
/**
Configure the specific socket Sock using configuration data ConfigData.
@param Sock Pointer to the socket to be configured.
@param ConfigData Pointer to the configuration data.
@retval EFI_SUCCESS The socket is configured successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket or the
socket is already configured.
**/
)
{
"socket failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_CONFIGURED (Sock)) {
goto OnExit;
}
return Status;
}
/**
Initiate a connection establishment process.
@param Sock Pointer to the socket to initiate the initate the
connection.
@param Token Pointer to the token used for the connection
operation.
@retval EFI_SUCCESS The connection is initialized successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
socket is closed, or the socket is not configured to
be an active one, or the token is already in one of
this socket's lists.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
**/
)
{
"socket failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto OnExit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto OnExit;
}
goto OnExit;
}
goto OnExit;
}
return Status;
}
/**
Issue a listen token to get an existed connected network instance
or wait for a connection if there is none.
@param Sock Pointer to the socket to accept connections.
@param Token The token to accept a connection.
@retval EFI_SUCCESS Either a connection is accpeted or the Token is
buffered for further acception.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
socket is closed, or the socket is not configured to
be a passive one, or the token is already in one of
this socket's lists.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
@retval EFI_OUT_OF_RESOURCE Failed to buffer the Token due to memory limit.
**/
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto Exit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
if (!SOCK_IS_LISTENING (Sock)) {
goto Exit;
}
goto Exit;
}
//
// Check if a connection has already in this Sock->ConnectionList
//
if (SOCK_IS_CONNECTED (Socket)) {
DEBUG (
"SockAccept: Accept a socket, now conncount is %d",
);
goto Exit;
}
}
//
// Buffer this token for latter incoming connection request
//
}
Exit:
return Status;
}
/**
Issue a token with data to the socket to send out.
@param Sock Pointer to the socket to process the token with
data.
@param Token The token with data that needs to send out.
@retval EFI_SUCCESS The token is processed successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
socket is closed, or the socket is not in a
synchronized state , or the token is already in one
of this socket's lists.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
@retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.
**/
SockSend (
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto Exit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
goto Exit;
}
//
// check if a token is already in the token buffer
//
goto Exit;
}
//
// process this sending token now or buffer it only?
//
Sock,
&Sock->SndTokenList,
);
}
} else {
Sock,
);
" socket processing SndToken List\n", Status));
goto Exit;
}
"Snd Data\n", Status));
}
}
Exit:
return Status;
}
/**
Issue a token to get data from the socket.
@param Sock Pointer to the socket to get data from.
@param Token The token to store the received data from the
socket.
@retval EFI_SUCCESS The token is processed successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
socket is closed, or the socket is not in a
synchronized state , or the token is already in one
of this socket's lists.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
@retval EFI_CONNECTION_FIN The connection is closed and there is no more data.
@retval EFI_OUT_OF_RESOURCE Failed to buffer the token due to memory limit.
**/
SockRcv (
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto Exit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
goto Exit;
}
//
// check if a token is already in the token buffer of this socket
//
goto Exit;
}
//
// check whether an error has happened before
//
goto Exit;
}
//
// check whether can not receive and there is no any
// data buffered in Sock->RcvBuffer
//
goto Exit;
}
if (RcvdBytes != 0) {
goto Exit;
}
} else {
}
}
Exit:
return Status;
}
/**
Reset the socket and its associated protocol control block.
@param Sock Pointer to the socket to be flushed.
@retval EFI_SUCCESS The socket is flushed successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
**/
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (!SOCK_IS_CONFIGURED (Sock)) {
goto Exit;
}
" SOCK_FLUSH with %r", Status));
goto Exit;
}
Exit:
return Status;
}
/**
Close or abort the socket associated connection.
@param Sock Pointer to the socket of the connection to close or
abort.
@param Token The token for close operation.
@param OnAbort TRUE for aborting the connection, FALSE to close it.
@retval EFI_SUCCESS The close or abort operation is initialized
successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket, or the
socket is closed, or the socket is not in a
synchronized state , or the token is already in one
of this socket's lists.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
**/
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto Exit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
if (SOCK_IS_DISCONNECTING (Sock)) {
goto Exit;
}
goto Exit;
}
if (OnAbort) {
} else {
}
Exit:
return Status;
}
/**
Get the mode data of the low layer protocol.
@param Sock Pointer to the socket to get mode data from.
@param Mode Pointer to the data to store the low layer mode
information.
@retval EFI_SUCCESS The mode data is got successfully.
@retval EFI_NOT_STARTED The socket is not configured.
**/
)
{
}
/**
Configure the low level protocol to join a multicast group for
this socket's connection.
@param Sock Pointer to the socket of the connection to join the
specific multicast group.
@param GroupInfo Pointer to the multicast group info.
@retval EFI_SUCCESS The configuration is done successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
@retval EFI_NOT_STARTED The socket is not configured.
**/
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
Exit:
return Status;
}
/**
Add or remove route information in IP route table associated
with this socket.
@param Sock Pointer to the socket associated with the IP route
table to operate on.
@param RouteInfo Pointer to the route information to be processed.
@retval EFI_SUCCESS The route table is updated successfully.
@retval EFI_ACCESS_DENIED Failed to get the lock to access the socket.
@retval EFI_NO_MAPPING The IP address configuration operation is not
finished.
@retval EFI_NOT_STARTED The socket is not configured.
**/
)
{
" failed with %r", Status));
return EFI_ACCESS_DENIED;
}
if (SOCK_IS_NO_MAPPING (Sock)) {
goto Exit;
}
if (SOCK_IS_UNCONFIGURED (Sock)) {
goto Exit;
}
Exit:
return Status;
}