summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-20 00:29:59 +0000
committerlpleahy <lpleahy@6f19259b-4bc3-4df7-8a09-765794883524>2011-08-20 00:29:59 +0000
commita86f6e9e94f1a063eeb698feb65347b1936d04ec (patch)
tree0e40a82cc93c459500d2e1ebe11c2bd6a1f82334
parent7196d5abe97129f458c8d3a4a19d9472451b70c8 (diff)
downloadedk2-a86f6e9e94f1a063eeb698feb65347b1936d04ec.zip
edk2-a86f6e9e94f1a063eeb698feb65347b1936d04ec.tar.gz
edk2-a86f6e9e94f1a063eeb698feb65347b1936d04ec.tar.bz2
Add the PortScan application.
Notes: * This application does NOT run under Windows, see http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx#limitations_on_raw_sockets * This application does NOT run under the UEFI Shell since RawData is not supported by Ip4Dxe, see line 1199 of MdeModulePkg\Universal\Network\Ip4Dxe\Ip4Impl.c git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/EADK@12178 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--AppPkg/Applications/Sockets/PortScan/Main.c44
-rw-r--r--AppPkg/Applications/Sockets/PortScan/OsTimer.c156
-rw-r--r--AppPkg/Applications/Sockets/PortScan/OsTimer.h92
-rw-r--r--AppPkg/Applications/Sockets/PortScan/OsTypes.h74
-rw-r--r--AppPkg/Applications/Sockets/PortScan/PortScan.c494
-rw-r--r--AppPkg/Applications/Sockets/PortScan/PortScan.h54
-rw-r--r--AppPkg/Applications/Sockets/PortScan/PortScan.inf65
-rw-r--r--AppPkg/Applications/Sockets/PortScan/Windows/OsTimer.c190
-rw-r--r--AppPkg/Applications/Sockets/PortScan/Windows/PortMap.sln20
-rw-r--r--AppPkg/Applications/Sockets/PortScan/Windows/PortMap.vcproj223
-rw-r--r--AppPkg/Applications/Sockets/PortScan/Windows/main.c63
-rw-r--r--AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.suobin25600 -> 0 bytes
-rw-r--r--AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c5
-rw-r--r--AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.suobin20480 -> 0 bytes
-rw-r--r--AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c5
-rw-r--r--AppPkg/Applications/Sockets/Sockets.inc1
16 files changed, 1486 insertions, 0 deletions
diff --git a/AppPkg/Applications/Sockets/PortScan/Main.c b/AppPkg/Applications/Sockets/PortScan/Main.c
new file mode 100644
index 0000000..2beb4c9
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/Main.c
@@ -0,0 +1,44 @@
+/** @file
+ Port scan application
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PortScan.h"
+
+
+/**
+ Determine which TCP ports are open on a remote system
+
+ @param [in] Argc The number of arguments
+ @param [in] Argv The argument value array
+
+ @retval 0 The application exited normally.
+ @retval Other An error occurred.
+**/
+int
+main (
+ IN int Argc,
+ IN char **Argv
+ )
+{
+ int RetVal;
+
+ //
+ // Run the application
+ //
+ RetVal = PortScan ( Argc, Argv );
+
+ //
+ // Return the operation status
+ //
+ return RetVal;
+}
diff --git a/AppPkg/Applications/Sockets/PortScan/OsTimer.c b/AppPkg/Applications/Sockets/PortScan/OsTimer.c
new file mode 100644
index 0000000..0a95f6f
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/OsTimer.c
@@ -0,0 +1,156 @@
+/** @file
+ OS Timer Support
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "OsTimer.h"
+#include <Library/UefiBootServicesTableLib.h>
+
+
+/**
+ Cancel a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCancel (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Cancel the timer
+ //
+ Status = gBS->SetTimer ( TimerEvent,
+ TimerCancel,
+ 0 );
+
+ //
+ // Return the cancel status
+ //
+ return Status;
+}
+
+
+/**
+ Close a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerClose (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Close the timer event
+ //
+ Status = gBS->CloseEvent ( TimerEvent );
+
+ //
+ // Return the close status
+ //
+ return Status;
+}
+
+
+/**
+ Create a timer
+
+ @param [out] TimerEvent Address to return the timer event handle
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCreate (
+ OUT EFI_EVENT * pTimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Create the timer event
+ //
+ Status = gBS->CreateEvent ( EVT_TIMER,
+ 0,
+ NULL,
+ NULL,
+ pTimerEvent );
+
+ //
+ // Return the creation status
+ //
+ return Status;
+}
+
+
+/**
+ Determine if a timer has expired
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Timer expired
+ **/
+EFI_STATUS
+OsTimerExpired (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Determine if the timer is expired
+ //
+ Status = gBS->CheckEvent ( TimerEvent );
+
+ //
+ // Return the expiration status
+ //
+ return Status;
+}
+
+
+/**
+ Start a timer
+
+ @param [in] TimerEvent Event handle for the timer
+ @param [in] Timeout Relative time when the timer expires
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerStart (
+ IN EFI_EVENT TimerEvent,
+ IN UINT64 Timeout
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Start the timer
+ //
+ Status = gBS->SetTimer ( TimerEvent,
+ TimerRelative,
+ Timeout );
+
+ //
+ // Return the start status
+ //
+ return Status;
+}
diff --git a/AppPkg/Applications/Sockets/PortScan/OsTimer.h b/AppPkg/Applications/Sockets/PortScan/OsTimer.h
new file mode 100644
index 0000000..c969431
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/OsTimer.h
@@ -0,0 +1,92 @@
+/** @file
+ Definitions for the OS timer support routines
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _OS_TIMER_H_
+#define _OS_TIMER_H_
+
+//------------------------------------------------------------------------------
+// Include Files
+//------------------------------------------------------------------------------
+
+#include "OsTypes.h"
+
+//------------------------------------------------------------------------------
+// Timer API
+//------------------------------------------------------------------------------
+
+/**
+ Cancel a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCancel (
+ IN EFI_EVENT TimerEvent
+ );
+
+/**
+ Close a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerClose (
+ IN EFI_EVENT TimerEvent
+ );
+
+/**
+ Create a timer
+
+ @param [out] TimerEvent Address to return the timer event handle
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCreate (
+ OUT EFI_EVENT * pTimerEvent
+ );
+
+/**
+ Determine if a timer has expired
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Timer expired
+ **/
+EFI_STATUS
+OsTimerExpired (
+ IN EFI_EVENT TimerEvent
+ );
+
+/**
+ Start a timer
+
+ @param [in] TimerEvent Event handle for the timer
+ @param [in] Timeout Relative time when the timer expires
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerStart (
+ IN EFI_EVENT TimerEvent,
+ IN UINT64 Timeout
+ );
+
+//------------------------------------------------------------------------------
+
+#endif // _OS_TIMER_H_ \ No newline at end of file
diff --git a/AppPkg/Applications/Sockets/PortScan/OsTypes.h b/AppPkg/Applications/Sockets/PortScan/OsTypes.h
new file mode 100644
index 0000000..0aba1dd
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/OsTypes.h
@@ -0,0 +1,74 @@
+/** @file
+ Definitions for the OS types
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _OS_TYPES_H_
+#define _OS_TYPES_H_
+
+//------------------------------------------------------------------------------
+// Include Files
+//------------------------------------------------------------------------------
+
+#ifdef BUILD_FOR_WINDOWS
+//
+// Build for Windows environment
+//
+
+#include <winsock2.h>
+#include <WS2tcpip.h>
+#include <windows.h>
+
+#define CLOSE_SOCKET closesocket
+#define EFI_ERROR(Status) ( NO_ERROR != Status )
+#define EFI_EVENT HANDLE
+#define EFI_STATUS DWORD
+#define EINVAL 22 // Invalid argument
+#define SIN_ADDR(port) port.sin_addr.S_un.S_addr
+#define SIN_FAMILY(port) port.sin_family
+#define SIN_LEN(port) port.sin_family
+#define SIN_PORT(port) port.sin_port
+#define GET_ERRNO WSAGetLastError ( )
+
+#define ssize_t int
+#define socklen_t int
+
+#else // BUILD_FOR_WINDOWS
+//
+// Build for EFI environment
+//
+
+#include <Uefi.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include <netinet/in.h>
+#include <netdb.h>
+
+#include <sys/EfiSysCall.h>
+#include <sys/endian.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+
+#define CLOSE_SOCKET close
+#define SIN_ADDR(port) port.sin_addr.s_addr
+#define SIN_FAMILY(port) port.sin_family
+#define SIN_LEN(port) port.sin_len
+#define SIN_PORT(port) port.sin_port
+#define SOCKET int
+#define GET_ERRNO errno
+
+#endif // BUILD_FOR_WINDOWS
+
+//------------------------------------------------------------------------------
+
+#endif // _OS_TYPES_H_ \ No newline at end of file
diff --git a/AppPkg/Applications/Sockets/PortScan/PortScan.c b/AppPkg/Applications/Sockets/PortScan/PortScan.c
new file mode 100644
index 0000000..cc13a0c
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/PortScan.c
@@ -0,0 +1,494 @@
+/** @file
+ Port scan application
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "PortScan.h"
+
+UINT8 mRxBuffer[65536];
+UINT8 mTxBuffer[65536];
+
+#define FLG_FIN 0x01
+#define FLG_SYN 0x02
+#define FLG_RST 0x04
+#define FLG_PSH 0x08
+#define FLG_ACK 0x10
+#define FLG_URG 0x20
+
+/**
+ Determine which TCP ports are open on a remote system
+
+ @param [in] ArgC Argument count
+ @param [in] ArgV Argument value array
+
+ @retval 0 Successfully operation
+ **/
+int
+PortScan (
+ IN int ArgC,
+ IN char **ArgV
+ )
+{
+ ssize_t BytesReceived;
+ ssize_t BytesTransmitted;
+ UINT32 Checksum;
+ UINT16 Identification;
+ struct sockaddr_in LocalAddress;
+ UINT32 LocalInput[4];
+ int MaxPortNumber;
+ UINT8 * pData;
+ UINT16 * pEnd;
+ UINT8 * pIpHeader;
+ int PortNumber;
+ UINT8 * pRxIpHeader;
+ UINT8 * pRxTcpHeader;
+ UINT8 * pTcpHeader;
+ UINT16 * pWord;
+ struct sockaddr_in RemoteAddress;
+ socklen_t RemoteAddressLength;
+ UINT64 ResponseTimeDelay;
+ int RetVal;
+ SOCKET s;
+ struct servent * pServEnt;
+ UINT16 SourcePort;
+ EFI_STATUS Status;
+ struct sockaddr_in TargetAddress;
+ UINT32 TargetInput[4];
+ UINT32 TcpChecksum;
+ EFI_EVENT Timer;
+ int TxBytes;
+ int Value;
+
+ //
+ // Assume success
+ //
+ RetVal = 0;
+
+ //
+ // Set the ID value
+ //
+ Identification = 0xdead;
+ SourcePort = 54321;
+
+ //
+ // Validate the arguments
+ //
+ if (( 3 > ArgC )
+ || ( 4 != sscanf ( ArgV[1],
+ "%d.%d.%d.%d",
+ &LocalInput[0],
+ &LocalInput[1],
+ &LocalInput[2],
+ &LocalInput[3]))
+ || ( 224 < LocalInput[0])
+ || ( 255 < LocalInput[1])
+ || ( 255 < LocalInput[2])
+ || ( 255 < LocalInput[3])
+ || (( 0 == LocalInput[0])
+ && ( 0 == LocalInput[1])
+ && ( 0 == LocalInput[2])
+ && ( 0 == LocalInput[3]))
+ || ( 4 != sscanf ( ArgV[2],
+ "%d.%d.%d.%d",
+ &TargetInput[0],
+ &TargetInput[1],
+ &TargetInput[2],
+ &TargetInput[3]))
+ || ( 224 < TargetInput[0])
+ || ( 255 < TargetInput[1])
+ || ( 255 < TargetInput[2])
+ || ( 255 < TargetInput[3])
+ || (( 0 == TargetInput[0])
+ && ( 0 == TargetInput[1])
+ && ( 0 == TargetInput[2])
+ && ( 0 == TargetInput[3]))) {
+ printf ( "%s <local IP address> <target IP address>\r\n", ArgV[0]);
+ RetVal = EINVAL;
+ }
+ else {
+ //
+ // Set the local address
+ //
+ memset ( &LocalAddress, 0, sizeof ( LocalAddress ));
+ SIN_FAMILY ( LocalAddress ) = AF_INET;
+ SIN_LEN ( LocalAddress ) = sizeof ( LocalAddress );
+ SIN_ADDR ( LocalAddress ) = LocalInput[0]
+ | ( LocalInput[1] << 8 )
+ | ( LocalInput[2] << 16 )
+ | ( LocalInput[3] << 24 );
+
+ //
+ // Set the target address
+ //
+ memset ( &TargetAddress, 0, sizeof ( TargetAddress ));
+ SIN_FAMILY ( TargetAddress ) = AF_INET;
+ SIN_LEN ( TargetAddress ) = sizeof ( TargetAddress );
+ SIN_ADDR ( TargetAddress ) = TargetInput[0]
+ | ( TargetInput[1] << 8 )
+ | ( TargetInput[2] << 16 )
+ | ( TargetInput[3] << 24 );
+
+ //
+ // Determine the maximum port number
+ //
+ MaxPortNumber = 1024;
+
+ //
+ // Set the receive time delay
+ //
+ ResponseTimeDelay = PORT_RESPONSE_MSEC;
+ ResponseTimeDelay *= 1000 * 10;
+
+ //
+ // Create the timer event
+ //
+ Status = OsTimerCreate ( &Timer );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Open the socket
+ //
+ s = socket ( AF_INET, SOCK_RAW, IPPROTO_TCP );
+ if ( -1 != s ) {
+ //
+ // Set socket mode to include the header
+ //
+ Value = 1;
+ RetVal = setsockopt ( s,
+ IPPROTO_IP,
+ IP_HDRINCL,
+ (UINT8 *)&Value,
+ sizeof ( Value ));
+ if ( -1 != RetVal ) {
+ //
+ // Bind to the local adapter
+ //
+ RetVal = bind ( s,
+ (struct sockaddr *)&LocalAddress,
+ sizeof ( LocalAddress ));
+ if ( -1 != RetVal ) {
+ //
+ // Attempt to connect to the remote system
+ //
+ RetVal = connect ( s,
+ (struct sockaddr *)&TargetAddress,
+ sizeof ( TargetAddress ));
+ if ( -1 != RetVal ) {
+ //
+ // Build the IP header
+ // See http://www.ietf.org/rfc/rfc791.txt
+ //
+ pData = &mTxBuffer[0];
+ pIpHeader = pData;
+ *pData++ = 0x45; // IPv: 4, Header length: 5 * 32-bits
+ *pData++ = 0;
+ pData += 2; // Skip over packet length
+ *pData++ = (UINT8)Identification; // 16-bit ID value
+ *pData++ = (UINT8)( Identification >> 8 );
+ *pData++ = 0x40; // Don't fragment
+ *pData++ = 0; // Fragment offset
+ *pData++ = 128; // TTL
+ *pData++ = IPPROTO_TCP; // Protocol
+ *pData++ = 0; // 16-bit Checksum
+ *pData++ = 0;
+
+ *pData++ = (UINT8)SIN_ADDR ( LocalAddress ); // Source address
+ *pData++ = (UINT8)( SIN_ADDR ( LocalAddress ) >> 8 );
+ *pData++ = (UINT8)( SIN_ADDR ( LocalAddress ) >> 16 );
+ *pData++ = (UINT8)( SIN_ADDR ( LocalAddress ) >> 24 );
+
+ *pData++ = (UINT8)SIN_ADDR ( TargetAddress ); // Destination address
+ *pData++ = (UINT8)( SIN_ADDR ( TargetAddress ) >> 8 );
+ *pData++ = (UINT8)( SIN_ADDR ( TargetAddress ) >> 16 );
+ *pData++ = (UINT8)( SIN_ADDR ( TargetAddress ) >> 24 );
+
+ //
+ // Build the TCP header
+ // See http://www.ietf.org/rfc/rfc793.txt
+ //
+ pTcpHeader = pData;
+ *pData++ = (UINT8)( SourcePort >> 8 ); // 16-bit Source port
+ *pData++ = (UINT8)SourcePort;
+ *pData++ = 0; // 16-bit Destination port
+ *pData++ = 0;
+ *pData++ = 0xdb; // 32-bit Sequence number
+ *pData++ = 0xb1;
+ *pData++ = 0x62;
+ *pData++ = 0x54;
+ *pData++ = 0; // 32-bit Acknowledgement number
+ *pData++ = 0;
+ *pData++ = 0;
+ *pData++ = 0;
+ *pData++ = 0; // Header length in 32-bit words / reserved
+ *pData++ = FLG_SYN; // Flags
+ *pData++ = 0x20; // 16-bit Window size: 8192
+ *pData++ = 0;
+ *pData++ = 0; // 16-bit Checksum
+ *pData++ = 0;
+ *pData++ = 0; // 16-bit Urgent pointer
+ *pData++ = 0;
+
+ //
+ // TCP Options
+ //
+/*
+ *pData++ = 2; // Max segment size 1460
+ *pData++ = 4;
+ *pData++ = 5;
+ *pData++ = 0xb4;
+
+ *pData++ = 1; // NOP
+
+ *pData++ = 3; // Windows scale 2
+ *pData++ = 3;
+ *pData++ = 2;
+
+ *pData++ = 1; // NOP
+ *pData++ = 1; // NOP
+
+ *pData++ = 4; // TCP SACK Permitted
+ *pData++ = 2;
+*/
+
+ //
+ // Set the header length in 32-bit words
+ //
+ pTcpHeader[12] = (UINT8)((( pData - pTcpHeader ) >> 2 ) << 4 );
+
+ //
+ // Set the message length
+ //
+ TxBytes = (int)( pData - &mTxBuffer[0]);
+ pIpHeader[2] = (UINT8)( TxBytes >> 8 );
+ pIpHeader[3] = (UINT8)TxBytes;
+
+ //
+ // Computer the IP header checksum
+ //
+ Checksum = 0;
+ pWord = (UINT16 *)&mTxBuffer[0];
+ pEnd = (UINT16 *)pTcpHeader;
+ while ( pEnd > pWord ) {
+ Checksum += htons ( *pWord++ );
+ }
+ while ( 0xffff < Checksum ) {
+ Checksum = ( Checksum >> 16 ) + ( Checksum & 0xffff );
+ }
+ Checksum = ~Checksum;
+
+ //
+ // Insert the IP header checksum
+ //
+ pIpHeader[10] = (UINT8)( Checksum >> 8 );
+ pIpHeader[11] = (UINT8)Checksum;
+
+ //
+ // Compute the TCP header checksum
+ //
+ TcpChecksum = IPPROTO_TCP;
+ TcpChecksum += ((UINT16)( pData - pTcpHeader ));
+ pWord = (UINT16 *)&pTcpHeader[-8];
+ pEnd = (UINT16 *)pData;
+ while ( pEnd > pWord ) {
+ TcpChecksum += htons ( *pWord++ );
+ }
+
+ //
+ // Loop through the list of ports
+ //
+ for ( PortNumber = 1; MaxPortNumber > PortNumber; PortNumber++ ) {
+ //
+ // Set the port number
+ //
+ pTcpHeader[2] = (UINT8)( PortNumber >> 8 );
+ pTcpHeader[3] = (UINT8)PortNumber;
+
+ //
+ // Finish computing the TCP header checksum
+ //
+ Checksum = TcpChecksum + htons( *(UINT16 *)&pTcpHeader[2]);
+ while ( 0xffff < Checksum ) {
+ Checksum = ( Checksum >> 16 ) + ( Checksum & 0xffff );
+ }
+ Checksum = ~Checksum;
+
+ //
+ // Insert the TCP header checksum
+ //
+ pTcpHeader[16] = (UINT8)( Checksum >> 8 );
+ pTcpHeader[17] = (UINT8)Checksum;
+
+ //
+ // Send the TCP packet - SYN RST
+ //
+ BytesTransmitted = sendto ( s,
+ &mTxBuffer[0],
+ TxBytes,
+ 0,
+ (struct sockaddr *)&TargetAddress,
+ sizeof ( TargetAddress ));
+ if ( 0 < BytesTransmitted ) {
+ //
+ // Start the timer
+ //
+ Status = OsTimerStart ( Timer, ResponseTimeDelay );
+ if ( !EFI_ERROR ( Status )) {
+ do {
+ RemoteAddressLength = sizeof ( RemoteAddress );
+ BytesReceived = recvfrom ( s,
+ &mRxBuffer[0],
+ sizeof ( mRxBuffer ),
+ 0,
+ (struct sockaddr *)&RemoteAddress,
+ &RemoteAddressLength );
+ if ( 0 < BytesReceived ) {
+ //
+ // Packet received
+ // Validate the response (SYN ACK)
+ //
+ pRxIpHeader = &mRxBuffer[0];
+ pRxTcpHeader = &pRxIpHeader [( pRxIpHeader [0] & 0xf ) << 2 ];
+ if (( pIpHeader[12] == pRxIpHeader[16]) // Our address
+ && ( pIpHeader[13] == pRxIpHeader[17])
+ && ( pIpHeader[14] == pRxIpHeader[18])
+ && ( pIpHeader[15] == pRxIpHeader[19])
+ && ( pIpHeader[16] == pRxIpHeader[12]) // Target address
+ && ( pIpHeader[17] == pRxIpHeader[13])
+ && ( pIpHeader[18] == pRxIpHeader[14])
+ && ( pIpHeader[19] == pRxIpHeader[15])
+ && ( IPPROTO_TCP == pRxIpHeader[9]) // TCP protocol
+ && ( pTcpHeader[0] == pRxTcpHeader[2]) // Source port
+ && ( pTcpHeader[1] == pRxTcpHeader[3])
+ && ( pTcpHeader[2] == pRxTcpHeader[0]) // Destination port
+ && ( pTcpHeader[3] == pRxTcpHeader[1])
+ && (( FLG_ACK | FLG_SYN ) == pRxTcpHeader[13])) {
+ //
+ // Cancel the timeout
+ //
+ Status = OsTimerCancel ( Timer );
+ if ( EFI_ERROR ( Status )) {
+ RetVal = (int)Status;
+ printf ( "ERROR - OsTimerCancel error, Status: %d\r\n", Status );
+ break;
+ }
+
+ //
+ // Display the port number and name
+ //
+ pServEnt = getservbyport ( PortNumber, "TCP" );
+ printf ( "%5d", PortNumber );
+ if ( NULL != pServEnt ) {
+ printf ( " - %s", pServEnt->s_name );
+ }
+ printf ( "\r\n" );
+ }
+ else {
+ //
+ // Invalid response
+ //
+ BytesReceived = -1;
+ }
+ }
+ else {
+ //
+ // No data received
+ // Check for response timeout
+ //
+ Status = OsTimerExpired ( Timer );
+ if ( !EFI_ERROR ( Status )) {
+ //
+ // Receive timeout
+ //
+ break;
+ }
+ Status = 0;
+ }
+ } while ( 0 >= BytesReceived );
+ if ( EFI_ERROR ( Status )) {
+ break;
+ }
+ }
+ else {
+ //
+ // SetTimer error
+ //
+ RetVal = (int)Status;
+ printf ( "ERROR - OsTimerStart error, Status: %d\r\n", Status );
+ break;
+ }
+ }
+ else {
+ RetVal = GET_ERRNO;
+ printf ( "ERROR - sendto error, errno: %d\r\n", RetVal );
+ break;
+ }
+ }
+ }
+ else {
+ //
+ // connect error
+ //
+ RetVal = GET_ERRNO;
+ printf ( "ERROR - connect error, errno: %d\r\n", RetVal );
+ }
+ }
+ else {
+ //
+ // bind error
+ //
+ RetVal = GET_ERRNO;
+ printf ( "ERROR - bind error, errno: %d\r\n", RetVal );
+ }
+ }
+ else {
+ //
+ // setsockopt error
+ //
+ RetVal = GET_ERRNO;
+ printf ( "ERROR - setsockopt error, errno: %d\r\n", RetVal );
+ }
+
+ //
+ // Close the socket
+ //
+ CLOSE_SOCKET ( s );
+ printf ( "Socket closed\r\n" );
+ }
+ else {
+ //
+ // Socket creation error
+ //
+ RetVal = GET_ERRNO;
+ printf ( "ERROR - socket error, errno: %d\r\n", RetVal );
+ }
+
+ //
+ // Done with the event
+ //
+ Status = OsTimerClose ( Timer );
+ if ( EFI_ERROR ( Status )) {
+ printf ( "ERROR - CloseEvent error, Status: %d\r\n", Status );
+ }
+ }
+ else {
+ //
+ // Create event error
+ //
+ RetVal = (int)Status;
+ printf ( "ERROR - OsTimerCreate error, Status: %d\r\n", Status );
+ }
+ }
+
+ //
+ // Return the operation status
+ //
+ return RetVal;
+}
diff --git a/AppPkg/Applications/Sockets/PortScan/PortScan.h b/AppPkg/Applications/Sockets/PortScan/PortScan.h
new file mode 100644
index 0000000..809ff26
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/PortScan.h
@@ -0,0 +1,54 @@
+/** @file
+ Definitions for the port scan application
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _PORT_SCAN_H_
+#define _PORT_SCAN_H_
+
+//------------------------------------------------------------------------------
+// Include Files
+//------------------------------------------------------------------------------
+
+#include "OsTypes.h"
+#include "OsTimer.h"
+#include <stdio.h>
+
+//------------------------------------------------------------------------------
+// Constants
+//------------------------------------------------------------------------------
+
+#define PORT_RESPONSE_MSEC 100 // Milliseconds to wait for a response
+#define RX_TIMEOUT_MSEC 100 // Milliseconds to wait for a receive packet
+
+//------------------------------------------------------------------------------
+// API
+//------------------------------------------------------------------------------
+
+/**
+ Determine which TCP ports are open on a remote system
+
+ @param [in] ArgC Argument count
+ @param [in] ArgV Argument value array
+
+ @retval 0 Successfully operation
+ **/
+
+int
+PortScan (
+ IN int ArgC,
+ IN char **ArgV
+ );
+
+//------------------------------------------------------------------------------
+
+#endif // _PORT_SCAN_H_
diff --git a/AppPkg/Applications/Sockets/PortScan/PortScan.inf b/AppPkg/Applications/Sockets/PortScan/PortScan.inf
new file mode 100644
index 0000000..003adbf
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/PortScan.inf
@@ -0,0 +1,65 @@
+#/** @file
+# PortScan Application
+#
+# This file contains an 'Intel Peripheral Driver' and is
+# licensed for Intel CPUs and chipsets under the terms of your
+# license agreement with Intel or your vendor. This file may
+# be modified by the user, subject to additional terms of the
+# license agreement
+#
+#
+# Copyright (c) 20011 Intel Corporation. All rights reserved
+# This software and associated documentation (if any) is furnished
+# under a license and may only be used or copied in accordance
+# with the terms of the license. Except as permitted by such
+# license, no part of this software or documentation may be
+# reproduced, stored in a retrieval system, or transmitted in any
+# form or by any means without the express written consent of
+# Intel Corporation.
+#
+##
+
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PortScan
+ FILE_GUID = D11A661E-E23C-4ba6-ACB1-4928F3937E4C
+ MODULE_TYPE = UEFI_APPLICATION
+ VERSION_STRING = 1.0
+ ENTRY_POINT = ShellCEntryLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ Main.c
+ OsTimer.c
+ PortScan.c
+
+
+[Packages]
+ MdePkg/MdePkg.dec
+ ShellPkg/ShellPkg.dec
+ StdLib/StdLib.dec
+
+
+[LibraryClasses]
+ BaseMemoryLib
+ BsdSocketLib
+ DebugLib
+ EfiSocketLib
+ LibC
+ LibMath
+ ShellCEntryLib
+ UefiBootServicesTableLib
+ UefiLib
+# UseSocketDxe
+
+[BuildOptions]
+ INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
+ MSFT:*_*_*_CC_FLAGS = /Od
+ GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
+
diff --git a/AppPkg/Applications/Sockets/PortScan/Windows/OsTimer.c b/AppPkg/Applications/Sockets/PortScan/Windows/OsTimer.c
new file mode 100644
index 0000000..8e18adc
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/Windows/OsTimer.c
@@ -0,0 +1,190 @@
+/** @file
+ Windows version of the port map test application
+
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <OsTimer.h>
+
+
+/**
+ Cancel a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCancel (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Assume success
+ //
+ Status = NO_ERROR;
+
+ //
+ // Start the timer
+ //
+ if ( !CancelWaitableTimer ( TimerEvent )) {
+ Status = GetLastError ( );
+ }
+
+ //
+ // Return the start status
+ //
+ return Status;
+}
+
+
+/**
+ Close a timer
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerClose (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Assume success
+ //
+ Status = NO_ERROR;
+
+ //
+ // Close the timer event
+ //
+ if ( !CloseHandle ( TimerEvent )) {
+ Status = GetLastError ( );
+ }
+
+ //
+ // Return the close status
+ //
+ return Status;
+}
+
+
+/**
+ Create a timer
+
+ @param [out] TimerEvent Address to return the timer event handle
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerCreate (
+ OUT EFI_EVENT * pTimerEvent
+ )
+{
+ EFI_EVENT TimerEvent;
+ EFI_STATUS Status;
+
+ //
+ // Assume success
+ //
+ Status = NO_ERROR;
+
+ //
+ // Attempt to create the timer event
+ //
+ TimerEvent = CreateWaitableTimerA ( NULL, TRUE, NULL );
+ if ( NULL == TimerEvent ) {
+ Status = GetLastError ( );
+ }
+
+ //
+ // Return the timer handle
+ //
+ *pTimerEvent = TimerEvent;
+
+ //
+ // Return the creation status
+ //
+ return Status;
+}
+
+
+/**
+ Determine if a timer has expired
+
+ @param [in] TimerEvent Event handle for the timer
+
+ @retval 0 Timer expired
+ **/
+EFI_STATUS
+OsTimerExpired (
+ IN EFI_EVENT TimerEvent
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Determine if the timer is set
+ //
+ Status = WaitForSingleObject ( TimerEvent, 0 );
+
+ //
+ // Return the timeout status
+ //
+ return Status;
+}
+
+
+/**
+ Start a timer
+
+ @param [in] TimerEvent Event handle for the timer
+ @param [in] Timeout Relative time when the timer expires
+
+ @retval 0 Successfully operation
+ **/
+EFI_STATUS
+OsTimerStart (
+ IN EFI_EVENT TimerEvent,
+ IN UINT64 Timeout
+ )
+{
+ INT64 DueTime;
+ EFI_STATUS Status;
+
+ //
+ // Assume success
+ //
+ Status = NO_ERROR;
+
+ //
+ // Start the timer
+ //
+ DueTime = -(INT64)Timeout;
+ if ( !SetWaitableTimer ( TimerEvent,
+ (LARGE_INTEGER *)&DueTime,
+ 0,
+ NULL,
+ NULL,
+ 0 )) {
+ Status = GetLastError ( );
+ }
+
+ //
+ // Return the start status
+ //
+ return Status;
+} \ No newline at end of file
diff --git a/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.sln b/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.sln
new file mode 100644
index 0000000..62f3f53
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PortMap", "PortMap.vcproj", "{F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}.Debug|Win32.ActiveCfg = Debug|Win32
+ {F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}.Debug|Win32.Build.0 = Debug|Win32
+ {F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}.Release|Win32.ActiveCfg = Release|Win32
+ {F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.vcproj b/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.vcproj
new file mode 100644
index 0000000..9da2cae
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/Windows/PortMap.vcproj
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="PortMap"
+ ProjectGUID="{F659C07C-CF54-4ECB-B7D5-BFF74C1B906E}"
+ RootNamespace="PortMap"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE; _WIN32_WINDOWS=0x0500"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.LIB"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="BUILD_FOR_WINDOWS; _CRT_SECURE_NO_DEPRECATE; _WIN32_WINDOWS=0x0500"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ BrowseInformation="1"
+ WarningLevel="3"
+ Detect64BitPortabilityProblems="true"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="ws2_32.LIB"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\main.c"
+ >
+ </File>
+ <File
+ RelativePath=".\OsTimer.c"
+ >
+ </File>
+ <File
+ RelativePath="..\PortScan.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\OsTimer.h"
+ >
+ </File>
+ <File
+ RelativePath="..\OsTypes.h"
+ >
+ </File>
+ <File
+ RelativePath="..\PortScan.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/AppPkg/Applications/Sockets/PortScan/Windows/main.c b/AppPkg/Applications/Sockets/PortScan/Windows/main.c
new file mode 100644
index 0000000..bd746c9
--- /dev/null
+++ b/AppPkg/Applications/Sockets/PortScan/Windows/main.c
@@ -0,0 +1,63 @@
+/** @file
+ Windows version of the port scan application
+
+
+ Copyright (c) 2011, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PortScan.h>
+
+
+/**
+ Determine which TCP ports are open on a remote system
+
+ Please note that this program must be run with administrator privileges!
+ See http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx
+
+ @param [in] argc The number of arguments
+ @param [in] argv The argument value array
+
+ @retval 0 The application exited normally.
+ @retval Other An error occurred.
+**/
+int
+main(
+ int argc,
+ char ** argv
+ )
+{
+ int RetVal;
+ WSADATA WsaData;
+
+ //
+ // Initialize the WinSock layer
+ //
+ RetVal = WSAStartup ( MAKEWORD ( 2, 2 ), &WsaData );
+ if ( 0 == RetVal ) {
+ //
+ // Start the application
+ //
+ RetVal = PortScan ( argc, argv );
+ if ( WSAEACCES == RetVal ) {
+ printf ( "Requires administrator privileges to run!\r\n" );
+ }
+
+ //
+ // Done with the WinSock layer
+ //
+ WSACleanup ( );
+ }
+
+ //
+ // Return the final result
+ //
+ return RetVal;
+}
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.suo b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.suo
deleted file mode 100644
index 7e96f23..0000000
--- a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/RawIp4Rx.suo
+++ /dev/null
Binary files differ
diff --git a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c
index 4dda74b..d198db9 100644
--- a/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c
+++ b/AppPkg/Applications/Sockets/RawIp4Rx/Windows/main.c
@@ -18,6 +18,8 @@
/**
Receive raw IP4 packets from a remote system.
+ Please note that this program must be run with administrator privileges!
+
@param [in] argc The number of arguments
@param [in] argv The argument value array
@@ -42,6 +44,9 @@ main(
// Start the application
//
RetVal = RawIp4Rx ( argc, argv );
+ if ( WSAEACCES == RetVal ) {
+ printf ( "Requires administrator privileges to run!\r\n" );
+ }
//
// Done with the WinSock layer
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.suo b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.suo
deleted file mode 100644
index fcfd744..0000000
--- a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/RawIp4Tx.suo
+++ /dev/null
Binary files differ
diff --git a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c
index 32c6815..23946ac 100644
--- a/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c
+++ b/AppPkg/Applications/Sockets/RawIp4Tx/Windows/main.c
@@ -18,6 +18,8 @@
/**
Transmit raw IP4 packets to the remote system.
+ Please note that this program must be run with administrator privileges!
+
@param [in] argc The number of arguments
@param [in] argv The argument value array
@@ -43,6 +45,9 @@ main(
// See http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx
//
RetVal = RawIp4Tx ( argc, argv );
+ if ( WSAEACCES == RetVal ) {
+ printf ( "Requires administrator privileges to run!\r\n" );
+ }
//
// Done with the WinSock layer
diff --git a/AppPkg/Applications/Sockets/Sockets.inc b/AppPkg/Applications/Sockets/Sockets.inc
index c1bd8bc..0a892fa 100644
--- a/AppPkg/Applications/Sockets/Sockets.inc
+++ b/AppPkg/Applications/Sockets/Sockets.inc
@@ -15,6 +15,7 @@
AppPkg/Applications/Sockets/GetServByPort/GetServByPort.inf
AppPkg/Applications/Sockets/OobRx/OobRx.inf
AppPkg/Applications/Sockets/OobTx/OobTx.inf
+ AppPkg/Applications/Sockets/PortScan/PortScan.inf
AppPkg/Applications/Sockets/RawIp4Rx/RawIp4Rx.inf
AppPkg/Applications/Sockets/RawIp4Tx/RawIp4Tx.inf
AppPkg/Applications/Sockets/RecvDgram/RecvDgram.inf