From 59bc059327dd519619fa437c0d7c941e090cd8a3 Mon Sep 17 00:00:00 2001 From: lpleahy Date: Fri, 30 Sep 2011 23:04:13 +0000 Subject: [PATCH] Update the sockets applications * Builds with GCC 4.4 compiler. Signed-off by: lpleahy git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12498 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Applications/Sockets/DataSink/DataSink.c | 207 +++++++------- .../Sockets/DataSource/DataSource.c | 30 +-- .../Sockets/GetHostByAddr/GetHostByAddr.c | 10 +- .../Sockets/GetHostByDns/GetHostByDns.c | 4 +- .../Sockets/GetHostByName/GetHostByName.c | 2 +- .../Sockets/GetNetByAddr/GetNetByAddr.c | 8 +- .../Sockets/GetNetByName/GetNetByName.c | 2 +- .../Sockets/GetServByName/GetServByName.c | 2 +- .../Sockets/GetServByPort/GetServByPort.c | 2 +- AppPkg/Applications/Sockets/OobRx/Main.c | 44 +++ AppPkg/Applications/Sockets/OobRx/OobRx.c | 253 ++++++++++++++++++ AppPkg/Applications/Sockets/OobRx/OobRx.h | 96 +++++++ AppPkg/Applications/Sockets/OobRx/OobRx.inf | 64 +++++ .../Sockets/OobRx/Windows/OobRx.sln | 20 ++ .../Sockets/OobRx/Windows/OobRx.suo | Bin 0 -> 23040 bytes .../Sockets/OobRx/Windows/OobRx.vcproj | 211 +++++++++++++++ .../Applications/Sockets/OobRx/Windows/main.c | 56 ++++ AppPkg/Applications/Sockets/OobTx/Main.c | 44 +++ AppPkg/Applications/Sockets/OobTx/OobTx.c | 248 +++++++++++++++++ AppPkg/Applications/Sockets/OobTx/OobTx.h | 97 +++++++ AppPkg/Applications/Sockets/OobTx/OobTx.inf | 64 +++++ .../Sockets/OobTx/Windows/OobTx.sln | 20 ++ .../Sockets/OobTx/Windows/OobTx.suo | Bin 0 -> 38218 bytes .../Sockets/OobTx/Windows/OobTx.vcproj | 211 +++++++++++++++ .../Applications/Sockets/OobTx/Windows/main.c | 56 ++++ AppPkg/Applications/Sockets/RawIp4Rx/Main.c | 44 +++ .../Applications/Sockets/RawIp4Rx/RawIp4Rx.c | 188 +++++++++++++ .../Applications/Sockets/RawIp4Rx/RawIp4Rx.h | 98 +++++++ .../Sockets/RawIp4Rx/RawIp4Rx.inf | 64 +++++ .../Sockets/RawIp4Rx/Windows/RawIp4Rx.sln | 20 ++ .../Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj | 211 +++++++++++++++ .../Sockets/RawIp4Rx/Windows/main.c | 61 +++++ AppPkg/Applications/Sockets/RawIp4Tx/Main.c | 44 +++ .../Applications/Sockets/RawIp4Tx/RawIp4Tx.c | 157 +++++++++++ .../Applications/Sockets/RawIp4Tx/RawIp4Tx.h | 98 +++++++ .../Sockets/RawIp4Tx/RawIp4Tx.inf | 64 +++++ .../Sockets/RawIp4Tx/Windows/RawIp4Tx.sln | 20 ++ .../Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj | 211 +++++++++++++++ .../Sockets/RawIp4Tx/Windows/main.c | 62 +++++ AppPkg/Applications/Sockets/ReadMe.txt | 11 + .../Sockets/RecvDgram/RecvDgram.c | 2 +- .../Sockets/SetHostName/SetHostName.c | 2 +- .../Sockets/SetSockOpt/SetSockOpt.c | 17 +- AppPkg/Applications/Sockets/Sockets.inc | 4 + .../Sockets/TftpServer/TftpServer.c | 9 +- .../Sockets/TftpServer/TftpServer.h | 18 +- AppPkg/Applications/Sockets/WebServer/ACPI.c | 64 ++--- .../Sockets/WebServer/ConfigurationTable.c | 6 +- AppPkg/Applications/Sockets/WebServer/HTTP.c | 19 +- .../Applications/Sockets/WebServer/PageList.c | 2 +- .../Sockets/WebServer/WebServer.c | 38 ++- .../Sockets/WebServer/WebServer.h | 12 +- 52 files changed, 3062 insertions(+), 235 deletions(-) create mode 100644 AppPkg/Applications/Sockets/OobRx/Main.c create mode 100644 AppPkg/Applications/Sockets/OobRx/OobRx.c create mode 100644 AppPkg/Applications/Sockets/OobRx/OobRx.h create mode 100644 AppPkg/Applications/Sockets/OobRx/OobRx.inf create mode 100644 AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln create mode 100644 AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo create mode 100644 AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj create mode 100644 AppPkg/Applications/Sockets/OobRx/Windows/main.c create mode 100644 AppPkg/Applications/Sockets/OobTx/Main.c create mode 100644 AppPkg/Applications/Sockets/OobTx/OobTx.c create mode 100644 AppPkg/Applications/Sockets/OobTx/OobTx.h create mode 100644 AppPkg/Applications/Sockets/OobTx/OobTx.inf create mode 100644 AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln create mode 100644 AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo create mode 100644 AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj create mode 100644 AppPkg/Applications/Sockets/OobTx/Windows/main.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/Main.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj create mode 100644 AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/Main.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj create mode 100644 AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c create mode 100644 AppPkg/Applications/Sockets/ReadMe.txt diff --git a/AppPkg/Applications/Sockets/DataSink/DataSink.c b/AppPkg/Applications/Sockets/DataSink/DataSink.c index 911cf36940..8223ead118 100644 --- a/AppPkg/Applications/Sockets/DataSink/DataSink.c +++ b/AppPkg/Applications/Sockets/DataSink/DataSink.c @@ -51,9 +51,9 @@ BOOLEAN bTimerRunning; struct sockaddr_in LocalAddress; EFI_EVENT pTimer; int ListenSocket; -UINT8 Buffer [ DATA_BUFFER_SIZE ]; -struct pollfd PollFd [ MAX_CONNECTIONS ]; -DT_PORT Port [ MAX_CONNECTIONS ]; +UINT8 Buffer[ DATA_BUFFER_SIZE ]; +struct pollfd PollFd[ MAX_CONNECTIONS ]; +DT_PORT Port[ MAX_CONNECTIONS ]; nfds_t MaxPort; @@ -136,17 +136,17 @@ SocketAccept ( // Allocate a port // Index = MaxPort++; - PollFd [ Index ].fd = ListenSocket; - PollFd [ Index ].events = POLLRDNORM | POLLHUP; - PollFd [ Index ].revents = 0; - Port [ Index ].BytesAverage = 0; - Port [ Index ].BytesPrevious = 0; - Port [ Index ].BytesTotal = 0; - Port [ Index ].Samples = 0; - Port [ Index ].RemoteAddress.sin_len = 0; - Port [ Index ].RemoteAddress.sin_family = 0; - Port [ Index ].RemoteAddress.sin_port = 0; - Port [ Index ].RemoteAddress.sin_addr.s_addr= 0; + PollFd[ Index ].fd = ListenSocket; + PollFd[ Index ].events = POLLRDNORM | POLLHUP; + PollFd[ Index ].revents = 0; + Port[ Index ].BytesAverage = 0; + Port[ Index ].BytesPrevious = 0; + Port[ Index ].BytesTotal = 0; + Port[ Index ].Samples = 0; + Port[ Index ].RemoteAddress.sin_len = 0; + Port[ Index ].RemoteAddress.sin_family = 0; + Port[ Index ].RemoteAddress.sin_port = 0; + Port[ Index ].RemoteAddress.sin_addr.s_addr= 0; } } @@ -242,8 +242,7 @@ SocketNew ( "0x%08x: Socket created\r\n", ListenSocket )); } - else - { + else { Status = EFI_NOT_STARTED; } } @@ -312,16 +311,16 @@ SocketPoll ( // // Account for this descriptor // - if ( 0 != PollFd [ Index ].revents ) { + if ( 0 != PollFd[ Index ].revents ) { FdCount -= 1; } // // Check for a broken connection // - if ( 0 != ( PollFd [ Index ].revents & POLLHUP )) { + if ( 0 != ( PollFd[ Index ].revents & POLLHUP )) { bRemoveSocket = TRUE; - if ( ListenSocket == PollFd [ Index ].fd ) { + if ( ListenSocket == PollFd[ Index ].fd ) { bListenError = TRUE; DEBUG (( DEBUG_ERROR, "ERROR - Network closed on listen socket, errno: %d\r\n", @@ -330,37 +329,37 @@ SocketPoll ( else { DEBUG (( DEBUG_ERROR, "ERROR - Network closed on socket %d.%d.%d.%d:%d, errno: %d\r\n", - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ), + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ), errno )); // // Close the socket // - CloseStatus = close ( PollFd [ Index ].fd ); + CloseStatus = close ( PollFd[ Index ].fd ); if ( 0 == CloseStatus ) { bRemoveSocket = TRUE; DEBUG (( DEBUG_INFO, "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n", - PollFd [ Index ].fd, - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ))); + PollFd[ Index ].fd, + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ))); } else { DEBUG (( DEBUG_ERROR, "ERROR - Failed to close socket 0x%08x for %d.%d.%d.%d:%d, errno: %d\r\n", - PollFd [ Index ].fd, - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ), + PollFd[ Index ].fd, + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ), errno )); } } @@ -369,11 +368,11 @@ SocketPoll ( // // Check for a connection or read data // - if ( 0 != ( PollFd [ Index ].revents & POLLRDNORM )) { + if ( 0 != ( PollFd[ Index ].revents & POLLRDNORM )) { // // Check for a connection // - if ( ListenSocket == PollFd [ Index ].fd ) { + if ( ListenSocket == PollFd[ Index ].fd ) { // // Another client connection was received // @@ -416,7 +415,7 @@ SocketPoll ( bRemoveSocket = TRUE; DEBUG (( DEBUG_INFO, "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n", - PollFd [ Index ].fd, + PollFd[ Index ].fd, RemoteAddress.sin_addr.s_addr & 0xff, ( RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, ( RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, @@ -426,7 +425,7 @@ SocketPoll ( else { DEBUG (( DEBUG_ERROR, "ERROR - Failed to close socket 0x%08x, errno: %d\r\n", - PollFd [ Index ].fd, + PollFd[ Index ].fd, errno )); } @@ -436,8 +435,7 @@ SocketPoll ( // Status = EFI_SUCCESS; } - else - { + else { // // Display the connection // @@ -452,17 +450,17 @@ SocketPoll ( // Allocate the client connection // Index = MaxPort++; - Port [ Index ].BytesAverage = 0; - Port [ Index ].BytesPrevious = 0; - Port [ Index ].BytesTotal = 0; - Port [ Index ].Samples = 0; - Port [ Index ].RemoteAddress.sin_len = RemoteAddress.sin_len; - Port [ Index ].RemoteAddress.sin_family = RemoteAddress.sin_family; - Port [ Index ].RemoteAddress.sin_port = RemoteAddress.sin_port; - Port [ Index ].RemoteAddress.sin_addr = RemoteAddress.sin_addr; - PollFd [ Index ].fd = Socket; - PollFd [ Index ].events = POLLRDNORM | POLLHUP; - PollFd [ Index ].revents = 0; + Port[ Index ].BytesAverage = 0; + Port[ Index ].BytesPrevious = 0; + Port[ Index ].BytesTotal = 0; + Port[ Index ].Samples = 0; + Port[ Index ].RemoteAddress.sin_len = RemoteAddress.sin_len; + Port[ Index ].RemoteAddress.sin_family = RemoteAddress.sin_family; + Port[ Index ].RemoteAddress.sin_port = RemoteAddress.sin_port; + Port[ Index ].RemoteAddress.sin_addr = RemoteAddress.sin_addr; + PollFd[ Index ].fd = Socket; + PollFd[ Index ].events = POLLRDNORM | POLLHUP; + PollFd[ Index ].revents = 0; } } } @@ -470,7 +468,7 @@ SocketPoll ( // // Data received // - BytesReceived = read ( PollFd [ Index ].fd, + BytesReceived = read ( PollFd[ Index ].fd, &Buffer, sizeof ( Buffer )); if ( 0 < BytesReceived ) { @@ -479,13 +477,13 @@ SocketPoll ( // DEBUG (( DEBUG_INFO, "0x%08x: Socket received 0x%08x bytes from %d.%d.%d.%d:%d\r\n", - PollFd [ Index ].fd, + PollFd[ Index ].fd, BytesReceived, - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ))); + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ))); // // Synchronize with the TimerCallback routine @@ -495,7 +493,7 @@ SocketPoll ( // // Account for the data received // - Port [ Index ].BytesTotal += BytesReceived; + Port[ Index ].BytesTotal += BytesReceived; // // Release the synchronization with the TimerCallback routine @@ -508,33 +506,33 @@ SocketPoll ( // DEBUG (( DEBUG_INFO, "ERROR - Receive failure for %d.%d.%d.%d:%d, errno: %d\r\n", - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ), + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ), errno )); - CloseStatus = close ( PollFd [ Index ].fd ); + CloseStatus = close ( PollFd[ Index ].fd ); if ( 0 == CloseStatus ) { bRemoveSocket = TRUE; DEBUG (( DEBUG_INFO, "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n", - PollFd [ Index ].fd, - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ))); + PollFd[ Index ].fd, + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ))); } else { DEBUG (( DEBUG_ERROR, "ERROR - Failed to close socket 0x%08x for %d.%d.%d.%d:%d, errno: %d\r\n", - PollFd [ Index ].fd, - Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, - ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, - htons ( Port [ Index ].RemoteAddress.sin_port ), + PollFd[ Index ].fd, + Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff, + ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff, + htons ( Port[ Index ].RemoteAddress.sin_port ), errno )); } } @@ -553,23 +551,23 @@ SocketPoll ( if ( bRemoveSocket ) { DEBUG (( DEBUG_INFO, "0x%08x: Socket removed from polling\r\n", - PollFd [ Index ].fd )); + PollFd[ Index ].fd )); MaxPort -= 1; for ( Entry = Index + 1; MaxPort >= Entry; Entry++ ) { EntryPrevious = Entry; - Port [ EntryPrevious ].BytesAverage = Port [ Entry ].BytesAverage; - Port [ EntryPrevious ].BytesPrevious = Port [ Entry ].BytesPrevious; - Port [ EntryPrevious ].BytesTotal = Port [ Entry ].BytesTotal; - Port [ EntryPrevious ].RemoteAddress.sin_len = Port [ Entry ].RemoteAddress.sin_len; - Port [ EntryPrevious ].RemoteAddress.sin_family = Port [ Entry ].RemoteAddress.sin_family; - Port [ EntryPrevious ].RemoteAddress.sin_port = Port [ Entry ].RemoteAddress.sin_port; - Port [ EntryPrevious ].RemoteAddress.sin_addr.s_addr = Port [ Entry ].RemoteAddress.sin_addr.s_addr; - Port [ EntryPrevious ].Samples = Port [ Entry ].Samples; - PollFd [ EntryPrevious ].events = PollFd [ Entry ].events; - PollFd [ EntryPrevious ].fd = PollFd [ Entry ].fd; - PollFd [ EntryPrevious ].revents = PollFd [ Entry ].revents; + Port[ EntryPrevious ].BytesAverage = Port[ Entry ].BytesAverage; + Port[ EntryPrevious ].BytesPrevious = Port[ Entry ].BytesPrevious; + Port[ EntryPrevious ].BytesTotal = Port[ Entry ].BytesTotal; + Port[ EntryPrevious ].RemoteAddress.sin_len = Port[ Entry ].RemoteAddress.sin_len; + Port[ EntryPrevious ].RemoteAddress.sin_family = Port[ Entry ].RemoteAddress.sin_family; + Port[ EntryPrevious ].RemoteAddress.sin_port = Port[ Entry ].RemoteAddress.sin_port; + Port[ EntryPrevious ].RemoteAddress.sin_addr.s_addr = Port[ Entry ].RemoteAddress.sin_addr.s_addr; + Port[ EntryPrevious ].Samples = Port[ Entry ].Samples; + PollFd[ EntryPrevious ].events = PollFd[ Entry ].events; + PollFd[ EntryPrevious ].fd = PollFd[ Entry ].fd; + PollFd[ EntryPrevious ].revents = PollFd[ Entry ].revents; } - PollFd [ MaxPort ].fd = -1; + PollFd[ MaxPort ].fd = -1; Index -= 1; } @@ -625,31 +623,31 @@ TimerCallback ( // // Determine if any data was received // - BytesReceived = Port [ Index ].BytesTotal; - if (( ListenSocket != PollFd [ Index ].fd ) + BytesReceived = Port[ Index ].BytesTotal; + if (( ListenSocket != PollFd[ Index ].fd ) && ( 0 != BytesReceived )) { // // Update the average bytes per second // - DeltaBytes = Port [ Index ].BytesAverage >> AVERAGE_SHIFT_COUNT; - Port [ Index ].BytesAverage -= DeltaBytes; - DeltaBytes = BytesReceived - Port [ Index ].BytesPrevious; - Port [ Index ].BytesPrevious = BytesReceived; - Port [ Index ].BytesAverage += DeltaBytes; + DeltaBytes = Port[ Index ].BytesAverage >> AVERAGE_SHIFT_COUNT; + Port[ Index ].BytesAverage -= DeltaBytes; + DeltaBytes = BytesReceived - Port[ Index ].BytesPrevious; + Port[ Index ].BytesPrevious = BytesReceived; + Port[ Index ].BytesAverage += DeltaBytes; // // Separate the samples // - if (( 2 << AVERAGE_SHIFT_COUNT ) == Port [ Index ].Samples ) { + if (( 2 << AVERAGE_SHIFT_COUNT ) == Port[ Index ].Samples ) { Print ( L"---------- Stable average ----------\r\n" ); } - Port [ Index ].Samples += 1; + Port[ Index ].Samples += 1; // // Display the data rate // Delta = (UINT32)( DeltaBytes >> DATA_RATE_UPDATE_SHIFT ); - Average = Port [ Index ].BytesAverage >> ( AVERAGE_SHIFT_COUNT + DATA_RATE_UPDATE_SHIFT ); + Average = Port[ Index ].BytesAverage >> ( AVERAGE_SHIFT_COUNT + DATA_RATE_UPDATE_SHIFT ); if ( Average < RANGE_SWITCH ) { Print ( L"%d Bytes/sec, Ave: %d Bytes/Sec\r\n", Delta, @@ -919,8 +917,7 @@ main ( // // Use for/break instead of goto // - for ( ; ; ) - { + for ( ; ; ) { // // Create the timer // diff --git a/AppPkg/Applications/Sockets/DataSource/DataSource.c b/AppPkg/Applications/Sockets/DataSource/DataSource.c index 9add3f24e7..98a0c9f120 100644 --- a/AppPkg/Applications/Sockets/DataSource/DataSource.c +++ b/AppPkg/Applications/Sockets/DataSource/DataSource.c @@ -84,7 +84,7 @@ UINT64 TotalBytesSent; UINT64 PreviousBytes; UINT64 AverageBytes; UINT64 Samples; -UINT8 Buffer [ DATA_BUFFER_SIZE ]; +UINT8 Buffer[ DATA_BUFFER_SIZE ]; // @@ -146,8 +146,7 @@ GetDigit ( // Walk the digits // Value = 0; - while (( '0' <= *pDigit ) && ( '9' >= *pDigit )) - { + while (( '0' <= *pDigit ) && ( '9' >= *pDigit )) { // // Make room for the new least significant digit // @@ -313,7 +312,7 @@ SocketConnect ( // // Check for user stop request // - while ( ! bTick ) { + while ( !bTick ) { Status = ControlCCheck ( ); if ( EFI_ERROR ( Status )) { break; @@ -494,8 +493,7 @@ SocketOpen ( // // Use do/while and break instead of goto // - do - { + do { // // Wait for the network layer to initialize // @@ -801,7 +799,7 @@ Tcp4Locate ( // // Open the network controller's service protocol // - Tcp4Controller = pHandles [ Tcp4Index++ ]; + Tcp4Controller = pHandles[ Tcp4Index++ ]; Status = gBS->OpenProtocol ( Tcp4Controller, &gEfiTcp4ServiceBindingProtocolGuid, @@ -1499,12 +1497,15 @@ main ( // // Validate the command line // - if ( 2 != Argc ) { - Print ( L"%s \r\n", Argv[0] ); + if ( 2 > Argc ) { + Print ( L"%s [Use TCP]\r\n", Argv[0] ); return -1; } -bTcp4 = TRUE; + // + // Determine if TCP should be used + // + bTcp4 = (BOOLEAN)( 2 < Argc ); // // Determine the support routines @@ -1522,8 +1523,7 @@ bTcp4 = TRUE; // // Use for/break instead of goto // - for ( ; ; ) - { + for ( ; ; ) { // // No bytes sent so far // @@ -1540,14 +1540,10 @@ bTcp4 = TRUE; RemoteHostAddress.sin_family = AF_INET; RemoteHostAddress.sin_port = htons ( PcdGet16 ( DataSource_Port )); -Print ( L"Argc: %d\r\n", Argc); -Print ( L"Argv[0]: %a\r\n", Argv[0]); -Print ( L"Argv[1]: %a\r\n", Argv[1]); - // // Get the IP address // - pRemoteHost = Argv [1]; + pRemoteHost = Argv[1]; Status = IpAddress ( ); if ( EFI_ERROR ( Status )) { break; diff --git a/AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.c b/AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.c index 2e626396ca..63299a1f9d 100644 --- a/AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.c +++ b/AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.c @@ -59,10 +59,10 @@ main ( &RemoteAddress[1], &RemoteAddress[2], &RemoteAddress[3])) - || ( 255 < RemoteAddress [0]) - || ( 255 < RemoteAddress [1]) - || ( 255 < RemoteAddress [2]) - || ( 255 < RemoteAddress [3])) { + || ( 255 < RemoteAddress[0]) + || ( 255 < RemoteAddress[1]) + || ( 255 < RemoteAddress[2]) + || ( 255 < RemoteAddress[3])) { Print ( L"%a \r\n", Argv[0]); } else { @@ -78,7 +78,7 @@ main ( Print ( L"ERROR - host not found, errno: %d\r\n", errno ); } else { - pIpAddress = (UINT8 *)pHost->h_addr_list [ 0 ]; + pIpAddress = (UINT8 *)pHost->h_addr_list[ 0 ]; Print ( L"%d.%d.%d.%d, %a\r\n", pIpAddress[0], pIpAddress[1], diff --git a/AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.c b/AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.c index 47453aced2..c5c78ac2b3 100644 --- a/AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.c +++ b/AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.c @@ -23,9 +23,9 @@ #include -struct hostent * _gethostbydnsname(const char *, int); +struct hostent * _gethostbydnsname (const char *, int); -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c b/AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c index d539c99481..c58552abbc 100644 --- a/AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c +++ b/AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c @@ -23,7 +23,7 @@ #include -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.c b/AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.c index 51d8c6d101..ce07ceaa53 100644 --- a/AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.c +++ b/AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.c @@ -53,10 +53,10 @@ main ( &RemoteAddress[1], &RemoteAddress[2], &RemoteAddress[3])) - || ( 255 < RemoteAddress [0]) - || ( 255 < RemoteAddress [1]) - || ( 255 < RemoteAddress [2]) - || ( 255 < RemoteAddress [3])) { + || ( 255 < RemoteAddress[0]) + || ( 255 < RemoteAddress[1]) + || ( 255 < RemoteAddress[2]) + || ( 255 < RemoteAddress[3])) { Print ( L"%a \r\n", Argv[0]); } else { diff --git a/AppPkg/Applications/Sockets/GetNetByName/GetNetByName.c b/AppPkg/Applications/Sockets/GetNetByName/GetNetByName.c index b3609c9374..be81b3483d 100644 --- a/AppPkg/Applications/Sockets/GetNetByName/GetNetByName.c +++ b/AppPkg/Applications/Sockets/GetNetByName/GetNetByName.c @@ -23,7 +23,7 @@ #include -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/GetServByName/GetServByName.c b/AppPkg/Applications/Sockets/GetServByName/GetServByName.c index d7237d342c..f90bcf298d 100644 --- a/AppPkg/Applications/Sockets/GetServByName/GetServByName.c +++ b/AppPkg/Applications/Sockets/GetServByName/GetServByName.c @@ -23,7 +23,7 @@ #include -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c b/AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c index 6a5fc46ea7..5be03618f4 100644 --- a/AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c +++ b/AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c @@ -24,7 +24,7 @@ #include -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/OobRx/Main.c b/AppPkg/Applications/Sockets/OobRx/Main.c new file mode 100644 index 0000000000..0cdecdfaf4 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/Main.c @@ -0,0 +1,44 @@ +/** @file + Out-of-band receive test application + + 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 + + +/** + Receive out-of-band messages from the remote system. + + @param [in] Argc The number of arguments + @param [in] Argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main ( + IN int Argc, + IN char **Argv + ) +{ + int RetVal; + + // + // Run the application + // + RetVal = OobRx ( Argc, Argv ); + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.c b/AppPkg/Applications/Sockets/OobRx/OobRx.c new file mode 100644 index 0000000000..7e6b8f7ed1 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/OobRx.c @@ -0,0 +1,253 @@ +/** @file + Windows version of the OOB Receive application + + 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 + +UINT8 mBuffer[65536]; + + +/** + Run the OOB receive application + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ +int +OobRx ( + IN int ArgC, + IN char **ArgV + ) +{ + SOCKET a; + ssize_t BytesReceived; + struct sockaddr_in LocalPort; + UINT32 OobInLine; + UINT16 PortNumber; + struct timeval ReceiveTimeout; + struct sockaddr_in RemotePort; + socklen_t RemotePortLength; + int RetVal; + SOCKET s; + UINT32 TransmittedBefore; + UINT32 TransmittedDuring; + UINT32 TransmittedOob; + UINT32 TransmittedAfter; + UINT32 * pTransmittedBytes; + + // + // Create the socket + // + s = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if ( -1 == s ) { + RetVal = GET_ERRNO; + printf ( "ERROR - socket error, errno: %d\r\n", RetVal ); + } + else { + // + // Use for/break; instead of goto + // + for ( ; ; ) { + // + // Bind the socket to a known port + // + PortNumber = OOB_RX_PORT; + memset ( &LocalPort, 0, sizeof ( LocalPort )); + SIN_LEN ( LocalPort ) = sizeof ( LocalPort ); + SIN_FAMILY ( LocalPort ) = AF_INET; + SIN_ADDR ( LocalPort ) = 0; + SIN_PORT ( LocalPort ) = htons ( PortNumber ); + RetVal = bind ( s, + (struct sockaddr *)&LocalPort, + sizeof ( LocalPort )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - bind error, errno: %d\r\n", RetVal ); + break; + } + + // + // Make the port available on the server + // + RetVal = listen ( s, 2 ); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - listen error, errno: %d\r\n", RetVal ); + break; + } + + // + // Wait for a connection to the known port + // + RemotePortLength = sizeof ( RemotePort ); + a = accept ( s, + (struct sockaddr *)&RemotePort, + &RemotePortLength ); + if ( -1 == a ) { + RetVal = GET_ERRNO; + printf ( "ERROR - accept error, errno: %d\r\n", RetVal ); + break; + } + + // + // Use for/break instead of goto + // + for ( ; ; ) { + // + // Set the receive timeout + // + ReceiveTimeout.tv_sec = 0; + ReceiveTimeout.tv_usec = 20 * 1000; + RetVal = setsockopt ( a, + SOL_SOCKET, + SO_RCVTIMEO, + (char *)&ReceiveTimeout, + sizeof ( ReceiveTimeout )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - setsockopt RCVTIMEO error, errno: %d\r\n", RetVal ); + break; + } + + // + // Select the OOB processing + // + OobInLine = ( 1 < ArgC ); + RetVal = setsockopt ( s, + SOL_SOCKET, + SO_OOBINLINE, + (char *)&OobInLine, + sizeof ( OobInLine )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - setsockopt OOBINLINE error, errno: %d\r\n", RetVal ); + break; + } + printf ( "%s\r\n", ( 0 != OobInLine ) ? "OOB messages are in-line" + : "OOB messages move to the head of the queue" ); + + // + // Receive data from the remote system + // + TransmittedBefore = 0; + TransmittedOob = 0; + TransmittedDuring = 0; + TransmittedAfter = 0; + pTransmittedBytes = &TransmittedBefore; + do { + // + // Attempt to receive OOB data + // + BytesReceived = recv ( a, &mBuffer[0], sizeof ( mBuffer ), MSG_OOB ); + RetVal = (UINT32)BytesReceived; + if ( 0 < BytesReceived ) { + // + // Display the received OOB data + // + printf ( "%5Ld OOB bytes received\r\n", (UINT64)BytesReceived ); + + // + // Account for the bytes received + // + TransmittedOob += RetVal; + *pTransmittedBytes += TransmittedAfter; + TransmittedAfter = 0; + pTransmittedBytes = &TransmittedDuring; + } + else if ( -1 == BytesReceived ) { + // + // Check for connection timeout + // + RetVal = GET_ERRNO; + if ( RX_TIMEOUT_ERROR != RetVal ) { + // + // Receive error + // + printf ( "ERROR - recv OOB error, errno: %d\r\n", RetVal ); + break; + } + + // + // Ignore the timeout + // Try to receive normal data instead + // + BytesReceived = recv ( a, &mBuffer[0], sizeof ( mBuffer ), 0 ); + RetVal = (UINT32)BytesReceived; + if ( 0 < BytesReceived ) { + // + // Display the received data + // + printf ( "%4Ld bytes received\r\n", (UINT64)BytesReceived ); + + // + // Account for the bytes received + // + TransmittedAfter += RetVal; + } + else if ( -1 == BytesReceived ) { + // + // Check for a timeout + // + RetVal = GET_ERRNO; + if ( RX_TIMEOUT_ERROR != RetVal ) { + printf ( "ERROR - recv error, errno: %d\r\n", RetVal ); + break; + } + } + } + } while ( 0 != RetVal ); + + // + // Display the bytes received + // + if ( 0 == RetVal ) { + printf ( "Bytes before OOB: %8d\r\n", TransmittedBefore ); + if ( 0 != TransmittedDuring ) { + printf ( "Bytes during OOB: %8d\r\n", TransmittedDuring ); + } + printf ( "Out-of-band bytes: %8d\r\n", TransmittedOob ); + printf ( "Bytes after OOB: %8d\r\n", TransmittedAfter ); + printf ( " --------\r\n" ); + printf ( "Total Bytes: %8d\r\n", TransmittedBefore + + TransmittedDuring + + TransmittedOob + + TransmittedAfter ); + } + + // + // Test complete + // + break; + } + + // + // Close the test socket + // + CLOSE_SOCKET ( a ); + break; + } + + // + // Close the socket + // + CLOSE_SOCKET ( s ); + printf ( "Socket closed\r\n" ); + } + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.h b/AppPkg/Applications/Sockets/OobRx/OobRx.h new file mode 100644 index 0000000000..37730cada7 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/OobRx.h @@ -0,0 +1,96 @@ +/** @file + Definitions for the OOB Receive application + + 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. + +**/ + +#ifndef _OOB_RX_H_ +#define _OOB_RX_H_ + +//------------------------------------------------------------------------------ +// Include Files +//------------------------------------------------------------------------------ + +#ifdef BUILD_FOR_WINDOWS +// +// Build for Windows environment +// + +#include + +#define CLOSE_SOCKET closesocket +#define SIN_ADDR(port) port.sin_addr.S_un.S_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_family +#define SIN_PORT(port) port.sin_port +#define GET_ERRNO WSAGetLastError ( ) + +#define RX_TIMEOUT_ERROR WSAETIMEDOUT +#define ssize_t int +#define socklen_t int + +#else // BUILD_FOR_WINDOWS +// +// Build for EFI environment +// + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#define CLOSE_SOCKET close +#define SIN_ADDR(port) port.sin_addr.s_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_len +#define SIN_PORT(port) port.sin_port +#define SOCKET int +#define GET_ERRNO errno +#define RX_TIMEOUT_ERROR ETIMEDOUT + +#endif // BUILD_FOR_WINDOWS + +#include + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +#define OOB_RX_PORT 12344 + +//------------------------------------------------------------------------------ +// API +//------------------------------------------------------------------------------ + +/** + Run the OOB receive application + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +OobRx ( + IN int ArgC, + IN char **ArgV + ); + +//------------------------------------------------------------------------------ + +#endif // _OOB_RX_H_ diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.inf b/AppPkg/Applications/Sockets/OobRx/OobRx.inf new file mode 100644 index 0000000000..516f7cc215 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/OobRx.inf @@ -0,0 +1,64 @@ +#/** @file +# OobRx Application +# +# This file contains an 'Intel Peripheral Driver' and is +# licensed for Intel CPUs and chipsets under the terms of your +# license agreement with Intel or your vendor. This file may +# be modified by the user, subject to additional terms of the +# license agreement +# +# +# Copyright (c) 20011 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +## + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = OobRx + FILE_GUID = 79DED328-7FCE-4909-9AFD-D66176AF97A6 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = ShellCEntryLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + Main.c + OobRx.c + + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + StdLib/StdLib.dec + + +[LibraryClasses] + BaseMemoryLib + BsdSocketLib + DebugLib + EfiSocketLib + LibC + LibMath + ShellCEntryLib + UefiBootServicesTableLib + UefiLib +# UseSocketDxe + +[BuildOptions] + INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186 + MSFT:*_*_*_CC_FLAGS = /Od + GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable + diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln new file mode 100644 index 0000000000..f9c7825afd --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OobRx", "OobRx.vcproj", "{FA34A77A-5034-4065-B4BD-B74984DEB2F7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Debug|Win32.ActiveCfg = Debug|Win32 + {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Debug|Win32.Build.0 = Debug|Win32 + {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Release|Win32.ActiveCfg = Release|Win32 + {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo new file mode 100644 index 0000000000000000000000000000000000000000..025aa479731768a032072972a9e3f494b156ff83 GIT binary patch literal 23040 zcmeI42b5J+mWFSE615cpTM)I7r~($D$e?5p6c7*t1}F+puz(_nf;lI&G0|pi9T!W- z8S{*-PTMnU9J98z-D8hq8Zm*G+Cgbx{_np3!mbjESAy8>cwoP?-*@*t`JB7Yd9U6} zFE)7Vw)>jCom2{albXr8^>ve4ffq?he@a)4wPNoD(=-fvwC9G=Y7zqv_aGAJoiT%Me&R?a`{u2GYffN@e)c_*(Iz`V?ab$~UXy?M3<(66im%>Paj)&lOCqWE0NZjy!)(qvtT^Pje1 zy*N+8J$otMTe6R&P{LgAEXm5i{LggaIRD$}T2Dy_$$^q0Nk_>E5^TFDE|zqabdz+K z^pIR2=_Tnc=_9#9a**U;Nk2({$pFb=l0lNek|7e(9H#gX>w3E(j1(Is87(E$0z2BPhwHYLjth7bCHx zLP??9A~0_mr@3~>)s*rbq4LhrsF)do~ZLW-Mwf->oSs$1jo3o3&rrva65mKm}KkI*qN-#@h&3Ytfx#`!|-(mf)rKC2u z{tiy-JUJad^VAlUrK+I(3ut?MrhMyGt)~{59Um%>X92Y zx%r#5AF+pWL|erwB(#M$wUPox5|0iZ!sqTVvxXkm>(`gnND5ZJnp>L-YM#~o*pK5% zvr(@+{ti`5Pu8fz53IP>r8#`-rJcq<;~w82-|^2Lf@dXx`94>9maDBv z{I}=t?y}peb)T$Vy`{;cONdw8DYQGt2EAfPxn64!A(kE@sx5w*Z&BqJF zM_Z^~?kBIWi(b3wUq5-A#d;b++DnS$!4*sEFTKB72(6p+9`fkA==~tQ@1!)k$(!k* zp?^yHWZRhU$n@zEbEU;MUAEll!nRK8i*C!Z^-8_WZJA;Rc_F3g{9xBos$R^E*UoB> z4q9#drz3^kLw{LKR;@R-Jf82j%YvW83YU%X+&r72Q9o6*JWVh69M)ukM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G0P*}fFEu(Ia~^5$$V(?I7JNqi@$xtjyz74f)8+-8GhG1E-EZC|i_CZD`E#M|uCg7^i(93$j{eFFpZ!kh*k`^w<-5KT zBM*Fc^0?Rc;uGC3o&J5wjC)^^K3ef>W?X+;I?pM5bNx@-1^;}6^!Lq34_}x(!>cN3od!zpAbqeI_u{A12l(~a!SMG9!_6okK0akR zJTQEA*l~ePGMi#HQrC}`PB__&zFtaZ3bV}6XGl=S|nr$8^;=iB2Izb(;Qry{w(&FhH2WJw?16whhIv<9~br&-#$%MvAY&2--SAqDDofk7VB#+T{W@#%ULYe z!4rS-KS;tK0rwE?D$Dk|);awdfF5dznGWZGU6Ue11o# z2HtFi@Z%ouB_8kFvb8&Q%8mC5&6xii{Qvm7H2C+LJ!y!%nF#v}eC3Q|l>+ zze~C=`jB!)AD6N>F~hBHAz{Y1GDGL{2F?vQqvl>1dj{Bn5*YV#F2*&+AdIxxmk_#3 js_U1hH>NM2>6P5RkYu^7mQHTpn2{ShBf?tA#@zl7xTnbG literal 0 HcmV?d00001 diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj new file mode 100644 index 0000000000..e5ca534fd3 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/main.c b/AppPkg/Applications/Sockets/OobRx/Windows/main.c new file mode 100644 index 0000000000..7d2c644fc6 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobRx/Windows/main.c @@ -0,0 +1,56 @@ +/** @file + Windows version of the OOB Receive application + + 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 + + +/** + Receive out-of-band messages from the remote system. + + @param [in] argc The number of arguments + @param [in] argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main( + int argc, + char ** argv + ) +{ + int RetVal; + WSADATA WsaData; + + // + // Initialize the WinSock layer + // + RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData ); + if ( 0 == RetVal ) { + // + // Start the application + // + RetVal = OobRx ( argc, argv ); + + // + // Done with the WinSock layer + // + WSACleanup ( ); + } + + // + // Return the final result + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/OobTx/Main.c b/AppPkg/Applications/Sockets/OobTx/Main.c new file mode 100644 index 0000000000..ac7c8b0146 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/Main.c @@ -0,0 +1,44 @@ +/** @file + Out-of-band transmit test application + + 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 + + +/** + Transmit out-of-band messages to the remote system. + + @param [in] Argc The number of arguments + @param [in] Argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main ( + IN int Argc, + IN char **Argv + ) +{ + int RetVal; + + // + // Run the application + // + RetVal = OobTx ( Argc, Argv ); + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.c b/AppPkg/Applications/Sockets/OobTx/OobTx.c new file mode 100644 index 0000000000..d52cbb70c0 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/OobTx.c @@ -0,0 +1,248 @@ +/** @file + Windows version of the OOB Transmit application + + 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 + +UINT8 mBuffer[8192]; +UINT8 mOob[512]; + +/** + Transmit out-of-band messages to the remote system. + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +OobTx ( + IN int ArgC, + IN char **ArgV + ) +{ + UINT32 BytesSent; + ssize_t BytesTransmitted; + UINT32 Index; + struct sockaddr_in LocalPort; + UINT32 OobInLine; + UINT16 PortNumber; + UINT32 RemoteAddress[4]; + struct sockaddr_in RemotePort; + int RetVal; + UINT32 TransmittedAfter; + UINT32 TransmittedBefore; + UINT32 TransmittedOob; + SOCKET s; + + // + // Create the socket + // + s = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); + if ( -1 == s ) { + RetVal = GET_ERRNO; + printf ( "ERROR - socket error, errno: %d\r\n", RetVal ); + } + else { + // + // Use for/break; instead of goto + // + for ( ; ; ) { + // + // Validate the arguments + // + if (( 2 > ArgC ) + || ( 4 != sscanf ( ArgV[1], + "%d.%d.%d.%d", + &RemoteAddress[0], + &RemoteAddress[1], + &RemoteAddress[2], + &RemoteAddress[3])) + || ( 224 < RemoteAddress[0]) + || ( 255 < RemoteAddress[1]) + || ( 255 < RemoteAddress[2]) + || ( 255 < RemoteAddress[3]) + || (( 0 == RemoteAddress[0]) + && ( 0 == RemoteAddress[1]) + && ( 0 == RemoteAddress[2]) + && ( 0 == RemoteAddress[3]))) { + printf ( "%s [optional: enables in-line OOB]\r\n", ArgV[0]); + RetVal = EINVAL; + break; + } + + // + // Bind the socket to a local port + // + memset ( &LocalPort, 0, sizeof ( LocalPort )); + SIN_LEN ( LocalPort ) = sizeof ( LocalPort ); + SIN_FAMILY ( LocalPort ) = AF_INET; + SIN_ADDR ( LocalPort ) = 0; + SIN_PORT ( LocalPort ) = 0; + RetVal = bind ( s, + (struct sockaddr *)&LocalPort, + sizeof ( LocalPort )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - bind error, errno: %d\r\n", RetVal ); + break; + } + + // + // Specify the remote port + // + PortNumber = OOB_RX_PORT; + memset ( &RemotePort, 0, sizeof ( RemotePort )); + SIN_LEN ( RemotePort ) = sizeof ( RemotePort ); + SIN_FAMILY ( RemotePort ) = AF_INET; + SIN_ADDR ( RemotePort ) = ( RemoteAddress[3] << 24 ) + | ( RemoteAddress[2] << 16 ) + | ( RemoteAddress[1] << 8 ) + | RemoteAddress[0]; + SIN_PORT ( RemotePort ) = htons ( PortNumber ); + + // + // Connect to the remote server + // + RetVal = connect ( s, (struct sockaddr *)&RemotePort, sizeof ( RemotePort )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - connect error, errno: %d\r\n", RetVal ); + break; + } + + // + // Select the OOB processing + // + OobInLine = ( 2 < ArgC ); + RetVal = setsockopt ( s, + SOL_SOCKET, + SO_OOBINLINE, + (char *)&OobInLine, + sizeof ( OobInLine )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - setsockopt OOBINLINE error, errno: %d\r\n", RetVal ); + break; + } + printf ( "%s\r\n", ( 0 != OobInLine ) ? "OOB messages are in-line" + : "OOB messages move to the head of the queue" ); + + // + // Initialize the messages + // + memset ( &mBuffer[0], 0, sizeof ( mBuffer )); + memset ( &mOob[0], 0x11, sizeof ( mOob )); + + // + // Send the data before the out-of-band message + // + TransmittedBefore = 0; + for ( Index = 0; TX_MSGS_BEFORE > Index; Index++ ) { + BytesSent = 0; + do { + BytesTransmitted = send ( s, + &mBuffer[BytesSent], + sizeof ( mBuffer ) - BytesSent, + 0 ); + if ( -1 == BytesTransmitted ) { + RetVal = GET_ERRNO; + printf ( "ERROR - send before error, errno: %d\r\n", RetVal ); + break; + } + BytesSent += (UINT32)BytesTransmitted; + RetVal = 0; + } while ( sizeof ( mBuffer ) > BytesSent ); + if ( 0 != RetVal ) { + break; + } + TransmittedBefore += BytesSent; + } + if ( 0 != RetVal ) { + break; + } + + // + // Send the out-of-band message + // + BytesSent = 0; + do { + BytesTransmitted = send ( s, + &mOob[BytesSent], + sizeof ( mOob ) - BytesSent, + MSG_OOB ); + if ( -1 == BytesTransmitted ) { + RetVal = GET_ERRNO; + printf ( "ERROR - send OOB error, errno: %d\r\n", RetVal ); + break; + } + BytesSent += (UINT32)BytesTransmitted; + RetVal = 0; + } while ( sizeof ( mOob ) > BytesSent ); + if ( 0 != RetVal ) { + break; + } + TransmittedOob = BytesSent; + + // + // Send the data after the out-of-band message + // + TransmittedAfter = 0; + for ( Index = 0; TX_MSGS_AFTER > Index; Index++ ) { + BytesSent = 0; + do { + BytesTransmitted = send ( s, + &mBuffer[BytesSent], + sizeof ( mBuffer ) - BytesSent, + 0 ); + if ( -1 == BytesTransmitted ) { + RetVal = GET_ERRNO; + printf ( "ERROR - send after error, errno: %d\r\n", RetVal ); + break; + } + BytesSent += (UINT32)BytesTransmitted; + RetVal = 0; + } while ( sizeof ( mBuffer ) > BytesSent ); + if ( 0 != RetVal ) { + break; + } + TransmittedAfter += BytesSent; + } + + // + // Test completed successfully + // + if ( 0 == RetVal ) { + printf ( "Bytes before OOB: %8d\r\n", TransmittedBefore ); + printf ( "Out-of-band bytes: %8d\r\n", TransmittedOob ); + printf ( "Bytes after OOB: %8d\r\n", TransmittedAfter ); + printf ( " --------\r\n" ); + printf ( "Total Bytes: %8d\r\n", TransmittedBefore + + TransmittedOob + + TransmittedAfter ); + } + break; + } + + // + // Close the socket + // + CLOSE_SOCKET ( s ); + } + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.h b/AppPkg/Applications/Sockets/OobTx/OobTx.h new file mode 100644 index 0000000000..d700d3e59f --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/OobTx.h @@ -0,0 +1,97 @@ +/** @file + Definitions for the OOB Transmit application + + 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. + +**/ + +#ifndef _OOB_TX_H_ +#define _OOB_TX_H_ + +//------------------------------------------------------------------------------ +// Include Files +//------------------------------------------------------------------------------ + +#ifdef BUILD_FOR_WINDOWS +// +// Build for Windows environment +// + +#include + +#define CHAR8 char +#define CLOSE_SOCKET closesocket +#define EINVAL 22 // Invalid argument +#define GET_ERRNO WSAGetLastError ( ) +#define SIN_ADDR(port) port.sin_addr.S_un.S_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_family +#define SIN_PORT(port) port.sin_port +#define socklen_t int +#define ssize_t int + +#else // BUILD_FOR_WINDOWS +// +// Build for EFI environment +// + +#include +#include +#include + +#include + +#include +#include +#include + +#define CLOSE_SOCKET close +#define GET_ERRNO errno +#define SIN_ADDR(port) port.sin_addr.s_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_len +#define SIN_PORT(port) port.sin_port +#define SOCKET int + +#endif // BUILD_FOR_WINDOWS + +#include + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +#define OOB_RX_PORT 12344 + +#define TX_MSGS_BEFORE 32 +#define TX_MSGS_AFTER 8 + +//------------------------------------------------------------------------------ +// API +//------------------------------------------------------------------------------ + +/** + Transmit out-of-band messages to the remote system. + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +OobTx ( + IN int ArgC, + IN char **ArgV + ); + +//------------------------------------------------------------------------------ + +#endif // _OOB_TX_H_ diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.inf b/AppPkg/Applications/Sockets/OobTx/OobTx.inf new file mode 100644 index 0000000000..cc9c2b583e --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/OobTx.inf @@ -0,0 +1,64 @@ +#/** @file +# OobTx Application +# +# This file contains an 'Intel Peripheral Driver' and is +# licensed for Intel CPUs and chipsets under the terms of your +# license agreement with Intel or your vendor. This file may +# be modified by the user, subject to additional terms of the +# license agreement +# +# +# Copyright (c) 20011 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +## + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = OobTx + FILE_GUID = EB740091-A494-44d7-8D96-C192F95A6394 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = ShellCEntryLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + Main.c + OobTx.c + + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + StdLib/StdLib.dec + + +[LibraryClasses] + BaseMemoryLib + BsdSocketLib + DebugLib + EfiSocketLib + LibC + LibMath + ShellCEntryLib + UefiBootServicesTableLib + UefiLib +# UseSocketDxe + +[BuildOptions] + INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186 + MSFT:*_*_*_CC_FLAGS = /Od + GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable + diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln new file mode 100644 index 0000000000..e16b5fd505 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OobTx", "OobTx.vcproj", "{C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Debug|Win32.ActiveCfg = Debug|Win32 + {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Debug|Win32.Build.0 = Debug|Win32 + {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Release|Win32.ActiveCfg = Release|Win32 + {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo new file mode 100644 index 0000000000000000000000000000000000000000..0ded407845d579326931054543c91d9156980949 GIT binary patch literal 38218 zcmeI*37k*W|3C203`LO;3ei|X_TAWLBVO>LKbQu0+Hk;t>rH35bS>Mu^6UCWxj8Zu|e%scmQ|eo{j**z**m!$V`S z#~GjUq1FV)hJC@QrcDnGXgj*ihNw)K>B^FkIa{N|p`k%I&MBdO$TbX&In^ru@LoRj zKtcIT|1iT}0P8NN_MzUP5uw4M=AnT|Q$ro_I|&_5*B7e9iXH zZDjjrKfwK?vkzc;J<|CIZ~t5;`+$?%|J^Vy0=kH&ldr2RL;@>e06BU&I@B3dC@BibNXemkV?5gicMB03>DBf22EBCbYs zLv%;x1xRWgonVz|u>#1bhu z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g/Applications/Sockets/OobTx/Windows/OobTx.vcproj b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj new file mode 100644 index 0000000000..d53149c5d4 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/main.c b/AppPkg/Applications/Sockets/OobTx/Windows/main.c new file mode 100644 index 0000000000..cf149c4027 --- /dev/null +++ b/AppPkg/Applications/Sockets/OobTx/Windows/main.c @@ -0,0 +1,56 @@ +/** @file + Windows version of the OOB Transmit application + + 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 + + +/** + Transmit out-of-band messages to the remote system. + + @param [in] Argc The number of arguments + @param [in] Argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main( + int argc, + char ** argv + ) +{ + int RetVal; + WSADATA WsaData; + + // + // Initialize the WinSock layer + // + RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData ); + if ( 0 == RetVal ) { + // + // Start the application + // + RetVal = OobTx ( argc, argv ); + + // + // Done with the WinSock layer + // + WSACleanup ( ); + } + + // + // Return the final result + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Main.c b/AppPkg/Applications/Sockets/RawIp4Rx/Main.c new file mode 100644 index 0000000000..21d4827466 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/Main.c @@ -0,0 +1,44 @@ +/** @file + Raw IP4 receive test application + + 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 "RawIp4Rx.h" + + +/** + Receive raw datagrams from a remote system. + + @param [in] Argc The number of arguments + @param [in] Argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main ( + IN int Argc, + IN char **Argv + ) +{ + int RetVal; + + // + // Run the application + // + RetVal = RawIp4Rx ( Argc, Argv ); + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c new file mode 100644 index 0000000000..9b6725fcd2 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c @@ -0,0 +1,188 @@ +/** @file + Raw IP4 receive application + + 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 "RawIp4Rx.h" + +UINT8 mBuffer[65536]; + + +/** + Run the raw IP4 receive application + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ +int +RawIp4Rx ( + IN int ArgC, + IN char **ArgV + ) +{ + ssize_t BytesReceived; + struct sockaddr_in LocalPort; + socklen_t LocalPortLength; + struct sockaddr_in RemotePort; + socklen_t RemotePortLength; + int RetVal; + SOCKET s; + UINT64 TotalBytesReceived; + + // + // Create the socket + // + s = socket ( AF_INET, SOCK_RAW, RAW_PROTOCOL ); + if ( -1 == s ) { + RetVal = GET_ERRNO; + printf ( "ERROR - socket error, errno: %d\r\n", RetVal ); + } + else { + // + // Use for/break; instead of goto + // + for ( ; ; ) { + // + // Bind the socket to a known port + // + memset ( &LocalPort, 0, sizeof ( LocalPort )); + SIN_LEN ( LocalPort ) = sizeof ( LocalPort ); + SIN_FAMILY ( LocalPort ) = AF_INET; + SIN_ADDR ( LocalPort ) = 0; + SIN_PORT ( LocalPort ) = 0; + RetVal = bind ( s, + (struct sockaddr *)&LocalPort, + sizeof ( LocalPort )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - bind error, errno: %d\r\n", RetVal ); + break; + } + + // + // Display the local address and protocol + // + LocalPortLength = sizeof ( LocalPort ); + RetVal = getsockname ( s, (struct sockaddr *)&LocalPort, &LocalPortLength ); + if ( 0 != RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - getsockname error, errno: %d\r\n", RetVal ); + break; + } + printf ( "Local Address: %d.%d.%d.%d, Protocol: %d\r\n", + (UINT8)SIN_ADDR ( LocalPort ), + (UINT8)( SIN_ADDR ( LocalPort ) >> 8 ), + (UINT8)( SIN_ADDR ( LocalPort ) >> 16 ), + (UINT8)( SIN_ADDR ( LocalPort ) >> 24 ), + RAW_PROTOCOL ); + + // + // Use for/break instead of goto + // + TotalBytesReceived = 0; + for ( ; ; ) { + // + // Receive data from the remote system + // + do { + // + // Attempt to receive a packet + // + RemotePortLength = sizeof ( RemotePort ); + BytesReceived = recvfrom ( s, + &mBuffer[0], + sizeof ( mBuffer ), + 0, + (struct sockaddr *)&RemotePort, + &RemotePortLength ); + RetVal = (UINT32)BytesReceived; + if ( 0 < BytesReceived ) { + // + // Display the received data + // + printf ( "%4d bytes received from %d.%d.%d.%d:%d\r\n" + "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\r\n" + "%02x %02x %02x %02x\r\n", + (UINT32)BytesReceived, + (UINT8)SIN_ADDR ( RemotePort ), + (UINT8)( SIN_ADDR ( RemotePort ) >> 8 ), + (UINT8)( SIN_ADDR ( RemotePort ) >> 16 ), + (UINT8)( SIN_ADDR ( RemotePort ) >> 24 ), + SIN_PORT ( RemotePort ), + mBuffer[0], + mBuffer[1], + mBuffer[2], + mBuffer[3], + mBuffer[4], + mBuffer[5], + mBuffer[6], + mBuffer[7], + mBuffer[8], + mBuffer[9], + mBuffer[10], + mBuffer[11], + mBuffer[12], + mBuffer[13], + mBuffer[14], + mBuffer[15], + mBuffer[16], + mBuffer[17], + mBuffer[18], + mBuffer[19]); + TotalBytesReceived += BytesReceived; + + // + // All done when the correct packet is received + // + if ( mBuffer[9] == RAW_PROTOCOL ) { + break; + } + } + else if ( -1 == BytesReceived ) { + // + // Check for a timeout + // + RetVal = GET_ERRNO; + printf ( "ERROR - recv error, errno: %d\r\n", RetVal ); + break; + } + } while ( 0 != RetVal ); + + // + // Display the bytes received + // + if ( 0 == RetVal ) { + printf ( "Total Bytes Received: %Ld\r\n", TotalBytesReceived ); + } + + // + // Test complete + // + break; + } + break; + } + + // + // Close the socket + // + CLOSE_SOCKET ( s ); + printf ( "Socket closed\r\n" ); + } + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h new file mode 100644 index 0000000000..679692c176 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h @@ -0,0 +1,98 @@ +/** @file + Definitions for the raw IP4 receive application + + 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. + +**/ + +#ifndef _RAW_IP4_RX_H_ +#define _RAW_IP4_RX_H_ + +//------------------------------------------------------------------------------ +// Include Files +//------------------------------------------------------------------------------ + +#ifdef BUILD_FOR_WINDOWS +// +// Build for Windows environment +// + +#include + +#define CLOSE_SOCKET closesocket +#define SIN_ADDR(port) port.sin_addr.S_un.S_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_family +#define SIN_PORT(port) port.sin_port +#define GET_ERRNO WSAGetLastError ( ) + +#define ssize_t int +#define socklen_t int + +#else // BUILD_FOR_WINDOWS +// +// Build for EFI environment +// + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#define CLOSE_SOCKET close +#define SIN_ADDR(port) port.sin_addr.s_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_len +#define SIN_PORT(port) port.sin_port +#define SOCKET int +#define GET_ERRNO errno + +#endif // BUILD_FOR_WINDOWS + +#include + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +// +// See http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml +// and http://tools.ietf.org/html/rfc3692 +// +#define RAW_PROTOCOL 253 + +//------------------------------------------------------------------------------ +// API +//------------------------------------------------------------------------------ + +/** + Run the raw IP4 receive application + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +RawIp4Rx ( + IN int ArgC, + IN char **ArgV + ); + +//------------------------------------------------------------------------------ + +#endif // _RAW_IP4_RX_H_ diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf new file mode 100644 index 0000000000..4eba247f34 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf @@ -0,0 +1,64 @@ +#/** @file +# RawIp4 Application +# +# This file contains an 'Intel Peripheral Driver' and is +# licensed for Intel CPUs and chipsets under the terms of your +# license agreement with Intel or your vendor. This file may +# be modified by the user, subject to additional terms of the +# license agreement +# +# +# Copyright (c) 20011 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +## + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RawIp4Rx + FILE_GUID = 8D7AE6A9-B490-45e1-8795-C2BEAADC3814 + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = ShellCEntryLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + Main.c + RawIp4Rx.c + + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + StdLib/StdLib.dec + + +[LibraryClasses] + BaseMemoryLib + BsdSocketLib + DebugLib + EfiSocketLib + LibC + LibMath + ShellCEntryLib + UefiBootServicesTableLib + UefiLib +# UseSocketDxe + +[BuildOptions] + INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186 + MSFT:*_*_*_CC_FLAGS = /Od + GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable + diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln new file mode 100644 index 0000000000..5c2b797347 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RawIp4Rx", "RawIp4Rx.vcproj", "{FAD3909F-E05E-4A2A-9681-7C474EAC5025}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Debug|Win32.ActiveCfg = Debug|Win32 + {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Debug|Win32.Build.0 = Debug|Win32 + {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Release|Win32.ActiveCfg = Release|Win32 + {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj new file mode 100644 index 0000000000..f0f61c4e25 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c new file mode 100644 index 0000000000..d198db9ff0 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c @@ -0,0 +1,61 @@ +/** @file + Windows version of the raw IP4 receive application + + 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 + + +/** + Receive raw IP4 packets from a remote system. + + Please note that this program must be run with administrator privileges! + + @param [in] argc The number of arguments + @param [in] argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main( + int argc, + char ** argv + ) +{ + int RetVal; + WSADATA WsaData; + + // + // Initialize the WinSock layer + // + RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData ); + if ( 0 == RetVal ) { + // + // Start the application + // + RetVal = RawIp4Rx ( argc, argv ); + if ( WSAEACCES == RetVal ) { + printf ( "Requires administrator privileges to run!\r\n" ); + } + + // + // Done with the WinSock layer + // + WSACleanup ( ); + } + + // + // Return the final result + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Main.c b/AppPkg/Applications/Sockets/RawIp4Tx/Main.c new file mode 100644 index 0000000000..cec5cd7d61 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/Main.c @@ -0,0 +1,44 @@ +/** @file + Raw IP4 transmit test application + + 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 "RawIp4Tx.h" + + +/** + Transmit raw IP4 packets to the remote system. + + @param [in] Argc The number of arguments + @param [in] Argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main ( + IN int Argc, + IN char **Argv + ) +{ + int RetVal; + + // + // Run the application + // + RetVal = RawIp4Tx ( Argc, Argv ); + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c new file mode 100644 index 0000000000..aea946c27c --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c @@ -0,0 +1,157 @@ +/** @file + Raw IP4 transmit application + + 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 "RawIp4Tx.h" + +UINT8 mBuffer[1024]; + +/** + Transmit raw IP4 packets to the remote system. + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +RawIp4Tx ( + IN int ArgC, + IN char **ArgV + ) +{ + UINT32 BytesSent; + ssize_t BytesTransmitted; + struct sockaddr_in LocalPort; + UINT32 RemoteAddress[4]; + struct sockaddr_in RemotePort; + int RetVal; + UINT32 TotalSent; + SOCKET s; + + // + // Create the socket + // + s = socket ( AF_INET, SOCK_RAW, RAW_PROTOCOL ); + if ( -1 == s ) { + RetVal = GET_ERRNO; + printf ( "ERROR - socket error, errno: %d\r\n", RetVal ); + } + else { + // + // Use for/break; instead of goto + // + for ( ; ; ) { + // + // Validate the arguments + // + if (( 2 > ArgC ) + || ( 4 != sscanf ( ArgV[1], + "%d.%d.%d.%d", + &RemoteAddress[0], + &RemoteAddress[1], + &RemoteAddress[2], + &RemoteAddress[3])) + || ( 224 < RemoteAddress[0]) + || ( 255 < RemoteAddress[1]) + || ( 255 < RemoteAddress[2]) + || ( 255 < RemoteAddress[3]) + || (( 0 == RemoteAddress[0]) + && ( 0 == RemoteAddress[1]) + && ( 0 == RemoteAddress[2]) + && ( 0 == RemoteAddress[3]))) { + printf ( "%s \r\n", ArgV[0]); + RetVal = EINVAL; + break; + } + + // + // Bind the socket to a local port + // + memset ( &LocalPort, 0, sizeof ( LocalPort )); + SIN_LEN ( LocalPort ) = sizeof ( LocalPort ); + SIN_FAMILY ( LocalPort ) = AF_INET; + SIN_ADDR ( LocalPort ) = 0; + SIN_PORT ( LocalPort ) = 0; + RetVal = bind ( s, + (struct sockaddr *)&LocalPort, + sizeof ( LocalPort )); + if ( -1 == RetVal ) { + RetVal = GET_ERRNO; + printf ( "ERROR - bind error, errno: %d\r\n", RetVal ); + break; + } + + // + // Specify the remote port + // + memset ( &RemotePort, 0, sizeof ( RemotePort )); + SIN_LEN ( RemotePort ) = sizeof ( RemotePort ); + SIN_FAMILY ( RemotePort ) = AF_INET; + SIN_ADDR ( RemotePort ) = ( RemoteAddress[3] << 24 ) + | ( RemoteAddress[2] << 16 ) + | ( RemoteAddress[1] << 8 ) + | RemoteAddress[0]; + SIN_PORT ( RemotePort ) = 0; + + // + // Initialize the messages + // + memset ( &mBuffer[0], 0, sizeof ( mBuffer )); + + // + // Send the data before the out-of-band message + // + TotalSent = 0; + BytesSent = 0; + do { + BytesTransmitted = sendto ( s, + &mBuffer[BytesSent], + sizeof ( mBuffer ) - BytesSent, + 0, + (struct sockaddr *)&RemotePort, + sizeof ( RemotePort )); + if ( -1 == BytesTransmitted ) { + RetVal = GET_ERRNO; + printf ( "ERROR - send before error, errno: %d\r\n", RetVal ); + break; + } + BytesSent += (UINT32)BytesTransmitted; + RetVal = 0; + } while ( sizeof ( mBuffer ) > BytesSent ); + if ( 0 != RetVal ) { + break; + } + TotalSent += BytesSent; + + // + // Test completed successfully + // + if ( 0 == RetVal ) { + printf ( "Bytes sent: %8d\r\n", TotalSent ); + } + break; + } + + // + // Close the socket + // + CLOSE_SOCKET ( s ); + } + + // + // Return the operation status + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h new file mode 100644 index 0000000000..c37b718c5d --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h @@ -0,0 +1,98 @@ +/** @file + Definitions for the raw IP4 transmit application + + 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. + +**/ + +#ifndef _RAW_IP4_TX_H_ +#define _RAW_IP4_TX_H_ + +//------------------------------------------------------------------------------ +// Include Files +//------------------------------------------------------------------------------ + +#ifdef BUILD_FOR_WINDOWS +// +// Build for Windows environment +// + +#include + +#define CHAR8 char +#define CLOSE_SOCKET closesocket +#define EINVAL 22 // Invalid argument +#define GET_ERRNO WSAGetLastError ( ) +#define SIN_ADDR(port) port.sin_addr.S_un.S_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_family +#define SIN_PORT(port) port.sin_port +#define socklen_t int +#define ssize_t int + +#else // BUILD_FOR_WINDOWS +// +// Build for EFI environment +// + +#include +#include +#include + +#include + +#include +#include +#include + +#define CLOSE_SOCKET close +#define GET_ERRNO errno +#define SIN_ADDR(port) port.sin_addr.s_addr +#define SIN_FAMILY(port) port.sin_family +#define SIN_LEN(port) port.sin_len +#define SIN_PORT(port) port.sin_port +#define SOCKET int + +#endif // BUILD_FOR_WINDOWS + +#include + +//------------------------------------------------------------------------------ +// Constants +//------------------------------------------------------------------------------ + +// +// See http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml +// and http://tools.ietf.org/html/rfc3692 +// +#define RAW_PROTOCOL 253 + +//------------------------------------------------------------------------------ +// API +//------------------------------------------------------------------------------ + +/** + Transmit raw IP4 packets to the remote system. + + @param [in] ArgC Argument count + @param [in] ArgV Argument value array + + @retval 0 Successfully operation + **/ + +int +RawIp4Tx ( + IN int ArgC, + IN char **ArgV + ); + +//------------------------------------------------------------------------------ + +#endif // _RAW_IP4_TX_H_ \ No newline at end of file diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf new file mode 100644 index 0000000000..5452df08f6 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf @@ -0,0 +1,64 @@ +#/** @file +# RawIp4Tx Application +# +# This file contains an 'Intel Peripheral Driver' and is +# licensed for Intel CPUs and chipsets under the terms of your +# license agreement with Intel or your vendor. This file may +# be modified by the user, subject to additional terms of the +# license agreement +# +# +# Copyright (c) 20011 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +## + + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = RawIp4Tx + FILE_GUID = 3DFE0FAB-70C7-4b53-9855-985F14DB2DDA + MODULE_TYPE = UEFI_APPLICATION + VERSION_STRING = 1.0 + ENTRY_POINT = ShellCEntryLib + +# +# The following information is for reference only and not required by the build tools. +# +# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# + +[Sources] + Main.c + RawIp4Tx.c + + +[Packages] + MdePkg/MdePkg.dec + ShellPkg/ShellPkg.dec + StdLib/StdLib.dec + + +[LibraryClasses] + BaseMemoryLib + BsdSocketLib + DebugLib + EfiSocketLib + LibC + LibMath + ShellCEntryLib + UefiBootServicesTableLib + UefiLib +# UseSocketDxe + +[BuildOptions] + INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186 + MSFT:*_*_*_CC_FLAGS = /Od + GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable + diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln new file mode 100644 index 0000000000..d5a5d37de4 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RawIp4Tx", "RawIp4Tx.vcproj", "{11018D35-F3E3-40F4-9213-7D277AF01A17}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {11018D35-F3E3-40F4-9213-7D277AF01A17}.Debug|Win32.ActiveCfg = Debug|Win32 + {11018D35-F3E3-40F4-9213-7D277AF01A17}.Debug|Win32.Build.0 = Debug|Win32 + {11018D35-F3E3-40F4-9213-7D277AF01A17}.Release|Win32.ActiveCfg = Release|Win32 + {11018D35-F3E3-40F4-9213-7D277AF01A17}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj new file mode 100644 index 0000000000..87d3d5d42d --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c new file mode 100644 index 0000000000..23946ac765 --- /dev/null +++ b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c @@ -0,0 +1,62 @@ +/** @file + Windows version of the raw IP4 transmit application + + 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 + + +/** + Transmit raw IP4 packets to the remote system. + + Please note that this program must be run with administrator privileges! + + @param [in] argc The number of arguments + @param [in] argv The argument value array + + @retval 0 The application exited normally. + @retval Other An error occurred. +**/ +int +main( + int argc, + char ** argv + ) +{ + int RetVal; + WSADATA WsaData; + + // + // Initialize the WinSock layer + // + RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData ); + if ( 0 == RetVal ) { + // + // Start the application + // See http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx + // + RetVal = RawIp4Tx ( argc, argv ); + if ( WSAEACCES == RetVal ) { + printf ( "Requires administrator privileges to run!\r\n" ); + } + + // + // Done with the WinSock layer + // + WSACleanup ( ); + } + + // + // Return the final result + // + return RetVal; +} diff --git a/AppPkg/Applications/Sockets/ReadMe.txt b/AppPkg/Applications/Sockets/ReadMe.txt new file mode 100644 index 0000000000..0f6a162d60 --- /dev/null +++ b/AppPkg/Applications/Sockets/ReadMe.txt @@ -0,0 +1,11 @@ +Users of the socket library need to do the following: + +• Use the development branch: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK/ +• Create an Efi\etc directory on their system or USB flash device +• Copy the files from StdLib\Efi\etc into that directory +• Edit the files appropriately + o Set the correct DNS servers in resolv.conf + o Set the search order in host.conf +• At the EFI shell + o Set the device containing the \Efi directory as the default device + o Run the socket application diff --git a/AppPkg/Applications/Sockets/RecvDgram/RecvDgram.c b/AppPkg/Applications/Sockets/RecvDgram/RecvDgram.c index 7809e80ff8..695db938b9 100644 --- a/AppPkg/Applications/Sockets/RecvDgram/RecvDgram.c +++ b/AppPkg/Applications/Sockets/RecvDgram/RecvDgram.c @@ -25,7 +25,7 @@ #include #include -UINT8 mBuffer [ 65536 ]; +UINT8 mBuffer[ 65536 ]; /** Receive a datagram diff --git a/AppPkg/Applications/Sockets/SetHostName/SetHostName.c b/AppPkg/Applications/Sockets/SetHostName/SetHostName.c index 85dc1c43fe..2986b66bab 100644 --- a/AppPkg/Applications/Sockets/SetHostName/SetHostName.c +++ b/AppPkg/Applications/Sockets/SetHostName/SetHostName.c @@ -22,7 +22,7 @@ #include -char mBuffer [65536]; +char mBuffer[65536]; /** diff --git a/AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.c b/AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.c index fdc4552b60..dbecda35ac 100644 --- a/AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.c +++ b/AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.c @@ -39,7 +39,7 @@ typedef struct { DATA_TYPE DataType; } OPTIONS; -CONST OPTIONS mOptions [] = { +CONST OPTIONS mOptions[] = { { "SO_ACCEPTCONN", SO_ACCEPTCONN, SOL_SOCKET, FALSE, DATA_TYPE_UNKNOWN }, { "SO_BROADCAST", SO_BROADCAST, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN }, { "SO_DEBUG", SO_DEBUG, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN }, @@ -62,9 +62,9 @@ CONST OPTIONS mOptions [] = { }; -UINT8 mBuffer [ 65536 ]; -UINT8 mValue [ 65536 ]; -char * mSocketType [] = { +UINT8 mBuffer[ 65536 ]; +UINT8 mValue[ 65536 ]; +char * mSocketType[] = { "SOCK_STREAM", "SOCK_DGRAM", "SOCK_RAW", @@ -103,11 +103,10 @@ DisplayOption ( // Display the value // Value.u8 = &mBuffer[0]; - switch ( pOption->DataType ) - { + switch ( pOption->DataType ) { case DATA_TYPE_UNKNOWN: Print ( L"%a:", pOption->pOptionName ); - pEnd = &Value.u8 [ LengthInBytes ]; + pEnd = &Value.u8[ LengthInBytes ]; while ( pEnd > Value.u8 ) { Print ( L" %02x", *Value.u8 ); Value.u8 += 1; @@ -127,7 +126,7 @@ DisplayOption ( case DATA_TYPE_SOCKET_TYPE: if ( 4 == LengthInBytes ) { if (( SOCK_STREAM <= *Value.i32 ) && ( SOCK_SEQPACKET >= *Value.i32 )) { - pString = mSocketType [ *Value.i32 - SOCK_STREAM ]; + pString = mSocketType[ *Value.i32 - SOCK_STREAM ]; Print ( L"%a", pString ); } else { @@ -295,7 +294,7 @@ main ( // BytesToWrite = 0; if (( 3 > Argc ) - || ( 0 < ( BytesToWrite = GetOptionValue ( pOption, Argv [2])))) { + || ( 0 < ( BytesToWrite = GetOptionValue ( pOption, Argv[2])))) { // // Get the socket // diff --git a/AppPkg/Applications/Sockets/Sockets.inc b/AppPkg/Applications/Sockets/Sockets.inc index fa5ff478d1..c1bd8bcc4e 100644 --- a/AppPkg/Applications/Sockets/Sockets.inc +++ b/AppPkg/Applications/Sockets/Sockets.inc @@ -13,6 +13,10 @@ AppPkg/Applications/Sockets/GetNetByName/GetNetByName.inf AppPkg/Applications/Sockets/GetServByName/GetServByName.inf AppPkg/Applications/Sockets/GetServByPort/GetServByPort.inf + AppPkg/Applications/Sockets/OobRx/OobRx.inf + AppPkg/Applications/Sockets/OobTx/OobTx.inf + AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf + AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf AppPkg/Applications/Sockets/RecvDgram/RecvDgram.inf AppPkg/Applications/Sockets/SetHostName/SetHostName.inf AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.inf diff --git a/AppPkg/Applications/Sockets/TftpServer/TftpServer.c b/AppPkg/Applications/Sockets/TftpServer/TftpServer.c index 9b522d1b55..1da3c250d5 100644 --- a/AppPkg/Applications/Sockets/TftpServer/TftpServer.c +++ b/AppPkg/Applications/Sockets/TftpServer/TftpServer.c @@ -846,8 +846,7 @@ Print ( L"TFTP Opcode: 0x%08x\r\n", Opcode ); bIgnorePacket = TRUE; break; } - if ( pTftpServer->RxBytes > (ssize_t)( pContext->BlockSize + 2 + 2 )) - { + if ( pTftpServer->RxBytes > (ssize_t)( pContext->BlockSize + 2 + 2 )) { DEBUG (( DEBUG_ERROR, "ERROR - Receive data length of %d > %d bytes (maximum block size) for pContext 0x%08x\r\n", pTftpServer->RxBytes - 2 - 2, @@ -1049,8 +1048,7 @@ pContext->File = (EFI_HANDLE)1; "ACK for block 0x%04x received\r\n", BlockNumber )); if (( !pContext->bExpectAck ) - || ( BlockNumber != pContext->AckNext )) - { + || ( BlockNumber != pContext->AckNext )) { DEBUG (( DEBUG_WARN | DEBUG_TFTP_ACK, "WARNING - Expecting ACK 0x%0x4 not received ACK 0x%08x\r\n", pContext->AckNext, @@ -1248,8 +1246,7 @@ TftpServerTimer ( pTftpServer->TftpPort.fd = socket ( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); - if ( -1 != pTftpServer->TftpPort.fd ) - { + if ( -1 != pTftpServer->TftpPort.fd ) { // // Set the socket address // diff --git a/AppPkg/Applications/Sockets/TftpServer/TftpServer.h b/AppPkg/Applications/Sockets/TftpServer/TftpServer.h index e56d21be78..b1e9f83ce5 100644 --- a/AppPkg/Applications/Sockets/TftpServer/TftpServer.h +++ b/AppPkg/Applications/Sockets/TftpServer/TftpServer.h @@ -62,12 +62,12 @@ // Constants //------------------------------------------------------------------------------ -#define DEBUG_SOCKET_POLL 0x40000000 ///< Display the socket poll messages -#define DEBUG_PORT_WORK 0x20000000 ///< Display the port work messages -#define DEBUG_SERVER_TIMER 0x10000000 ///< Display the socket poll messages -#define DEBUG_TFTP_PORT 0x08000000 ///< Display the TFTP port messages -#define DEBUG_TFTP_REQUEST 0x04000000 ///< Display the TFTP request messages -#define DEBUG_TX 0x02000000 ///< Display transmit messages +#define DEBUG_PORT_WORK 0x40000000 ///< Display the port work messages +#define DEBUG_SERVER_TIMER 0x20000000 ///< Display the socket poll messages +#define DEBUG_TFTP_PORT 0x10000000 ///< Display the TFTP port messages +#define DEBUG_TFTP_REQUEST 0x08000000 ///< Display the TFTP request messages +#define DEBUG_TX 0x04000000 ///< Display transmit messages +#define DEBUG_SOCKET_POLL 0x02000000 ///< Display the socket poll messages #define DEBUG_RX 0x01000000 ///< Display receive messages #define DEBUG_TFTP_ACK 0x00800000 ///< Display the TFTP ACK messages @@ -155,13 +155,13 @@ typedef struct _TSDT_CONNECTION_CONTEXT { BOOLEAN bEofSent; ///< End of file sent UINT8 * pBuffer; ///< Pointer into the file data UINT8 * pEnd; ///< End of the file data - UINT8 FileData [ 64 * TFTP_MAX_BLOCK_SIZE ]; ///< File data to send + UINT8 FileData[ 64 * TFTP_MAX_BLOCK_SIZE ]; ///< File data to send // // Buffer management // ssize_t TxBytes; ///< Bytes in the TX buffer - UINT8 TxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Transmit buffer + UINT8 TxBuffer[ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Transmit buffer }GCC_TSDT_CONNECTION_CONTEXT; /** @@ -188,7 +188,7 @@ typedef struct { // struct sockaddr_in RemoteAddress; ///< Remote address ssize_t RxBytes; ///< Receive data length in bytes - UINT8 RxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Receive buffer + UINT8 RxBuffer[ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Receive buffer // // Client port management diff --git a/AppPkg/Applications/Sockets/WebServer/ACPI.c b/AppPkg/Applications/Sockets/WebServer/ACPI.c index bcb56d0ded..c6caa1a568 100644 --- a/AppPkg/Applications/Sockets/WebServer/ACPI.c +++ b/AppPkg/Applications/Sockets/WebServer/ACPI.c @@ -106,19 +106,19 @@ typedef struct { UINT16 IapcBootArch; // 109 UINT8 Reserved2; // 111 UINT32 Flags; // 112 - UINT32 ResetReg [3]; // 116 + UINT32 ResetReg[3]; // 116 UINT8 ResetValue; // 128 - UINT8 Reserved3 [3]; // 129 + UINT8 Reserved3[3]; // 129 UINT64 XFirmwareCtrl; // 132 UINT64 XDsdt; // 140 - UINT32 XPm1aEvtBlk [3]; // 148 - UINT32 XPm1bEvtBlk [3]; // 160 - UINT32 XPm1aCntBlk [3]; // 172 - UINT32 XPm1bCntBlk [3]; // 184 - UINT32 XPm2CntBlk [3]; // 196 - UINT32 XPmTmrBlk [3]; // 208 - UINT32 XGpe0Blk [3]; // 220 - UINT32 XGpe1Blk [3]; // 232 + UINT32 XPm1aEvtBlk[3]; // 148 + UINT32 XPm1bEvtBlk[3]; // 160 + UINT32 XPm1aCntBlk[3]; // 172 + UINT32 XPm1bCntBlk[3]; // 184 + UINT32 XPm2CntBlk[3]; // 196 + UINT32 XPmTmrBlk[3]; // 208 + UINT32 XGpe0Blk[3]; // 220 + UINT32 XGpe1Blk[3]; // 232 } ACPI_FADT; @@ -146,7 +146,7 @@ typedef struct { } TABLE_SIGNATURE; -CONST TABLE_SIGNATURE mTableId [] = { +CONST TABLE_SIGNATURE mTableId[] = { { DSDT_SIGNATURE, "DSDT", PAGE_ACPI_DSDT }, { FADT_SIGNATURE, "FADT", PAGE_ACPI_FADT } }; @@ -240,8 +240,8 @@ LocateTable ( // // Walk the list of entries // - pEntry = &pRsdt->Entry [ 0 ]; - pEnd = &pEntry [(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ]; + pEntry = &pRsdt->Entry[ 0 ]; + pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ]; while ( pEnd > pEntry ) { // // The entry is actually a 32-bit physical table address @@ -324,7 +324,7 @@ RowAnsiArray ( // Display the characters // pData = pChar; - pEnd = &pChar [ Length ]; + pEnd = &pChar[ Length ]; while ( pEnd > pData ) { Status = HttpSendCharacter ( SocketFD, pPort, @@ -440,7 +440,7 @@ RowBytes ( if ( EFI_ERROR ( Status )) { break; } - pEnd = &pData [ ByteCount ]; + pEnd = &pData[ ByteCount ]; while ( pEnd > pData ) { Status = HttpSendHexBits ( SocketFD, pPort, @@ -784,8 +784,8 @@ SignatureLookup ( // Walk the list of tables // Signature = *pSignature; - pTableId = &mTableId [ 0 ]; - pEnd = &pTableId [ sizeof ( mTableId ) / sizeof ( mTableId [ 0 ])]; + pTableId = &mTableId[ 0 ]; + pEnd = &pTableId[ sizeof ( mTableId ) / sizeof ( mTableId[ 0 ])]; while ( pEnd > pTableId ) { // // Attempt to locate the table signature @@ -895,7 +895,7 @@ AcpiDsdtPage ( pPort, "OEMID", sizeof ( pDsdt->OemId ), - &pDsdt->OemId [ 0 ]); + &pDsdt->OemId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -903,7 +903,7 @@ AcpiDsdtPage ( pPort, "OEM Table ID", sizeof ( pDsdt->OemTableId ), - &pDsdt->OemTableId [ 0 ]); + &pDsdt->OemTableId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1039,7 +1039,7 @@ AcpiFadtPage ( pPort, "OEMID", sizeof ( pFadt->OemId ), - &pFadt->OemId [ 0 ]); + &pFadt->OemId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1047,7 +1047,7 @@ AcpiFadtPage ( pPort, "OEM Table ID", sizeof ( pFadt->OemTableId ), - &pFadt->OemTableId [ 0 ]); + &pFadt->OemTableId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1576,7 +1576,7 @@ AcpiRsdp10Page ( pPort, "OemId", sizeof ( pRsdp10b->OemId ), - &pRsdp10b->OemId [ 0 ]); + &pRsdp10b->OemId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1679,7 +1679,7 @@ AcpiRsdp30Page ( pPort, "OemId", sizeof ( pRsdp30->OemId ), - &pRsdp30->OemId [ 0 ]); + &pRsdp30->OemId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1726,7 +1726,7 @@ AcpiRsdp30Page ( pPort, "Reserved", sizeof ( pRsdp30->Reserved ), - &pRsdp30->Reserved [ 0 ]); + &pRsdp30->Reserved[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1771,7 +1771,7 @@ AcpiRsdtPage ( CONST CHAR8 * pTableName; CONST CHAR16 * pWebPage; EFI_STATUS Status; - UINT32 TableName [ 2 ]; + UINT32 TableName[ 2 ]; DBG_ENTER ( ); @@ -1833,7 +1833,7 @@ AcpiRsdtPage ( pPort, "OEMID", sizeof ( pRsdt->OemId ), - &pRsdt->OemId [ 0 ]); + &pRsdt->OemId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1841,7 +1841,7 @@ AcpiRsdtPage ( pPort, "OEM Table ID", sizeof ( pRsdt->OemTableId ), - &pRsdt->OemTableId [ 0 ]); + &pRsdt->OemTableId[ 0 ]); if ( EFI_ERROR ( Status )) { break; } @@ -1871,16 +1871,16 @@ AcpiRsdtPage ( // // Walk the list of entries // - pEntry = &pRsdt->Entry [ 0 ]; - pEnd = &pEntry [(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ]; - TableName [ 1 ] = 0; + pEntry = &pRsdt->Entry[ 0 ]; + pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ]; + TableName[ 1 ] = 0; while ( pEnd > pEntry ) { // // The entry is actually a 32-bit physical table address // The first entry in the table is the 32-bit table signature // - TableName [ 0 ] = *(UINT32 *)*pEntry; - pWebPage = SignatureLookup ( &TableName [ 0 ], &pTableName ); + TableName[ 0 ] = *(UINT32 *)*pEntry; + pWebPage = SignatureLookup ( &TableName[ 0 ], &pTableName ); // // Display the table address diff --git a/AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c b/AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c index 8a3de87ed4..9208a46b5e 100644 --- a/AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c +++ b/AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c @@ -38,7 +38,7 @@ typedef struct { CHAR16 * pWebPage; } GUID_NAME; -CONST GUID_NAME mGuidName [] = { +CONST GUID_NAME mGuidName[] = { { L"gEfiAcpi10TableGuid", &gEfiAcpi10TableGuid, PAGE_ACPI_RSDP_10B }, { L"gEfiAcpiTableGuid", &gEfiAcpiTableGuid, PAGE_ACPI_RSDP_30 }, { L"gEfiDebugImageInfoTableGuid", &gEfiDebugImageInfoTableGuid, NULL }, @@ -101,7 +101,7 @@ RowGuid ( // Determine if this is a known GUID // pGuidName = &mGuidName[0]; - pGuidNameEnd = &pGuidName [ sizeof ( mGuidName ) / sizeof ( mGuidName[0])]; + pGuidNameEnd = &pGuidName[ sizeof ( mGuidName ) / sizeof ( mGuidName[0])]; while ( pGuidNameEnd > pGuidName ) { if ( CompareGuid ( pGuidName->pGuid, pGuid )) { // @@ -339,7 +339,7 @@ ConfigurationTablePage ( // Determine the location of the configuration tables // pTable = gST->ConfigurationTable; - pEnd = &pTable [ gST->NumberOfTableEntries ]; + pEnd = &pTable[ gST->NumberOfTableEntries ]; while ( pEnd > pTable ) { Status = RowGuid ( SocketFD, pPort, diff --git a/AppPkg/Applications/Sockets/WebServer/HTTP.c b/AppPkg/Applications/Sockets/WebServer/HTTP.c index 314705b68f..8487de751a 100644 --- a/AppPkg/Applications/Sockets/WebServer/HTTP.c +++ b/AppPkg/Applications/Sockets/WebServer/HTTP.c @@ -561,7 +561,7 @@ HttpRequest ( // Attempt to parse the command // pData = &pPort->Request[0]; - pEnd = &pData [ pPort->RequestLength ]; + pEnd = &pData[ pPort->RequestLength ]; pVerb = pData; pWebPage = HttpReplaceSpace ( pVerb, pEnd ); if ( pEnd <= pWebPage ) { @@ -589,7 +589,7 @@ HttpRequest ( // Walk the page table // pPage = &mPageList[0]; - pPageEnd = &pPage [ mPageCount ]; + pPageEnd = &pPage[ mPageCount ]; while ( pPageEnd > pPage ) { // // Determine if the page was located @@ -668,15 +668,14 @@ HttpSend ( // MaxBytes = sizeof ( pPort->TxBuffer ); DataBytes = MaxBytes - pPort->TxBytes; - if ( DataBytes > LengthInBytes ) - { + if ( DataBytes > LengthInBytes ) { DataBytes = LengthInBytes; } // // Copy the data into the buffer // - CopyMem ( &pPort->TxBuffer [ pPort->TxBytes ], + CopyMem ( &pPort->TxBuffer[ pPort->TxBytes ], pBuffer, DataBytes ); @@ -910,7 +909,7 @@ HttpSendDump ( // // Walk the bytes to be displayed // - pEnd = &pData [ ByteCount ]; + pEnd = &pData[ ByteCount ]; while ( pEnd > pData ) { // // Display the address @@ -958,7 +957,7 @@ HttpSendDump ( if (( BYTES_ON_A_LINE - InitialSpaces ) < BytesToDisplay ) { BytesToDisplay = BYTES_ON_A_LINE - InitialSpaces; } - pDataEnd = &pData [ BytesToDisplay ]; + pDataEnd = &pData[ BytesToDisplay ]; pTemp = pData; while ( pDataEnd > pTemp ) { Status = HttpSendHexBits ( SocketFD, @@ -1151,7 +1150,7 @@ HttpSendGuid ( Status = HttpSendHexBits ( SocketFD, pPort, 8, - pGuid->Data4 [ Index ]); + pGuid->Data4[ Index ]); if ( EFI_ERROR ( Status )) { break; } @@ -1488,7 +1487,7 @@ HttpSendValue ( UINT64 Digit; CONST UINT64 * pEnd; CONST UINT64 * pDivisor; - CONST UINT64 pDivisors [ ] = { + CONST UINT64 pDivisors[ ] = { 10000000000000000000L, 1000000000000000000L, 100000000000000000L, @@ -1522,7 +1521,7 @@ HttpSendValue ( // bDisplayZeros = FALSE; pDivisor = &pDivisors[0]; - pEnd = &pDivisor [ sizeof ( pDivisors ) / sizeof ( pDivisors [0])]; + pEnd = &pDivisor[ sizeof ( pDivisors ) / sizeof ( pDivisors[0])]; while ( pEnd > pDivisor ) { // // Determine the next digit diff --git a/AppPkg/Applications/Sockets/WebServer/PageList.c b/AppPkg/Applications/Sockets/WebServer/PageList.c index 5eccfb2181..f26ab0fdbb 100644 --- a/AppPkg/Applications/Sockets/WebServer/PageList.c +++ b/AppPkg/Applications/Sockets/WebServer/PageList.c @@ -29,7 +29,7 @@ Intel Corporation. /** List of pages in the system **/ -CONST DT_PAGE mPageList [] = { +CONST DT_PAGE mPageList[] = { // // The index page must be first diff --git a/AppPkg/Applications/Sockets/WebServer/WebServer.c b/AppPkg/Applications/Sockets/WebServer/WebServer.c index 00bf4b6fef..5c73bfe8f7 100644 --- a/AppPkg/Applications/Sockets/WebServer/WebServer.c +++ b/AppPkg/Applications/Sockets/WebServer/WebServer.c @@ -124,9 +124,9 @@ PortAdd ( // Initialize the new entries in the FD list // for ( ; MaxEntriesNew > Index; Index++ ) { - pFdListNew [ Index ].fd = -1; - pFdListNew [ Index ].events = 0; - pFdListNew [ Index ].revents = 0; + pFdListNew[ Index ].fd = -1; + pFdListNew[ Index ].events = 0; + pFdListNew[ Index ].revents = 0; } // @@ -156,7 +156,7 @@ PortAdd ( // Initialize the new entries in the port list // for ( ; MaxEntriesNew > Index; Index++ ) { - ppPortListNew [ Index ] = NULL; + ppPortListNew[ Index ] = NULL; } // @@ -200,15 +200,15 @@ PortAdd ( // // Add the socket to the FD list // - pFdList [ pWebServer->Entries ].fd = SocketFD; - pFdList [ pWebServer->Entries ].events = POLLRDNORM + pFdList[ pWebServer->Entries ].fd = SocketFD; + pFdList[ pWebServer->Entries ].events = POLLRDNORM | POLLHUP; - pFdList [ pWebServer->Entries ].revents = 0; + pFdList[ pWebServer->Entries ].revents = 0; // // Add the port to the port list // - pWebServer->ppPortList [ pWebServer->Entries ] = pPort; + pWebServer->ppPortList[ pWebServer->Entries ] = pPort; // // Account for the new entry @@ -263,7 +263,7 @@ PortRemove ( // // Locate the specified socket file descriptor // - if ( SocketFD == pFdList [ Index ].fd ) { + if ( SocketFD == pFdList[ Index ].fd ) { // // Determine if this is the listen port // @@ -279,7 +279,7 @@ PortRemove ( // // Free the port structure // - gBS->FreePool ( ppPortList [ Index ]); + gBS->FreePool ( ppPortList[ Index ]); // // Remove this port from the list by copying @@ -287,13 +287,13 @@ PortRemove ( // Entries -= 1; for ( ; Entries > Index; Index++ ) { - pFdList [ Index ] = pFdList [ Index + 1 ]; - ppPortList [ Index ] = ppPortList [ Index + 1 ]; + pFdList[ Index ] = pFdList[ Index + 1 ]; + ppPortList[ Index ] = ppPortList[ Index + 1 ]; } - pFdList [ Index ].fd = -1; - pFdList [ Index ].events = 0; - pFdList [ Index ].revents = 0; - ppPortList [ Index ] = NULL; + pFdList[ Index ].fd = -1; + pFdList[ Index ].events = 0; + pFdList[ Index ].revents = 0; + ppPortList[ Index ] = NULL; // // Update the number of entries in the list @@ -439,8 +439,7 @@ PortWork ( } } } - else - { + else { // // Receive the file data // @@ -610,8 +609,7 @@ WebServerTimer ( pWebServer->HttpListenPort = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP ); - if ( -1 != pWebServer->HttpListenPort ) - { + if ( -1 != pWebServer->HttpListenPort ) { // // Set the socket address // diff --git a/AppPkg/Applications/Sockets/WebServer/WebServer.h b/AppPkg/Applications/Sockets/WebServer/WebServer.h index 6078df0362..0eee114832 100644 --- a/AppPkg/Applications/Sockets/WebServer/WebServer.h +++ b/AppPkg/Applications/Sockets/WebServer/WebServer.h @@ -125,7 +125,7 @@ #endif // MDEPKG_NDEBUG -#define WEB_SERVER_SIGNATURE SIGNATURE_32('W','e','b','S') ///< DT_WEB_SERVER memory signature +#define WEB_SERVER_SIGNATURE SIGNATURE_32 ('W','e','b','S') ///< DT_WEB_SERVER memory signature #define SPACES_ADDRESS_TO_DATA 2 #define BYTES_ON_A_LINE 16 @@ -154,9 +154,9 @@ typedef struct { // size_t RequestLength; ///< Request length in bytes size_t TxBytes; ///< Bytes in the TX buffer - UINT8 Request [ 65536 ]; ///< Page request - UINT8 RxBuffer [ 65536 ]; ///< Receive buffer - UINT8 TxBuffer [ 65536 ]; ///< Transmit buffer + UINT8 Request[ 65536 ]; ///< Page request + UINT8 RxBuffer[ 65536 ]; ///< Receive buffer + UINT8 TxBuffer[ 65536 ]; ///< Transmit buffer } WSDT_PORT; /** @@ -186,7 +186,7 @@ typedef struct { WSDT_PORT ** ppPortList; ///< List of port management structures } DT_WEB_SERVER; -//#define SERVER_FROM_SERVICE(a) CR(a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding +//#define SERVER_FROM_SERVICE(a) CR (a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding extern DT_WEB_SERVER mWebServer; @@ -217,7 +217,7 @@ typedef struct { UINT16 * pDescription; ///< Description of the page } DT_PAGE; -extern CONST DT_PAGE mPageList []; ///< List of pages +extern CONST DT_PAGE mPageList[]; ///< List of pages extern CONST UINTN mPageCount; ///< Number of pages //------------------------------------------------------------------------------ -- 2.39.2