Merged socket development branch:
* Add TCPv6 support to DataSink * Add TCPv6 support to DataSource * Add GetAddrInfo test application * Add GetNameInfo test application * Fixed copyright date * Completed TFTP server - now downloads files from local directory * Added ports and exit pages to web server * Made PCD values package specific Signed-off-by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13003 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -401,8 +401,8 @@ HttpPageTrailer (
|
||||
int RetVal;
|
||||
EFI_STATUS Status;
|
||||
socklen_t LengthInBytes;
|
||||
struct sockaddr_in LocalAddress;
|
||||
struct sockaddr_in RemoteAddress;
|
||||
struct sockaddr_in6 LocalAddress;
|
||||
struct sockaddr_in6 RemoteAddress;
|
||||
|
||||
DBG_ENTER ( );
|
||||
|
||||
@ -413,12 +413,13 @@ HttpPageTrailer (
|
||||
LengthInBytes = sizeof ( LocalAddress );
|
||||
RetVal = getsockname ( SocketFD, (struct sockaddr *)&LocalAddress, &LengthInBytes );
|
||||
if ( 0 == RetVal ) {
|
||||
LengthInBytes = sizeof ( LocalAddress );
|
||||
RetVal = getpeername ( SocketFD, (struct sockaddr *)&RemoteAddress, &LengthInBytes );
|
||||
if ( 0 == RetVal ) {
|
||||
//
|
||||
// Seperate the body from the trailer
|
||||
//
|
||||
Status = HttpSendAnsiString ( SocketFD, pPort, " <hr>\r\n" );
|
||||
Status = HttpSendAnsiString ( SocketFD, pPort, " <hr>\r\n<code>" );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
@ -438,7 +439,7 @@ HttpPageTrailer (
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendAnsiString ( SocketFD, pPort, "\r\n" );
|
||||
Status = HttpSendAnsiString ( SocketFD, pPort, "</code>\r\n" );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
@ -1213,7 +1214,7 @@ HttpSendHexBits (
|
||||
//
|
||||
Digit = (UINT32)(( Value >> Shift ) & 0xf );
|
||||
if ( 10 <= Digit ) {
|
||||
Digit += 'A' - '0' - 10;
|
||||
Digit += 'a' - '0' - 10;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1274,7 +1275,7 @@ HttpSendHexValue (
|
||||
//
|
||||
Digit = (UINT32)(( Value >> Shift ) & 0xf );
|
||||
if ( 10 <= Digit ) {
|
||||
Digit += 'A' - '0' - 10;
|
||||
Digit += 'a' - '0' - 10;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1305,6 +1306,112 @@ HttpSendHexValue (
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Output an IP6 address value to the HTML page
|
||||
|
||||
@param [in] SocketFD Socket file descriptor
|
||||
@param [in] pPort The WSDT_PORT structure address
|
||||
@param [in] Value Value to display
|
||||
@param [in] bFirstValue TRUE if first value
|
||||
@param [in] bLastValue TRUE if last value
|
||||
@param [in] bZeroSuppression TRUE while zeros are being suppressed
|
||||
@param [in] pbZeroSuppression Address to receive TRUE when zero suppression
|
||||
has started, use NULL if next colon value not
|
||||
needed.
|
||||
|
||||
@retval EFI_SUCCESS Successfully displayed the address
|
||||
**/
|
||||
EFI_STATUS
|
||||
HttpSendIp6Value (
|
||||
IN int SocketFD,
|
||||
IN WSDT_PORT * pPort,
|
||||
IN UINT16 Value,
|
||||
IN BOOLEAN bFirstValue,
|
||||
IN BOOLEAN bLastValue,
|
||||
IN BOOLEAN bZeroSuppression,
|
||||
IN BOOLEAN * pbZeroSuppression
|
||||
)
|
||||
{
|
||||
BOOLEAN bZeroSuppressionStarting;
|
||||
UINT32 Digit;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Use break instead of goto
|
||||
//
|
||||
bZeroSuppressionStarting = FALSE;
|
||||
Status = EFI_SUCCESS;
|
||||
for ( ; ; ) {
|
||||
//
|
||||
// Display the leading colon if necessary
|
||||
//
|
||||
if ( bZeroSuppression && ( bLastValue || ( 0 != Value ))) {
|
||||
Status = HttpSendByte ( SocketFD, pPort, ':' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Skip over a series of zero values
|
||||
//
|
||||
bZeroSuppressionStarting = (BOOLEAN)( 0 == Value );
|
||||
if ( !bZeroSuppressionStarting ) {
|
||||
//
|
||||
// Display the value
|
||||
//
|
||||
Digit = ( Value >> 4 ) & 0xf;
|
||||
Status = HttpSendHexValue ( SocketFD,
|
||||
pPort,
|
||||
Digit );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Digit = Value & 0xf;
|
||||
Status = HttpSendHexValue ( SocketFD,
|
||||
pPort,
|
||||
Digit );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Digit = ( Value >> 12 ) & 0xf;
|
||||
Status = HttpSendHexValue ( SocketFD,
|
||||
pPort,
|
||||
Digit );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Digit = ( Value >> 8 ) & 0xf;
|
||||
Status = HttpSendHexValue ( SocketFD,
|
||||
pPort,
|
||||
Digit );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Display the trailing colon if necessary
|
||||
//
|
||||
if (( !bLastValue ) && ( bFirstValue || ( 0 != Value ))) {
|
||||
Status = HttpSendByte ( SocketFD, pPort, ':' );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the next colon display
|
||||
if ( NULL != pbZeroSuppression ) {
|
||||
*pbZeroSuppression = bZeroSuppressionStarting;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the operation status
|
||||
//
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Output an IP address to the HTML page
|
||||
|
||||
@ -1318,41 +1425,109 @@ EFI_STATUS
|
||||
HttpSendIpAddress (
|
||||
IN int SocketFD,
|
||||
IN WSDT_PORT * pPort,
|
||||
IN struct sockaddr_in * pAddress
|
||||
IN struct sockaddr_in6 * pAddress
|
||||
)
|
||||
{
|
||||
BOOLEAN bZeroSuppression;
|
||||
UINT32 Index;
|
||||
struct sockaddr_in * pIpv4;
|
||||
struct sockaddr_in6 * pIpv6;
|
||||
UINT16 PortNumber;
|
||||
EFI_STATUS Status;
|
||||
|
||||
//
|
||||
// Output the IPv4 address
|
||||
// Use break instead of goto
|
||||
//
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)pAddress->sin_addr.s_addr );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pAddress->sin_addr.s_addr >> 8 ));
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pAddress->sin_addr.s_addr >> 16 ));
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pAddress->sin_addr.s_addr >> 24 ));
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
//
|
||||
// Output the port number
|
||||
//
|
||||
Status = HttpSendByte ( SocketFD, pPort, ':' );
|
||||
if ( !EFI_ERROR ( Status )) {
|
||||
Status = HttpSendValue ( SocketFD, pPort, htons ( pAddress->sin_port ));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( ; ; ) {
|
||||
//
|
||||
// Determine the type of address
|
||||
//
|
||||
if ( AF_INET6 == pAddress->sin6_family ) {
|
||||
pIpv6 = pAddress;
|
||||
|
||||
//
|
||||
// Display the address in RFC2732 format
|
||||
//
|
||||
bZeroSuppression = FALSE;
|
||||
Status = HttpSendByte ( SocketFD, pPort, '[' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
for ( Index = 0; 8 > Index; Index++ ) {
|
||||
Status = HttpSendIp6Value ( SocketFD,
|
||||
pPort,
|
||||
pIpv6->sin6_addr.__u6_addr.__u6_addr16[ Index ],
|
||||
(BOOLEAN)( 0 == Index ),
|
||||
(BOOLEAN)( 7 == Index ),
|
||||
bZeroSuppression,
|
||||
&bZeroSuppression );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Separate the port number
|
||||
//
|
||||
Status = HttpSendByte ( SocketFD, pPort, ']' );
|
||||
|
||||
//
|
||||
// Get the port number
|
||||
//
|
||||
PortNumber = pIpv6->sin6_port;
|
||||
}
|
||||
else {
|
||||
//
|
||||
// Output the IPv4 address
|
||||
//
|
||||
pIpv4 = (struct sockaddr_in *)pAddress;
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)pIpv4->sin_addr.s_addr );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pIpv4->sin_addr.s_addr >> 8 ));
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pIpv4->sin_addr.s_addr >> 16 ));
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendByte ( SocketFD, pPort, '.' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendValue ( SocketFD, pPort, (UINT8)( pIpv4->sin_addr.s_addr >> 24 ));
|
||||
|
||||
//
|
||||
// Get the port number
|
||||
//
|
||||
PortNumber = pIpv4->sin_port;
|
||||
}
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Display the port number
|
||||
//
|
||||
Status = HttpSendByte ( SocketFD, pPort, ':' );
|
||||
if ( EFI_ERROR ( Status )) {
|
||||
break;
|
||||
}
|
||||
Status = HttpSendValue ( SocketFD, pPort, htons ( PortNumber ));
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
|
Reference in New Issue
Block a user