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:
@ -1259,7 +1259,10 @@ EslSocketBind (
|
||||
//
|
||||
// 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 ) {
|
||||
DEBUG (( DEBUG_BIND | DEBUG_POOL | DEBUG_INIT,
|
||||
"ERROR - Socket address is not available!\r\n" ));
|
||||
@ -1993,70 +1996,60 @@ EslSocketGetLocalAddress (
|
||||
//
|
||||
// Verify the socket state
|
||||
//
|
||||
Status = EslSocketIsConfigured ( pSocket );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
EslSocketIsConfigured ( pSocket );
|
||||
if ( pSocket->bAddressSet ) {
|
||||
//
|
||||
// Verify the address buffer and length address
|
||||
//
|
||||
if (( NULL != pAddress ) && ( NULL != pAddressLength )) {
|
||||
//
|
||||
// Verify the socket state
|
||||
// Verify the API
|
||||
//
|
||||
if (( SOCKET_STATE_CONNECTED == pSocket->State )
|
||||
|| ( SOCKET_STATE_LISTENING == pSocket->State )) {
|
||||
//
|
||||
// Verify the API
|
||||
//
|
||||
if ( NULL == pSocket->pApi->pfnLocalAddrGet ) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
pSocket->errno = ENOTSUP;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Synchronize with the socket layer
|
||||
//
|
||||
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
|
||||
|
||||
//
|
||||
// Verify that there is just a single connection
|
||||
//
|
||||
pPort = pSocket->pPortList;
|
||||
if (( NULL != pPort ) && ( NULL == pPort->pLinkSocket )) {
|
||||
//
|
||||
// Verify the address length
|
||||
//
|
||||
LengthInBytes = pSocket->pApi->AddressLength;
|
||||
if (( LengthInBytes <= *pAddressLength )
|
||||
&& ( 255 >= LengthInBytes )) {
|
||||
//
|
||||
// Return the local address and address length
|
||||
//
|
||||
ZeroMem ( pAddress, LengthInBytes );
|
||||
pAddress->sa_len = (uint8_t)LengthInBytes;
|
||||
*pAddressLength = pAddress->sa_len;
|
||||
pSocket->pApi->pfnLocalAddrGet ( pPort, pAddress );
|
||||
pSocket->errno = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
pSocket->errno = EINVAL;
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pSocket->errno = ENOTCONN;
|
||||
Status = EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Release the socket layer synchronization
|
||||
//
|
||||
RESTORE_TPL ( TplPrevious );
|
||||
}
|
||||
if ( NULL == pSocket->pApi->pfnLocalAddrGet ) {
|
||||
Status = EFI_UNSUPPORTED;
|
||||
pSocket->errno = ENOTSUP;
|
||||
}
|
||||
else {
|
||||
pSocket->errno = ENOTCONN;
|
||||
Status = EFI_NOT_STARTED;
|
||||
//
|
||||
// Synchronize with the socket layer
|
||||
//
|
||||
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
|
||||
|
||||
//
|
||||
// Verify that there is just a single connection
|
||||
//
|
||||
pPort = pSocket->pPortList;
|
||||
if ( NULL != pPort ) {
|
||||
//
|
||||
// Verify the address length
|
||||
//
|
||||
LengthInBytes = pSocket->pApi->AddressLength;
|
||||
if (( LengthInBytes <= *pAddressLength )
|
||||
&& ( 255 >= LengthInBytes )) {
|
||||
//
|
||||
// Return the local address and address length
|
||||
//
|
||||
ZeroMem ( pAddress, LengthInBytes );
|
||||
pAddress->sa_len = (uint8_t)LengthInBytes;
|
||||
*pAddressLength = pAddress->sa_len;
|
||||
pSocket->pApi->pfnLocalAddrGet ( pPort, pAddress );
|
||||
pSocket->errno = 0;
|
||||
Status = EFI_SUCCESS;
|
||||
}
|
||||
else {
|
||||
pSocket->errno = EINVAL;
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
pSocket->errno = ENOTCONN;
|
||||
Status = EFI_NOT_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Release the socket layer synchronization
|
||||
//
|
||||
RESTORE_TPL ( TplPrevious );
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -2064,6 +2057,13 @@ EslSocketGetLocalAddress (
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Address not set
|
||||
//
|
||||
Status = EFI_NOT_STARTED;
|
||||
pSocket->errno = EADDRNOTAVAIL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -2808,6 +2808,14 @@ EslSocketOptionGet (
|
||||
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
||||
break;
|
||||
|
||||
case SO_REUSEADDR:
|
||||
//
|
||||
// Return the address reuse flag
|
||||
//
|
||||
pOptionData = (UINT8 *)&pSocket->bReUseAddr;
|
||||
LengthInBytes = sizeof ( pSocket->bReUseAddr );
|
||||
break;
|
||||
|
||||
case SO_SNDBUF:
|
||||
//
|
||||
// Return the maximum transmit buffer size
|
||||
@ -3032,6 +3040,14 @@ EslSocketOptionSet (
|
||||
LengthInBytes = sizeof ( pSocket->MaxRxBuf );
|
||||
break;
|
||||
|
||||
case SO_REUSEADDR:
|
||||
//
|
||||
// Return the address reuse flag
|
||||
//
|
||||
pOptionData = (UINT8 *)&pSocket->bReUseAddr;
|
||||
LengthInBytes = sizeof ( pSocket->bReUseAddr );
|
||||
break;
|
||||
|
||||
case SO_SNDBUF:
|
||||
//
|
||||
// Send buffer size
|
||||
|
Reference in New Issue
Block a user