/*\r
- * FreeRTOS+TCP V2.0.3\r
- * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
- *\r
- * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
- * this software and associated documentation files (the "Software"), to deal in\r
- * the Software without restriction, including without limitation the rights to\r
- * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
- * the Software, and to permit persons to whom the Software is furnished to do so,\r
- * subject to the following conditions:\r
- *\r
- * The above copyright notice and this permission notice shall be included in all\r
- * copies or substantial portions of the Software.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
- * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
- * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
- * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
- *\r
- * http://aws.amazon.com/freertos\r
- * http://www.FreeRTOS.org\r
- */\r
-\r
+FreeRTOS+TCP V2.0.7\r
+Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+this software and associated documentation files (the "Software"), to deal in\r
+the Software without restriction, including without limitation the rights to\r
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+the Software, and to permit persons to whom the Software is furnished to do so,\r
+subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in all\r
+copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+\r
+ http://aws.amazon.com/freertos\r
+ http://www.FreeRTOS.org\r
+*/\r
\r
/* WinPCap includes. */\r
#define HAVE_REMOTE\r
* by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h.\r
*/\r
static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces );\r
-static void prvOpenInterface( const char *pucName );\r
+static int prvOpenInterface( const char *pucName );\r
\r
/*\r
* Configure the capture filter to allow blocking reads, and to filter out\r
printf( "\r\nThe interface that will be opened is set by " );\r
printf( "\"configNETWORK_INTERFACE_TO_USE\", which\r\nshould be defined in FreeRTOSConfig.h\r\n" );\r
\r
- if( ( xConfigNextworkInterfaceToUse < 1L ) || ( xConfigNextworkInterfaceToUse >= lInterfaceNumber ) )\r
+ if( ( xConfigNextworkInterfaceToUse < 0L ) || ( xConfigNextworkInterfaceToUse >= lInterfaceNumber ) )\r
{\r
printf( "\r\nERROR: configNETWORK_INTERFACE_TO_USE is set to %d, which is an invalid value.\r\n", xConfigNextworkInterfaceToUse );\r
printf( "Please set configNETWORK_INTERFACE_TO_USE to one of the interface numbers listed above,\r\n" );\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvOpenInterface( const char *pucName )\r
+static int prvOpenInterface( const char *pucName )\r
{\r
static char pucInterfaceName[ 256 ];\r
\r
if ( pxOpenedInterfaceHandle == NULL )\r
{\r
printf( "\n%s is not supported by WinPcap and cannot be opened\n", pucInterfaceName );\r
+ return 1;\r
}\r
else\r
{\r
out packets that are not of interest to this demo. */\r
prvConfigureCaptureBehaviour();\r
}\r
+ return 0;\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
/* Walk the list of devices until the selected device is located. */\r
xInterface = pxAllNetworkInterfaces;\r
- for( x = 0L; x < ( xConfigNextworkInterfaceToUse - 1L ); x++ )\r
- {\r
- xInterface = xInterface->next;\r
+ if (0 == xConfigNextworkInterfaceToUse) {\r
+ while (NULL != xInterface) {\r
+ xInterface = xInterface->next;\r
+ if (0 == prvOpenInterface(xInterface->name)) {\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ for (x = 1L; x < xConfigNextworkInterfaceToUse; x++)\r
+ {\r
+ xInterface = xInterface->next;\r
+ }\r
+ /* Open the selected interface. */\r
+ (void) prvOpenInterface(xInterface->name);\r
}\r
-\r
- /* Open the selected interface. */\r
- prvOpenInterface( xInterface->name );\r
\r
/* The device list is no longer required. */\r
pcap_freealldevs( pxAllNetworkInterfaces );\r
\r
iptraceNETWORK_INTERFACE_RECEIVE();\r
\r
- eResult = ipCONSIDER_FRAME_FOR_PROCESSING( pucPacketData );\r
+ /* Check for minimal size. */\r
+ if( pxHeader->len >= sizeof( EthernetHeader_t ) )\r
+ {\r
+ eResult = ipCONSIDER_FRAME_FOR_PROCESSING( pucPacketData );\r
+ }\r
+ else\r
+ {\r
+ eResult = eReleaseBuffer;\r
+ }\r
+\r
if( eResult == eProcessBuffer )\r
{\r
/* Will the data fit into the frame buffer? */\r