]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update the sockets applications
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Sep 2011 23:04:13 +0000 (23:04 +0000)
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 30 Sep 2011 23:04:13 +0000 (23:04 +0000)
* 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

52 files changed:
AppPkg/Applications/Sockets/DataSink/DataSink.c
AppPkg/Applications/Sockets/DataSource/DataSource.c
AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.c
AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.c
AppPkg/Applications/Sockets/GetHostByName/GetHostByName.c
AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.c
AppPkg/Applications/Sockets/GetNetByName/GetNetByName.c
AppPkg/Applications/Sockets/GetServByName/GetServByName.c
AppPkg/Applications/Sockets/GetServByPort/GetServByPort.c
AppPkg/Applications/Sockets/OobRx/Main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/OobRx.c [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/OobRx.h [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/OobRx.inf [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj [new file with mode: 0644]
AppPkg/Applications/Sockets/OobRx/Windows/main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/Main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/OobTx.c [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/OobTx.h [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/OobTx.inf [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj [new file with mode: 0644]
AppPkg/Applications/Sockets/OobTx/Windows/main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/Main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/Main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj [new file with mode: 0644]
AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c [new file with mode: 0644]
AppPkg/Applications/Sockets/ReadMe.txt [new file with mode: 0644]
AppPkg/Applications/Sockets/RecvDgram/RecvDgram.c
AppPkg/Applications/Sockets/SetHostName/SetHostName.c
AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.c
AppPkg/Applications/Sockets/Sockets.inc
AppPkg/Applications/Sockets/TftpServer/TftpServer.c
AppPkg/Applications/Sockets/TftpServer/TftpServer.h
AppPkg/Applications/Sockets/WebServer/ACPI.c
AppPkg/Applications/Sockets/WebServer/ConfigurationTable.c
AppPkg/Applications/Sockets/WebServer/HTTP.c
AppPkg/Applications/Sockets/WebServer/PageList.c
AppPkg/Applications/Sockets/WebServer/WebServer.c
AppPkg/Applications/Sockets/WebServer/WebServer.h

index 911cf369400e09aa15a35ac4d5d2d521c863953e..8223ead118079e3b652eb7d7f32c7d4ea122a4c2 100644 (file)
@@ -51,9 +51,9 @@ BOOLEAN bTimerRunning;
 struct sockaddr_in LocalAddress;\r
 EFI_EVENT pTimer;\r
 int ListenSocket;\r
-UINT8 Buffer [ DATA_BUFFER_SIZE ];\r
-struct pollfd PollFd [ MAX_CONNECTIONS ];\r
-DT_PORT Port [ MAX_CONNECTIONS ];\r
+UINT8 Buffer[ DATA_BUFFER_SIZE ];\r
+struct pollfd PollFd[ MAX_CONNECTIONS ];\r
+DT_PORT Port[ MAX_CONNECTIONS ];\r
 nfds_t MaxPort;\r
 \r
 \r
@@ -136,17 +136,17 @@ SocketAccept (
       //  Allocate a port\r
       //\r
       Index = MaxPort++;\r
-      PollFd [ Index ].fd = ListenSocket;\r
-      PollFd [ Index ].events = POLLRDNORM | POLLHUP;\r
-      PollFd [ Index ].revents = 0;\r
-      Port [ Index ].BytesAverage = 0;\r
-      Port [ Index ].BytesPrevious = 0;\r
-      Port [ Index ].BytesTotal = 0;\r
-      Port [ Index ].Samples = 0;\r
-      Port [ Index ].RemoteAddress.sin_len = 0;\r
-      Port [ Index ].RemoteAddress.sin_family = 0;\r
-      Port [ Index ].RemoteAddress.sin_port = 0;\r
-      Port [ Index ].RemoteAddress.sin_addr.s_addr= 0;\r
+      PollFd[ Index ].fd = ListenSocket;\r
+      PollFd[ Index ].events = POLLRDNORM | POLLHUP;\r
+      PollFd[ Index ].revents = 0;\r
+      Port[ Index ].BytesAverage = 0;\r
+      Port[ Index ].BytesPrevious = 0;\r
+      Port[ Index ].BytesTotal = 0;\r
+      Port[ Index ].Samples = 0;\r
+      Port[ Index ].RemoteAddress.sin_len = 0;\r
+      Port[ Index ].RemoteAddress.sin_family = 0;\r
+      Port[ Index ].RemoteAddress.sin_port = 0;\r
+      Port[ Index ].RemoteAddress.sin_addr.s_addr= 0;\r
     }\r
   }\r
 \r
@@ -242,8 +242,7 @@ SocketNew (
                 "0x%08x: Socket created\r\n",\r
                 ListenSocket ));\r
     }\r
-    else\r
-    {\r
+    else {\r
       Status = EFI_NOT_STARTED;\r
     }\r
   }\r
@@ -312,16 +311,16 @@ SocketPoll (
         //\r
         //  Account for this descriptor\r
         //\r
-        if ( 0 != PollFd [ Index ].revents ) {\r
+        if ( 0 != PollFd[ Index ].revents ) {\r
           FdCount -= 1;\r
         }\r
 \r
         //\r
         //  Check for a broken connection\r
         //\r
-        if ( 0 != ( PollFd [ Index ].revents & POLLHUP )) {\r
+        if ( 0 != ( PollFd[ Index ].revents & POLLHUP )) {\r
           bRemoveSocket = TRUE;\r
-          if ( ListenSocket == PollFd [ Index ].fd ) {\r
+          if ( ListenSocket == PollFd[ Index ].fd ) {\r
             bListenError = TRUE;\r
             DEBUG (( DEBUG_ERROR,\r
                       "ERROR - Network closed on listen socket, errno: %d\r\n",\r
@@ -330,37 +329,37 @@ SocketPoll (
           else {\r
             DEBUG (( DEBUG_ERROR,\r
                       "ERROR - Network closed on socket %d.%d.%d.%d:%d, errno: %d\r\n",\r
-                      Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                      ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                      ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                      ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                      htons ( Port [ Index ].RemoteAddress.sin_port ),\r
+                      Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                      ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                      ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                      ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                      htons ( Port[ Index ].RemoteAddress.sin_port ),\r
                       errno ));\r
 \r
             //\r
             //  Close the socket\r
             //\r
-            CloseStatus = close ( PollFd [ Index ].fd );\r
+            CloseStatus = close ( PollFd[ Index ].fd );\r
             if ( 0 == CloseStatus ) {\r
               bRemoveSocket = TRUE;\r
               DEBUG (( DEBUG_INFO,\r
                         "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n",\r
-                        PollFd [ Index ].fd,\r
-                        Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                        htons ( Port [ Index ].RemoteAddress.sin_port )));\r
+                        PollFd[ Index ].fd,\r
+                        Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                        htons ( Port[ Index ].RemoteAddress.sin_port )));\r
             }\r
             else {\r
               DEBUG (( DEBUG_ERROR,\r
                         "ERROR - Failed to close socket 0x%08x for %d.%d.%d.%d:%d, errno: %d\r\n",\r
-                        PollFd [ Index ].fd,\r
-                        Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                        htons ( Port [ Index ].RemoteAddress.sin_port ),\r
+                        PollFd[ Index ].fd,\r
+                        Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                        htons ( Port[ Index ].RemoteAddress.sin_port ),\r
                         errno ));\r
             }\r
           }\r
@@ -369,11 +368,11 @@ SocketPoll (
         //\r
         //  Check for a connection or read data\r
         //\r
-        if ( 0 != ( PollFd [ Index ].revents & POLLRDNORM )) {\r
+        if ( 0 != ( PollFd[ Index ].revents & POLLRDNORM )) {\r
           //\r
           //  Check for a connection\r
           //\r
-          if ( ListenSocket == PollFd [ Index ].fd ) {\r
+          if ( ListenSocket == PollFd[ Index ].fd ) {\r
             //\r
             //  Another client connection was received\r
             //\r
@@ -416,7 +415,7 @@ SocketPoll (
                   bRemoveSocket = TRUE;\r
                   DEBUG (( DEBUG_INFO,\r
                             "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n",\r
-                            PollFd [ Index ].fd,\r
+                            PollFd[ Index ].fd,\r
                             RemoteAddress.sin_addr.s_addr & 0xff,\r
                             ( RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
                             ( RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
@@ -426,7 +425,7 @@ SocketPoll (
                 else {\r
                   DEBUG (( DEBUG_ERROR,\r
                             "ERROR - Failed to close socket 0x%08x, errno: %d\r\n",\r
-                            PollFd [ Index ].fd,\r
+                            PollFd[ Index ].fd,\r
                             errno ));\r
                 }\r
 \r
@@ -436,8 +435,7 @@ SocketPoll (
                 //\r
                 Status = EFI_SUCCESS;\r
               }\r
-              else\r
-              {\r
+              else {\r
                 //\r
                 //  Display the connection\r
                 //\r
@@ -452,17 +450,17 @@ SocketPoll (
                 //  Allocate the client connection\r
                 //\r
                 Index = MaxPort++;\r
-                Port [ Index ].BytesAverage = 0;\r
-                Port [ Index ].BytesPrevious = 0;\r
-                Port [ Index ].BytesTotal = 0;\r
-                Port [ Index ].Samples = 0;\r
-                Port [ Index ].RemoteAddress.sin_len = RemoteAddress.sin_len;\r
-                Port [ Index ].RemoteAddress.sin_family = RemoteAddress.sin_family;\r
-                Port [ Index ].RemoteAddress.sin_port = RemoteAddress.sin_port;\r
-                Port [ Index ].RemoteAddress.sin_addr = RemoteAddress.sin_addr;\r
-                PollFd [ Index ].fd = Socket;\r
-                PollFd [ Index ].events = POLLRDNORM | POLLHUP;\r
-                PollFd [ Index ].revents = 0;\r
+                Port[ Index ].BytesAverage = 0;\r
+                Port[ Index ].BytesPrevious = 0;\r
+                Port[ Index ].BytesTotal = 0;\r
+                Port[ Index ].Samples = 0;\r
+                Port[ Index ].RemoteAddress.sin_len = RemoteAddress.sin_len;\r
+                Port[ Index ].RemoteAddress.sin_family = RemoteAddress.sin_family;\r
+                Port[ Index ].RemoteAddress.sin_port = RemoteAddress.sin_port;\r
+                Port[ Index ].RemoteAddress.sin_addr = RemoteAddress.sin_addr;\r
+                PollFd[ Index ].fd = Socket;\r
+                PollFd[ Index ].events = POLLRDNORM | POLLHUP;\r
+                PollFd[ Index ].revents = 0;\r
               }\r
             }\r
           }\r
@@ -470,7 +468,7 @@ SocketPoll (
             //\r
             //  Data received\r
             //\r
-            BytesReceived = read ( PollFd [ Index ].fd,\r
+            BytesReceived = read ( PollFd[ Index ].fd,\r
                                    &Buffer,\r
                                    sizeof ( Buffer ));\r
             if ( 0 < BytesReceived ) {\r
@@ -479,13 +477,13 @@ SocketPoll (
               //\r
               DEBUG (( DEBUG_INFO,\r
                         "0x%08x: Socket received 0x%08x bytes from %d.%d.%d.%d:%d\r\n",\r
-                        PollFd [ Index ].fd,\r
+                        PollFd[ Index ].fd,\r
                         BytesReceived,\r
-                        Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                        htons ( Port [ Index ].RemoteAddress.sin_port )));\r
+                        Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                        htons ( Port[ Index ].RemoteAddress.sin_port )));\r
 \r
               //\r
               //  Synchronize with the TimerCallback routine\r
@@ -495,7 +493,7 @@ SocketPoll (
               //\r
               //  Account for the data received\r
               //\r
-              Port [ Index ].BytesTotal += BytesReceived;\r
+              Port[ Index ].BytesTotal += BytesReceived;\r
 \r
               //\r
               //  Release the synchronization with the TimerCallback routine\r
@@ -508,33 +506,33 @@ SocketPoll (
               //\r
               DEBUG (( DEBUG_INFO,\r
                         "ERROR - Receive failure for %d.%d.%d.%d:%d, errno: %d\r\n",\r
-                        Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                        ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                        htons ( Port [ Index ].RemoteAddress.sin_port ),\r
+                        Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                        ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                        htons ( Port[ Index ].RemoteAddress.sin_port ),\r
                         errno ));\r
-              CloseStatus = close ( PollFd [ Index ].fd );\r
+              CloseStatus = close ( PollFd[ Index ].fd );\r
               if ( 0 == CloseStatus ) {\r
                 bRemoveSocket = TRUE;\r
                 DEBUG (( DEBUG_INFO,\r
                           "0x%08x: Socket closed for %d.%d.%d.%d:%d\r\n",\r
-                          PollFd [ Index ].fd,\r
-                          Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                          htons ( Port [ Index ].RemoteAddress.sin_port )));\r
+                          PollFd[ Index ].fd,\r
+                          Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                          htons ( Port[ Index ].RemoteAddress.sin_port )));\r
               }\r
               else {\r
                 DEBUG (( DEBUG_ERROR,\r
                           "ERROR - Failed to close socket 0x%08x for %d.%d.%d.%d:%d, errno: %d\r\n",\r
-                          PollFd [ Index ].fd,\r
-                          Port [ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
-                          ( Port [ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
-                          htons ( Port [ Index ].RemoteAddress.sin_port ),\r
+                          PollFd[ Index ].fd,\r
+                          Port[ Index ].RemoteAddress.sin_addr.s_addr & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 8 ) & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 16 ) & 0xff,\r
+                          ( Port[ Index ].RemoteAddress.sin_addr.s_addr >> 24 ) & 0xff,\r
+                          htons ( Port[ Index ].RemoteAddress.sin_port ),\r
                           errno ));\r
               }\r
             }\r
@@ -553,23 +551,23 @@ SocketPoll (
         if ( bRemoveSocket ) {\r
           DEBUG (( DEBUG_INFO,\r
                     "0x%08x: Socket removed from polling\r\n",\r
-                    PollFd [ Index ].fd ));\r
+                    PollFd[ Index ].fd ));\r
           MaxPort -= 1;\r
           for ( Entry = Index + 1; MaxPort >= Entry; Entry++ ) {\r
             EntryPrevious = Entry;\r
-            Port [ EntryPrevious ].BytesAverage = Port [ Entry ].BytesAverage;\r
-            Port [ EntryPrevious ].BytesPrevious = Port [ Entry ].BytesPrevious;\r
-            Port [ EntryPrevious ].BytesTotal = Port [ Entry ].BytesTotal;\r
-            Port [ EntryPrevious ].RemoteAddress.sin_len = Port [ Entry ].RemoteAddress.sin_len;\r
-            Port [ EntryPrevious ].RemoteAddress.sin_family = Port [ Entry ].RemoteAddress.sin_family;\r
-            Port [ EntryPrevious ].RemoteAddress.sin_port = Port [ Entry ].RemoteAddress.sin_port;\r
-            Port [ EntryPrevious ].RemoteAddress.sin_addr.s_addr = Port [ Entry ].RemoteAddress.sin_addr.s_addr;\r
-            Port [ EntryPrevious ].Samples = Port [ Entry ].Samples;\r
-            PollFd [ EntryPrevious ].events = PollFd [ Entry ].events;\r
-            PollFd [ EntryPrevious ].fd = PollFd [ Entry ].fd;\r
-            PollFd [ EntryPrevious ].revents = PollFd [ Entry ].revents;\r
+            Port[ EntryPrevious ].BytesAverage = Port[ Entry ].BytesAverage;\r
+            Port[ EntryPrevious ].BytesPrevious = Port[ Entry ].BytesPrevious;\r
+            Port[ EntryPrevious ].BytesTotal = Port[ Entry ].BytesTotal;\r
+            Port[ EntryPrevious ].RemoteAddress.sin_len = Port[ Entry ].RemoteAddress.sin_len;\r
+            Port[ EntryPrevious ].RemoteAddress.sin_family = Port[ Entry ].RemoteAddress.sin_family;\r
+            Port[ EntryPrevious ].RemoteAddress.sin_port = Port[ Entry ].RemoteAddress.sin_port;\r
+            Port[ EntryPrevious ].RemoteAddress.sin_addr.s_addr = Port[ Entry ].RemoteAddress.sin_addr.s_addr;\r
+            Port[ EntryPrevious ].Samples = Port[ Entry ].Samples;\r
+            PollFd[ EntryPrevious ].events = PollFd[ Entry ].events;\r
+            PollFd[ EntryPrevious ].fd = PollFd[ Entry ].fd;\r
+            PollFd[ EntryPrevious ].revents = PollFd[ Entry ].revents;\r
           }\r
-          PollFd [ MaxPort ].fd = -1;\r
+          PollFd[ MaxPort ].fd = -1;\r
           Index -= 1;\r
         }\r
 \r
@@ -625,31 +623,31 @@ TimerCallback (
     //\r
     //  Determine if any data was received\r
     //\r
-    BytesReceived = Port [ Index ].BytesTotal;\r
-    if (( ListenSocket != PollFd [ Index ].fd )\r
+    BytesReceived = Port[ Index ].BytesTotal;\r
+    if (( ListenSocket != PollFd[ Index ].fd )\r
       && ( 0 != BytesReceived )) {\r
       //\r
       //  Update the average bytes per second\r
       //\r
-      DeltaBytes = Port [ Index ].BytesAverage >> AVERAGE_SHIFT_COUNT;\r
-      Port [ Index ].BytesAverage -= DeltaBytes;\r
-      DeltaBytes = BytesReceived - Port [ Index ].BytesPrevious;\r
-      Port [ Index ].BytesPrevious = BytesReceived;\r
-      Port [ Index ].BytesAverage += DeltaBytes;\r
+      DeltaBytes = Port[ Index ].BytesAverage >> AVERAGE_SHIFT_COUNT;\r
+      Port[ Index ].BytesAverage -= DeltaBytes;\r
+      DeltaBytes = BytesReceived - Port[ Index ].BytesPrevious;\r
+      Port[ Index ].BytesPrevious = BytesReceived;\r
+      Port[ Index ].BytesAverage += DeltaBytes;\r
 \r
       //\r
       //  Separate the samples\r
       //\r
-      if (( 2 << AVERAGE_SHIFT_COUNT ) == Port [ Index ].Samples ) {\r
+      if (( 2 << AVERAGE_SHIFT_COUNT ) == Port[ Index ].Samples ) {\r
         Print ( L"---------- Stable average ----------\r\n" );\r
       }\r
-      Port [ Index ].Samples += 1;\r
+      Port[ Index ].Samples += 1;\r
 \r
       //\r
       //  Display the data rate\r
       //\r
       Delta = (UINT32)( DeltaBytes >> DATA_RATE_UPDATE_SHIFT );\r
-      Average = Port [ Index ].BytesAverage >> ( AVERAGE_SHIFT_COUNT + DATA_RATE_UPDATE_SHIFT );\r
+      Average = Port[ Index ].BytesAverage >> ( AVERAGE_SHIFT_COUNT + DATA_RATE_UPDATE_SHIFT );\r
       if ( Average < RANGE_SWITCH ) {\r
         Print ( L"%d Bytes/sec, Ave: %d Bytes/Sec\r\n",\r
                 Delta,\r
@@ -919,8 +917,7 @@ main (
   //\r
   //  Use for/break instead of goto\r
   //\r
-  for ( ; ; )\r
-  {\r
+  for ( ; ; ) {\r
     //\r
     //  Create the timer\r
     //\r
index 9add3f24e7b7c89c5dc1e4aae720aa592a25ad83..98a0c9f1209db132fa5d40b47ce5e139f746ccdc 100644 (file)
@@ -84,7 +84,7 @@ UINT64 TotalBytesSent;
 UINT64 PreviousBytes;\r
 UINT64 AverageBytes;\r
 UINT64 Samples;\r
-UINT8 Buffer [ DATA_BUFFER_SIZE ];\r
+UINT8 Buffer[ DATA_BUFFER_SIZE ];\r
 \r
 \r
 //\r
@@ -146,8 +146,7 @@ GetDigit (
   //  Walk the digits\r
   //\r
   Value = 0;\r
-  while (( '0' <= *pDigit ) && ( '9' >= *pDigit ))\r
-  {\r
+  while (( '0' <= *pDigit ) && ( '9' >= *pDigit )) {\r
     //\r
     //  Make room for the new least significant digit\r
     //\r
@@ -313,7 +312,7 @@ SocketConnect (
     //\r
     //  Check for user stop request\r
     //\r
-    while ( ! bTick ) {\r
+    while ( !bTick ) {\r
       Status = ControlCCheck ( );\r
       if ( EFI_ERROR ( Status )) {\r
         break;\r
@@ -494,8 +493,7 @@ SocketOpen (
   //\r
   //  Use do/while and break instead of goto\r
   //\r
-  do\r
-  {\r
+  do {\r
     //\r
     //  Wait for the network layer to initialize\r
     //\r
@@ -801,7 +799,7 @@ Tcp4Locate (
     //\r
     //  Open the network controller's service protocol\r
     //\r
-    Tcp4Controller = pHandles [ Tcp4Index++ ];\r
+    Tcp4Controller = pHandles[ Tcp4Index++ ];\r
     Status = gBS->OpenProtocol (\r
                     Tcp4Controller,\r
                     &gEfiTcp4ServiceBindingProtocolGuid,\r
@@ -1499,12 +1497,15 @@ main (
   //\r
   //  Validate the command line\r
   //\r
-  if ( 2 != Argc ) {\r
-    Print ( L"%s  <remote IP address>\r\n", Argv[0] );\r
+  if ( 2 > Argc ) {\r
+    Print ( L"%s  <remote IP address> [Use TCP]\r\n", Argv[0] );\r
     return -1;\r
   }\r
 \r
-bTcp4 = TRUE;\r
+  //\r
+  //  Determine if TCP should be used\r
+  //\r
+  bTcp4 = (BOOLEAN)( 2 < Argc );\r
 \r
   //\r
   //  Determine the support routines\r
@@ -1522,8 +1523,7 @@ bTcp4 = TRUE;
   //\r
   //  Use for/break instead of goto\r
   //\r
-  for ( ; ; )\r
-  {\r
+  for ( ; ; ) {\r
     //\r
     //  No bytes sent so far\r
     //\r
@@ -1540,14 +1540,10 @@ bTcp4 = TRUE;
     RemoteHostAddress.sin_family = AF_INET;\r
     RemoteHostAddress.sin_port = htons ( PcdGet16 ( DataSource_Port ));\r
 \r
-Print ( L"Argc: %d\r\n", Argc);\r
-Print ( L"Argv[0]: %a\r\n", Argv[0]);\r
-Print ( L"Argv[1]: %a\r\n", Argv[1]);\r
-\r
     //\r
     //  Get the IP address\r
     //\r
-    pRemoteHost = Argv [1];\r
+    pRemoteHost = Argv[1];\r
     Status = IpAddress ( );\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
index 2e626396caa3fb4c786762bea916958cfbc6a413..63299a1f9d5d28390979bb83c16595b1a24aa503 100644 (file)
@@ -59,10 +59,10 @@ main (
                        &RemoteAddress[1],\r
                        &RemoteAddress[2],\r
                        &RemoteAddress[3]))\r
-    || ( 255 < RemoteAddress [0])\r
-    || ( 255 < RemoteAddress [1])\r
-    || ( 255 < RemoteAddress [2])\r
-    || ( 255 < RemoteAddress [3])) {\r
+    || ( 255 < RemoteAddress[0])\r
+    || ( 255 < RemoteAddress[1])\r
+    || ( 255 < RemoteAddress[2])\r
+    || ( 255 < RemoteAddress[3])) {\r
     Print ( L"%a  <IPv4 Address>\r\n", Argv[0]);\r
   }\r
   else {\r
@@ -78,7 +78,7 @@ main (
       Print ( L"ERROR - host not found, errno: %d\r\n", errno );\r
     }\r
     else {\r
-      pIpAddress = (UINT8 *)pHost->h_addr_list [ 0 ];\r
+      pIpAddress = (UINT8 *)pHost->h_addr_list[ 0 ];\r
       Print ( L"%d.%d.%d.%d, %a\r\n",\r
               pIpAddress[0],\r
               pIpAddress[1],\r
index 47453aced2ef40e97decbacc2daaacd8c26e225b..c5c78ac2b3813974b0e57d066fd72121a7bae881 100644 (file)
@@ -23,9 +23,9 @@
 \r
 #include <sys/socket.h>\r
 \r
-struct hostent * _gethostbydnsname(const char *, int);\r
+struct hostent * _gethostbydnsname (const char *, int);\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
index d539c994815076207d492e485f8ab9d19b81de62..c58552abbc55e05ff02140a366525a58cbfe8135 100644 (file)
@@ -23,7 +23,7 @@
 \r
 #include <sys/socket.h>\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
index 51d8c6d1014d99cdd49b36a0a4953a4c4bcbd126..ce07ceaa534e84b1b038857c49156dba84c9f6f8 100644 (file)
@@ -53,10 +53,10 @@ main (
                        &RemoteAddress[1],\r
                        &RemoteAddress[2],\r
                        &RemoteAddress[3]))\r
-    || ( 255 < RemoteAddress [0])\r
-    || ( 255 < RemoteAddress [1])\r
-    || ( 255 < RemoteAddress [2])\r
-    || ( 255 < RemoteAddress [3])) {\r
+    || ( 255 < RemoteAddress[0])\r
+    || ( 255 < RemoteAddress[1])\r
+    || ( 255 < RemoteAddress[2])\r
+    || ( 255 < RemoteAddress[3])) {\r
     Print ( L"%a  <IPv4 Address>\r\n", Argv[0]);\r
   }\r
   else {\r
index b3609c9374c5dd7b0c8092d2376247464fec75ee..be81b3483d26612fdfb3f6ca34689fd21712f77d 100644 (file)
@@ -23,7 +23,7 @@
 \r
 #include <sys/socket.h>\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
index d7237d342cda0da8e9a18b96497c36dc9c6c3a46..f90bcf298d4f68268b58fd5dd8dcaa6098f050ef 100644 (file)
@@ -23,7 +23,7 @@
 \r
 #include <sys/socket.h>\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
index 6a5fc46ea7d837ea1efcd03a16b004a8f8e67eaa..5be03618f4ab4d9e8ab14319d6ae2dd8f1c012e9 100644 (file)
@@ -24,7 +24,7 @@
 \r
 #include <sys/socket.h>\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
diff --git a/AppPkg/Applications/Sockets/OobRx/Main.c b/AppPkg/Applications/Sockets/OobRx/Main.c
new file mode 100644 (file)
index 0000000..0cdecdf
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Out-of-band receive test application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobRx.h>\r
+\r
+\r
+/**\r
+  Receive out-of-band messages from the remote system.\r
+\r
+  @param [in] Argc  The number of arguments\r
+  @param [in] Argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main (\r
+  IN int Argc,\r
+  IN char **Argv\r
+  )\r
+{\r
+  int RetVal;\r
+\r
+  //\r
+  //  Run the application\r
+  //\r
+  RetVal = OobRx ( Argc, Argv );\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.c b/AppPkg/Applications/Sockets/OobRx/OobRx.c
new file mode 100644 (file)
index 0000000..7e6b8f7
--- /dev/null
@@ -0,0 +1,253 @@
+/** @file\r
+  Windows version of the OOB Receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobRx.h>\r
+\r
+UINT8 mBuffer[65536];\r
+\r
+\r
+/**\r
+  Run the OOB receive application\r
+\r
+  @param [in] ArgC      Argument count\r
+  @param [in] ArgV      Argument value array\r
+\r
+  @retval 0             Successfully operation\r
+ **/\r
+int\r
+OobRx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  )\r
+{\r
+  SOCKET a;\r
+  ssize_t BytesReceived;\r
+  struct sockaddr_in LocalPort;\r
+  UINT32 OobInLine;\r
+  UINT16 PortNumber;\r
+  struct timeval ReceiveTimeout;\r
+  struct sockaddr_in RemotePort;\r
+  socklen_t RemotePortLength;\r
+  int RetVal;\r
+  SOCKET s;\r
+  UINT32 TransmittedBefore;\r
+  UINT32 TransmittedDuring;\r
+  UINT32 TransmittedOob;\r
+  UINT32 TransmittedAfter;\r
+  UINT32 * pTransmittedBytes;\r
+\r
+  //\r
+  //  Create the socket\r
+  //\r
+  s = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP );\r
+  if ( -1 == s ) {\r
+    RetVal = GET_ERRNO;\r
+    printf ( "ERROR - socket error, errno: %d\r\n", RetVal );\r
+  }\r
+  else {\r
+    //\r
+    //  Use for/break; instead of goto\r
+    //\r
+    for ( ; ; ) {\r
+      //\r
+      //  Bind the socket to a known port\r
+      //\r
+      PortNumber = OOB_RX_PORT;\r
+      memset ( &LocalPort, 0, sizeof ( LocalPort ));\r
+      SIN_LEN ( LocalPort ) = sizeof ( LocalPort );\r
+      SIN_FAMILY ( LocalPort ) = AF_INET;\r
+      SIN_ADDR ( LocalPort ) = 0;\r
+      SIN_PORT ( LocalPort ) = htons ( PortNumber );\r
+      RetVal = bind ( s,\r
+                      (struct sockaddr *)&LocalPort,\r
+                      sizeof ( LocalPort ));\r
+      if ( -1 == RetVal ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - bind error, errno: %d\r\n", RetVal );\r
+          break;\r
+      }\r
+\r
+      //\r
+      //  Make the port available on the server\r
+      //\r
+      RetVal = listen ( s, 2 );\r
+      if ( -1 == RetVal ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - listen error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Wait for a connection to the known port\r
+      //\r
+      RemotePortLength = sizeof ( RemotePort );\r
+      a = accept ( s,\r
+                   (struct sockaddr *)&RemotePort,\r
+                   &RemotePortLength );\r
+      if ( -1 == a ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - accept error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Use for/break instead of goto\r
+      //\r
+      for ( ; ; ) {\r
+        //\r
+        //  Set the receive timeout\r
+        //\r
+        ReceiveTimeout.tv_sec = 0;\r
+        ReceiveTimeout.tv_usec = 20 * 1000;\r
+        RetVal = setsockopt ( a,\r
+                              SOL_SOCKET,\r
+                              SO_RCVTIMEO,\r
+                              (char *)&ReceiveTimeout,\r
+                              sizeof ( ReceiveTimeout ));\r
+        if ( -1 == RetVal ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - setsockopt RCVTIMEO error, errno: %d\r\n", RetVal );\r
+          break;\r
+        }\r
+\r
+        //\r
+        //  Select the OOB processing\r
+        //\r
+        OobInLine = ( 1 < ArgC );\r
+        RetVal = setsockopt ( s,\r
+                              SOL_SOCKET,\r
+                              SO_OOBINLINE,\r
+                              (char *)&OobInLine,\r
+                              sizeof ( OobInLine ));\r
+        if ( -1 == RetVal ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - setsockopt OOBINLINE error, errno: %d\r\n", RetVal );\r
+          break;\r
+        }\r
+        printf ( "%s\r\n", ( 0 != OobInLine ) ? "OOB messages are in-line"\r
+                                              : "OOB messages move to the head of the queue" );\r
+\r
+        //\r
+        //  Receive data from the remote system\r
+        //\r
+        TransmittedBefore = 0;\r
+        TransmittedOob = 0;\r
+        TransmittedDuring = 0;\r
+        TransmittedAfter = 0;\r
+        pTransmittedBytes = &TransmittedBefore;\r
+        do {\r
+          //\r
+          //  Attempt to receive OOB data\r
+          //\r
+          BytesReceived = recv ( a, &mBuffer[0], sizeof ( mBuffer ), MSG_OOB );\r
+          RetVal = (UINT32)BytesReceived;\r
+          if ( 0 < BytesReceived ) {\r
+            //\r
+            //  Display the received OOB data\r
+            //\r
+            printf ( "%5Ld OOB bytes received\r\n", (UINT64)BytesReceived );\r
+\r
+            //\r
+            //  Account for the bytes received\r
+            //\r
+            TransmittedOob += RetVal;\r
+            *pTransmittedBytes += TransmittedAfter;\r
+            TransmittedAfter = 0;\r
+            pTransmittedBytes = &TransmittedDuring;\r
+          }\r
+          else if ( -1 == BytesReceived ) {\r
+            //\r
+            //  Check for connection timeout\r
+            //\r
+            RetVal = GET_ERRNO;\r
+            if ( RX_TIMEOUT_ERROR != RetVal ) {\r
+              //\r
+              //  Receive error\r
+              //\r
+              printf ( "ERROR - recv OOB error, errno: %d\r\n", RetVal );\r
+              break;\r
+            }\r
+\r
+            //\r
+            //  Ignore the timeout\r
+            //  Try to receive normal data instead\r
+            //\r
+            BytesReceived = recv ( a, &mBuffer[0], sizeof ( mBuffer ), 0 );\r
+            RetVal = (UINT32)BytesReceived;\r
+            if ( 0 < BytesReceived ) {\r
+              //\r
+              //  Display the received data\r
+              //\r
+              printf ( "%4Ld bytes received\r\n", (UINT64)BytesReceived );\r
+\r
+              //\r
+              //  Account for the bytes received\r
+              //\r
+              TransmittedAfter += RetVal;\r
+            }\r
+            else if ( -1 == BytesReceived ) {\r
+              //\r
+              //  Check for a timeout\r
+              //\r
+              RetVal = GET_ERRNO;\r
+              if ( RX_TIMEOUT_ERROR != RetVal ) {\r
+                printf ( "ERROR - recv error, errno: %d\r\n", RetVal );\r
+                break;\r
+              }\r
+            }\r
+          }\r
+        } while ( 0 != RetVal );\r
+\r
+        //\r
+        //  Display the bytes received\r
+        //\r
+        if ( 0 == RetVal ) {\r
+          printf ( "Bytes before OOB:  %8d\r\n", TransmittedBefore );\r
+          if ( 0 != TransmittedDuring ) {\r
+            printf ( "Bytes during OOB:  %8d\r\n", TransmittedDuring );\r
+          }\r
+          printf ( "Out-of-band bytes: %8d\r\n", TransmittedOob );\r
+          printf ( "Bytes after OOB:   %8d\r\n", TransmittedAfter );\r
+          printf ( "                   --------\r\n" );\r
+          printf ( "Total Bytes:       %8d\r\n", TransmittedBefore\r
+                                                 + TransmittedDuring\r
+                                                 + TransmittedOob\r
+                                                 + TransmittedAfter );\r
+        }\r
+\r
+        //\r
+        //  Test complete\r
+        //\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Close the test socket\r
+      //\r
+      CLOSE_SOCKET ( a );\r
+      break;\r
+    }\r
+\r
+    //\r
+    //  Close the socket\r
+    //\r
+    CLOSE_SOCKET ( s );\r
+    printf ( "Socket closed\r\n" );\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.h b/AppPkg/Applications/Sockets/OobRx/OobRx.h
new file mode 100644 (file)
index 0000000..37730ca
--- /dev/null
@@ -0,0 +1,96 @@
+/** @file\r
+  Definitions for the OOB Receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _OOB_RX_H_\r
+#define _OOB_RX_H_\r
+\r
+//------------------------------------------------------------------------------\r
+//  Include Files\r
+//------------------------------------------------------------------------------\r
+\r
+#ifdef  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for Windows environment\r
+//\r
+\r
+#include <winsock2.h>\r
+\r
+#define CLOSE_SOCKET      closesocket\r
+#define SIN_ADDR(port)    port.sin_addr.S_un.S_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_family\r
+#define SIN_PORT(port)    port.sin_port\r
+#define GET_ERRNO         WSAGetLastError ( )\r
+\r
+#define RX_TIMEOUT_ERROR  WSAETIMEDOUT\r
+#define ssize_t           int\r
+#define socklen_t         int\r
+\r
+#else   //  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for EFI environment\r
+//\r
+\r
+#include <Uefi.h>\r
+#include <errno.h>\r
+#include <stdlib.h>\r
+\r
+#include <netinet/in.h>\r
+\r
+#include <sys/EfiSysCall.h>\r
+#include <sys/endian.h>\r
+#include <sys/socket.h>\r
+#include <sys/time.h>\r
+\r
+#define CLOSE_SOCKET      close\r
+#define SIN_ADDR(port)    port.sin_addr.s_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_len\r
+#define SIN_PORT(port)    port.sin_port\r
+#define SOCKET            int\r
+#define GET_ERRNO         errno\r
+#define RX_TIMEOUT_ERROR  ETIMEDOUT\r
+\r
+#endif  //  BUILD_FOR_WINDOWS\r
+\r
+#include <stdio.h>\r
+\r
+//------------------------------------------------------------------------------\r
+//  Constants\r
+//------------------------------------------------------------------------------\r
+\r
+#define OOB_RX_PORT       12344\r
+\r
+//------------------------------------------------------------------------------\r
+//  API\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+  Run the OOB receive application\r
+\r
+  @param [in] ArgC      Argument count\r
+  @param [in] ArgV      Argument value array\r
+\r
+  @retval 0             Successfully operation\r
+ **/\r
+\r
+int\r
+OobRx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  );\r
+\r
+//------------------------------------------------------------------------------\r
+\r
+#endif  //  _OOB_RX_H_\r
diff --git a/AppPkg/Applications/Sockets/OobRx/OobRx.inf b/AppPkg/Applications/Sockets/OobRx/OobRx.inf
new file mode 100644 (file)
index 0000000..516f7cc
--- /dev/null
@@ -0,0 +1,64 @@
+#/** @file\r
+#  OobRx Application\r
+#\r
+# This file contains an 'Intel Peripheral Driver' and is      \r
+# licensed for Intel CPUs and chipsets under the terms of your\r
+# license agreement with Intel or your vendor.  This file may \r
+# be modified by the user, subject to additional terms of the \r
+# license agreement                                           \r
+#\r
+#\r
+# Copyright (c)  20011 Intel Corporation. All rights reserved\r
+# This software and associated documentation (if any) is furnished\r
+# under a license and may only be used or copied in accordance\r
+# with the terms of the license. Except as permitted by such\r
+# license, no part of this software or documentation may be\r
+# reproduced, stored in a retrieval system, or transmitted in any\r
+# form or by any means without the express written consent of\r
+# Intel Corporation.\r
+#\r
+##\r
+\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = OobRx\r
+  FILE_GUID                      = 79DED328-7FCE-4909-9AFD-D66176AF97A6\r
+  MODULE_TYPE                    = UEFI_APPLICATION\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = ShellCEntryLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Main.c\r
+  OobRx.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  StdLib/StdLib.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BsdSocketLib\r
+  DebugLib\r
+  EfiSocketLib\r
+  LibC\r
+  LibMath\r
+  ShellCEntryLib\r
+  UefiBootServicesTableLib\r
+  UefiLib\r
+#  UseSocketDxe\r
+\r
+[BuildOptions]\r
+  INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186\r
+   MSFT:*_*_*_CC_FLAGS = /Od\r
+    GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable\r
+\r
diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.sln
new file mode 100644 (file)
index 0000000..f9c7825
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OobRx", "OobRx.vcproj", "{FA34A77A-5034-4065-B4BD-B74984DEB2F7}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Debug|Win32.Build.0 = Debug|Win32\r
+               {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Release|Win32.ActiveCfg = Release|Win32\r
+               {FA34A77A-5034-4065-B4BD-B74984DEB2F7}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo
new file mode 100644 (file)
index 0000000..025aa47
Binary files /dev/null and b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.suo differ
diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj b/AppPkg/Applications/Sockets/OobRx/Windows/OobRx.vcproj
new file mode 100644 (file)
index 0000000..e5ca534
--- /dev/null
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="OobRx"\r
+       ProjectGUID="{FA34A77A-5034-4065-B4BD-B74984DEB2F7}"\r
+       RootNamespace="OobRx"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\main.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\OobRx.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\OobRx.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/AppPkg/Applications/Sockets/OobRx/Windows/main.c b/AppPkg/Applications/Sockets/OobRx/Windows/main.c
new file mode 100644 (file)
index 0000000..7d2c644
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Windows version of the OOB Receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobRx.h>\r
+\r
+\r
+/**\r
+  Receive out-of-band messages from the remote system.\r
+\r
+  @param [in] argc  The number of arguments\r
+  @param [in] argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main(\r
+  int argc,\r
+  char ** argv\r
+  )\r
+{\r
+  int RetVal;\r
+  WSADATA WsaData;\r
+\r
+  //\r
+  //  Initialize the WinSock layer\r
+  //\r
+  RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData );\r
+  if ( 0 == RetVal ) {\r
+    //\r
+    //  Start the application\r
+    //\r
+    RetVal = OobRx ( argc, argv );\r
+\r
+    //\r
+    //  Done with the WinSock layer\r
+    //\r
+    WSACleanup ( );\r
+  }\r
+\r
+  //\r
+  //  Return the final result\r
+  //\r
+  return RetVal;  \r
+}\r
diff --git a/AppPkg/Applications/Sockets/OobTx/Main.c b/AppPkg/Applications/Sockets/OobTx/Main.c
new file mode 100644 (file)
index 0000000..ac7c8b0
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Out-of-band transmit test application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobTx.h>\r
+\r
+\r
+/**\r
+  Transmit out-of-band messages to the remote system.\r
+\r
+  @param [in] Argc  The number of arguments\r
+  @param [in] Argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main (\r
+  IN int Argc,\r
+  IN char **Argv\r
+  )\r
+{\r
+  int RetVal;\r
+\r
+  //\r
+  //  Run the application\r
+  //\r
+  RetVal = OobTx ( Argc, Argv );\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.c b/AppPkg/Applications/Sockets/OobTx/OobTx.c
new file mode 100644 (file)
index 0000000..d52cbb7
--- /dev/null
@@ -0,0 +1,248 @@
+/** @file\r
+  Windows version of the OOB Transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobTx.h>\r
+\r
+UINT8 mBuffer[8192];\r
+UINT8 mOob[512];\r
+\r
+/**\r
+  Transmit out-of-band messages to the remote system.\r
+\r
+  @param [in] ArgC        Argument count\r
+  @param [in] ArgV        Argument value array\r
+\r
+  @retval 0               Successfully operation\r
+ **/\r
+\r
+int\r
+OobTx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  )\r
+{\r
+  UINT32 BytesSent;\r
+  ssize_t BytesTransmitted;\r
+  UINT32 Index;\r
+  struct sockaddr_in LocalPort;\r
+  UINT32 OobInLine;\r
+  UINT16 PortNumber;\r
+  UINT32 RemoteAddress[4];\r
+  struct sockaddr_in RemotePort;\r
+  int RetVal;\r
+  UINT32 TransmittedAfter;\r
+  UINT32 TransmittedBefore;\r
+  UINT32 TransmittedOob;\r
+  SOCKET s;\r
+\r
+  //\r
+  //  Create the socket\r
+  //\r
+  s = socket ( AF_INET, SOCK_STREAM, IPPROTO_TCP );\r
+  if ( -1 == s ) {\r
+    RetVal = GET_ERRNO;\r
+    printf ( "ERROR - socket error, errno: %d\r\n", RetVal );\r
+  }\r
+  else {\r
+    //\r
+    //  Use for/break; instead of goto\r
+    //\r
+    for ( ; ; ) {\r
+      //\r
+      //  Validate the arguments\r
+      //\r
+      if (( 2 > ArgC )\r
+        || ( 4 != sscanf ( ArgV[1],\r
+                           "%d.%d.%d.%d",\r
+                           &RemoteAddress[0],\r
+                           &RemoteAddress[1],\r
+                           &RemoteAddress[2],\r
+                           &RemoteAddress[3]))\r
+          || ( 224 < RemoteAddress[0])\r
+          || ( 255 < RemoteAddress[1])\r
+          || ( 255 < RemoteAddress[2])\r
+          || ( 255 < RemoteAddress[3])\r
+          || (( 0 == RemoteAddress[0])\r
+              && ( 0 == RemoteAddress[1])\r
+              && ( 0 == RemoteAddress[2])\r
+              && ( 0 == RemoteAddress[3]))) {\r
+        printf ( "%s  <remote IP address>  [optional: enables in-line OOB]\r\n", ArgV[0]);\r
+        RetVal = EINVAL;\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Bind the socket to a local port\r
+      //\r
+      memset ( &LocalPort, 0, sizeof ( LocalPort ));\r
+      SIN_LEN ( LocalPort ) = sizeof ( LocalPort );\r
+      SIN_FAMILY ( LocalPort ) = AF_INET;\r
+      SIN_ADDR ( LocalPort ) = 0;\r
+      SIN_PORT ( LocalPort ) = 0;\r
+      RetVal = bind ( s,\r
+                      (struct sockaddr *)&LocalPort,\r
+                      sizeof ( LocalPort ));\r
+      if ( -1 == RetVal ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - bind error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Specify the remote port\r
+      //\r
+      PortNumber = OOB_RX_PORT;\r
+      memset ( &RemotePort, 0, sizeof ( RemotePort ));\r
+      SIN_LEN ( RemotePort ) = sizeof ( RemotePort );\r
+      SIN_FAMILY ( RemotePort ) = AF_INET;\r
+      SIN_ADDR ( RemotePort ) = ( RemoteAddress[3] << 24 )\r
+                              | ( RemoteAddress[2] << 16 )\r
+                              | ( RemoteAddress[1] << 8 )\r
+                              | RemoteAddress[0];\r
+      SIN_PORT ( RemotePort ) = htons ( PortNumber );\r
+\r
+      //\r
+      //  Connect to the remote server\r
+      //\r
+      RetVal = connect ( s, (struct sockaddr *)&RemotePort, sizeof ( RemotePort ));\r
+      if ( -1 == RetVal ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - connect error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Select the OOB processing\r
+      //\r
+      OobInLine = ( 2 < ArgC );\r
+      RetVal = setsockopt ( s,\r
+                            SOL_SOCKET,\r
+                            SO_OOBINLINE,\r
+                            (char *)&OobInLine,\r
+                            sizeof ( OobInLine ));\r
+      if ( -1 == RetVal ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - setsockopt OOBINLINE error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+      printf ( "%s\r\n", ( 0 != OobInLine ) ? "OOB messages are in-line"\r
+                                            : "OOB messages move to the head of the queue" );\r
+\r
+      //\r
+      //  Initialize the messages\r
+      //\r
+      memset ( &mBuffer[0], 0, sizeof ( mBuffer ));\r
+      memset ( &mOob[0], 0x11, sizeof ( mOob ));\r
+\r
+      //\r
+      //  Send the data before the out-of-band message\r
+      //\r
+      TransmittedBefore = 0;\r
+      for ( Index = 0; TX_MSGS_BEFORE > Index; Index++ ) {\r
+        BytesSent = 0;\r
+        do {\r
+          BytesTransmitted = send ( s,\r
+                                    &mBuffer[BytesSent],\r
+                                    sizeof ( mBuffer ) - BytesSent,\r
+                                    0 );\r
+          if ( -1 == BytesTransmitted ) {\r
+            RetVal = GET_ERRNO;\r
+            printf ( "ERROR - send before error, errno: %d\r\n", RetVal );\r
+            break;\r
+          }\r
+          BytesSent += (UINT32)BytesTransmitted;\r
+          RetVal = 0;\r
+        } while ( sizeof ( mBuffer ) > BytesSent );\r
+        if ( 0 != RetVal ) {\r
+          break;\r
+        }\r
+        TransmittedBefore += BytesSent;\r
+      }\r
+      if ( 0 != RetVal ) {\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Send the out-of-band message\r
+      //\r
+      BytesSent = 0;\r
+      do {\r
+        BytesTransmitted = send ( s,\r
+                                  &mOob[BytesSent],\r
+                                  sizeof ( mOob ) - BytesSent,\r
+                                  MSG_OOB );\r
+        if ( -1 == BytesTransmitted ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - send OOB error, errno: %d\r\n", RetVal );\r
+          break;\r
+        }\r
+        BytesSent += (UINT32)BytesTransmitted;\r
+        RetVal = 0;\r
+      } while ( sizeof ( mOob ) > BytesSent );\r
+      if ( 0 != RetVal ) {\r
+        break;\r
+      }\r
+      TransmittedOob = BytesSent;\r
+\r
+      //\r
+      //  Send the data after the out-of-band message\r
+      //\r
+      TransmittedAfter = 0;\r
+      for ( Index = 0; TX_MSGS_AFTER > Index; Index++ ) {\r
+        BytesSent = 0;\r
+        do {\r
+          BytesTransmitted = send ( s,\r
+                                    &mBuffer[BytesSent],\r
+                                    sizeof ( mBuffer ) - BytesSent,\r
+                                    0 );\r
+          if ( -1 == BytesTransmitted ) {\r
+            RetVal = GET_ERRNO;\r
+            printf ( "ERROR - send after error, errno: %d\r\n", RetVal );\r
+            break;\r
+          }\r
+          BytesSent += (UINT32)BytesTransmitted;\r
+          RetVal = 0;\r
+        } while ( sizeof ( mBuffer ) > BytesSent );\r
+        if ( 0 != RetVal ) {\r
+          break;\r
+        }\r
+        TransmittedAfter += BytesSent;\r
+      }\r
+\r
+      //\r
+      //  Test completed successfully\r
+      //\r
+      if ( 0 == RetVal ) {\r
+        printf ( "Bytes before OOB:  %8d\r\n", TransmittedBefore );\r
+        printf ( "Out-of-band bytes: %8d\r\n", TransmittedOob );\r
+        printf ( "Bytes after OOB:   %8d\r\n", TransmittedAfter );\r
+        printf ( "                   --------\r\n" );\r
+        printf ( "Total Bytes:       %8d\r\n", TransmittedBefore\r
+                                               + TransmittedOob\r
+                                               + TransmittedAfter );\r
+      }\r
+      break;\r
+    }\r
+\r
+    //\r
+    //  Close the socket\r
+    //\r
+    CLOSE_SOCKET ( s );\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.h b/AppPkg/Applications/Sockets/OobTx/OobTx.h
new file mode 100644 (file)
index 0000000..d700d3e
--- /dev/null
@@ -0,0 +1,97 @@
+/** @file\r
+  Definitions for the OOB Transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _OOB_TX_H_\r
+#define _OOB_TX_H_\r
+\r
+//------------------------------------------------------------------------------\r
+//  Include Files\r
+//------------------------------------------------------------------------------\r
+\r
+#ifdef  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for Windows environment\r
+//\r
+\r
+#include <winsock2.h>\r
+\r
+#define CHAR8             char\r
+#define CLOSE_SOCKET      closesocket\r
+#define EINVAL            22    //  Invalid argument\r
+#define GET_ERRNO         WSAGetLastError ( )\r
+#define SIN_ADDR(port)    port.sin_addr.S_un.S_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_family\r
+#define SIN_PORT(port)    port.sin_port\r
+#define socklen_t         int\r
+#define ssize_t           int\r
+\r
+#else   //  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for EFI environment\r
+//\r
+\r
+#include <Uefi.h>\r
+#include <errno.h>\r
+#include <stdlib.h>\r
+\r
+#include <netinet/in.h>\r
+\r
+#include <sys/EfiSysCall.h>\r
+#include <sys/endian.h>\r
+#include <sys/socket.h>\r
+\r
+#define CLOSE_SOCKET      close\r
+#define GET_ERRNO         errno\r
+#define SIN_ADDR(port)    port.sin_addr.s_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_len\r
+#define SIN_PORT(port)    port.sin_port\r
+#define SOCKET            int\r
+\r
+#endif  //  BUILD_FOR_WINDOWS\r
+\r
+#include <stdio.h>\r
+\r
+//------------------------------------------------------------------------------\r
+//  Constants\r
+//------------------------------------------------------------------------------\r
+\r
+#define OOB_RX_PORT       12344\r
+\r
+#define TX_MSGS_BEFORE    32\r
+#define TX_MSGS_AFTER     8\r
+\r
+//------------------------------------------------------------------------------\r
+//  API\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+  Transmit out-of-band messages to the remote system.\r
+\r
+  @param [in] ArgC        Argument count\r
+  @param [in] ArgV        Argument value array\r
+\r
+  @retval 0               Successfully operation\r
+ **/\r
+\r
+int\r
+OobTx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  );\r
+\r
+//------------------------------------------------------------------------------\r
+\r
+#endif  //  _OOB_TX_H_\r
diff --git a/AppPkg/Applications/Sockets/OobTx/OobTx.inf b/AppPkg/Applications/Sockets/OobTx/OobTx.inf
new file mode 100644 (file)
index 0000000..cc9c2b5
--- /dev/null
@@ -0,0 +1,64 @@
+#/** @file\r
+#  OobTx Application\r
+#\r
+# This file contains an 'Intel Peripheral Driver' and is      \r
+# licensed for Intel CPUs and chipsets under the terms of your\r
+# license agreement with Intel or your vendor.  This file may \r
+# be modified by the user, subject to additional terms of the \r
+# license agreement                                           \r
+#\r
+#\r
+# Copyright (c)  20011 Intel Corporation. All rights reserved\r
+# This software and associated documentation (if any) is furnished\r
+# under a license and may only be used or copied in accordance\r
+# with the terms of the license. Except as permitted by such\r
+# license, no part of this software or documentation may be\r
+# reproduced, stored in a retrieval system, or transmitted in any\r
+# form or by any means without the express written consent of\r
+# Intel Corporation.\r
+#\r
+##\r
+\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = OobTx\r
+  FILE_GUID                      = EB740091-A494-44d7-8D96-C192F95A6394\r
+  MODULE_TYPE                    = UEFI_APPLICATION\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = ShellCEntryLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Main.c\r
+  OobTx.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  StdLib/StdLib.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BsdSocketLib\r
+  DebugLib\r
+  EfiSocketLib\r
+  LibC\r
+  LibMath\r
+  ShellCEntryLib\r
+  UefiBootServicesTableLib\r
+  UefiLib\r
+#  UseSocketDxe\r
+\r
+[BuildOptions]\r
+  INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186\r
+   MSFT:*_*_*_CC_FLAGS = /Od\r
+    GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable\r
+\r
diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.sln
new file mode 100644 (file)
index 0000000..e16b5fd
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OobTx", "OobTx.vcproj", "{C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Debug|Win32.Build.0 = Debug|Win32\r
+               {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Release|Win32.ActiveCfg = Release|Win32\r
+               {C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo
new file mode 100644 (file)
index 0000000..0ded407
Binary files /dev/null and b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.suo differ
diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj b/AppPkg/Applications/Sockets/OobTx/Windows/OobTx.vcproj
new file mode 100644 (file)
index 0000000..d53149c
--- /dev/null
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="OobTx"\r
+       ProjectGUID="{C5B91ED2-C2BA-4EE7-A789-F6621CE601B9}"\r
+       RootNamespace="OobTx"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\main.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\OobTx.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\OobTx.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/AppPkg/Applications/Sockets/OobTx/Windows/main.c b/AppPkg/Applications/Sockets/OobTx/Windows/main.c
new file mode 100644 (file)
index 0000000..cf149c4
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Windows version of the OOB Transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <OobTx.h>\r
+\r
+\r
+/**\r
+  Transmit out-of-band messages to the remote system.\r
+\r
+  @param [in] Argc  The number of arguments\r
+  @param [in] Argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main(\r
+  int argc,\r
+  char ** argv\r
+  )\r
+{\r
+  int RetVal;\r
+  WSADATA WsaData;\r
+\r
+  //\r
+  //  Initialize the WinSock layer\r
+  //\r
+  RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData );\r
+  if ( 0 == RetVal ) {\r
+    //\r
+    //  Start the application\r
+    //\r
+    RetVal = OobTx ( argc, argv );\r
+\r
+    //\r
+    //  Done with the WinSock layer\r
+    //\r
+    WSACleanup ( );\r
+  }\r
+\r
+  //\r
+  //  Return the final result\r
+  //\r
+  return RetVal;  \r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Main.c b/AppPkg/Applications/Sockets/RawIp4Rx/Main.c
new file mode 100644 (file)
index 0000000..21d4827
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Raw IP4 receive test application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "RawIp4Rx.h"\r
+\r
+\r
+/**\r
+  Receive raw datagrams from a remote system.\r
+\r
+  @param [in] Argc  The number of arguments\r
+  @param [in] Argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main (\r
+  IN int Argc,\r
+  IN char **Argv\r
+  )\r
+{\r
+  int RetVal;\r
+\r
+  //\r
+  //  Run the application\r
+  //\r
+  RetVal = RawIp4Rx ( Argc, Argv );\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.c
new file mode 100644 (file)
index 0000000..9b6725f
--- /dev/null
@@ -0,0 +1,188 @@
+/** @file\r
+  Raw IP4 receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "RawIp4Rx.h"\r
+\r
+UINT8 mBuffer[65536];\r
+\r
+\r
+/**\r
+  Run the raw IP4 receive application\r
+\r
+  @param [in] ArgC      Argument count\r
+  @param [in] ArgV      Argument value array\r
+\r
+  @retval 0             Successfully operation\r
+ **/\r
+int\r
+RawIp4Rx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  )\r
+{\r
+  ssize_t BytesReceived;\r
+  struct sockaddr_in LocalPort;\r
+  socklen_t LocalPortLength;\r
+  struct sockaddr_in RemotePort;\r
+  socklen_t RemotePortLength;\r
+  int RetVal;\r
+  SOCKET s;\r
+  UINT64 TotalBytesReceived;\r
+\r
+  //\r
+  //  Create the socket\r
+  //\r
+  s = socket ( AF_INET, SOCK_RAW, RAW_PROTOCOL );\r
+  if ( -1 == s ) {\r
+    RetVal = GET_ERRNO;\r
+    printf ( "ERROR - socket error, errno: %d\r\n", RetVal );\r
+  }\r
+  else {\r
+    //\r
+    //  Use for/break; instead of goto\r
+    //\r
+    for ( ; ; ) {\r
+      //\r
+      //  Bind the socket to a known port\r
+      //\r
+      memset ( &LocalPort, 0, sizeof ( LocalPort ));\r
+      SIN_LEN ( LocalPort ) = sizeof ( LocalPort );\r
+      SIN_FAMILY ( LocalPort ) = AF_INET;\r
+      SIN_ADDR ( LocalPort ) = 0;\r
+      SIN_PORT ( LocalPort ) = 0;\r
+      RetVal = bind ( s,\r
+                      (struct sockaddr *)&LocalPort,\r
+                      sizeof ( LocalPort ));\r
+      if ( -1 == RetVal ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - bind error, errno: %d\r\n", RetVal );\r
+          break;\r
+      }\r
+\r
+      //\r
+      //  Display the local address and protocol\r
+      //\r
+      LocalPortLength = sizeof ( LocalPort );\r
+      RetVal = getsockname ( s, (struct sockaddr *)&LocalPort, &LocalPortLength );\r
+      if ( 0 != RetVal ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - getsockname error, errno: %d\r\n", RetVal );\r
+          break;\r
+      }\r
+      printf ( "Local Address: %d.%d.%d.%d, Protocol: %d\r\n",\r
+               (UINT8)SIN_ADDR ( LocalPort ),\r
+               (UINT8)( SIN_ADDR ( LocalPort ) >> 8 ),\r
+               (UINT8)( SIN_ADDR ( LocalPort ) >> 16 ),\r
+               (UINT8)( SIN_ADDR ( LocalPort ) >> 24 ),\r
+               RAW_PROTOCOL );\r
+\r
+      //\r
+      //  Use for/break instead of goto\r
+      //\r
+      TotalBytesReceived = 0;\r
+      for ( ; ; ) {\r
+        //\r
+        //  Receive data from the remote system\r
+        //\r
+        do {\r
+          //\r
+          //  Attempt to receive a packet\r
+          //\r
+          RemotePortLength = sizeof ( RemotePort );\r
+          BytesReceived = recvfrom ( s,\r
+                                     &mBuffer[0],\r
+                                     sizeof ( mBuffer ),\r
+                                     0,\r
+                                     (struct sockaddr *)&RemotePort,\r
+                                     &RemotePortLength );\r
+          RetVal = (UINT32)BytesReceived;\r
+          if ( 0 < BytesReceived ) {\r
+            //\r
+            //  Display the received data\r
+            //\r
+            printf ( "%4d bytes received from %d.%d.%d.%d:%d\r\n"\r
+                     "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\r\n"\r
+                     "%02x %02x %02x %02x\r\n",\r
+                     (UINT32)BytesReceived,\r
+                     (UINT8)SIN_ADDR ( RemotePort ),\r
+                     (UINT8)( SIN_ADDR ( RemotePort ) >> 8 ),\r
+                     (UINT8)( SIN_ADDR ( RemotePort ) >> 16 ),\r
+                     (UINT8)( SIN_ADDR ( RemotePort ) >> 24 ),\r
+                     SIN_PORT ( RemotePort ),\r
+                     mBuffer[0],\r
+                     mBuffer[1],\r
+                     mBuffer[2],\r
+                     mBuffer[3],\r
+                     mBuffer[4],\r
+                     mBuffer[5],\r
+                     mBuffer[6],\r
+                     mBuffer[7],\r
+                     mBuffer[8],\r
+                     mBuffer[9],\r
+                     mBuffer[10],\r
+                     mBuffer[11],\r
+                     mBuffer[12],\r
+                     mBuffer[13],\r
+                     mBuffer[14],\r
+                     mBuffer[15],\r
+                     mBuffer[16],\r
+                     mBuffer[17],\r
+                     mBuffer[18],\r
+                     mBuffer[19]);\r
+            TotalBytesReceived += BytesReceived;\r
+\r
+            //\r
+            //  All done when the correct packet is received\r
+            //\r
+            if ( mBuffer[9] == RAW_PROTOCOL ) {\r
+              break;\r
+            }\r
+          }\r
+          else if ( -1 == BytesReceived ) {\r
+            //\r
+            //  Check for a timeout\r
+            //\r
+            RetVal = GET_ERRNO;\r
+            printf ( "ERROR - recv error, errno: %d\r\n", RetVal );\r
+            break;\r
+          }\r
+        } while ( 0 != RetVal );\r
+\r
+        //\r
+        //  Display the bytes received\r
+        //\r
+        if ( 0 == RetVal ) {\r
+          printf ( "Total Bytes Received:  %Ld\r\n", TotalBytesReceived );\r
+        }\r
+\r
+        //\r
+        //  Test complete\r
+        //\r
+        break;\r
+      }\r
+      break;\r
+    }\r
+\r
+    //\r
+    //  Close the socket\r
+    //\r
+    CLOSE_SOCKET ( s );\r
+    printf ( "Socket closed\r\n" );\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.h
new file mode 100644 (file)
index 0000000..679692c
--- /dev/null
@@ -0,0 +1,98 @@
+/** @file\r
+  Definitions for the raw IP4 receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _RAW_IP4_RX_H_\r
+#define _RAW_IP4_RX_H_\r
+\r
+//------------------------------------------------------------------------------\r
+//  Include Files\r
+//------------------------------------------------------------------------------\r
+\r
+#ifdef  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for Windows environment\r
+//\r
+\r
+#include <winsock2.h>\r
+\r
+#define CLOSE_SOCKET      closesocket\r
+#define SIN_ADDR(port)    port.sin_addr.S_un.S_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_family\r
+#define SIN_PORT(port)    port.sin_port\r
+#define GET_ERRNO         WSAGetLastError ( )\r
+\r
+#define ssize_t           int\r
+#define socklen_t         int\r
+\r
+#else   //  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for EFI environment\r
+//\r
+\r
+#include <Uefi.h>\r
+#include <errno.h>\r
+#include <stdlib.h>\r
+\r
+#include <netinet/in.h>\r
+\r
+#include <sys/EfiSysCall.h>\r
+#include <sys/endian.h>\r
+#include <sys/socket.h>\r
+#include <sys/time.h>\r
+\r
+#define CLOSE_SOCKET      close\r
+#define SIN_ADDR(port)    port.sin_addr.s_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_len\r
+#define SIN_PORT(port)    port.sin_port\r
+#define SOCKET            int\r
+#define GET_ERRNO         errno\r
+\r
+#endif  //  BUILD_FOR_WINDOWS\r
+\r
+#include <stdio.h>\r
+\r
+//------------------------------------------------------------------------------\r
+//  Constants\r
+//------------------------------------------------------------------------------\r
+\r
+//\r
+//  See http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml\r
+//  and http://tools.ietf.org/html/rfc3692\r
+//\r
+#define RAW_PROTOCOL      253\r
+\r
+//------------------------------------------------------------------------------\r
+//  API\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+  Run the raw IP4 receive application\r
+\r
+  @param [in] ArgC      Argument count\r
+  @param [in] ArgV      Argument value array\r
+\r
+  @retval 0             Successfully operation\r
+ **/\r
+\r
+int\r
+RawIp4Rx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  );\r
+\r
+//------------------------------------------------------------------------------\r
+\r
+#endif  //  _RAW_IP4_RX_H_\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf b/AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf
new file mode 100644 (file)
index 0000000..4eba247
--- /dev/null
@@ -0,0 +1,64 @@
+#/** @file\r
+#  RawIp4 Application\r
+#\r
+# This file contains an 'Intel Peripheral Driver' and is      \r
+# licensed for Intel CPUs and chipsets under the terms of your\r
+# license agreement with Intel or your vendor.  This file may \r
+# be modified by the user, subject to additional terms of the \r
+# license agreement                                           \r
+#\r
+#\r
+# Copyright (c)  20011 Intel Corporation. All rights reserved\r
+# This software and associated documentation (if any) is furnished\r
+# under a license and may only be used or copied in accordance\r
+# with the terms of the license. Except as permitted by such\r
+# license, no part of this software or documentation may be\r
+# reproduced, stored in a retrieval system, or transmitted in any\r
+# form or by any means without the express written consent of\r
+# Intel Corporation.\r
+#\r
+##\r
+\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = RawIp4Rx\r
+  FILE_GUID                      = 8D7AE6A9-B490-45e1-8795-C2BEAADC3814\r
+  MODULE_TYPE                    = UEFI_APPLICATION\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = ShellCEntryLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Main.c\r
+  RawIp4Rx.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  StdLib/StdLib.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BsdSocketLib\r
+  DebugLib\r
+  EfiSocketLib\r
+  LibC\r
+  LibMath\r
+  ShellCEntryLib\r
+  UefiBootServicesTableLib\r
+  UefiLib\r
+#  UseSocketDxe\r
+\r
+[BuildOptions]\r
+  INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186\r
+   MSFT:*_*_*_CC_FLAGS = /Od\r
+    GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable\r
+\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.sln
new file mode 100644 (file)
index 0000000..5c2b797
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RawIp4Rx", "RawIp4Rx.vcproj", "{FAD3909F-E05E-4A2A-9681-7C474EAC5025}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Debug|Win32.Build.0 = Debug|Win32\r
+               {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Release|Win32.ActiveCfg = Release|Win32\r
+               {FAD3909F-E05E-4A2A-9681-7C474EAC5025}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.vcproj
new file mode 100644 (file)
index 0000000..f0f61c4
--- /dev/null
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="RawIp4Rx"\r
+       ProjectGUID="{FAD3909F-E05E-4A2A-9681-7C474EAC5025}"\r
+       RootNamespace="RawIp4Rx"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="ws2_32.lib"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\main.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\RawIp4Rx.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\RawIp4Rx.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c
new file mode 100644 (file)
index 0000000..d198db9
--- /dev/null
@@ -0,0 +1,61 @@
+/** @file\r
+  Windows version of the raw IP4 receive application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <RawIp4Rx.h>\r
+\r
+\r
+/**\r
+  Receive raw IP4 packets from a remote system.\r
+\r
+  Please note that this program must be run with administrator privileges!\r
+\r
+  @param [in] argc  The number of arguments\r
+  @param [in] argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main(\r
+  int argc,\r
+  char ** argv\r
+  )\r
+{\r
+  int RetVal;\r
+  WSADATA WsaData;\r
+\r
+  //\r
+  //  Initialize the WinSock layer\r
+  //\r
+  RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData );\r
+  if ( 0 == RetVal ) {\r
+    //\r
+    //  Start the application\r
+    //\r
+    RetVal = RawIp4Rx ( argc, argv );\r
+    if ( WSAEACCES == RetVal ) {\r
+      printf ( "Requires administrator privileges to run!\r\n" );\r
+    }\r
+\r
+    //\r
+    //  Done with the WinSock layer\r
+    //\r
+    WSACleanup ( );\r
+  }\r
+\r
+  //\r
+  //  Return the final result\r
+  //\r
+  return RetVal;  \r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Main.c b/AppPkg/Applications/Sockets/RawIp4Tx/Main.c
new file mode 100644 (file)
index 0000000..cec5cd7
--- /dev/null
@@ -0,0 +1,44 @@
+/** @file\r
+  Raw IP4 transmit test application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "RawIp4Tx.h"\r
+\r
+\r
+/**\r
+  Transmit raw IP4 packets to the remote system.\r
+\r
+  @param [in] Argc  The number of arguments\r
+  @param [in] Argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main (\r
+  IN int Argc,\r
+  IN char **Argv\r
+  )\r
+{\r
+  int RetVal;\r
+\r
+  //\r
+  //  Run the application\r
+  //\r
+  RetVal = RawIp4Tx ( Argc, Argv );\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.c
new file mode 100644 (file)
index 0000000..aea946c
--- /dev/null
@@ -0,0 +1,157 @@
+/** @file\r
+  Raw IP4 transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include "RawIp4Tx.h"\r
+\r
+UINT8 mBuffer[1024];\r
+\r
+/**\r
+  Transmit raw IP4 packets to the remote system.\r
+\r
+  @param [in] ArgC        Argument count\r
+  @param [in] ArgV        Argument value array\r
+\r
+  @retval 0               Successfully operation\r
+ **/\r
+\r
+int\r
+RawIp4Tx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  )\r
+{\r
+  UINT32 BytesSent;\r
+  ssize_t BytesTransmitted;\r
+  struct sockaddr_in LocalPort;\r
+  UINT32 RemoteAddress[4];\r
+  struct sockaddr_in RemotePort;\r
+  int RetVal;\r
+  UINT32 TotalSent;\r
+  SOCKET s;\r
+\r
+  //\r
+  //  Create the socket\r
+  //\r
+  s = socket ( AF_INET, SOCK_RAW, RAW_PROTOCOL );\r
+  if ( -1 == s ) {\r
+    RetVal = GET_ERRNO;\r
+    printf ( "ERROR - socket error, errno: %d\r\n", RetVal );\r
+  }\r
+  else {\r
+    //\r
+    //  Use for/break; instead of goto\r
+    //\r
+    for ( ; ; ) {\r
+      //\r
+      //  Validate the arguments\r
+      //\r
+      if (( 2 > ArgC )\r
+        || ( 4 != sscanf ( ArgV[1],\r
+                           "%d.%d.%d.%d",\r
+                           &RemoteAddress[0],\r
+                           &RemoteAddress[1],\r
+                           &RemoteAddress[2],\r
+                           &RemoteAddress[3]))\r
+          || ( 224 < RemoteAddress[0])\r
+          || ( 255 < RemoteAddress[1])\r
+          || ( 255 < RemoteAddress[2])\r
+          || ( 255 < RemoteAddress[3])\r
+          || (( 0 == RemoteAddress[0])\r
+              && ( 0 == RemoteAddress[1])\r
+              && ( 0 == RemoteAddress[2])\r
+              && ( 0 == RemoteAddress[3]))) {\r
+        printf ( "%s  <remote IP address>\r\n", ArgV[0]);\r
+        RetVal = EINVAL;\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Bind the socket to a local port\r
+      //\r
+      memset ( &LocalPort, 0, sizeof ( LocalPort ));\r
+      SIN_LEN ( LocalPort ) = sizeof ( LocalPort );\r
+      SIN_FAMILY ( LocalPort ) = AF_INET;\r
+      SIN_ADDR ( LocalPort ) = 0;\r
+      SIN_PORT ( LocalPort ) = 0;\r
+      RetVal = bind ( s,\r
+                      (struct sockaddr *)&LocalPort,\r
+                      sizeof ( LocalPort ));\r
+      if ( -1 == RetVal ) {\r
+        RetVal = GET_ERRNO;\r
+        printf ( "ERROR - bind error, errno: %d\r\n", RetVal );\r
+        break;\r
+      }\r
+\r
+      //\r
+      //  Specify the remote port\r
+      //\r
+      memset ( &RemotePort, 0, sizeof ( RemotePort ));\r
+      SIN_LEN ( RemotePort ) = sizeof ( RemotePort );\r
+      SIN_FAMILY ( RemotePort ) = AF_INET;\r
+      SIN_ADDR ( RemotePort ) = ( RemoteAddress[3] << 24 )\r
+                              | ( RemoteAddress[2] << 16 )\r
+                              | ( RemoteAddress[1] << 8 )\r
+                              | RemoteAddress[0];\r
+      SIN_PORT ( RemotePort ) = 0;\r
+\r
+      //\r
+      //  Initialize the messages\r
+      //\r
+      memset ( &mBuffer[0], 0, sizeof ( mBuffer ));\r
+\r
+      //\r
+      //  Send the data before the out-of-band message\r
+      //\r
+      TotalSent = 0;\r
+      BytesSent = 0;\r
+      do {\r
+        BytesTransmitted = sendto ( s,\r
+                                    &mBuffer[BytesSent],\r
+                                    sizeof ( mBuffer ) - BytesSent,\r
+                                    0,\r
+                                    (struct sockaddr *)&RemotePort,\r
+                                    sizeof ( RemotePort ));\r
+        if ( -1 == BytesTransmitted ) {\r
+          RetVal = GET_ERRNO;\r
+          printf ( "ERROR - send before error, errno: %d\r\n", RetVal );\r
+          break;\r
+        }\r
+        BytesSent += (UINT32)BytesTransmitted;\r
+        RetVal = 0;\r
+      } while ( sizeof ( mBuffer ) > BytesSent );\r
+      if ( 0 != RetVal ) {\r
+        break;\r
+      }\r
+      TotalSent += BytesSent;\r
+\r
+      //\r
+      //  Test completed successfully\r
+      //\r
+      if ( 0 == RetVal ) {\r
+        printf ( "Bytes sent:  %8d\r\n", TotalSent );\r
+      }\r
+      break;\r
+    }\r
+\r
+    //\r
+    //  Close the socket\r
+    //\r
+    CLOSE_SOCKET ( s );\r
+  }\r
+\r
+  //\r
+  //  Return the operation status\r
+  //\r
+  return RetVal;\r
+}\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h b/AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.h
new file mode 100644 (file)
index 0000000..c37b718
--- /dev/null
@@ -0,0 +1,98 @@
+/** @file\r
+  Definitions for the raw IP4 transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _RAW_IP4_TX_H_\r
+#define _RAW_IP4_TX_H_\r
+\r
+//------------------------------------------------------------------------------\r
+//  Include Files\r
+//------------------------------------------------------------------------------\r
+\r
+#ifdef  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for Windows environment\r
+//\r
+\r
+#include <winsock2.h>\r
+\r
+#define CHAR8             char\r
+#define CLOSE_SOCKET      closesocket\r
+#define EINVAL            22    //  Invalid argument\r
+#define GET_ERRNO         WSAGetLastError ( )\r
+#define SIN_ADDR(port)    port.sin_addr.S_un.S_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_family\r
+#define SIN_PORT(port)    port.sin_port\r
+#define socklen_t         int\r
+#define ssize_t           int\r
+\r
+#else   //  BUILD_FOR_WINDOWS\r
+//\r
+//  Build for EFI environment\r
+//\r
+\r
+#include <Uefi.h>\r
+#include <errno.h>\r
+#include <stdlib.h>\r
+\r
+#include <netinet/in.h>\r
+\r
+#include <sys/EfiSysCall.h>\r
+#include <sys/endian.h>\r
+#include <sys/socket.h>\r
+\r
+#define CLOSE_SOCKET      close\r
+#define GET_ERRNO         errno\r
+#define SIN_ADDR(port)    port.sin_addr.s_addr\r
+#define SIN_FAMILY(port)  port.sin_family\r
+#define SIN_LEN(port)     port.sin_len\r
+#define SIN_PORT(port)    port.sin_port\r
+#define SOCKET            int\r
+\r
+#endif  //  BUILD_FOR_WINDOWS\r
+\r
+#include <stdio.h>\r
+\r
+//------------------------------------------------------------------------------\r
+//  Constants\r
+//------------------------------------------------------------------------------\r
+\r
+//\r
+//  See http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml\r
+//  and http://tools.ietf.org/html/rfc3692\r
+//\r
+#define RAW_PROTOCOL      253\r
+\r
+//------------------------------------------------------------------------------\r
+//  API\r
+//------------------------------------------------------------------------------\r
+\r
+/**\r
+  Transmit raw IP4 packets to the remote system.\r
+\r
+  @param [in] ArgC        Argument count\r
+  @param [in] ArgV        Argument value array\r
+\r
+  @retval 0               Successfully operation\r
+ **/\r
+\r
+int\r
+RawIp4Tx (\r
+  IN int ArgC,\r
+  IN char **ArgV\r
+  );\r
+\r
+//------------------------------------------------------------------------------\r
+\r
+#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 (file)
index 0000000..5452df0
--- /dev/null
@@ -0,0 +1,64 @@
+#/** @file\r
+#  RawIp4Tx Application\r
+#\r
+# This file contains an 'Intel Peripheral Driver' and is      \r
+# licensed for Intel CPUs and chipsets under the terms of your\r
+# license agreement with Intel or your vendor.  This file may \r
+# be modified by the user, subject to additional terms of the \r
+# license agreement                                           \r
+#\r
+#\r
+# Copyright (c)  20011 Intel Corporation. All rights reserved\r
+# This software and associated documentation (if any) is furnished\r
+# under a license and may only be used or copied in accordance\r
+# with the terms of the license. Except as permitted by such\r
+# license, no part of this software or documentation may be\r
+# reproduced, stored in a retrieval system, or transmitted in any\r
+# form or by any means without the express written consent of\r
+# Intel Corporation.\r
+#\r
+##\r
+\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = RawIp4Tx\r
+  FILE_GUID                      = 3DFE0FAB-70C7-4b53-9855-985F14DB2DDA\r
+  MODULE_TYPE                    = UEFI_APPLICATION\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = ShellCEntryLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+[Sources]\r
+  Main.c\r
+  RawIp4Tx.c\r
+\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  StdLib/StdLib.dec\r
+\r
+\r
+[LibraryClasses]\r
+  BaseMemoryLib\r
+  BsdSocketLib\r
+  DebugLib\r
+  EfiSocketLib\r
+  LibC\r
+  LibMath\r
+  ShellCEntryLib\r
+  UefiBootServicesTableLib\r
+  UefiLib\r
+#  UseSocketDxe\r
+\r
+[BuildOptions]\r
+  INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186\r
+   MSFT:*_*_*_CC_FLAGS = /Od\r
+    GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable\r
+\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.sln
new file mode 100644 (file)
index 0000000..d5a5d37
--- /dev/null
@@ -0,0 +1,20 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 9.00\r
+# Visual Studio 2005\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RawIp4Tx", "RawIp4Tx.vcproj", "{11018D35-F3E3-40F4-9213-7D277AF01A17}"\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Win32 = Debug|Win32\r
+               Release|Win32 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {11018D35-F3E3-40F4-9213-7D277AF01A17}.Debug|Win32.ActiveCfg = Debug|Win32\r
+               {11018D35-F3E3-40F4-9213-7D277AF01A17}.Debug|Win32.Build.0 = Debug|Win32\r
+               {11018D35-F3E3-40F4-9213-7D277AF01A17}.Release|Win32.ActiveCfg = Release|Win32\r
+               {11018D35-F3E3-40F4-9213-7D277AF01A17}.Release|Win32.Build.0 = Release|Win32\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.vcproj
new file mode 100644 (file)
index 0000000..87d3d5d
--- /dev/null
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="8.00"\r
+       Name="RawIp4Tx"\r
+       ProjectGUID="{11018D35-F3E3-40F4-9213-7D277AF01A17}"\r
+       RootNamespace="RawIp4Tx"\r
+       Keyword="Win32Proj"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="0"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE"\r
+                               MinimalRebuild="true"\r
+                               BasicRuntimeChecks="3"\r
+                               RuntimeLibrary="3"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="4"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="WS2_32.lib"\r
+                               LinkIncremental="2"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
+                       IntermediateDirectory="$(ConfigurationName)"\r
+                       ConfigurationType="1"\r
+                       CharacterSet="1"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               AdditionalIncludeDirectories=".."\r
+                               PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE"\r
+                               RuntimeLibrary="2"\r
+                               UsePrecompiledHeader="0"\r
+                               BrowseInformation="1"\r
+                               WarningLevel="3"\r
+                               Detect64BitPortabilityProblems="true"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="WS2_32.lib"\r
+                               LinkIncremental="1"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="1"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebDeploymentTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath=".\main.c"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\RawIp4Tx.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\RawIp4Tx.h"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c
new file mode 100644 (file)
index 0000000..23946ac
--- /dev/null
@@ -0,0 +1,62 @@
+/** @file\r
+  Windows version of the raw IP4 transmit application\r
+\r
+  Copyright (c) 2011, Intel Corporation\r
+  All rights reserved. This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <RawIp4Tx.h>\r
+\r
+\r
+/**\r
+  Transmit raw IP4 packets to the remote system.\r
+\r
+  Please note that this program must be run with administrator privileges!\r
+\r
+  @param [in] argc  The number of arguments\r
+  @param [in] argv  The argument value array\r
+\r
+  @retval  0        The application exited normally.\r
+  @retval  Other    An error occurred.\r
+**/\r
+int\r
+main(\r
+  int argc,\r
+  char ** argv\r
+  )\r
+{\r
+  int RetVal;\r
+  WSADATA WsaData;\r
+\r
+  //\r
+  //  Initialize the WinSock layer\r
+  //\r
+  RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData );\r
+  if ( 0 == RetVal ) {\r
+    //\r
+    //  Start the application\r
+    //  See http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx\r
+    //\r
+    RetVal = RawIp4Tx ( argc, argv );\r
+    if ( WSAEACCES == RetVal ) {\r
+      printf ( "Requires administrator privileges to run!\r\n" );\r
+    }\r
+\r
+    //\r
+    //  Done with the WinSock layer\r
+    //\r
+    WSACleanup ( );\r
+  }\r
+\r
+  //\r
+  //  Return the final result\r
+  //\r
+  return RetVal;  \r
+}\r
diff --git a/AppPkg/Applications/Sockets/ReadMe.txt b/AppPkg/Applications/Sockets/ReadMe.txt
new file mode 100644 (file)
index 0000000..0f6a162
--- /dev/null
@@ -0,0 +1,11 @@
+Users of the socket library need to do the following:\r
+\r
+\95      Use the development branch: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK/\r
+\95      Create an Efi\etc directory on their system or USB flash device\r
+\95      Copy the files from StdLib\Efi\etc into that directory\r
+\95      Edit the files appropriately\r
+       o       Set the correct DNS servers in resolv.conf\r
+       o       Set the search order in host.conf\r
+\95      At the EFI shell\r
+       o       Set the device containing the \Efi directory as the default device\r
+       o       Run the socket application\r
index 7809e80ff8b7cdf467ad1e9e1c49e1eb8ffc166a..695db938b97ad8ccc7e210ef2c4910e0442b859a 100644 (file)
@@ -25,7 +25,7 @@
 #include <sys/socket.h>\r
 #include <sys/time.h>\r
 \r
-UINT8 mBuffer [ 65536 ];\r
+UINT8 mBuffer[ 65536 ];\r
 \r
 /**\r
   Receive a datagram\r
index 85dc1c43fe9c98e52dc7c9265ef7b7eaa31136db..2986b66babbd4617439b66fe262cb05c0ec320c7 100644 (file)
@@ -22,7 +22,7 @@
 \r
 #include <sys/socket.h>\r
 \r
-char mBuffer [65536];\r
+char mBuffer[65536];\r
 \r
 \r
 /**\r
index fdc4552b6061352d43be0ea5aa69d2ef1ea439c0..dbecda35acb9ec706512f0ae89b0840779fc67d6 100644 (file)
@@ -39,7 +39,7 @@ typedef struct {
   DATA_TYPE DataType;\r
 } OPTIONS;\r
 \r
-CONST OPTIONS mOptions [] = {\r
+CONST OPTIONS mOptions[] = {\r
   { "SO_ACCEPTCONN", SO_ACCEPTCONN, SOL_SOCKET, FALSE, DATA_TYPE_UNKNOWN },\r
   { "SO_BROADCAST", SO_BROADCAST, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },\r
   { "SO_DEBUG", SO_DEBUG, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },\r
@@ -62,9 +62,9 @@ CONST OPTIONS mOptions [] = {
 };\r
 \r
 \r
-UINT8 mBuffer [ 65536 ];\r
-UINT8 mValue [ 65536 ];\r
-char * mSocketType [] = {\r
+UINT8 mBuffer[ 65536 ];\r
+UINT8 mValue[ 65536 ];\r
+char * mSocketType[] = {\r
   "SOCK_STREAM",\r
   "SOCK_DGRAM",\r
   "SOCK_RAW",\r
@@ -103,11 +103,10 @@ DisplayOption (
   //  Display the value\r
   //\r
   Value.u8 = &mBuffer[0];\r
-  switch ( pOption->DataType )\r
-  {\r
+  switch ( pOption->DataType ) {\r
   case DATA_TYPE_UNKNOWN:\r
     Print ( L"%a:", pOption->pOptionName );\r
-    pEnd = &Value.u8 [ LengthInBytes ];\r
+    pEnd = &Value.u8[ LengthInBytes ];\r
     while ( pEnd > Value.u8 ) {\r
       Print ( L" %02x", *Value.u8 );\r
       Value.u8 += 1;\r
@@ -127,7 +126,7 @@ DisplayOption (
   case DATA_TYPE_SOCKET_TYPE:\r
     if ( 4 == LengthInBytes ) {\r
       if (( SOCK_STREAM <= *Value.i32 ) && ( SOCK_SEQPACKET >= *Value.i32 )) {\r
-        pString = mSocketType [ *Value.i32 - SOCK_STREAM ];\r
+        pString = mSocketType[ *Value.i32 - SOCK_STREAM ];\r
         Print ( L"%a", pString );\r
       }\r
       else {\r
@@ -295,7 +294,7 @@ main (
     //\r
     BytesToWrite = 0;\r
     if (( 3 > Argc )\r
-      || ( 0 < ( BytesToWrite = GetOptionValue ( pOption, Argv [2])))) {\r
+      || ( 0 < ( BytesToWrite = GetOptionValue ( pOption, Argv[2])))) {\r
       //\r
       //  Get the socket\r
       //\r
index fa5ff478d1be123c5acf82236579d3ea5491cac3..c1bd8bcc4ec4fbd6db55f37cb349232076d09b69 100644 (file)
   AppPkg/Applications/Sockets/GetNetByName/GetNetByName.inf\r
   AppPkg/Applications/Sockets/GetServByName/GetServByName.inf\r
   AppPkg/Applications/Sockets/GetServByPort/GetServByPort.inf\r
+  AppPkg/Applications/Sockets/OobRx/OobRx.inf\r
+  AppPkg/Applications/Sockets/OobTx/OobTx.inf\r
+  AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf\r
+  AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf\r
   AppPkg/Applications/Sockets/RecvDgram/RecvDgram.inf\r
   AppPkg/Applications/Sockets/SetHostName/SetHostName.inf\r
   AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.inf\r
index 9b522d1b5570bdbe5c84342b4afa5275f99edf5e..1da3c250d56693672762deda02d8d91fbe3fb705 100644 (file)
@@ -846,8 +846,7 @@ Print ( L"TFTP Opcode: 0x%08x\r\n", Opcode );
       bIgnorePacket = TRUE;\r
       break;\r
     }\r
-    if ( pTftpServer->RxBytes > (ssize_t)( pContext->BlockSize + 2 + 2 ))\r
-    {\r
+    if ( pTftpServer->RxBytes > (ssize_t)( pContext->BlockSize + 2 + 2 )) {\r
       DEBUG (( DEBUG_ERROR,\r
                 "ERROR - Receive data length of %d > %d bytes (maximum block size) for pContext 0x%08x\r\n",\r
                 pTftpServer->RxBytes - 2 - 2,\r
@@ -1049,8 +1048,7 @@ pContext->File = (EFI_HANDLE)1;
                 "ACK for block 0x%04x received\r\n",\r
                 BlockNumber ));\r
       if (( !pContext->bExpectAck )\r
-        || ( BlockNumber != pContext->AckNext ))\r
-      {\r
+        || ( BlockNumber != pContext->AckNext )) {\r
         DEBUG (( DEBUG_WARN | DEBUG_TFTP_ACK,\r
                   "WARNING - Expecting ACK 0x%0x4 not received ACK 0x%08x\r\n",\r
                   pContext->AckNext,\r
@@ -1248,8 +1246,7 @@ TftpServerTimer (
     pTftpServer->TftpPort.fd = socket ( AF_INET,\r
                                         SOCK_DGRAM,\r
                                         IPPROTO_UDP );\r
-    if ( -1 != pTftpServer->TftpPort.fd )\r
-    {\r
+    if ( -1 != pTftpServer->TftpPort.fd ) {\r
       //\r
       //  Set the socket address\r
       //\r
index e56d21be780092e094a0b03da384ec12ae400a75..b1e9f83ce59995d1f99080d9f5d2242d16e65dfb 100644 (file)
 //  Constants\r
 //------------------------------------------------------------------------------\r
 \r
-#define DEBUG_SOCKET_POLL       0x40000000  ///<  Display the socket poll messages\r
-#define DEBUG_PORT_WORK         0x20000000  ///<  Display the port work messages\r
-#define DEBUG_SERVER_TIMER      0x10000000  ///<  Display the socket poll messages\r
-#define DEBUG_TFTP_PORT         0x08000000  ///<  Display the TFTP port messages\r
-#define DEBUG_TFTP_REQUEST      0x04000000  ///<  Display the TFTP request messages\r
-#define DEBUG_TX                0x02000000  ///<  Display transmit messages\r
+#define DEBUG_PORT_WORK         0x40000000  ///<  Display the port work messages\r
+#define DEBUG_SERVER_TIMER      0x20000000  ///<  Display the socket poll messages\r
+#define DEBUG_TFTP_PORT         0x10000000  ///<  Display the TFTP port messages\r
+#define DEBUG_TFTP_REQUEST      0x08000000  ///<  Display the TFTP request messages\r
+#define DEBUG_TX                0x04000000  ///<  Display transmit messages\r
+#define DEBUG_SOCKET_POLL       0x02000000  ///<  Display the socket poll messages\r
 #define DEBUG_RX                0x01000000  ///<  Display receive messages\r
 #define DEBUG_TFTP_ACK          0x00800000  ///<  Display the TFTP ACK messages\r
 \r
@@ -155,13 +155,13 @@ typedef struct _TSDT_CONNECTION_CONTEXT {
   BOOLEAN bEofSent;             ///<  End of file sent\r
   UINT8 * pBuffer;              ///<  Pointer into the file data\r
   UINT8 * pEnd;                 ///<  End of the file data\r
-  UINT8 FileData [ 64 * TFTP_MAX_BLOCK_SIZE ];  ///<  File data to send\r
+  UINT8 FileData[ 64 * TFTP_MAX_BLOCK_SIZE ]; ///<  File data to send\r
 \r
   //\r
   //  Buffer management\r
   //\r
   ssize_t   TxBytes;            ///<  Bytes in the TX buffer\r
-  UINT8     TxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///<  Transmit buffer\r
+  UINT8     TxBuffer[ 2 + 2 + TFTP_MAX_BLOCK_SIZE ];  ///<  Transmit buffer\r
 }GCC_TSDT_CONNECTION_CONTEXT;\r
 \r
 /**\r
@@ -188,7 +188,7 @@ typedef struct {
   //\r
   struct sockaddr_in RemoteAddress; ///<  Remote address\r
   ssize_t   RxBytes;                ///<  Receive data length in bytes\r
-  UINT8     RxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///<  Receive buffer\r
+  UINT8     RxBuffer[ 2 + 2 + TFTP_MAX_BLOCK_SIZE ];  ///<  Receive buffer\r
 \r
   //\r
   //  Client port management\r
index bcb56d0ded9e38dcc9038e74f4cc8fd49c884e3e..c6caa1a568d2666e9e4d80aeaa308e0f216a78b3 100644 (file)
@@ -106,19 +106,19 @@ typedef struct {
   UINT16 IapcBootArch;        //  109\r
   UINT8 Reserved2;            //  111\r
   UINT32 Flags;               //  112\r
-  UINT32 ResetReg [3];        //  116\r
+  UINT32 ResetReg[3];         //  116\r
   UINT8 ResetValue;           //  128\r
-  UINT8 Reserved3 [3];        //  129\r
+  UINT8 Reserved3[3];         //  129\r
   UINT64 XFirmwareCtrl;       //  132\r
   UINT64 XDsdt;               //  140\r
-  UINT32 XPm1aEvtBlk [3];     //  148\r
-  UINT32 XPm1bEvtBlk [3];     //  160\r
-  UINT32 XPm1aCntBlk [3];     //  172\r
-  UINT32 XPm1bCntBlk [3];     //  184\r
-  UINT32 XPm2CntBlk [3];      //  196\r
-  UINT32 XPmTmrBlk [3];       //  208\r
-  UINT32 XGpe0Blk [3];        //  220\r
-  UINT32 XGpe1Blk [3];        //  232\r
+  UINT32 XPm1aEvtBlk[3];      //  148\r
+  UINT32 XPm1bEvtBlk[3];      //  160\r
+  UINT32 XPm1aCntBlk[3];      //  172\r
+  UINT32 XPm1bCntBlk[3];      //  184\r
+  UINT32 XPm2CntBlk[3];       //  196\r
+  UINT32 XPmTmrBlk[3];        //  208\r
+  UINT32 XGpe0Blk[3];         //  220\r
+  UINT32 XGpe1Blk[3];         //  232\r
 } ACPI_FADT;\r
 \r
 \r
@@ -146,7 +146,7 @@ typedef struct {
 } TABLE_SIGNATURE;\r
 \r
 \r
-CONST TABLE_SIGNATURE mTableId [] = {\r
+CONST TABLE_SIGNATURE mTableId[] = {\r
   { DSDT_SIGNATURE, "DSDT", PAGE_ACPI_DSDT },\r
   { FADT_SIGNATURE, "FADT", PAGE_ACPI_FADT }\r
 };\r
@@ -240,8 +240,8 @@ LocateTable (
     //\r
     //  Walk the list of entries\r
     //\r
-    pEntry = &pRsdt->Entry [ 0 ];\r
-    pEnd = &pEntry [(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];\r
+    pEntry = &pRsdt->Entry[ 0 ];\r
+    pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];\r
     while ( pEnd > pEntry ) {\r
       //\r
       //  The entry is actually a 32-bit physical table address\r
@@ -324,7 +324,7 @@ RowAnsiArray (
     //  Display the characters\r
     //\r
     pData = pChar;\r
-    pEnd = &pChar [ Length ];\r
+    pEnd = &pChar[ Length ];\r
     while ( pEnd > pData ) {\r
       Status = HttpSendCharacter ( SocketFD,\r
                                    pPort,\r
@@ -440,7 +440,7 @@ RowBytes (
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
-    pEnd = &pData [ ByteCount ];\r
+    pEnd = &pData[ ByteCount ];\r
     while ( pEnd > pData ) {\r
       Status = HttpSendHexBits ( SocketFD,\r
                                  pPort,\r
@@ -784,8 +784,8 @@ SignatureLookup (
   //  Walk the list of tables\r
   //\r
   Signature = *pSignature;\r
-  pTableId = &mTableId [ 0 ];\r
-  pEnd = &pTableId [ sizeof ( mTableId ) / sizeof ( mTableId [ 0 ])];\r
+  pTableId = &mTableId[ 0 ];\r
+  pEnd = &pTableId[ sizeof ( mTableId ) / sizeof ( mTableId[ 0 ])];\r
   while ( pEnd > pTableId ) {\r
     //\r
     //  Attempt to locate the table signature\r
@@ -895,7 +895,7 @@ AcpiDsdtPage (
                             pPort,\r
                             "OEMID",\r
                             sizeof ( pDsdt->OemId ),\r
-                            &pDsdt->OemId [ 0 ]);\r
+                            &pDsdt->OemId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -903,7 +903,7 @@ AcpiDsdtPage (
                             pPort,\r
                             "OEM Table ID",\r
                             sizeof ( pDsdt->OemTableId ),\r
-                            &pDsdt->OemTableId [ 0 ]);\r
+                            &pDsdt->OemTableId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1039,7 +1039,7 @@ AcpiFadtPage (
                             pPort,\r
                             "OEMID",\r
                             sizeof ( pFadt->OemId ),\r
-                            &pFadt->OemId [ 0 ]);\r
+                            &pFadt->OemId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1047,7 +1047,7 @@ AcpiFadtPage (
                             pPort,\r
                             "OEM Table ID",\r
                             sizeof ( pFadt->OemTableId ),\r
-                            &pFadt->OemTableId [ 0 ]);\r
+                            &pFadt->OemTableId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1576,7 +1576,7 @@ AcpiRsdp10Page (
                             pPort,\r
                             "OemId",\r
                             sizeof ( pRsdp10b->OemId ),\r
-                            &pRsdp10b->OemId [ 0 ]);\r
+                            &pRsdp10b->OemId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1679,7 +1679,7 @@ AcpiRsdp30Page (
                             pPort,\r
                             "OemId",\r
                             sizeof ( pRsdp30->OemId ),\r
-                            &pRsdp30->OemId [ 0 ]);\r
+                            &pRsdp30->OemId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1726,7 +1726,7 @@ AcpiRsdp30Page (
                         pPort,\r
                         "Reserved",\r
                         sizeof ( pRsdp30->Reserved ),\r
-                        &pRsdp30->Reserved [ 0 ]);\r
+                        &pRsdp30->Reserved[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1771,7 +1771,7 @@ AcpiRsdtPage (
   CONST CHAR8 * pTableName;\r
   CONST CHAR16 * pWebPage;\r
   EFI_STATUS Status;\r
-  UINT32 TableName [ 2 ];\r
+  UINT32 TableName[ 2 ];\r
 \r
   DBG_ENTER ( );\r
 \r
@@ -1833,7 +1833,7 @@ AcpiRsdtPage (
                             pPort,\r
                             "OEMID",\r
                             sizeof ( pRsdt->OemId ),\r
-                            &pRsdt->OemId [ 0 ]);\r
+                            &pRsdt->OemId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1841,7 +1841,7 @@ AcpiRsdtPage (
                             pPort,\r
                             "OEM Table ID",\r
                             sizeof ( pRsdt->OemTableId ),\r
-                            &pRsdt->OemTableId [ 0 ]);\r
+                            &pRsdt->OemTableId[ 0 ]);\r
     if ( EFI_ERROR ( Status )) {\r
       break;\r
     }\r
@@ -1871,16 +1871,16 @@ AcpiRsdtPage (
     //\r
     //  Walk the list of entries\r
     //\r
-    pEntry = &pRsdt->Entry [ 0 ];\r
-    pEnd = &pEntry [(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];\r
-    TableName [ 1 ] = 0;\r
+    pEntry = &pRsdt->Entry[ 0 ];\r
+    pEnd = &pEntry[(( pRsdt->Length - sizeof ( *pRsdt )) >> 2 ) + 1 ];\r
+    TableName[ 1 ] = 0;\r
     while ( pEnd > pEntry ) {\r
       //\r
       //  The entry is actually a 32-bit physical table address\r
       //  The first entry in the table is the 32-bit table signature\r
       //\r
-      TableName [ 0 ] = *(UINT32 *)*pEntry;\r
-      pWebPage = SignatureLookup ( &TableName [ 0 ], &pTableName );\r
+      TableName[ 0 ] = *(UINT32 *)*pEntry;\r
+      pWebPage = SignatureLookup ( &TableName[ 0 ], &pTableName );\r
 \r
       //\r
       //  Display the table address\r
index 8a3de87ed4c61a7d5cfbd5d91a8ebbb1302b6ebc..9208a46b5ee8be054402793d277718558e9d81b2 100644 (file)
@@ -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,
index 314705b68f9189ecf9b0e591c490d70a8a58cc2c..8487de751a1287074b90c452f8273d7cb1109215 100644 (file)
@@ -561,7 +561,7 @@ HttpRequest (
     //  Attempt to parse the command\r
     //\r
     pData = &pPort->Request[0];\r
-    pEnd = &pData [ pPort->RequestLength ];\r
+    pEnd = &pData[ pPort->RequestLength ];\r
     pVerb = pData;\r
     pWebPage = HttpReplaceSpace ( pVerb, pEnd );\r
     if ( pEnd <= pWebPage ) {\r
@@ -589,7 +589,7 @@ HttpRequest (
     //  Walk the page table\r
     //\r
     pPage = &mPageList[0];\r
-    pPageEnd = &pPage [ mPageCount ];\r
+    pPageEnd = &pPage[ mPageCount ];\r
     while ( pPageEnd > pPage ) {\r
       //\r
       //  Determine if the page was located\r
@@ -668,15 +668,14 @@ HttpSend (
     //\r
     MaxBytes = sizeof ( pPort->TxBuffer );\r
     DataBytes = MaxBytes - pPort->TxBytes;\r
-    if ( DataBytes > LengthInBytes )\r
-    {\r
+    if ( DataBytes > LengthInBytes ) {\r
       DataBytes = LengthInBytes;\r
     }\r
 \r
     //\r
     //  Copy the data into the buffer\r
     //\r
-    CopyMem ( &pPort->TxBuffer [ pPort->TxBytes ],\r
+    CopyMem ( &pPort->TxBuffer[ pPort->TxBytes ],\r
               pBuffer,\r
               DataBytes );\r
 \r
@@ -910,7 +909,7 @@ HttpSendDump (
     //\r
     //  Walk the bytes to be displayed\r
     //\r
-    pEnd = &pData [ ByteCount ];\r
+    pEnd = &pData[ ByteCount ];\r
     while ( pEnd > pData ) {\r
       //\r
       //  Display the address\r
@@ -958,7 +957,7 @@ HttpSendDump (
       if (( BYTES_ON_A_LINE - InitialSpaces ) < BytesToDisplay ) {\r
         BytesToDisplay = BYTES_ON_A_LINE - InitialSpaces;\r
       }\r
-      pDataEnd = &pData [ BytesToDisplay ];\r
+      pDataEnd = &pData[ BytesToDisplay ];\r
       pTemp = pData;\r
       while ( pDataEnd > pTemp ) {\r
         Status = HttpSendHexBits ( SocketFD,\r
@@ -1151,7 +1150,7 @@ HttpSendGuid (
       Status = HttpSendHexBits ( SocketFD,\r
                                  pPort,\r
                                  8,\r
-                                 pGuid->Data4 [ Index ]);\r
+                                 pGuid->Data4[ Index ]);\r
       if ( EFI_ERROR ( Status )) {\r
         break;\r
       }\r
@@ -1488,7 +1487,7 @@ HttpSendValue (
   UINT64 Digit;\r
   CONST UINT64 * pEnd;\r
   CONST UINT64 * pDivisor;\r
-  CONST UINT64 pDivisors [ ] = {\r
+  CONST UINT64 pDivisors[ ] = {\r
      10000000000000000000L,\r
       1000000000000000000L,\r
        100000000000000000L,\r
@@ -1522,7 +1521,7 @@ HttpSendValue (
   //\r
   bDisplayZeros = FALSE;\r
   pDivisor = &pDivisors[0];\r
-  pEnd = &pDivisor [ sizeof ( pDivisors ) / sizeof ( pDivisors [0])];\r
+  pEnd = &pDivisor[ sizeof ( pDivisors ) / sizeof ( pDivisors[0])];\r
   while ( pEnd > pDivisor ) {\r
     //\r
     //  Determine the next digit\r
index 5eccfb21817167439d0935171530face6994e5b3..f26ab0fdbbb12852f3048db1d883fa712d468be7 100644 (file)
@@ -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
index 00bf4b6feff4b79c1599b3e4333c42032f35cade..5c73bfe8f7d40df280ffaaace29375672dbbea56 100644 (file)
@@ -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
       //
index 6078df0362acc2269fa3268d51b807fdb14b5b45..0eee114832b0318a7d9c1021c6312a0c87c5f8ca 100644 (file)
 \r
 #endif  //  MDEPKG_NDEBUG\r
 \r
-#define WEB_SERVER_SIGNATURE        SIGNATURE_32('W','e','b','S') ///<  DT_WEB_SERVER memory signature\r
+#define WEB_SERVER_SIGNATURE        SIGNATURE_32 ('W','e','b','S')  ///<  DT_WEB_SERVER memory signature\r
 \r
 #define SPACES_ADDRESS_TO_DATA      2\r
 #define BYTES_ON_A_LINE             16\r
@@ -154,9 +154,9 @@ typedef struct {
   //\r
   size_t    RequestLength;      ///<  Request length in bytes\r
   size_t    TxBytes;            ///<  Bytes in the TX buffer\r
-  UINT8     Request [ 65536 ];  ///<  Page request\r
-  UINT8     RxBuffer [ 65536 ]; ///<  Receive buffer\r
-  UINT8     TxBuffer [ 65536 ]; ///<  Transmit buffer\r
+  UINT8     Request[ 65536 ];   ///<  Page request\r
+  UINT8     RxBuffer[ 65536 ];  ///<  Receive buffer\r
+  UINT8     TxBuffer[ 65536 ];  ///<  Transmit buffer\r
 } WSDT_PORT;\r
 \r
 /**\r
@@ -186,7 +186,7 @@ typedef struct {
   WSDT_PORT ** ppPortList;      ///<  List of port management structures\r
 } DT_WEB_SERVER;\r
 \r
-//#define SERVER_FROM_SERVICE(a) CR(a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding\r
+//#define SERVER_FROM_SERVICE(a) CR (a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE)  ///< Locate DT_LAYER from service binding\r
 \r
 extern DT_WEB_SERVER mWebServer;\r
 \r
@@ -217,7 +217,7 @@ typedef struct {
   UINT16 * pDescription;      ///<  Description of the page\r
 } DT_PAGE;\r
 \r
-extern CONST DT_PAGE mPageList [];  ///<  List of pages\r
+extern CONST DT_PAGE mPageList[];   ///<  List of pages\r
 extern CONST UINTN mPageCount;      ///<  Number of pages\r
 \r
 //------------------------------------------------------------------------------\r