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:
@ -57,7 +57,7 @@
|
||||
address for the file
|
||||
@param [in] pErrno Address of the errno variable
|
||||
|
||||
@return A pointer to the socket protocol structure or NULL if
|
||||
@return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
|
||||
an invalid file descriptor was passed in.
|
||||
|
||||
**/
|
||||
@ -71,13 +71,17 @@ BslFdToSocketProtocol (
|
||||
/**
|
||||
Close the socket
|
||||
|
||||
@param [in] pDescriptor Descriptor address for the file
|
||||
The BslSocketClose routine is called indirectly from the close file
|
||||
system routine. This routine closes the socket and returns the
|
||||
status to the caller.
|
||||
|
||||
@param[in] pDescriptor Descriptor address for the file
|
||||
|
||||
@return This routine returns 0 upon success and -1 upon failure.
|
||||
In the case of failure, errno contains more information.
|
||||
In the case of failure, ::errno contains more information.
|
||||
|
||||
**/
|
||||
INT32
|
||||
int
|
||||
BslSocketClose (
|
||||
struct __filedes * pDescriptor
|
||||
);
|
||||
@ -85,9 +89,9 @@ BslSocketClose (
|
||||
/**
|
||||
Worker routine to close the socket.
|
||||
|
||||
@param [in] pSocketProtocol Socket protocol structure address
|
||||
@param[in] pSocketProtocol Socket protocol structure address
|
||||
|
||||
@param [in] pErrno Address of the errno variable
|
||||
@param[in] pErrno Address of the ::errno variable
|
||||
|
||||
@retval EFI_SUCCESS Successfully closed the socket
|
||||
|
||||
@ -133,12 +137,18 @@ BslSocketProtocolToFd (
|
||||
/**
|
||||
Read support routine for sockets
|
||||
|
||||
The BslSocketRead routine is called indirectly by the read file
|
||||
system routine. This routine is typically used for SOCK_STREAM
|
||||
because it waits for receive data from the target system specified
|
||||
in the ::connect call.
|
||||
|
||||
@param [in] pDescriptor Descriptor address for the file
|
||||
@param [in] pOffset File offset
|
||||
@param [in] LengthInBytes Number of bytes to read
|
||||
@param [in] pBuffer Address of the buffer to receive the data
|
||||
|
||||
@return The number of bytes read or -1 if an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
@ -158,6 +168,7 @@ BslSocketRead (
|
||||
@param [in] pBuffer Address of the data
|
||||
|
||||
@return The number of bytes written or -1 if an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
@ -175,7 +186,7 @@ BslSocketWrite (
|
||||
|
||||
@param [in] pErrno Address of the errno variable
|
||||
|
||||
@return A pointer to the socket protocol structure or NULL if
|
||||
@return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
|
||||
an invalid file descriptor was passed in.
|
||||
|
||||
**/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/** @file
|
||||
/*
|
||||
Definitions for the socket library functions that are used internally.
|
||||
|
||||
Copyright (c) 2011, Intel Corporation
|
||||
@ -10,33 +10,33 @@
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
*/
|
||||
|
||||
#ifndef _SOCKLIB_INTERNALS_H_
|
||||
#define _SOCKLIB_INTERNALS_H_
|
||||
|
||||
void _sethosthtent(int);
|
||||
void _endhosthtent(void);
|
||||
void _sethostdnsent(int);
|
||||
void _endhostdnsent(void);
|
||||
void _setnethtent(int);
|
||||
void _endnethtent(void);
|
||||
void _setnetdnsent(int);
|
||||
void _endnetdnsent(void);
|
||||
void _sethosthtent (int);
|
||||
void _endhosthtent (void);
|
||||
void _sethostdnsent (int);
|
||||
void _endhostdnsent (void);
|
||||
void _setnethtent (int);
|
||||
void _endnethtent (void);
|
||||
void _setnetdnsent (int);
|
||||
void _endnetdnsent (void);
|
||||
|
||||
struct hostent * _gethostbyhtname(const char *, int);
|
||||
struct hostent * _gethostbydnsname(const char *, int);
|
||||
struct hostent * _gethostbynisname(const char *, int);
|
||||
struct hostent * _gethostbyhtaddr(const char *, int, int);
|
||||
struct hostent * _gethostbydnsaddr(const char *, int, int);
|
||||
struct hostent * _gethostbynisaddr(const char *, int, int);
|
||||
struct netent * _getnetbyhtname(const char *);
|
||||
struct netent * _getnetbydnsname(const char *);
|
||||
struct netent * _getnetbynisname(const char *);
|
||||
struct netent * _getnetbyhtaddr(unsigned long, int);
|
||||
struct netent * _getnetbydnsaddr(unsigned long, int);
|
||||
struct netent * _getnetbynisaddr(unsigned long, int);
|
||||
void _map_v4v6_address(const char *src, char *dst);
|
||||
void _map_v4v6_hostent(struct hostent *hp, char **bp, int *len);
|
||||
struct hostent * _gethostbyhtname (const char *, int);
|
||||
struct hostent * _gethostbydnsname (const char *, int);
|
||||
struct hostent * _gethostbynisname (const char *, int);
|
||||
struct hostent * _gethostbyhtaddr (const char *, int, int);
|
||||
struct hostent * _gethostbydnsaddr (const char *, int, int);
|
||||
struct hostent * _gethostbynisaddr (const char *, int, int);
|
||||
struct netent * _getnetbyhtname (const char *);
|
||||
struct netent * _getnetbydnsname (const char *);
|
||||
struct netent * _getnetbynisname (const char *);
|
||||
struct netent * _getnetbyhtaddr (unsigned long, int);
|
||||
struct netent * _getnetbydnsaddr (unsigned long, int);
|
||||
struct netent * _getnetbynisaddr (unsigned long, int);
|
||||
void _map_v4v6_address (const char *src, char *dst);
|
||||
void _map_v4v6_hostent (struct hostent *hp, char **bp, int *len);
|
||||
#endif
|
||||
|
||||
|
@ -16,29 +16,30 @@
|
||||
|
||||
|
||||
/**
|
||||
Worker routine for ::Accept and ::AcceptNB
|
||||
Worker routine for ::accept and ::AcceptNB
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@param [in] bBlocking TRUE if this is a blocking call
|
||||
@param [in] bBlockingAllowed TRUE if this is a blocking call
|
||||
@param [in] address Address of a buffer to receive the remote network address.
|
||||
|
||||
@param [in, out] address_len Address of a buffer containing the Length in bytes
|
||||
of the remote network address buffer. Upon return,
|
||||
contains the length of the remote network address.
|
||||
|
||||
@return ::accept returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
@return AcceptWork returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
AcceptWork (
|
||||
int s,
|
||||
BOOLEAN bBlocking,
|
||||
BOOLEAN bBlockingAllowed,
|
||||
struct sockaddr * address,
|
||||
socklen_t * address_len
|
||||
)
|
||||
{
|
||||
BOOLEAN bBlocking;
|
||||
INT32 NewSocketFd;
|
||||
struct __filedes * pDescriptor;
|
||||
EFI_SOCKET_PROTOCOL * pNewSocket;
|
||||
@ -58,8 +59,10 @@ AcceptWork (
|
||||
&errno );
|
||||
if ( NULL != pSocketProtocol ) {
|
||||
//
|
||||
// TODO: Update bBlocking by anding with check for NON_BLOCKING
|
||||
// Determine if the operation is blocking
|
||||
//
|
||||
bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
|
||||
bBlocking &= bBlockingAllowed;
|
||||
|
||||
//
|
||||
// Attempt to accept a new network connection
|
||||
@ -75,6 +78,7 @@ AcceptWork (
|
||||
//
|
||||
// Convert the protocol to a socket
|
||||
//
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
NewSocketFd = BslSocketProtocolToFd ( pNewSocket, &errno );
|
||||
if ( -1 == NewSocketFd ) {
|
||||
//
|
||||
@ -83,6 +87,7 @@ AcceptWork (
|
||||
BslSocketCloseWork ( pNewSocket, NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Return the new socket file descriptor
|
||||
@ -94,9 +99,10 @@ AcceptWork (
|
||||
/**
|
||||
Accept a network connection.
|
||||
|
||||
The ::accept routine waits for a network connection to the socket.
|
||||
It is able to return the remote network address to the caller if
|
||||
requested. The
|
||||
The accept routine waits for a network connection to the socket.
|
||||
It returns the remote network address to the caller if requested.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@ -108,8 +114,8 @@ AcceptWork (
|
||||
of the remote network address buffer. Upon return,
|
||||
contains the length of the remote network address.
|
||||
|
||||
@return ::accept returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
@return The accept routine returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
@ -127,9 +133,7 @@ accept (
|
||||
|
||||
|
||||
/**
|
||||
Non blocking version of accept.
|
||||
|
||||
See ::accept
|
||||
Non blocking version of ::accept.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@ -140,7 +144,7 @@ accept (
|
||||
contains the length of the remote network address.
|
||||
|
||||
@return This routine returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,9 +18,11 @@
|
||||
/**
|
||||
Bind a name to a socket.
|
||||
|
||||
The ::bind routine connects a name to a socket on the local machine. The
|
||||
The bind routine connects a name (network address) to a socket on the local machine.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
documentation is available online.
|
||||
|
||||
@param[in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@ -37,6 +39,7 @@
|
||||
@param[in] namelen Specifies the length in bytes of the sockaddr structure.
|
||||
|
||||
@return The bind routine returns zero (0) if successful and -1 upon failure.
|
||||
In the case of an error, ::errno contains more information.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
@param[in] pSocketProtocol Socket protocol structure address
|
||||
|
||||
@param[in] pErrno Address of the errno variable
|
||||
@param[in] pErrno Address of the ::errno variable
|
||||
|
||||
@retval EFI_SUCCESS Successfully closed the socket
|
||||
|
||||
@ -83,10 +83,14 @@ BslSocketCloseWork (
|
||||
/**
|
||||
Close the socket
|
||||
|
||||
The BslSocketClose routine is called indirectly from the close file
|
||||
system routine. This routine closes the socket and returns the
|
||||
status to the caller.
|
||||
|
||||
@param[in] pDescriptor Descriptor address for the file
|
||||
|
||||
@return This routine returns 0 upon success and -1 upon failure.
|
||||
In the case of failure, errno contains more information.
|
||||
In the case of failure, ::errno contains more information.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,11 +18,8 @@
|
||||
/**
|
||||
Connect to a remote system via the network.
|
||||
|
||||
The ::connect routine attempts to establish a connection to a
|
||||
The connect routine attempts to establish a connection to a
|
||||
socket on the local or remote system using the specified address.
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
There are three states associated with a connection:
|
||||
<ul>
|
||||
@ -30,23 +27,27 @@
|
||||
<li>Connection in progress</li>
|
||||
<li>Connected</li>
|
||||
</ul>
|
||||
In the "Not connected" state, calls to ::connect start the connection
|
||||
In the initial "Not connected" state, calls to connect start the connection
|
||||
processing and update the state to "Connection in progress". During
|
||||
the "Connection in progress" state, connect polls for connection completion
|
||||
and moves the state to "Connected" after the connection is established.
|
||||
Note that these states are only visible when the file descriptor is marked
|
||||
with O_NONBLOCK. Also, the POLL_WRITE bit is set when the connection
|
||||
with O_NONBLOCK. Also, the POLLOUT bit is set when the connection
|
||||
completes and may be used by poll or select as an indicator to call
|
||||
connect again.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@param [in] address Network address of the remote system
|
||||
|
||||
@param [in] address_len Length of the remote network address
|
||||
|
||||
@return ::connect returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
@return This routine returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
@ -70,9 +71,9 @@ connect (
|
||||
&errno );
|
||||
if ( NULL != pSocketProtocol ) {
|
||||
//
|
||||
// TODO: Check for NON_BLOCKING
|
||||
// Determine if the operation is blocking
|
||||
//
|
||||
bBlocking = TRUE;
|
||||
bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
|
||||
|
||||
//
|
||||
// Attempt to connect to a remote system
|
||||
|
@ -15,4 +15,7 @@
|
||||
#include <sys/errno.h>
|
||||
|
||||
|
||||
/**
|
||||
Variable that contains additional error information when an API call fails.
|
||||
**/
|
||||
int errno;
|
||||
|
@ -18,7 +18,8 @@
|
||||
/**
|
||||
Get the remote address
|
||||
|
||||
The ::getpeername routine retrieves the remote system address from the socket.
|
||||
The getpeername routine retrieves the remote system address from the socket.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html#">POSIX</a>
|
||||
documentation is available online.
|
||||
@ -29,8 +30,8 @@
|
||||
|
||||
@param [in] address_len Length of the remote network address structure
|
||||
|
||||
@return ::getpeername returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
@return This routine returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,7 +18,8 @@
|
||||
/**
|
||||
Get the local socket address.
|
||||
|
||||
The ::getsockname routine retrieves the local system address from the socket.
|
||||
The getsockname routine retrieves the local system address from the socket.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html#">POSIX</a>
|
||||
documentation is available online.
|
||||
@ -29,8 +30,8 @@
|
||||
|
||||
@param [in] address_len Length of the local network address structure
|
||||
|
||||
@return ::getsockname returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
@return This routine returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,6 +18,10 @@
|
||||
/**
|
||||
Get the socket options
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html#">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] option_name Name of the option
|
||||
@ -25,8 +29,8 @@
|
||||
@param [in,out] option_len Length of the buffer in bytes,
|
||||
upon return length of the option value in bytes
|
||||
|
||||
@retval Zero (0) upon success
|
||||
@retval Minus one (-1) upon failure, errno set with additional error information
|
||||
@return This routine returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,20 +18,23 @@
|
||||
/**
|
||||
Establish the known port to listen for network connections.
|
||||
|
||||
The ::listen routine places the port into a state that enables connection
|
||||
The listen routine places the port into a state that enables connection
|
||||
attempts. Connections are placed into FIFO order in a queue to be serviced
|
||||
by the application. The application calls the ::accept routine to remove
|
||||
the next connection from the queue and get the associated socket. The
|
||||
the next connection from the queue and get the associated socket.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
documentation is available online.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@param [in] backlog backlog specifies the maximum FIFO depth for the connections
|
||||
waiting for the application to call accept. Connection attempts
|
||||
waiting for the application to call ::accept. Connection attempts
|
||||
received while the queue is full are refused.
|
||||
|
||||
@return The listen routine returns zero (0) if successful and -1 upon failure.
|
||||
@return This routine returns zero (0) if successful or -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,12 +18,18 @@
|
||||
/**
|
||||
Read support routine for sockets
|
||||
|
||||
The BslSocketRead routine is called indirectly by the read file
|
||||
system routine. This routine is typically used for SOCK_STREAM
|
||||
because it waits for receive data from the target system specified
|
||||
in the ::connect call.
|
||||
|
||||
@param [in] pDescriptor Descriptor address for the file
|
||||
@param [in] pOffset File offset
|
||||
@param [in] LengthInBytes Number of bytes to read
|
||||
@param [in] pBuffer Address of the buffer to receive the data
|
||||
|
||||
@return The number of bytes read or -1 if an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
|
@ -18,8 +18,12 @@
|
||||
/**
|
||||
Receive data from a network connection.
|
||||
|
||||
The ::recv routine waits for receive data from a remote network
|
||||
connection. The
|
||||
The recv routine waits for receive data from a remote network
|
||||
connection. This routine is typically used for SOCK_STREAM
|
||||
because it waits for receive data from the target system specified
|
||||
in the ::connect call.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@ -31,9 +35,9 @@
|
||||
|
||||
@param [in] flags Message control flags
|
||||
|
||||
@return ::recv returns the number of valid bytes in the buffer,
|
||||
@return This routine returns the number of valid bytes in the buffer,
|
||||
zero if no data was received, and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
|
@ -18,8 +18,12 @@
|
||||
/**
|
||||
Receive data from a network connection and return the remote system's address.
|
||||
|
||||
The ::recvfrom routine waits for receive data from a remote network
|
||||
connection. The
|
||||
The recvfrom routine waits for receive data from a remote network
|
||||
connection. This routine is typically called for SOCK_DGRAM sockets
|
||||
when the socket is being shared by multiple remote systems and it is
|
||||
important to get the remote system address for a response.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@ -35,9 +39,9 @@
|
||||
|
||||
@param [in] address_len Length of the remote network address structure
|
||||
|
||||
@return ::recvfrom returns the number of valid bytes in the buffer,
|
||||
@return This routine returns the number of valid bytes in the buffer,
|
||||
zero if no data was received, and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
|
@ -767,7 +767,7 @@ read_len:
|
||||
errno = 0;
|
||||
fromlen = sizeof(struct sockaddr_in);
|
||||
resplen = (int)recvfrom(s, (char*)ans, anssiz, 0,
|
||||
(struct sockaddr *)&from, &fromlen);
|
||||
(struct sockaddr *)&from, (socklen_t *)&fromlen);
|
||||
if (resplen <= 0) {
|
||||
Perror(stderr, "recvfrom", errno);
|
||||
res_close();
|
||||
|
@ -18,7 +18,10 @@
|
||||
/**
|
||||
Send data using a network connection.
|
||||
|
||||
The ::send routine queues data to the network for transmission.
|
||||
The send routine queues data to the network for transmission.
|
||||
This routine is typically used for SOCK_STREAM sockets where the target
|
||||
system was specified in the ::connect call.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">POSIX</a>
|
||||
documentation is available online.
|
||||
@ -31,9 +34,9 @@
|
||||
|
||||
@param [in] flags Message control flags
|
||||
|
||||
@return ::send returns the number of data bytes that were
|
||||
@return This routine returns the number of data bytes that were
|
||||
sent and -1 when an error occurs. In the case of
|
||||
an error, errno contains more details.
|
||||
an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
|
@ -18,7 +18,11 @@
|
||||
/**
|
||||
Send data using a network connection.
|
||||
|
||||
The ::send routine queues data to the network for transmission.
|
||||
The sendto routine queues data to the network for transmission.
|
||||
This routine is typically used for SOCK_DGRAM sockets that are shared
|
||||
between multiple machine where it is required to specify the target
|
||||
system address when sending the data.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html">POSIX</a>
|
||||
documentation is available online.
|
||||
@ -35,9 +39,9 @@
|
||||
|
||||
@param [in] tolen Length of remote system address structure
|
||||
|
||||
@return ::send returns the number of data bytes that were
|
||||
@return This routine returns the number of data bytes that were
|
||||
sent and -1 when an error occurs. In the case of
|
||||
an error, errno contains more details.
|
||||
an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
@ -50,6 +54,7 @@ sendto (
|
||||
socklen_t tolen
|
||||
)
|
||||
{
|
||||
BOOLEAN bBlocking;
|
||||
ssize_t LengthInBytes;
|
||||
CONST UINT8 * pData;
|
||||
struct __filedes * pDescriptor;
|
||||
@ -68,13 +73,18 @@ sendto (
|
||||
&pDescriptor,
|
||||
&errno );
|
||||
if ( NULL != pSocketProtocol ) {
|
||||
//
|
||||
// Determine if the operation is blocking
|
||||
//
|
||||
bBlocking = (BOOLEAN)( 0 == ( pDescriptor->Oflags & O_NONBLOCK ));
|
||||
|
||||
//
|
||||
// Send the data using the socket
|
||||
//
|
||||
pData = buffer;
|
||||
do {
|
||||
errno = 0;
|
||||
Status = pSocketProtocol->pfnSend ( pSocketProtocol,
|
||||
Status = pSocketProtocol->pfnTransmit ( pSocketProtocol,
|
||||
flags,
|
||||
length,
|
||||
pData,
|
||||
@ -92,8 +102,7 @@ sendto (
|
||||
//
|
||||
pData += LengthInBytes;
|
||||
length -= LengthInBytes;
|
||||
// TODO: Add non-blocking check
|
||||
} while (( 0 != length ) && ( EFI_NOT_READY == Status ));
|
||||
} while (( 0 != length ) && ( EFI_NOT_READY == Status ) && bBlocking );
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -97,7 +97,7 @@ Returns:
|
||||
// Create a zero terminated string for name
|
||||
//
|
||||
memcpy ( pName, name, namelen );
|
||||
pName [ namelen ] = 0;
|
||||
pName[ namelen ] = 0;
|
||||
|
||||
//
|
||||
// Set the environment variable
|
||||
|
@ -18,14 +18,18 @@
|
||||
/**
|
||||
Set the socket options
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>
|
||||
documentation is available online.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] option_name Name of the option
|
||||
@param [in] option_value Buffer containing the option value
|
||||
@param [in] option_len Length of the value in bytes
|
||||
|
||||
@retval Zero (0) upon success
|
||||
@retval Minus one (-1) upon failure, errno set with additional error information
|
||||
@return This routine returns zero (0) upon success and -1 when an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -18,7 +18,8 @@
|
||||
/**
|
||||
Shutdown the socket receive and transmit operations
|
||||
|
||||
The ::shutdown routine stops socket receive and transmit operations.
|
||||
The shutdown routine stops socket receive and transmit operations.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html">POSIX</a>
|
||||
documentation is available online.
|
||||
@ -27,8 +28,8 @@
|
||||
|
||||
@param [in] how Which operations to shutdown
|
||||
|
||||
@return ::shutdown returns the zero (0) if successful or -1 when an
|
||||
error occurs. In the latter case, errno contains more details.
|
||||
@return This routine returns the zero (0) if successful or -1 when an
|
||||
error occurs. In the latter case, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
|
@ -15,6 +15,12 @@
|
||||
#include <SocketInternals.h>
|
||||
|
||||
|
||||
/**
|
||||
File system interface for the socket layer.
|
||||
|
||||
This data structure defines the routines for the various
|
||||
file system functions associated with the socket layer.
|
||||
**/
|
||||
const struct fileops SocketOperations = {
|
||||
BslSocketClose, // close
|
||||
BslSocketRead, // read
|
||||
@ -47,7 +53,7 @@ const struct fileops SocketOperations = {
|
||||
address for the file
|
||||
@param [in] pErrno Address of the errno variable
|
||||
|
||||
@return A pointer to the socket protocol structure or NULL if
|
||||
@return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
|
||||
an invalid file descriptor was passed in.
|
||||
|
||||
**/
|
||||
@ -79,7 +85,7 @@ BslFdToSocketProtocol (
|
||||
//
|
||||
// Get the descriptor for the file
|
||||
//
|
||||
pDescriptor = &gMD->fdarray [ s ];
|
||||
pDescriptor = &gMD->fdarray[ s ];
|
||||
|
||||
//
|
||||
// Validate that the descriptor is associated with sockets
|
||||
@ -125,7 +131,7 @@ BslSocketProtocolToFd (
|
||||
// Locate a file descriptor
|
||||
//
|
||||
FileDescriptor = FindFreeFD ( VALID_CLOSED );
|
||||
if( FileDescriptor < 0 ) {
|
||||
if ( FileDescriptor < 0 ) {
|
||||
//
|
||||
// All available FDs are in use
|
||||
//
|
||||
@ -135,7 +141,7 @@ BslSocketProtocolToFd (
|
||||
//
|
||||
// Initialize the file descriptor
|
||||
//
|
||||
pDescriptor = &gMD->fdarray [ FileDescriptor ];
|
||||
pDescriptor = &gMD->fdarray[ FileDescriptor ];
|
||||
pDescriptor->f_offset = 0;
|
||||
pDescriptor->f_flag = 0;
|
||||
pDescriptor->f_iflags = DTYPE_SOCKET;
|
||||
@ -162,28 +168,33 @@ BslSocketProtocolToFd (
|
||||
/**
|
||||
Creates an endpoint for network communication.
|
||||
|
||||
The ::Socket routine initializes the communication endpoint by providing
|
||||
the support for the socket library function ::socket. The
|
||||
The socket routine initializes the communication endpoint and returns a
|
||||
file descriptor.
|
||||
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html">POSIX</a>
|
||||
documentation for the socket routine is available online for reference.
|
||||
documentation is available online.
|
||||
|
||||
@param [in] domain Select the family of protocols for the client or server
|
||||
application.
|
||||
application. The supported values are:
|
||||
<ul>
|
||||
<li>AF_INET - Version 4 UEFI network stack</li>
|
||||
</ul>
|
||||
|
||||
@param [in] type Specifies how to make the network connection. The following values
|
||||
are supported:
|
||||
<ul>
|
||||
<li>
|
||||
SOCK_DGRAM - Connect to UDP, provides a datagram service that is
|
||||
manipulated by recvfrom and sendto.
|
||||
</li>
|
||||
<li>
|
||||
SOCK_STREAM - Connect to TCP, provides a byte stream
|
||||
that is manipluated by read, recv, send and write.
|
||||
</li>
|
||||
<li>
|
||||
SOCK_SEQPACKET - Connect to TCP, provides sequenced packet stream
|
||||
that is manipulated by read, recv, send and write.
|
||||
</li>
|
||||
<li>
|
||||
SOCK_DGRAM - Connect to UDP, provides a datagram service that is
|
||||
manipulated by recvfrom and sendto.
|
||||
SOCK_RAW - Connect to IP, provides a datagram service that
|
||||
is manipulated by recvfrom and sendto.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -192,9 +203,14 @@ BslSocketProtocolToFd (
|
||||
<ul>
|
||||
<li>IPPROTO_TCP</li> - This value must be combined with SOCK_STREAM.</li>
|
||||
<li>IPPROTO_UDP</li> - This value must be combined with SOCK_DGRAM.</li>
|
||||
<li>0 - 254</li> - An assigned
|
||||
<a href="http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml">protocol number</a>
|
||||
is combined with SOCK_RAW.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@return This routine returns a file descriptor for the socket.
|
||||
@return This routine returns a file descriptor for the socket. If an error
|
||||
occurs -1 is returned and ::errno contains more details.
|
||||
|
||||
**/
|
||||
INT32
|
||||
@ -226,8 +242,7 @@ socket (
|
||||
type,
|
||||
protocol,
|
||||
&errno );
|
||||
if ( !EFI_ERROR ( Status ))
|
||||
{
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
//
|
||||
// Build the file descriptor for the socket
|
||||
//
|
||||
@ -250,7 +265,7 @@ socket (
|
||||
|
||||
@param [in] pErrno Address of the errno variable
|
||||
|
||||
@return A pointer to the socket protocol structure or NULL if
|
||||
@return A pointer to the EFI_SOCKET_PROTOCOL structure or NULL if
|
||||
an invalid file descriptor was passed in.
|
||||
|
||||
**/
|
||||
|
@ -24,6 +24,7 @@
|
||||
@param [in] pBuffer Address of the data
|
||||
|
||||
@return The number of bytes written or -1 if an error occurs.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
ssize_t
|
||||
|
322
StdLib/EfiSocketLib/DxeSupport.c
Normal file
322
StdLib/EfiSocketLib/DxeSupport.c
Normal file
@ -0,0 +1,322 @@
|
||||
/** @file
|
||||
SocketDxe support routines
|
||||
|
||||
Copyright (c) 2011, Intel Corporation
|
||||
All rights reserved. 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
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
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 "Socket.h"
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs gEfiSocketProtocolGuid.
|
||||
|
||||
This routine creates a child handle for the socket driver and
|
||||
installs the ::gEfiSocketProtocolGuid on that handle with a pointer
|
||||
to the ::EFI_SOCKET_PROTOCOL structure address.
|
||||
|
||||
This routine is called by ::EslServiceGetProtocol in UseSocketDxe
|
||||
when the socket application is linked with UseSocketDxe.
|
||||
|
||||
@param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
|
||||
@param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,
|
||||
then a new handle is created. If it is a pointer to an existing UEFI handle,
|
||||
then the protocol is added to the existing UEFI handle.
|
||||
|
||||
@retval EFI_SUCCESS The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
|
||||
the child
|
||||
@retval other The child handle was not created
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN OUT EFI_HANDLE * pChildHandle
|
||||
)
|
||||
{
|
||||
ESL_SOCKET * pSocket;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DBG_ENTER ( );
|
||||
|
||||
//
|
||||
// Create a socket structure
|
||||
//
|
||||
Status = EslSocketAllocate ( pChildHandle,
|
||||
DEBUG_SOCKET,
|
||||
&pSocket );
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
DBG_EXIT_STATUS ( Status );
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Removes gEfiSocketProtocolGuid and destroys the child handle.
|
||||
|
||||
This routine uninstalls ::gEfiSocketProtocolGuid from the child handle
|
||||
and destroys the child handle if necessary.
|
||||
|
||||
This routine is called from ???.
|
||||
|
||||
@param [in] pThis Address of the EFI_SERVICE_BINDING_PROTOCOL structure.
|
||||
@param [in] ChildHandle Handle of the child to destroy
|
||||
|
||||
@retval EFI_SUCCESS The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
||||
because its services are being used.
|
||||
@retval other The child handle was not destroyed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
)
|
||||
{
|
||||
ESL_LAYER * pLayer;
|
||||
ESL_SOCKET * pSocket;
|
||||
ESL_SOCKET * pSocketPrevious;
|
||||
EFI_SOCKET_PROTOCOL * pSocketProtocol;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL TplPrevious;
|
||||
|
||||
DBG_ENTER ( );
|
||||
|
||||
//
|
||||
// Locate the socket control structure
|
||||
//
|
||||
pLayer = &mEslLayer;
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiSocketProtocolGuid,
|
||||
(VOID **)&pSocketProtocol,
|
||||
pLayer->ImageHandle,
|
||||
NULL,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
pSocket = SOCKET_FROM_PROTOCOL ( pSocketProtocol );
|
||||
|
||||
//
|
||||
// Synchronize with the socket layer
|
||||
//
|
||||
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
|
||||
|
||||
//
|
||||
// Walk the socket list
|
||||
//
|
||||
pSocketPrevious = pLayer->pSocketList;
|
||||
if ( NULL != pSocketPrevious ) {
|
||||
if ( pSocket == pSocketPrevious ) {
|
||||
//
|
||||
// Remove the socket from the head of the list
|
||||
//
|
||||
pLayer->pSocketList = pSocket->pNext;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Find the socket in the middle of the list
|
||||
//
|
||||
while (( NULL != pSocketPrevious )
|
||||
&& ( pSocket != pSocketPrevious->pNext )) {
|
||||
//
|
||||
// Set the next socket
|
||||
//
|
||||
pSocketPrevious = pSocketPrevious->pNext;
|
||||
}
|
||||
if ( NULL != pSocketPrevious ) {
|
||||
//
|
||||
// Remove the socket from the middle of the list
|
||||
//
|
||||
pSocketPrevious = pSocket->pNext;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL,
|
||||
"ERROR - Socket list is empty!\r\n" ));
|
||||
}
|
||||
|
||||
//
|
||||
// Release the socket layer synchronization
|
||||
//
|
||||
RESTORE_TPL ( TplPrevious );
|
||||
|
||||
//
|
||||
// Determine if the socket was found
|
||||
//
|
||||
if ( NULL != pSocketPrevious ) {
|
||||
pSocket->pNext = NULL;
|
||||
|
||||
//
|
||||
// Remove the socket protocol
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiSocketProtocolGuid,
|
||||
&pSocket->SocketProtocol,
|
||||
NULL );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INFO,
|
||||
"Removed: gEfiSocketProtocolGuid from 0x%08x\r\n",
|
||||
ChildHandle ));
|
||||
|
||||
//
|
||||
// Free the socket structure
|
||||
//
|
||||
Status = gBS->FreePool ( pSocket );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL,
|
||||
"0x%08x: Free pSocket, %d bytes\r\n",
|
||||
pSocket,
|
||||
sizeof ( *pSocket )));
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL,
|
||||
"ERROR - Failed to free pSocket 0x%08x, Status: %r\r\n",
|
||||
pSocket,
|
||||
Status ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INFO,
|
||||
"ERROR - Failed to remove gEfiSocketProtocolGuid from 0x%08x, Status: %r\r\n",
|
||||
ChildHandle,
|
||||
Status ));
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_INFO,
|
||||
"ERROR - The socket was not in the socket list!\r\n" ));
|
||||
Status = EFI_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR,
|
||||
"ERROR - Failed to open socket protocol on 0x%08x, Status; %r\r\n",
|
||||
ChildHandle,
|
||||
Status ));
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
DBG_EXIT_STATUS ( Status );
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Install the socket service
|
||||
|
||||
This routine installs the ::gEfiSocketServiceBindingProtocolGuid
|
||||
on the SocketDxe image handle to announce the availability
|
||||
of the socket layer to the rest of EFI.
|
||||
|
||||
SocketDxe's EntryPoint routine calls this routine to
|
||||
make the socket layer available.
|
||||
|
||||
@param [in] pImageHandle Address of the image handle
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeInstall (
|
||||
IN EFI_HANDLE * pImageHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install the socket service binding protocol
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
pImageHandle,
|
||||
&gEfiSocketServiceBindingProtocolGuid,
|
||||
mEslLayer.pServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
|
||||
"Installed: gEfiSocketServiceBindingProtocolGuid on 0x%08x\r\n",
|
||||
*pImageHandle ));
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
|
||||
"ERROR - InstallMultipleProtocolInterfaces failed, Status: %r\r\n",
|
||||
Status ));
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Uninstall the socket service
|
||||
|
||||
This routine removes the gEfiSocketServiceBindingProtocolGuid from
|
||||
the SocketDxe image handle to notify EFI that the socket layer
|
||||
is no longer available.
|
||||
|
||||
SocketDxe's DriverUnload routine calls this routine to remove the
|
||||
socket layer.
|
||||
|
||||
@param [in] ImageHandle Handle for the image.
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeUninstall (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install the socket service binding protocol
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiSocketServiceBindingProtocolGuid,
|
||||
mEslLayer.pServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT,
|
||||
"Removed: gEfiSocketServiceBindingProtocolGuid from 0x%08x\r\n",
|
||||
ImageHandle ));
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
|
||||
"ERROR - Failed to remove gEfiSocketServiceBindingProtocolGuid from 0x%08x, Status: %r\r\n",
|
||||
ImageHandle,
|
||||
Status ));
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
return Status;
|
||||
}
|
@ -28,7 +28,9 @@
|
||||
#
|
||||
|
||||
[Sources.common]
|
||||
DxeSupport.c
|
||||
Init.c
|
||||
Ip4.c
|
||||
Service.c
|
||||
Socket.c
|
||||
Tcp4.c
|
||||
@ -43,10 +45,13 @@
|
||||
[LibraryClasses]
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiLib
|
||||
|
||||
[Protocols]
|
||||
gEfiIp4ProtocolGuid
|
||||
gEfiIp4ServiceBindingProtocolGuid
|
||||
gEfiTcp4ProtocolGuid
|
||||
gEfiTcp4ServiceBindingProtocolGuid
|
||||
gEfiUdp4ProtocolGuid
|
||||
|
@ -18,7 +18,22 @@
|
||||
/**
|
||||
EFI Socket Library Constructor
|
||||
|
||||
@retval EFI_SUCCESS The initialization was successful
|
||||
This routine supports an implementation dependent constructor
|
||||
depending upon whether the library is linked to a socket
|
||||
application or the SocketDxe driver. The following modules
|
||||
declare the redirection for the constructor in ::mpfnEslConstructor:
|
||||
<ul>
|
||||
<li>StdLib/EfiSocketLib/UseSocketLib.c - Application links against EfiSocketLib</li>
|
||||
<li>StdLib/SocketDxe/EntryUnload.c - SocketDxe links against EfiSocketLib</li>
|
||||
</ul>
|
||||
|
||||
The EfiSocketLib.inf file lists ::EslConstructor as the CONSTRUCTOR
|
||||
in the [Defines] section. As a result, this routine is called by
|
||||
the ProcessLibraryConstructorList routine of the AutoGen.c module
|
||||
in the Build directory associated with the socket application or
|
||||
the SocketDxe driver.
|
||||
|
||||
@retval EFI_SUCCESS The socket layer initialization was successful
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
@ -54,7 +69,22 @@ EslConstructor (
|
||||
/**
|
||||
EFI Socket Library Destructor
|
||||
|
||||
@retval EFI_SUCCESS The shutdown was successful
|
||||
This routine supports an implementation dependent destructor
|
||||
depending upon whether the library is linked to a socket
|
||||
application or the SocketDxe driver. The following modules
|
||||
declare the redirection for the destructor in ::mpfnEslDestructor:
|
||||
<ul>
|
||||
<li>StdLib/EfiSocketLib/UseSocketLib.c - Application links against EfiSocketLib</li>
|
||||
<li>StdLib/SocketDxe/EntryUnload.c - SocketDxe links against EfiSocketLib</li>
|
||||
</ul>
|
||||
|
||||
The EfiSocketLib.inf file lists ::EslDestructor as the DESTRUCTOR
|
||||
in the [Defines] section. As a result, this routine is called by
|
||||
the ProcessLibraryDestructorList routine of the AutoGen.c module
|
||||
in the Build directory associated with the socket application or
|
||||
the SocketDxe driver.
|
||||
|
||||
@retval EFI_SUCCESS The socket layer shutdown was successful
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
1264
StdLib/EfiSocketLib/Ip4.c
Normal file
1264
StdLib/EfiSocketLib/Ip4.c
Normal file
File diff suppressed because it is too large
Load Diff
31
StdLib/EfiSocketLib/ReleaseNotes.txt
Normal file
31
StdLib/EfiSocketLib/ReleaseNotes.txt
Normal file
@ -0,0 +1,31 @@
|
||||
The following issues exist with the EFI Socket Library:
|
||||
|
||||
* Don't run socket applications or the socket driver for a long time - The IPv4Config
|
||||
and DHCP protocols are not properly running the renew and lease expiration timers.
|
||||
When the DHCP lease expires it is possible for a duplicate IP address to exist on
|
||||
the network. HSD 206136
|
||||
|
||||
* Network adapters must be initialized prior to running the socket application - Static
|
||||
and dynamic IP address need to be properly assigned to the network adapters on the
|
||||
system. Note that sockets does not assign the IP addresses since it does not
|
||||
understand how the system is connected to the network!
|
||||
|
||||
* The default device must contain the Efi\etc directory populated with files containing
|
||||
the proper network configuration - A template set of files is in StdLib\Efi\etc. Note
|
||||
that the resolv.conf file contains the set of DNS servers.
|
||||
|
||||
* Since DHCP is not running when the sockets application is running, the last negotiated
|
||||
packet is no longer available. As a result, any of the options that DHCP did negotiate
|
||||
are no longer available for sockets such as the list of DNS servers.
|
||||
|
||||
* DHCP does not request the domain name and domain name server (DNS) addresses. This
|
||||
requires that sockets use configuration files in Efi\etc!
|
||||
|
||||
* TCPv4 transfer rate is slow (< 10 Mbits/sec) - This is an unidentified issue.
|
||||
|
||||
* Raw socket applications are not able to pass the IP header as part of their
|
||||
payload by using the IP option IP_HDRINCL. This is because the UEFI IPv4 driver
|
||||
(Ip4Dxe) does not support RawData. HSD 206136
|
||||
|
||||
* Only version 4 of the UEFI network stack is supported
|
||||
|
@ -14,15 +14,16 @@
|
||||
|
||||
#include "Socket.h"
|
||||
|
||||
EFI_TCP4_PROTOCOL * mpEfiTcpClose4 [ 1024 ];
|
||||
|
||||
|
||||
/**
|
||||
Connect to the network service bindings
|
||||
|
||||
Walk the network service protocols on the controller handle and
|
||||
locate any that are not in use. Create service structures to
|
||||
manage the service binding for the socket driver.
|
||||
locate any that are not in use. Create ::ESL_SERVICE structures to
|
||||
manage the network layer interfaces for the socket driver. Tag
|
||||
each of the network interfaces that are being used. Finally, this
|
||||
routine calls ESL_SOCKET_BINDING::pfnInitialize to prepare the network
|
||||
interface for use by the socket layer.
|
||||
|
||||
@param [in] BindingHandle Handle for protocol binding.
|
||||
@param [in] Controller Handle of device to work with.
|
||||
@ -40,11 +41,13 @@ EslServiceConnect (
|
||||
{
|
||||
BOOLEAN bInUse;
|
||||
UINTN LengthInBytes;
|
||||
CONST DT_SOCKET_BINDING * pEnd;
|
||||
UINT8 * pBuffer;
|
||||
CONST ESL_SOCKET_BINDING * pEnd;
|
||||
VOID * pJunk;
|
||||
VOID * pInterface;
|
||||
DT_SERVICE * pService;
|
||||
CONST DT_SOCKET_BINDING * pSocketBinding;
|
||||
ESL_SERVICE ** ppServiceListHead;
|
||||
ESL_SERVICE * pService;
|
||||
CONST ESL_SOCKET_BINDING * pSocketBinding;
|
||||
EFI_SERVICE_BINDING_PROTOCOL * pServiceBinding;
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL TplPrevious;
|
||||
|
||||
@ -68,7 +71,7 @@ EslServiceConnect (
|
||||
Status = gBS->OpenProtocol (
|
||||
Controller,
|
||||
pSocketBinding->pNetworkBinding,
|
||||
&pInterface,
|
||||
(VOID**)&pServiceBinding,
|
||||
BindingHandle,
|
||||
Controller,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
@ -108,7 +111,7 @@ EslServiceConnect (
|
||||
pService->Signature = SERVICE_SIGNATURE;
|
||||
pService->pSocketBinding = pSocketBinding;
|
||||
pService->Controller = Controller;
|
||||
pService->pInterface = pInterface;
|
||||
pService->pServiceBinding = pServiceBinding;
|
||||
|
||||
//
|
||||
// Mark the controller in use
|
||||
@ -154,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
|
||||
@ -253,9 +260,10 @@ EslServiceConnect (
|
||||
|
||||
|
||||
/**
|
||||
Shutdown the network connections to this controller by removing
|
||||
NetworkInterfaceIdentifier protocol and closing the DevicePath
|
||||
and PciIo protocols on Controller.
|
||||
Shutdown the connections to the network layer by locating the
|
||||
tags on the network interfaces established by ::EslServiceConnect.
|
||||
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.
|
||||
@ -272,9 +280,13 @@ EslServiceDisconnect (
|
||||
IN EFI_HANDLE Controller
|
||||
)
|
||||
{
|
||||
CONST DT_SOCKET_BINDING * pEnd;
|
||||
DT_SERVICE * pService;
|
||||
CONST DT_SOCKET_BINDING * pSocketBinding;
|
||||
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;
|
||||
|
||||
@ -310,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
|
||||
@ -387,48 +444,6 @@ EslServiceDisconnect (
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Install the socket service
|
||||
|
||||
@param [in] pImageHandle Address of the image handle
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslServiceInstall (
|
||||
IN EFI_HANDLE * pImageHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install the socket service binding protocol
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
pImageHandle,
|
||||
&gEfiSocketServiceBindingProtocolGuid,
|
||||
&mEslLayer.ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
|
||||
"Installed: gEfiSocketServiceBindingProtocolGuid on 0x%08x\r\n",
|
||||
*pImageHandle ));
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
|
||||
"ERROR - InstallMultipleProtocolInterfaces failed, Status: %r\r\n",
|
||||
Status ));
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Initialize the service layer
|
||||
|
||||
@ -441,69 +456,20 @@ EslServiceLoad (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
{
|
||||
DT_LAYER * pLayer;
|
||||
ESL_LAYER * pLayer;
|
||||
|
||||
//
|
||||
// Save the image handle
|
||||
//
|
||||
pLayer = &mEslLayer;
|
||||
ZeroMem ( pLayer, sizeof ( *pLayer ));
|
||||
pLayer->Signature = LAYER_SIGNATURE;
|
||||
pLayer->ImageHandle = ImageHandle;
|
||||
|
||||
//
|
||||
// Initialize the TCP4 close
|
||||
//
|
||||
pLayer->TcpCloseMax4 = DIM ( mpEfiTcpClose4 );
|
||||
pLayer->ppTcpClose4 = mpEfiTcpClose4;
|
||||
|
||||
//
|
||||
// Connect the service binding protocol to the image handle
|
||||
//
|
||||
pLayer->ServiceBinding.CreateChild = EslSocketCreateChild;
|
||||
pLayer->ServiceBinding.DestroyChild = EslSocketDestroyChild;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Uninstall the socket service
|
||||
|
||||
@param [in] ImageHandle Handle for the image.
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslServiceUninstall (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Install the socket service binding protocol
|
||||
//
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiSocketServiceBindingProtocolGuid,
|
||||
&mEslLayer.ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT,
|
||||
"Removed: gEfiSocketServiceBindingProtocolGuid from 0x%08x\r\n",
|
||||
ImageHandle ));
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_POOL | DEBUG_INIT,
|
||||
"ERROR - Failed to remove gEfiSocketServiceBindingProtocolGuid from 0x%08x, Status: %r\r\n",
|
||||
ImageHandle,
|
||||
Status ));
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
return Status;
|
||||
pLayer->pServiceBinding = &mEfiServiceBinding;
|
||||
}
|
||||
|
||||
|
||||
@ -517,13 +483,12 @@ EslServiceUnload (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
DT_LAYER * pLayer;
|
||||
ESL_LAYER * pLayer;
|
||||
|
||||
//
|
||||
// Undo the work by ServiceLoad
|
||||
//
|
||||
pLayer = &mEslLayer;
|
||||
pLayer->ImageHandle = NULL;
|
||||
pLayer->ServiceBinding.CreateChild = NULL;
|
||||
pLayer->ServiceBinding.DestroyChild = NULL;
|
||||
pLayer->pServiceBinding = NULL;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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,18 +159,23 @@ EslServiceNetworkConnect (
|
||||
&HandleCount,
|
||||
&pHandles );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
DEBUG (( DEBUG_ERROR,
|
||||
"ERROR with %s layer, Status: %r\r\n",
|
||||
pSocketBinding->pName,
|
||||
Status ));
|
||||
}
|
||||
else {
|
||||
if ( NULL != pHandles ) {
|
||||
//
|
||||
// Attempt to connect to this network adapter
|
||||
//
|
||||
for ( Index = 0; HandleCount > Index; Index++ ) {
|
||||
Status = EslServiceConnect ( gImageHandle,
|
||||
pHandles [ Index ]);
|
||||
pHandles[ Index ]);
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
bSomethingFound = TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
@ -140,6 +183,7 @@ EslServiceNetworkConnect (
|
||||
//
|
||||
gBS->FreePool ( pHandles );
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Set the next network protocol
|
||||
@ -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
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
|
||||
@ -49,12 +50,12 @@
|
||||
#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
|
||||
#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
|
||||
#else // _MSC_VER
|
||||
#define DBG_ENTER()
|
||||
#define DBG_EXIT()
|
||||
#define DBG_EXIT_DEC(Status)
|
||||
#define DBG_EXIT_HEX(Status)
|
||||
#define DBG_EXIT_STATUS(Status)
|
||||
#define DBG_EXIT_TF(Status)
|
||||
#define DBG_ENTER() ///< Display routine entry
|
||||
#define DBG_EXIT() ///< Display routine exit
|
||||
#define DBG_EXIT_DEC(Status) ///< Display routine exit with decimal value
|
||||
#define DBG_EXIT_HEX(Status) ///< Display routine exit with hex value
|
||||
#define DBG_EXIT_STATUS(Status) ///< Display routine exit with status value
|
||||
#define DBG_EXIT_TF(Status) ///< Display routine with TRUE/FALSE value
|
||||
#endif // _MSC_VER
|
||||
|
||||
#define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array
|
||||
@ -71,12 +72,27 @@
|
||||
|
||||
#if !defined(MDEPKG_NDEBUG)
|
||||
|
||||
/**
|
||||
Verify that the TPL is at the correct level
|
||||
**/
|
||||
#define VERIFY_AT_TPL(tpl) \
|
||||
{ \
|
||||
EFI_TPL PreviousTpl; \
|
||||
\
|
||||
PreviousTpl = EfiGetCurrentTpl ( ); \
|
||||
if ( PreviousTpl != tpl ) { \
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_TPL, \
|
||||
"Current TPL: %d, New TPL: %d\r\n", \
|
||||
PreviousTpl, tpl )); \
|
||||
ASSERT ( PreviousTpl == tpl ); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define VERIFY_TPL(tpl) \
|
||||
{ \
|
||||
EFI_TPL PreviousTpl; \
|
||||
\
|
||||
PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
|
||||
gBS->RestoreTPL ( PreviousTpl ); \
|
||||
PreviousTpl = EfiGetCurrentTpl ( ); \
|
||||
if ( PreviousTpl > tpl ) { \
|
||||
DEBUG (( DEBUG_ERROR | DEBUG_TPL, \
|
||||
"Current TPL: %d, New TPL: %d\r\n", \
|
||||
@ -87,10 +103,14 @@
|
||||
|
||||
#else // MDEPKG_NDEBUG
|
||||
|
||||
#define VERIFY_TPL(tpl)
|
||||
#define VERIFY_AT_TPL(tpl) ///< Verify that the TPL is at the correct level
|
||||
#define VERIFY_TPL(tpl) ///< Verify that the TPL is at the correct level
|
||||
|
||||
#endif // MDEPKG_NDEBUG
|
||||
|
||||
/**
|
||||
Raise TPL to the specified level
|
||||
**/
|
||||
#define RAISE_TPL(PreviousTpl, tpl) \
|
||||
VERIFY_TPL ( tpl ); \
|
||||
PreviousTpl = gBS->RaiseTPL ( tpl ); \
|
||||
@ -98,29 +118,20 @@
|
||||
"%d: TPL\r\n", \
|
||||
tpl ))
|
||||
|
||||
/**
|
||||
Restore the TPL to the previous value
|
||||
**/
|
||||
#define RESTORE_TPL(tpl) \
|
||||
gBS->RestoreTPL ( tpl ); \
|
||||
DEBUG (( DEBUG_TPL | DEBUG_TPL, \
|
||||
"%d: TPL\r\n", \
|
||||
tpl ))
|
||||
tpl )); \
|
||||
gBS->RestoreTPL ( tpl )
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Data Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
typedef struct _DT_SERVICE DT_SERVICE; ///< Forward delcaration
|
||||
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(EFIAPI * PFN_SB_INITIALIZE) (
|
||||
DT_SERVICE * pService
|
||||
);
|
||||
|
||||
typedef
|
||||
VOID
|
||||
(EFIAPI * PFN_SB_SHUTDOWN) (
|
||||
DT_SERVICE * pService
|
||||
);
|
||||
typedef struct _ESL_SERVICE ESL_SERVICE; ///< Forward delcaration
|
||||
|
||||
/**
|
||||
Protocol binding and installation control structure
|
||||
@ -130,25 +141,119 @@ VOID
|
||||
typedef struct {
|
||||
CHAR16 * pName; ///< Protocol name
|
||||
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
|
||||
} DT_SOCKET_BINDING;
|
||||
UINTN ServiceListOffset; ///< Offset in ::ESL_LAYER for the list of services
|
||||
UINTN RxIo; ///< Number of receive ESL_IO_MGMT structures for data
|
||||
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;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// GUIDs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern CONST EFI_GUID mEslRawServiceGuid;
|
||||
extern CONST EFI_GUID mEslTcp4ServiceGuid;
|
||||
extern CONST EFI_GUID mEslUdp4ServiceGuid;
|
||||
extern CONST EFI_GUID mEslIp4ServiceGuid; ///< Tag GUID for the IPv4 layer
|
||||
extern CONST EFI_GUID mEslTcp4ServiceGuid; ///< Tag GUID for the TCPv4 layer
|
||||
extern CONST EFI_GUID mEslUdp4ServiceGuid; ///< Tag GUID for the UDPv4 layer
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Data
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern CONST DT_SOCKET_BINDING cEslSocketBinding [];
|
||||
extern CONST UINTN cEslSocketBindingEntries;
|
||||
extern CONST ESL_SOCKET_BINDING cEslSocketBinding[];///< List of network service bindings
|
||||
extern CONST UINTN cEslSocketBindingEntries; ///< Number of network service bindings
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// DXE Support Routines
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
When the socket application is linked against UseSocketDxe, the ::socket
|
||||
routine indirectly calls this routine in SocketDxe to create a child
|
||||
handle if necessary and install the socket protocol on the handle.
|
||||
Upon return, EslServiceGetProtocol in UseSocketLib returns the
|
||||
::EFI_SOCKET_PROTOCOL address to the socket routine.
|
||||
|
||||
@param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,
|
||||
then a new handle is created. If it is a pointer to an existing UEFI handle,
|
||||
then the protocol is added to the existing UEFI handle.
|
||||
|
||||
@retval EFI_SUCCESS The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
|
||||
the child
|
||||
@retval other The child handle was not created
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN OUT EFI_HANDLE * pChildHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
When the socket application is linked against UseSocketDxe, the ::close
|
||||
routine indirectly calls this routine in SocketDxe to undo the operations
|
||||
done by the ::EslDxeCreateChild routine. This routine removes the socket
|
||||
protocol from the handle and then destroys the child handle if there are
|
||||
no other protocols attached.
|
||||
|
||||
@param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param [in] ChildHandle Handle of the child to destroy
|
||||
|
||||
@retval EFI_SUCCESS The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
||||
because its services are being used.
|
||||
@retval other The child handle was not destroyed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Install the socket service
|
||||
|
||||
SocketDxe uses this routine to announce the socket interface to
|
||||
the rest of EFI.
|
||||
|
||||
@param [in] pImageHandle Address of the image handle
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeInstall (
|
||||
IN EFI_HANDLE * pImageHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Uninstall the socket service
|
||||
|
||||
SocketDxe uses this routine to notify EFI that the socket layer
|
||||
is no longer available.
|
||||
|
||||
@param [in] ImageHandle Handle for the image.
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslDxeUninstall (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Service Support Routines
|
||||
@ -158,8 +263,11 @@ extern CONST UINTN cEslSocketBindingEntries;
|
||||
Connect to the network service bindings
|
||||
|
||||
Walk the network service protocols on the controller handle and
|
||||
locate any that are not in use. Create service structures to
|
||||
manage the service binding for the socket driver.
|
||||
locate any that are not in use. Create ::ESL_SERVICE structures to
|
||||
manage the network layer interfaces for the socket driver. Tag
|
||||
each of the network interfaces that are being used. Finally, this
|
||||
routine calls ESL_SOCKET_BINDING::pfnInitialize to prepare the network
|
||||
interface for use by the socket layer.
|
||||
|
||||
@param [in] BindingHandle Handle for protocol binding.
|
||||
@param [in] Controller Handle of device to work with.
|
||||
@ -176,9 +284,11 @@ EslServiceConnect (
|
||||
);
|
||||
|
||||
/**
|
||||
Shutdown the network connections to this controller by removing
|
||||
NetworkInterfaceIdentifier protocol and closing the DevicePath
|
||||
and PciIo protocols on Controller.
|
||||
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.
|
||||
|
||||
@param [in] BindingHandle Handle for protocol binding.
|
||||
@param [in] Controller Handle of device to stop driver on.
|
||||
@ -195,19 +305,6 @@ EslServiceDisconnect (
|
||||
IN EFI_HANDLE Controller
|
||||
);
|
||||
|
||||
/**
|
||||
Install the socket service
|
||||
|
||||
@param [in] pImageHandle Address of the image handle
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslServiceInstall (
|
||||
IN EFI_HANDLE * pImageHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Initialize the service layer
|
||||
|
||||
@ -220,19 +317,6 @@ EslServiceLoad (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Uninstall the socket service
|
||||
|
||||
@param [in] ImageHandle Handle for the image.
|
||||
|
||||
@retval EFI_SUCCESS Service installed successfully
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslServiceUninstall (
|
||||
IN EFI_HANDLE ImageHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Shutdown the service layer
|
||||
|
||||
@ -243,61 +327,6 @@ EslServiceUnload (
|
||||
VOID
|
||||
);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Socket Service Binding Protocol Routines
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
The CreateChild() function installs a protocol on ChildHandle.
|
||||
If pChildHandle is a pointer to NULL, then a new handle is created and returned in pChildHandle.
|
||||
If pChildHandle is not a pointer to NULL, then the protocol installs on the existing pChildHandle.
|
||||
|
||||
@param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param [in] pChildHandle Pointer to the handle of the child to create. If it is NULL,
|
||||
then a new handle is created. If it is a pointer to an existing UEFI handle,
|
||||
then the protocol is added to the existing UEFI handle.
|
||||
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
|
||||
the child
|
||||
@retval other The child handle was not created
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslSocketCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN OUT EFI_HANDLE * pChildHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
|
||||
that was installed by CreateChild() from ChildHandle. If the removed protocol is the
|
||||
last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param [in] pThis Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param [in] ChildHandle Handle of the child to destroy
|
||||
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
||||
because its services are being used.
|
||||
@retval other The child handle was not destroyed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EslSocketDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL * pThis,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Socket Protocol Routines
|
||||
//------------------------------------------------------------------------------
|
||||
@ -305,11 +334,13 @@ EslSocketDestroyChild (
|
||||
/**
|
||||
Bind a name to a socket.
|
||||
|
||||
The ::SocketBind routine connects a name to a socket on the local machine. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
This routine calls the network specific layer to save the network
|
||||
address of the local connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::bind routine calls this routine to connect a name
|
||||
(network address and port) to a socket on the local machine.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] pSockAddr Address of a sockaddr structure that contains the
|
||||
connection point on the local machine. An IPv4 address
|
||||
@ -321,7 +352,7 @@ EslSocketDestroyChild (
|
||||
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.
|
||||
@param [in] SockAddrLength Specifies the length in bytes of the sockaddr structure.
|
||||
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@ -331,7 +362,7 @@ EslSocketDestroyChild (
|
||||
EFI_STATUS
|
||||
EslSocketBind (
|
||||
IN EFI_SOCKET_PROTOCOL * pSocketProtocol,
|
||||
IN const struct sockaddr * pSockAddr,
|
||||
IN CONST struct sockaddr * pSockAddr,
|
||||
IN socklen_t SockAddrLength,
|
||||
OUT int * pErrno
|
||||
);
|
||||
@ -339,9 +370,14 @@ EslSocketBind (
|
||||
/**
|
||||
Determine if the socket is closed
|
||||
|
||||
Reverses the operations of the ::SocketAllocate() routine.
|
||||
This routine checks the state of the socket to determine if
|
||||
the network specific layer has completed the close operation.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::close routine polls this routine to determine when the
|
||||
close operation is complete. The close operation needs to
|
||||
reverse the operations of the ::EslSocketAllocate routine.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS Socket successfully closed
|
||||
@ -359,11 +395,19 @@ EslSocketClosePoll (
|
||||
/**
|
||||
Start the close operation on the socket
|
||||
|
||||
Start closing the socket by closing all of the ports. Upon
|
||||
completion, the ::SocketPoll() routine finishes closing the
|
||||
socket.
|
||||
This routine calls the network specific layer to initiate the
|
||||
close state machine. This routine then calls the network
|
||||
specific layer to determine if the close state machine has gone
|
||||
to completion. The result from this poll is returned to the
|
||||
caller.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::close routine calls this routine to start the close
|
||||
operation which reverses the operations of the
|
||||
::EslSocketAllocate routine. The close routine then polls
|
||||
the ::EslSocketClosePoll routine to determine when the
|
||||
socket is closed.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] bCloseNow Boolean to control close behavior
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@ -383,28 +427,16 @@ EslSocketCloseStart (
|
||||
/**
|
||||
Connect to a remote system via the network.
|
||||
|
||||
The ::SocketConnect routine attempts to establish a connection to a
|
||||
socket on the local or remote system using the specified address.
|
||||
The POSIX
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">connect</a>
|
||||
documentation is available online.
|
||||
This routine calls the network specific layer to establish
|
||||
the remote system address and establish the connection to
|
||||
the remote system.
|
||||
|
||||
There are three states associated with a connection:
|
||||
<ul>
|
||||
<li>Not connected</li>
|
||||
<li>Connection in progress</li>
|
||||
<li>Connected</li>
|
||||
</ul>
|
||||
In the "Not connected" state, calls to ::connect start the connection
|
||||
processing and update the state to "Connection in progress". During
|
||||
the "Connection in progress" state, connect polls for connection completion
|
||||
and moves the state to "Connected" after the connection is established.
|
||||
Note that these states are only visible when the file descriptor is marked
|
||||
with O_NONBLOCK. Also, the POLL_WRITE bit is set when the connection
|
||||
completes and may be used by poll or select as an indicator to call
|
||||
connect again.
|
||||
The ::connect routine calls this routine to establish a
|
||||
connection with the specified remote system. This routine
|
||||
is designed to be polled by the connect routine for completion
|
||||
of the network connection.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] pSockAddr Network address of the remote system.
|
||||
|
||||
@ -428,7 +460,13 @@ EslSocketConnect (
|
||||
/**
|
||||
Get the local address.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
This routine calls the network specific layer to get the network
|
||||
address of the local host connection point.
|
||||
|
||||
The ::getsockname routine calls this routine to obtain the network
|
||||
address associated with the local host connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [out] pAddress Network address to receive the local system address
|
||||
|
||||
@ -450,7 +488,13 @@ EslSocketGetLocalAddress (
|
||||
/**
|
||||
Get the peer address.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
This routine calls the network specific layer to get the remote
|
||||
system connection point.
|
||||
|
||||
The ::getpeername routine calls this routine to obtain the network
|
||||
address of the remote connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [out] pAddress Network address to receive the remote system address
|
||||
|
||||
@ -472,14 +516,18 @@ EslSocketGetPeerAddress (
|
||||
/**
|
||||
Establish the known port to listen for network connections.
|
||||
|
||||
The ::SocketListen routine places the port into a state that enables connection
|
||||
attempts. Connections are placed into FIFO order in a queue to be serviced
|
||||
by the application. The application calls the ::SocketAccept routine to remove
|
||||
the next connection from the queue and get the associated socket. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
This routine calls into the network protocol layer to establish
|
||||
a handler that is called upon connection completion. The handler
|
||||
is responsible for inserting the connection into the FIFO.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::listen routine indirectly calls this routine to place the
|
||||
socket into a state that enables connection attempts. Connections
|
||||
are placed in a FIFO that is serviced by the application. The
|
||||
application calls the ::accept (::EslSocketAccept) routine to
|
||||
remove the next connection from the FIFO and get the associated
|
||||
socket and address.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Backlog Backlog specifies the maximum FIFO depth for
|
||||
the connections waiting for the application
|
||||
@ -502,15 +550,17 @@ EslSocketListen (
|
||||
/**
|
||||
Get the socket options
|
||||
|
||||
Retrieve the socket options one at a time by name. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine handles the socket level options and passes the
|
||||
others to the network specific layer.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::getsockopt routine calls this routine to retrieve the
|
||||
socket options one at a time by name.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] option_name Name of the option
|
||||
@param [out] option_value Buffer to receive the option value
|
||||
@param [in,out] option_len Length of the buffer in bytes,
|
||||
@param [in] OptionName Name of the option
|
||||
@param [out] pOptionValue Buffer to receive the option value
|
||||
@param [in,out] pOptionLength Length of the buffer in bytes,
|
||||
upon return length of the option value in bytes
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@ -530,18 +580,20 @@ EslSocketOptionGet (
|
||||
/**
|
||||
Set the socket options
|
||||
|
||||
Adjust the socket options one at a time by name. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine handles the socket level options and passes the
|
||||
others to the network specific layer.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::setsockopt routine calls this routine to adjust the socket
|
||||
options one at a time by name.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] option_name Name of the option
|
||||
@param [in] option_value Buffer containing the option value
|
||||
@param [in] option_len Length of the buffer in bytes
|
||||
@param [in] OptionName Name of the option
|
||||
@param [in] pOptionValue Buffer containing the option value
|
||||
@param [in] OptionLength Length of the buffer in bytes
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket data successfully received
|
||||
@retval EFI_SUCCESS - Option successfully set
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
@ -557,10 +609,14 @@ EslSocketOptionSet (
|
||||
/**
|
||||
Poll a socket for pending activity.
|
||||
|
||||
The SocketPoll routine checks a socket for pending activity associated
|
||||
with the event mask. Activity is returned in the detected event buffer.
|
||||
This routine builds a detected event mask which is returned to
|
||||
the caller in the buffer provided.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::poll routine calls this routine to determine if the socket
|
||||
needs to be serviced as a result of connection, error, receive or
|
||||
transmit activity.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Events Events of interest for this socket
|
||||
|
||||
@ -583,8 +639,15 @@ EslSocketPoll (
|
||||
/**
|
||||
Receive data from a network connection.
|
||||
|
||||
This routine calls the network specific routine to remove the
|
||||
next portion of data from the receive queue and return it to the
|
||||
caller.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::recvfrom routine calls this routine to determine if any data
|
||||
is received from the remote system. Note that the other routines
|
||||
::recv and ::read are layered on top of ::recvfrom.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Flags Message control flags
|
||||
|
||||
@ -618,10 +681,13 @@ EslSocketReceive (
|
||||
/**
|
||||
Shutdown the socket receive and transmit operations
|
||||
|
||||
The SocketShutdown routine stops the socket receive and transmit
|
||||
operations.
|
||||
This routine sets a flag to stop future transmissions and calls
|
||||
the network specific layer to cancel the pending receive operation.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::shutdown routine calls this routine to stop receive and transmit
|
||||
operations on the socket.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] How Which operations to stop
|
||||
|
||||
@ -640,10 +706,16 @@ EslSocketShutdown (
|
||||
/**
|
||||
Send data using a network connection.
|
||||
|
||||
The SocketTransmit routine queues the data for transmission to the
|
||||
remote network connection.
|
||||
This routine calls the network specific layer to queue the data
|
||||
for transmission. Eventually the buffer will reach the head of
|
||||
the queue and will get transmitted over the network. For datagram
|
||||
sockets there is no guarantee that the data reaches the application
|
||||
running on the remote system.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::sendto routine calls this routine to send data to the remote
|
||||
system. Note that ::send and ::write are layered on top of ::sendto.
|
||||
|
||||
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Flags Message control flags
|
||||
|
||||
@ -659,7 +731,7 @@ EslSocketShutdown (
|
||||
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket data successfully received
|
||||
@retval EFI_SUCCESS - Socket data successfully queued for transmit
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
|
@ -27,6 +27,9 @@
|
||||
// Data Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
EfiSocketLib (SocketDxe) interface
|
||||
**/
|
||||
typedef struct _EFI_SOCKET_PROTOCOL EFI_SOCKET_PROTOCOL;
|
||||
|
||||
/**
|
||||
@ -45,11 +48,11 @@ EFI_STATUS
|
||||
// Data
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern PFN_ESL_xSTRUCTOR mpfnEslConstructor;
|
||||
extern PFN_ESL_xSTRUCTOR mpfnEslDestructor;
|
||||
extern PFN_ESL_xSTRUCTOR mpfnEslConstructor; ///< Constructor address for EslSocketLib
|
||||
extern PFN_ESL_xSTRUCTOR mpfnEslDestructor; ///< Destructor address for EslSocketLib
|
||||
|
||||
extern EFI_GUID gEfiSocketProtocolGuid;
|
||||
extern EFI_GUID gEfiSocketServiceBindingProtocolGuid;
|
||||
extern EFI_GUID gEfiSocketProtocolGuid; ///< Socket protocol GUID
|
||||
extern EFI_GUID gEfiSocketServiceBindingProtocolGuid; ///< Socket layer service binding protocol GUID
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Socket API
|
||||
@ -58,11 +61,16 @@ extern EFI_GUID gEfiSocketServiceBindingProtocolGuid;
|
||||
/**
|
||||
Accept a network connection.
|
||||
|
||||
The SocketAccept routine waits for a network connection to the socket.
|
||||
It is able to return the remote network address to the caller if
|
||||
requested.
|
||||
This routine calls the network specific layer to remove the next
|
||||
connection from the FIFO.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::accept calls this routine to poll for a network
|
||||
connection to the socket. When a connection is available
|
||||
this routine returns the ::EFI_SOCKET_PROTOCOL structure address
|
||||
associated with the new socket and the remote network address
|
||||
if requested.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] pSockAddr Address of a buffer to receive the remote
|
||||
network address.
|
||||
@ -71,8 +79,9 @@ extern EFI_GUID gEfiSocketServiceBindingProtocolGuid;
|
||||
On output specifies the length of the
|
||||
remote network address.
|
||||
|
||||
@param [out] ppSocketProtocol Address of a buffer to receive the socket protocol
|
||||
instance associated with the new socket.
|
||||
@param [out] ppSocketProtocol Address of a buffer to receive the
|
||||
::EFI_SOCKET_PROTOCOL instance
|
||||
associated with the new socket.
|
||||
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@ -93,11 +102,13 @@ EFI_STATUS
|
||||
/**
|
||||
Bind a name to a socket.
|
||||
|
||||
The ::SocketBind routine connects a name to a socket on the local machine. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
This routine calls the network specific layer to save the network
|
||||
address of the local connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::bind routine calls this routine to connect a name
|
||||
(network address and port) to a socket on the local machine.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] pSockAddr Address of a sockaddr structure that contains the
|
||||
connection point on the local machine. An IPv4 address
|
||||
@ -128,9 +139,14 @@ EFI_STATUS
|
||||
/**
|
||||
Determine if the socket is closed
|
||||
|
||||
Reverses the operations of the ::SocketAllocate() routine.
|
||||
This routine checks the state of the socket to determine if
|
||||
the network specific layer has completed the close operation.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::close routine polls this routine to determine when the
|
||||
close operation is complete. The close operation needs to
|
||||
reverse the operations of the ::EslSocketAllocate routine.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS Socket successfully closed
|
||||
@ -149,11 +165,19 @@ EFI_STATUS
|
||||
/**
|
||||
Start the close operation on the socket
|
||||
|
||||
Start closing the socket by closing all of the ports. Upon
|
||||
completion, the ::pfnClosePoll() routine finishes closing the
|
||||
socket.
|
||||
This routine calls the network specific layer to initiate the
|
||||
close state machine. This routine then calls the network
|
||||
specific layer to determine if the close state machine has gone
|
||||
to completion. The result from this poll is returned to the
|
||||
caller.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::close routine calls this routine to start the close
|
||||
operation which reverses the operations of the
|
||||
::EslSocketAllocate routine. The close routine then polls
|
||||
the ::EslSocketClosePoll routine to determine when the
|
||||
socket is closed.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] bCloseNow Boolean to control close behavior
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@ -174,28 +198,16 @@ EFI_STATUS
|
||||
/**
|
||||
Connect to a remote system via the network.
|
||||
|
||||
The ::Connect routine attempts to establish a connection to a
|
||||
socket on the local or remote system using the specified address.
|
||||
The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine calls the network specific layer to establish
|
||||
the remote system address and establish the connection to
|
||||
the remote system.
|
||||
|
||||
There are three states associated with a connection:
|
||||
<ul>
|
||||
<li>Not connected</li>
|
||||
<li>Connection in progress</li>
|
||||
<li>Connected</li>
|
||||
</ul>
|
||||
In the "Not connected" state, calls to ::connect start the connection
|
||||
processing and update the state to "Connection in progress". During
|
||||
the "Connection in progress" state, connect polls for connection completion
|
||||
and moves the state to "Connected" after the connection is established.
|
||||
Note that these states are only visible when the file descriptor is marked
|
||||
with O_NONBLOCK. Also, the POLL_WRITE bit is set when the connection
|
||||
completes and may be used by poll or select as an indicator to call
|
||||
connect again.
|
||||
The ::connect routine calls this routine to establish a
|
||||
connection with the specified remote system. This routine
|
||||
is designed to be polled by the connect routine for completion
|
||||
of the network connection.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] pSockAddr Network address of the remote system.
|
||||
|
||||
@ -220,7 +232,13 @@ EFI_STATUS
|
||||
/**
|
||||
Get the local address.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
This routine calls the network specific layer to get the network
|
||||
address of the local host connection point.
|
||||
|
||||
The ::getsockname routine calls this routine to obtain the network
|
||||
address associated with the local host connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [out] pAddress Network address to receive the local system address
|
||||
|
||||
@ -243,7 +261,13 @@ EFI_STATUS
|
||||
/**
|
||||
Get the peer address.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
This routine calls the network specific layer to get the remote
|
||||
system connection point.
|
||||
|
||||
The ::getpeername routine calls this routine to obtain the network
|
||||
address of the remote connection point.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [out] pAddress Network address to receive the remote system address
|
||||
|
||||
@ -266,12 +290,16 @@ EFI_STATUS
|
||||
/**
|
||||
Establish the known port to listen for network connections.
|
||||
|
||||
The ::SocketAisten routine places the port into a state that enables connection
|
||||
attempts. Connections are placed into FIFO order in a queue to be serviced
|
||||
by the application. The application calls the ::SocketAccept routine to remove
|
||||
the next connection from the queue and get the associated socket. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html">POSIX</a>
|
||||
documentation for the bind routine is available online for reference.
|
||||
This routine calls into the network protocol layer to establish
|
||||
a handler that is called upon connection completion. The handler
|
||||
is responsible for inserting the connection into the FIFO.
|
||||
|
||||
The ::listen routine indirectly calls this routine to place the
|
||||
socket into a state that enables connection attempts. Connections
|
||||
are placed in a FIFO that is serviced by the application. The
|
||||
application calls the ::accept (::EslSocketAccept) routine to
|
||||
remove the next connection from the FIFO and get the associated
|
||||
socket and address.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
|
||||
@ -297,11 +325,13 @@ EFI_STATUS
|
||||
/**
|
||||
Get the socket options
|
||||
|
||||
Retrieve the socket options one at a time by name. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine handles the socket level options and passes the
|
||||
others to the network specific layer.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::getsockopt routine calls this routine to retrieve the
|
||||
socket options one at a time by name.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] OptionName Name of the option
|
||||
@param [out] pOptionValue Buffer to receive the option value
|
||||
@ -326,18 +356,20 @@ EFI_STATUS
|
||||
/**
|
||||
Set the socket options
|
||||
|
||||
Adjust the socket options one at a time by name. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine handles the socket level options and passes the
|
||||
others to the network specific layer.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::setsockopt routine calls this routine to adjust the socket
|
||||
options one at a time by name.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
@param [in] level Option protocol level
|
||||
@param [in] OptionName Name of the option
|
||||
@param [in] pOptionValue Buffer containing the option value
|
||||
@param [in] OptionLength Length of the buffer in bytes
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket data successfully received
|
||||
@retval EFI_SUCCESS - Option successfully set
|
||||
|
||||
**/
|
||||
typedef
|
||||
@ -354,10 +386,14 @@ EFI_STATUS
|
||||
/**
|
||||
Poll a socket for pending activity.
|
||||
|
||||
The SocketPoll routine checks a socket for pending activity associated
|
||||
with the event mask. Activity is returned in the detected event buffer.
|
||||
This routine builds a detected event mask which is returned to
|
||||
the caller in the buffer provided.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::poll routine calls this routine to determine if the socket
|
||||
needs to be serviced as a result of connection, error, receive or
|
||||
transmit activity.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Events Events of interest for this socket
|
||||
|
||||
@ -381,12 +417,15 @@ EFI_STATUS
|
||||
/**
|
||||
Receive data from a network connection.
|
||||
|
||||
The ::recv routine waits for receive data from a remote network
|
||||
connection. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html">POSIX</a>
|
||||
documentation is available online.
|
||||
This routine calls the network specific routine to remove the
|
||||
next portion of data from the receive queue and return it to the
|
||||
caller.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::recvfrom routine calls this routine to determine if any data
|
||||
is received from the remote system. Note that the other routines
|
||||
::recv and ::read are layered on top of ::recvfrom.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Flags Message control flags
|
||||
|
||||
@ -418,51 +457,16 @@ EFI_STATUS
|
||||
IN int * pErrno
|
||||
);
|
||||
|
||||
/**
|
||||
Send data using a network connection.
|
||||
|
||||
The SocketTransmit routine queues the data for transmission to the
|
||||
remote network connection.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
|
||||
@param [in] Flags Message control flags
|
||||
|
||||
@param [in] BufferLength Length of the the buffer
|
||||
|
||||
@param [in] pBuffer Address of a buffer containing the data to send
|
||||
|
||||
@param [in] pDataLength Address to receive the number of data bytes sent
|
||||
|
||||
@param [in] pAddress Network address of the remote system address
|
||||
|
||||
@param [in] AddressLength Length of the remote network address structure
|
||||
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket data successfully queued for transmission
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(* PFN_SEND) (
|
||||
IN EFI_SOCKET_PROTOCOL * pSocketProtocol,
|
||||
IN int Flags,
|
||||
IN size_t BufferLength,
|
||||
IN CONST UINT8 * pBuffer,
|
||||
OUT size_t * pDataLength,
|
||||
IN const struct sockaddr * pAddress,
|
||||
IN socklen_t AddressLength,
|
||||
IN int * pErrno
|
||||
);
|
||||
|
||||
/**
|
||||
Shutdown the socket receive and transmit operations
|
||||
|
||||
The SocketShutdown routine stops the socket receive and transmit
|
||||
operations.
|
||||
This routine sets a flag to stop future transmissions and calls
|
||||
the network specific layer to cancel the pending receive operation.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
The ::shutdown routine calls this routine to stop receive and transmit
|
||||
operations on the socket.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] How Which operations to stop
|
||||
|
||||
@ -482,40 +486,18 @@ EFI_STATUS
|
||||
/**
|
||||
Initialize an endpoint for network communication.
|
||||
|
||||
The ::Socket routine initializes the communication endpoint by providing
|
||||
the support for the socket library function ::socket. The
|
||||
<a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html">POSIX</a>
|
||||
documentation for the socket routine is available online for reference.
|
||||
This routine initializes the communication endpoint.
|
||||
|
||||
The ::socket routine calls this routine indirectly to create
|
||||
the communication endpoint.
|
||||
|
||||
@param [in] pSocketProtocol Address of the socket protocol structure.
|
||||
|
||||
@param [in] domain Select the family of protocols for the client or server
|
||||
application.
|
||||
|
||||
@param [in] type Specifies how to make the network connection. The following values
|
||||
are supported:
|
||||
<ul>
|
||||
<li>
|
||||
SOCK_STREAM - Connect to TCP, provides a byte stream
|
||||
that is manipluated by read, recv, send and write.
|
||||
</li>
|
||||
<li>
|
||||
SOCK_SEQPACKET - Connect to TCP, provides sequenced packet stream
|
||||
that is manipulated by read, recv, send and write.
|
||||
</li>
|
||||
<li>
|
||||
SOCK_DGRAM - Connect to UDP, provides a datagram service that is
|
||||
manipulated by recvfrom and sendto.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@param [in] protocol Specifies the lower layer protocol to use. The following
|
||||
values are supported:
|
||||
<ul>
|
||||
<li>IPPROTO_TCP</li> - This value must be combined with SOCK_STREAM.</li>
|
||||
<li>IPPROTO_UDP</li> - This value must be combined with SOCK_DGRAM.</li>
|
||||
</ul>
|
||||
|
||||
application. See the ::socket documentation for values.
|
||||
@param [in] type Specifies how to make the network connection.
|
||||
See the ::socket documentation for values.
|
||||
@param [in] protocol Specifies the lower layer protocol to use.
|
||||
See the ::socket documentation for values.
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket successfully created
|
||||
@ -534,6 +516,50 @@ EFI_STATUS
|
||||
IN int * pErrno
|
||||
);
|
||||
|
||||
/**
|
||||
Send data using a network connection.
|
||||
|
||||
This routine calls the network specific layer to queue the data
|
||||
for transmission. Eventually the buffer will reach the head of
|
||||
the queue and will get transmitted over the network. For datagram
|
||||
sockets there is no guarantee that the data reaches the application
|
||||
running on the remote system.
|
||||
|
||||
The ::sendto routine calls this routine to send data to the remote
|
||||
system. Note that ::send and ::write are layered on top of ::sendto.
|
||||
|
||||
@param [in] pSocketProtocol Address of the ::EFI_SOCKET_PROTOCOL structure.
|
||||
|
||||
@param [in] Flags Message control flags
|
||||
|
||||
@param [in] BufferLength Length of the the buffer
|
||||
|
||||
@param [in] pBuffer Address of a buffer containing the data to send
|
||||
|
||||
@param [in] pDataLength Address to receive the number of data bytes sent
|
||||
|
||||
@param [in] pAddress Network address of the remote system address
|
||||
|
||||
@param [in] AddressLength Length of the remote network address structure
|
||||
|
||||
@param [out] pErrno Address to receive the errno value upon completion.
|
||||
|
||||
@retval EFI_SUCCESS - Socket data successfully queued for transmit
|
||||
|
||||
**/
|
||||
typedef
|
||||
EFI_STATUS
|
||||
(* PFN_TRANSMIT) (
|
||||
IN EFI_SOCKET_PROTOCOL * pSocketProtocol,
|
||||
IN int Flags,
|
||||
IN size_t BufferLength,
|
||||
IN CONST UINT8 * pBuffer,
|
||||
OUT size_t * pDataLength,
|
||||
IN const struct sockaddr * pAddress,
|
||||
IN socklen_t AddressLength,
|
||||
IN int * pErrno
|
||||
);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Socket Protocol
|
||||
//------------------------------------------------------------------------------
|
||||
@ -551,13 +577,13 @@ typedef struct _EFI_SOCKET_PROTOCOL {
|
||||
PFN_GET_LOCAL pfnGetLocal; ///< Get local address
|
||||
PFN_GET_PEER pfnGetPeer; ///< Get peer address
|
||||
PFN_LISTEN pfnListen; ///< Enable connection attempts on known port
|
||||
PFN_POLL pfnPoll; ///< Poll for socket activity
|
||||
PFN_OPTION_GET pfnOptionGet; ///< Get socket options
|
||||
PFN_OPTION_SET pfnOptionSet; ///< Set socket options
|
||||
PFN_POLL pfnPoll; ///< Poll for socket activity
|
||||
PFN_RECEIVE pfnReceive; ///< Receive data from a socket
|
||||
PFN_SEND pfnSend; ///< Transmit data using the socket
|
||||
PFN_SHUTDOWN pfnShutdown; ///< Shutdown receive and transmit operations
|
||||
PFN_SOCKET pfnSocket; ///< Initialize the socket
|
||||
PFN_TRANSMIT pfnTransmit; ///< Transmit data using the socket
|
||||
} GCC_EFI_SOCKET_PROTOCOL;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -565,9 +591,7 @@ typedef struct _EFI_SOCKET_PROTOCOL {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
Non blocking version of accept.
|
||||
|
||||
See ::accept
|
||||
Non blocking version of ::accept.
|
||||
|
||||
@param [in] s Socket file descriptor returned from ::socket.
|
||||
|
||||
@ -578,7 +602,7 @@ typedef struct _EFI_SOCKET_PROTOCOL {
|
||||
contains the length of the remote network address.
|
||||
|
||||
@return This routine returns zero if successful and -1 when an error occurs.
|
||||
In the case of an error, errno contains more details.
|
||||
In the case of an error, ::errno contains more details.
|
||||
|
||||
**/
|
||||
int
|
||||
@ -589,12 +613,12 @@ AcceptNB (
|
||||
);
|
||||
|
||||
/**
|
||||
Connect to the socket driver
|
||||
Connect to the EFI socket library
|
||||
|
||||
@param [in] ppSocketProtocol Address to receive the socket protocol address
|
||||
|
||||
@retval 0 Successfully returned the socket protocol
|
||||
@retval other Value for errno
|
||||
@return Value for ::errno, zero (0) indicates success.
|
||||
|
||||
**/
|
||||
int
|
||||
EslServiceGetProtocol (
|
||||
|
@ -17,7 +17,7 @@
|
||||
/**
|
||||
EFI Component Name Protocol declaration
|
||||
**/
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL mComponentName = {
|
||||
GetDriverName,
|
||||
GetControllerName,
|
||||
"eng"
|
||||
@ -26,7 +26,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
|
||||
/**
|
||||
EFI Component Name 2 Protocol declaration
|
||||
**/
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL mComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) GetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) GetControllerName,
|
||||
"en"
|
||||
@ -91,7 +91,7 @@ GetDriverName (
|
||||
pThis->SupportedLanguages,
|
||||
mDriverNameTable,
|
||||
ppDriverName,
|
||||
(BOOLEAN)(pThis == &gComponentName)
|
||||
(BOOLEAN)(pThis == &mComponentName)
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
@ -10,6 +10,31 @@
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
\section NetworkAdapterManagement Network Adapter Management
|
||||
Network adapters may come and go over the life if a system running
|
||||
UEFI. The SocketDxe driver uses the driver binding API to manage
|
||||
the connections to network adapters.
|
||||
|
||||
The ::DriverSupported routine selects network adapters that the
|
||||
socket layer is not using. This determination by the lack of the
|
||||
tag GUID associated with the network protocol in the
|
||||
::cEslSocketBinding array. The selected network adapters are
|
||||
passed to the ::DriverStart routine.
|
||||
|
||||
The ::DriverStart routine calls the ::EslServiceConnect routine
|
||||
to create an ::ESL_SERVICE structure to manage the network adapter
|
||||
for the socket layer. EslServiceConnect also installs the tag
|
||||
GUID on the network adapter to prevent future calls from
|
||||
::DriverSupported. EslService also calls the network specific
|
||||
initialization routine listed in ESL_SOCKET_BINDING::pfnInitialize
|
||||
field of the ::cEslSocketBinding entry.
|
||||
|
||||
The ::DriverStop routine calls the ::EslServiceDisconnect routine
|
||||
to undo the work done by ::DriverStart. The socket layer must break
|
||||
the active network connections, then remove the tag GUIDs from the
|
||||
controller handle and free ::ESL_SERVICE structure.
|
||||
|
||||
**/
|
||||
|
||||
#include "Socket.h"
|
||||
@ -17,10 +42,17 @@
|
||||
/**
|
||||
Verify the controller type
|
||||
|
||||
Determine if any of the network service binding protocols exist on
|
||||
the controller handle. If so, verify that these protocols are not
|
||||
already in use. Call ::DriverStart for any network service binding
|
||||
protocol that is not in use.
|
||||
This routine walks the cEslSocketBinding array to determines if
|
||||
the controller is a network adapter by supporting any of the
|
||||
network protocols required by the sockets layer. If so, the
|
||||
routine verifies that the socket layer is not already using the
|
||||
support by looking for the tag GUID listed in the corresponding
|
||||
array entry. The controller handle is passed to the ::DriverStart
|
||||
routine if sockets can use the network adapter.
|
||||
See the \ref NetworkAdapterManagement section.
|
||||
|
||||
This routine is called by the UEFI driver framework during connect
|
||||
processing.
|
||||
|
||||
@param [in] pThis Protocol instance pointer.
|
||||
@param [in] Controller Handle of device to test.
|
||||
@ -38,9 +70,9 @@ DriverSupported (
|
||||
IN EFI_DEVICE_PATH_PROTOCOL * pRemainingDevicePath
|
||||
)
|
||||
{
|
||||
CONST DT_SOCKET_BINDING * pEnd;
|
||||
CONST ESL_SOCKET_BINDING * pEnd;
|
||||
VOID * pInterface;
|
||||
CONST DT_SOCKET_BINDING * pSocketBinding;
|
||||
CONST ESL_SOCKET_BINDING * pSocketBinding;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
@ -104,11 +136,14 @@ DriverSupported (
|
||||
|
||||
|
||||
/**
|
||||
Connect to the network service bindings
|
||||
Connect to a network adapter
|
||||
|
||||
Walk the network service protocols on the controller handle and
|
||||
locate any that are not in use. Create service structures to
|
||||
manage the service binding for the socket driver.
|
||||
This routine calls ::EslServiceConnect to connect the socket
|
||||
layer to the network adapters. See the \ref NetworkAdapterManagement
|
||||
section.
|
||||
|
||||
This routine is called by the UEFI driver framework during connect
|
||||
processing if the controller passes the tests in ::DriverSupported.
|
||||
|
||||
@param [in] pThis Protocol instance pointer.
|
||||
@param [in] Controller Handle of device to work with.
|
||||
@ -145,8 +180,16 @@ DriverStart (
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and
|
||||
closing the DevicePath and PciIo protocols on Controller.
|
||||
Disconnect from a network adapter
|
||||
|
||||
This routine calls ::EslServiceDisconnect to disconnect the socket
|
||||
layer from the network adapters. See the \ref NetworkAdapterManagement
|
||||
section.
|
||||
|
||||
This routine is called by ::DriverUnload when the socket layer
|
||||
is being unloaded. This routine should also called by the UEFI
|
||||
driver framework when a network adapter is being unloaded from
|
||||
the system.
|
||||
|
||||
@param [in] pThis Protocol instance pointer.
|
||||
@param [in] Controller Handle of device to stop driver on.
|
||||
@ -186,9 +229,9 @@ DriverStop (
|
||||
|
||||
|
||||
/**
|
||||
Driver binding protocol definition
|
||||
Driver binding protocol for the SocketDxe driver.
|
||||
**/
|
||||
EFI_DRIVER_BINDING_PROTOCOL gDriverBinding = {
|
||||
EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
|
||||
DriverSupported,
|
||||
DriverStart,
|
||||
DriverStop,
|
||||
|
@ -15,14 +15,31 @@
|
||||
#include "Socket.h"
|
||||
|
||||
|
||||
CONST EFI_GUID mEslRawServiceGuid = {
|
||||
0xf9f5d280, 0x8a4b, 0x48e2, { 0x96, 0x28, 0xda, 0xfa, 0xa7, 0x70, 0x54, 0x5d }
|
||||
/**
|
||||
The following GUID values are only used by the SocketDxe driver. An
|
||||
alternative set of values exists in EfiSocketLib\UseEfiSocketLib.c
|
||||
which an application uses when it links against EfiSocketLib. These
|
||||
two sets of values allow the SocketDxe driver to coexist with socket
|
||||
applications.
|
||||
|
||||
Tag GUID - IPv4 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslIp4ServiceGuid = {
|
||||
0x4e3a82e6, 0xe43f, 0x460a, { 0x86, 0x6e, 0x9b, 0x5a, 0xab, 0x80, 0x44, 0x48 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - TCPv4 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslTcp4ServiceGuid = {
|
||||
0x4dcaab0a, 0x1990, 0x4352, { 0x8d, 0x2f, 0x2d, 0x8f, 0x13, 0x55, 0x98, 0xa5 }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Tag GUID - UDPv4 in use by SocketDxe
|
||||
**/
|
||||
CONST EFI_GUID mEslUdp4ServiceGuid = {
|
||||
0x43a110ce, 0x9ccd, 0x402b, { 0x8c, 0x29, 0x4a, 0x6d, 0x8a, 0xf7, 0x79, 0x90 }
|
||||
};
|
||||
@ -98,7 +115,7 @@ DriverUnload (
|
||||
//
|
||||
Max = BufferSize / sizeof ( pHandle[ 0 ]);
|
||||
for ( Index = 0; Max > Index; Index++ ) {
|
||||
Status = DriverStop ( &gDriverBinding,
|
||||
Status = DriverStop ( &mDriverBinding,
|
||||
pHandle[ Index ],
|
||||
0,
|
||||
NULL );
|
||||
@ -131,7 +148,7 @@ DriverUnload (
|
||||
// Done with the socket layer
|
||||
//
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = EslServiceUninstall ( ImageHandle );
|
||||
Status = EslDxeUninstall ( ImageHandle );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
//
|
||||
// Remove the protocols installed by the EntryPoint routine.
|
||||
@ -139,11 +156,11 @@ DriverUnload (
|
||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
&gDriverBinding,
|
||||
&mDriverBinding,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
&gComponentName,
|
||||
&mComponentName,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
&gComponentName2,
|
||||
&mComponentName2,
|
||||
NULL
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
@ -225,10 +242,10 @@ EntryPoint (
|
||||
Status = EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
pSystemTable,
|
||||
&gDriverBinding,
|
||||
&mDriverBinding,
|
||||
ImageHandle,
|
||||
&gComponentName,
|
||||
&gComponentName2
|
||||
&mComponentName,
|
||||
&mComponentName2
|
||||
);
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
|
||||
@ -250,7 +267,7 @@ EntryPoint (
|
||||
// Make the socket serivces available to other drivers
|
||||
// and applications
|
||||
//
|
||||
Status = EslServiceInstall ( &ImageHandle );
|
||||
Status = EslDxeInstall ( &ImageHandle );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
//
|
||||
// Disconnect from the network
|
||||
@ -263,11 +280,11 @@ EntryPoint (
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
ImageHandle,
|
||||
&gEfiDriverBindingProtocolGuid,
|
||||
&gDriverBinding,
|
||||
&mDriverBinding,
|
||||
&gEfiComponentNameProtocolGuid,
|
||||
&gComponentName,
|
||||
&mComponentName,
|
||||
&gEfiComponentName2ProtocolGuid,
|
||||
&gComponentName2,
|
||||
&mComponentName2,
|
||||
NULL
|
||||
);
|
||||
DEBUG (( DEBUG_POOL | DEBUG_INIT | DEBUG_INFO,
|
||||
@ -292,5 +309,19 @@ EntryPoint (
|
||||
}
|
||||
|
||||
|
||||
PFN_ESL_xSTRUCTOR mpfnEslConstructor = NULL;
|
||||
PFN_ESL_xSTRUCTOR mpfnEslDestructor = NULL;
|
||||
/**
|
||||
Socket layer's service binding protocol delcaration.
|
||||
**/
|
||||
CONST EFI_SERVICE_BINDING_PROTOCOL mEfiServiceBinding = {
|
||||
EslDxeCreateChild,
|
||||
EslDxeDestroyChild
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
The following entries disable the constructor and destructor
|
||||
for the SocketDxe driver. Note that socket applications linking
|
||||
against EfiSocketLib use different redirection.
|
||||
**/
|
||||
PFN_ESL_xSTRUCTOR mpfnEslConstructor = NULL; ///< No EfiSocketLib constructor needed for SocketDxe
|
||||
PFN_ESL_xSTRUCTOR mpfnEslDestructor = NULL; ///< No EfiSocketLib destructor needed for SocketDxe
|
||||
|
@ -23,9 +23,9 @@
|
||||
// Protocol Declarations
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL gDriverBinding; ///< Driver binding protocol declaration
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL mComponentName; ///< Component name protocol declaration
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL mComponentName2; ///< Component name 2 protocol declaration
|
||||
extern EFI_DRIVER_BINDING_PROTOCOL mDriverBinding; ///< Driver binding protocol declaration
|
||||
extern EFI_SERVICE_BINDING_PROTOCOL mServiceBinding; ///< Service binding protocol delcaration
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -23,12 +23,26 @@
|
||||
|
||||
|
||||
/**
|
||||
Connect to the socket driver
|
||||
Connect to the EFI socket library
|
||||
|
||||
@param [in] ppSocketProtocol Address to receive the socket protocol address
|
||||
This routine establishes a connection to the socket driver
|
||||
and returns the API (::EFI_SOCKET_PROTOCOL address) to the
|
||||
socket file system layer in BsdSocketLib. This routine looks for
|
||||
the gEfiSocketServiceBindingProtocolGuid to locate the socket
|
||||
driver. This routine then creates a child handle and locates
|
||||
the gEfiSocketProtocolGuid protocol on that handle to get the
|
||||
::EFI_SOCKET_PROTOCOL structure address.
|
||||
|
||||
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 UseSocketDxe.
|
||||
|
||||
@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 (
|
||||
@ -148,7 +162,7 @@ EslServiceGetProtocol (
|
||||
}
|
||||
else {
|
||||
DEBUG (( DEBUG_ERROR,
|
||||
"ERROR - No socket service binding protocol, Status: %r\r\n",
|
||||
"ERROR - Socket driver not loaded, Status: %r\r\n",
|
||||
Status ));
|
||||
RetVal = ENODEV;
|
||||
}
|
||||
|
Reference in New Issue
Block a user