Fix issues detected by python web-server.
* Removed display of TPL * Added NOP implementation for SO_REUSEADDR * Add better detection of socket address * Return first address Signed-off-by: lpleahy Python Web server below: --------------- import sys import BaseHTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler HandlerClass = SimpleHTTPRequestHandler ServerClass = BaseHTTPServer.HTTPServer Protocol = "HTTP/1.0" port = 80 server_address = ('', port) HandlerClass.protocol_version = Protocol httpd = ServerClass(server_address, HandlerClass) sa = httpd.socket.getsockname() print "Serving HTTP on", sa[0], "port", sa[1], "..." httpd.serve_forever() git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13034 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
287b4d32ee
commit
f74dc4bbba
@ -619,6 +619,7 @@ EslIp4RemoteAddressSet (
|
|||||||
pIp4->DestinationAddress.Addr[1] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 8 );
|
pIp4->DestinationAddress.Addr[1] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 8 );
|
||||||
pIp4->DestinationAddress.Addr[2] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 16 );
|
pIp4->DestinationAddress.Addr[2] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 16 );
|
||||||
pIp4->DestinationAddress.Addr[3] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 24 );
|
pIp4->DestinationAddress.Addr[3] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 24 );
|
||||||
|
pPort->pSocket->bAddressSet = TRUE;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1259,7 +1259,10 @@ EslSocketBind (
|
|||||||
//
|
//
|
||||||
// Verify that at least one network connection was found
|
// Verify that at least one network connection was found
|
||||||
//
|
//
|
||||||
if ( NULL == pSocket->pPortList ) {
|
if ( NULL != pSocket->pPortList ) {
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
else {
|
||||||
if ( EADDRNOTAVAIL == pSocket->errno ) {
|
if ( EADDRNOTAVAIL == pSocket->errno ) {
|
||||||
DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
|
DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
|
||||||
"ERROR - Socket address is not available!\r\n" ));
|
"ERROR - Socket address is not available!\r\n" ));
|
||||||
@ -1993,17 +1996,12 @@ EslSocketGetLocalAddress (
|
|||||||
//
|
//
|
||||||
// Verify the socket state
|
// Verify the socket state
|
||||||
//
|
//
|
||||||
Status = EslSocketIsConfigured ( pSocket );
|
EslSocketIsConfigured ( pSocket );
|
||||||
if ( !EFI_ERROR ( Status )) {
|
if ( pSocket->bAddressSet ) {
|
||||||
//
|
//
|
||||||
// Verify the address buffer and length address
|
// Verify the address buffer and length address
|
||||||
//
|
//
|
||||||
if (( NULL != pAddress ) && ( NULL != pAddressLength )) {
|
if (( NULL != pAddress ) && ( NULL != pAddressLength )) {
|
||||||
//
|
|
||||||
// Verify the socket state
|
|
||||||
//
|
|
||||||
if (( SOCKET_STATE_CONNECTED == pSocket->State )
|
|
||||||
|| ( SOCKET_STATE_LISTENING == pSocket->State )) {
|
|
||||||
//
|
//
|
||||||
// Verify the API
|
// Verify the API
|
||||||
//
|
//
|
||||||
@ -2021,7 +2019,7 @@ EslSocketGetLocalAddress (
|
|||||||
// Verify that there is just a single connection
|
// Verify that there is just a single connection
|
||||||
//
|
//
|
||||||
pPort = pSocket->pPortList;
|
pPort = pSocket->pPortList;
|
||||||
if (( NULL != pPort ) && ( NULL == pPort->pLinkSocket )) {
|
if ( NULL != pPort ) {
|
||||||
//
|
//
|
||||||
// Verify the address length
|
// Verify the address length
|
||||||
//
|
//
|
||||||
@ -2054,16 +2052,18 @@ EslSocketGetLocalAddress (
|
|||||||
RESTORE_TPL ( TplPrevious );
|
RESTORE_TPL ( TplPrevious );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
pSocket->errno = ENOTCONN;
|
|
||||||
Status = EFI_NOT_STARTED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
pSocket->errno = EINVAL;
|
pSocket->errno = EINVAL;
|
||||||
Status = EFI_INVALID_PARAMETER;
|
Status = EFI_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Address not set
|
||||||
|
//
|
||||||
|
Status = EFI_NOT_STARTED;
|
||||||
|
pSocket->errno = EADDRNOTAVAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -2808,6 +2808,14 @@ EslSocketOptionGet (
|
|||||||
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SO_REUSEADDR:
|
||||||
|
//
|
||||||
|
// Return the address reuse flag
|
||||||
|
//
|
||||||
|
pOptionData = (UINT8 *)&pSocket->bReUseAddr;
|
||||||
|
LengthInBytes = sizeof ( pSocket->bReUseAddr );
|
||||||
|
break;
|
||||||
|
|
||||||
case SO_SNDBUF:
|
case SO_SNDBUF:
|
||||||
//
|
//
|
||||||
// Return the maximum transmit buffer size
|
// Return the maximum transmit buffer size
|
||||||
@ -3032,6 +3040,14 @@ EslSocketOptionSet (
|
|||||||
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SO_REUSEADDR:
|
||||||
|
//
|
||||||
|
// Return the address reuse flag
|
||||||
|
//
|
||||||
|
pOptionData = (UINT8 *)&pSocket->bReUseAddr;
|
||||||
|
LengthInBytes = sizeof ( pSocket->bReUseAddr );
|
||||||
|
break;
|
||||||
|
|
||||||
case SO_SNDBUF:
|
case SO_SNDBUF:
|
||||||
//
|
//
|
||||||
// Send buffer size
|
// Send buffer size
|
||||||
|
@ -989,9 +989,10 @@ typedef struct _ESL_SOCKET {
|
|||||||
//
|
//
|
||||||
// Socket options
|
// Socket options
|
||||||
//
|
//
|
||||||
|
BOOLEAN bIncludeHeader; ///< TRUE if including the IP header
|
||||||
BOOLEAN bListenCalled; ///< TRUE if listen was successfully called
|
BOOLEAN bListenCalled; ///< TRUE if listen was successfully called
|
||||||
BOOLEAN bOobInLine; ///< TRUE if out-of-band messages are to be received inline with normal data
|
BOOLEAN bOobInLine; ///< TRUE if out-of-band messages are to be received inline with normal data
|
||||||
BOOLEAN bIncludeHeader; ///< TRUE if including the IP header
|
BOOLEAN bReUseAddr; ///< TRUE if using same address is allowed
|
||||||
|
|
||||||
//
|
//
|
||||||
// Socket data
|
// Socket data
|
||||||
@ -999,6 +1000,7 @@ typedef struct _ESL_SOCKET {
|
|||||||
int Domain; ///< Specifies family of protocols
|
int Domain; ///< Specifies family of protocols
|
||||||
int Type; ///< Specifies how to make network connection
|
int Type; ///< Specifies how to make network connection
|
||||||
int Protocol; ///< Specifies lower layer protocol to use
|
int Protocol; ///< Specifies lower layer protocol to use
|
||||||
|
BOOLEAN bAddressSet; ///< Set when the address is specified
|
||||||
BOOLEAN bConfigured; ///< Set after the socket is configured
|
BOOLEAN bConfigured; ///< Set after the socket is configured
|
||||||
|
|
||||||
BOOLEAN bRxDisable; ///< Receive disabled via shutdown
|
BOOLEAN bRxDisable; ///< Receive disabled via shutdown
|
||||||
|
@ -1171,6 +1171,7 @@ EslTcp4LocalAddressSet (
|
|||||||
// Set the port number
|
// Set the port number
|
||||||
//
|
//
|
||||||
pAccessPoint->StationPort = SwapBytes16 ( pIpAddress->sin_port );
|
pAccessPoint->StationPort = SwapBytes16 ( pIpAddress->sin_port );
|
||||||
|
pPort->pSocket->bAddressSet = TRUE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display the local address
|
// Display the local address
|
||||||
|
@ -1210,6 +1210,7 @@ EslTcp6LocalAddressSet (
|
|||||||
// Set the port number
|
// Set the port number
|
||||||
//
|
//
|
||||||
pAccessPoint->StationPort = SwapBytes16 ( pIpAddress->sin6_port );
|
pAccessPoint->StationPort = SwapBytes16 ( pIpAddress->sin6_port );
|
||||||
|
pPort->pSocket->bAddressSet = TRUE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display the local address
|
// Display the local address
|
||||||
|
@ -463,6 +463,7 @@ EslUdp4RemoteAddressSet (
|
|||||||
pUdp4->ConfigData.RemoteAddress.Addr[2] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 16 );
|
pUdp4->ConfigData.RemoteAddress.Addr[2] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 16 );
|
||||||
pUdp4->ConfigData.RemoteAddress.Addr[3] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 24 );
|
pUdp4->ConfigData.RemoteAddress.Addr[3] = (UINT8)( pRemoteAddress->sin_addr.s_addr >> 24 );
|
||||||
pUdp4->ConfigData.RemotePort = SwapBytes16 ( pRemoteAddress->sin_port );
|
pUdp4->ConfigData.RemotePort = SwapBytes16 ( pRemoteAddress->sin_port );
|
||||||
|
pPort->pSocket->bAddressSet = TRUE;
|
||||||
Status = EFI_SUCCESS;
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -113,6 +113,7 @@ EslUdp6LocalAddressSet (
|
|||||||
// Set the port number
|
// Set the port number
|
||||||
//
|
//
|
||||||
pConfig->StationPort = SwapBytes16 ( pIpAddress->sin6_port );
|
pConfig->StationPort = SwapBytes16 ( pIpAddress->sin6_port );
|
||||||
|
pPort->pSocket->bAddressSet = TRUE;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display the local address
|
// Display the local address
|
||||||
|
@ -115,18 +115,12 @@
|
|||||||
**/
|
**/
|
||||||
#define RAISE_TPL(PreviousTpl, tpl) \
|
#define RAISE_TPL(PreviousTpl, tpl) \
|
||||||
VERIFY_TPL ( tpl ); \
|
VERIFY_TPL ( tpl ); \
|
||||||
PreviousTpl = gBS->RaiseTPL ( tpl ); \
|
PreviousTpl = gBS->RaiseTPL ( tpl );
|
||||||
DEBUG (( DEBUG_TPL | DEBUG_TPL, \
|
|
||||||
"%d: TPL\r\n", \
|
|
||||||
tpl ))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Restore the TPL to the previous value
|
Restore the TPL to the previous value
|
||||||
**/
|
**/
|
||||||
#define RESTORE_TPL(tpl) \
|
#define RESTORE_TPL(tpl) \
|
||||||
DEBUG (( DEBUG_TPL | DEBUG_TPL, \
|
|
||||||
"%d: TPL\r\n", \
|
|
||||||
tpl )); \
|
|
||||||
gBS->RestoreTPL ( tpl )
|
gBS->RestoreTPL ( tpl )
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user