2 * FreeRTOS+TCP V2.0.0
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software. If you wish to use our Amazon
\r
14 * FreeRTOS name, please do so in a fair use way that does not cause confusion.
\r
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
18 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
19 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 * http://www.FreeRTOS.org
\r
24 * http://aws.amazon.com/freertos
\r
26 * 1 tab == 4 spaces!
\r
29 /* WinPCap includes. */
\r
33 /* FreeRTOS includes. */
\r
34 #include "FreeRTOS.h"
\r
38 /* FreeRTOS+TCP includes. */
\r
39 #include "FreeRTOS_IP.h"
\r
40 #include "FreeRTOS_IP_Private.h"
\r
41 #include "NetworkBufferManagement.h"
\r
43 /* Thread-safe circular buffers are being used to pass data to and from the PCAP
\r
44 access functions. */
\r
45 #include "Win32-Extensions.h"
\r
46 #include "FreeRTOS_Stream_Buffer.h"
\r
48 /* Sizes of the thread safe circular buffers used to pass data to and from the
\r
49 WinPCAP Windows threads. */
\r
50 #define xSEND_BUFFER_SIZE 32768
\r
51 #define xRECV_BUFFER_SIZE 32768
\r
53 /* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet
\r
54 driver will filter incoming packets and only pass the stack those packets it
\r
55 considers need processing. */
\r
56 #if( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 )
\r
57 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
\r
59 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
\r
62 /* Used to insert test code only. */
\r
63 #define niDISRUPT_PACKETS 0
\r
65 /*-----------------------------------------------------------*/
\r
68 * Windows threads that are outside of the control of the FreeRTOS simulator are
\r
69 * used to interface with the WinPCAP libraries.
\r
71 DWORD WINAPI prvWinPcapRecvThread( void *pvParam );
\r
72 DWORD WINAPI prvWinPcapSendThread( void *pvParam );
\r
75 * Print out a numbered list of network interfaces that are available on the
\r
78 static pcap_if_t * prvPrintAvailableNetworkInterfaces( void );
\r
81 * Open the network interface. The number of the interface to be opened is set
\r
82 * by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h.
\r
84 static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces );
\r
85 static void prvOpenInterface( const char *pucName );
\r
88 * Configure the capture filter to allow blocking reads, and to filter out
\r
89 * packets that are not of interest to this demo.
\r
91 static void prvConfigureCaptureBehaviour( void );
\r
94 * A function that simulates Ethernet interrupts by periodically polling the
\r
95 * WinPCap interface for new data.
\r
97 static void prvInterruptSimulatorTask( void *pvParameters );
\r
100 * Create the buffers that are used to pass data between the FreeRTOS simulator
\r
101 * and the Win32 threads that manage WinPCAP.
\r
103 static void prvCreateThreadSafeBuffers( void );
\r
106 * Utility function used to format print messages only.
\r
108 static const char *prvRemoveSpaces( char *pcBuffer, int aBuflen, const char *pcMessage );
\r
110 /*-----------------------------------------------------------*/
\r
112 /* Required by the WinPCap library. */
\r
113 static char cErrorBuffer[ PCAP_ERRBUF_SIZE ];
\r
115 /* An event used to wake up the Win32 thread that sends data through the WinPCAP
\r
117 static void *pvSendEvent = NULL;
\r
119 /* _HT_ made the PCAP interface number configurable through the program's
\r
120 parameters in order to test in different machines. */
\r
121 static BaseType_t xConfigNextworkInterfaceToUse = configNETWORK_INTERFACE_TO_USE;
\r
123 /* Handles to the Windows threads that handle the PCAP IO. */
\r
124 static HANDLE vWinPcapRecvThreadHandle = NULL;
\r
125 static HANDLE vWinPcapSendThreadHandle = NULL;;
\r
127 /* The interface being used by WinPCap. */
\r
128 static pcap_t *pxOpenedInterfaceHandle = NULL;
\r
130 /* Circular buffers used by the PCAP Win32 threads. */
\r
131 static StreamBuffer_t *xSendBuffer = NULL;
\r
132 static StreamBuffer_t *xRecvBuffer = NULL;
\r
134 /* The MAC address initially set to the constants defined in FreeRTOSConfig.h. */
\r
135 extern uint8_t ucMACAddress[ 6 ];
\r
137 /* Logs the number of WinPCAP send failures, for viewing in the debugger only. */
\r
138 static volatile uint32_t ulWinPCAPSendFailures = 0;
\r
140 /*-----------------------------------------------------------*/
\r
142 BaseType_t xNetworkInterfaceInitialise( void )
\r
144 BaseType_t xReturn = pdFALSE;
\r
145 pcap_if_t *pxAllNetworkInterfaces;
\r
147 /* Query the computer the simulation is being executed on to find the
\r
148 network interfaces it has installed. */
\r
149 pxAllNetworkInterfaces = prvPrintAvailableNetworkInterfaces();
\r
151 /* Open the network interface. The number of the interface to be opened is
\r
152 set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h.
\r
153 Calling this function will set the pxOpenedInterfaceHandle variable. If,
\r
154 after calling this function, pxOpenedInterfaceHandle is equal to NULL, then
\r
155 the interface could not be opened. */
\r
156 if( pxAllNetworkInterfaces != NULL )
\r
158 prvOpenSelectedNetworkInterface( pxAllNetworkInterfaces );
\r
161 if( pxOpenedInterfaceHandle != NULL )
\r
168 /*-----------------------------------------------------------*/
\r
170 static void prvCreateThreadSafeBuffers( void )
\r
172 /* The buffer used to pass data to be transmitted from a FreeRTOS task to
\r
173 the Win32 thread that sends via the WinPCAP library. */
\r
174 if( xSendBuffer == NULL)
\r
176 xSendBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xSendBuffer ) - sizeof( xSendBuffer->ucArray ) + xSEND_BUFFER_SIZE + 1 );
\r
177 configASSERT( xSendBuffer );
\r
178 memset( xSendBuffer, '\0', sizeof( *xSendBuffer ) - sizeof( xSendBuffer->ucArray ) );
\r
179 xSendBuffer->LENGTH = xSEND_BUFFER_SIZE + 1;
\r
182 /* The buffer used to pass received data from the Win32 thread that receives
\r
183 via the WinPCAP library to the FreeRTOS task. */
\r
184 if( xRecvBuffer == NULL)
\r
186 xRecvBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xRecvBuffer ) - sizeof( xRecvBuffer->ucArray ) + xRECV_BUFFER_SIZE + 1 );
\r
187 configASSERT( xRecvBuffer );
\r
188 memset( xRecvBuffer, '\0', sizeof( *xRecvBuffer ) - sizeof( xRecvBuffer->ucArray ) );
\r
189 xRecvBuffer->LENGTH = xRECV_BUFFER_SIZE + 1;
\r
192 /*-----------------------------------------------------------*/
\r
194 BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t bReleaseAfterSend )
\r
198 iptraceNETWORK_INTERFACE_TRANSMIT();
\r
199 configASSERT( xIsCallingFromIPTask() == pdTRUE );
\r
201 /* Both the length of the data being sent and the actual data being sent
\r
202 are placed in the thread safe buffer used to pass data between the FreeRTOS
\r
203 tasks and the Win32 thread that sends data via the WinPCAP library. Drop
\r
204 the packet if there is insufficient space in the buffer to hold both. */
\r
205 xSpace = uxStreamBufferGetSpace( xSendBuffer );
\r
207 if( ( pxNetworkBuffer->xDataLength <= ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) ) &&
\r
208 ( xSpace >= ( pxNetworkBuffer->xDataLength + sizeof( pxNetworkBuffer->xDataLength ) ) ) )
\r
210 /* First write in the length of the data, then write in the data
\r
212 uxStreamBufferAdd( xSendBuffer, 0, ( const uint8_t * ) &( pxNetworkBuffer->xDataLength ), sizeof( pxNetworkBuffer->xDataLength ) );
\r
213 uxStreamBufferAdd( xSendBuffer, 0, ( const uint8_t * ) pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength );
\r
217 FreeRTOS_debug_printf( ( "xNetworkInterfaceOutput: send buffers full to store %lu\n", pxNetworkBuffer->xDataLength ) );
\r
220 /* Kick the Tx task in either case in case it doesn't know the buffer is
\r
222 SetEvent( pvSendEvent );
\r
224 /* The buffer has been sent so can be released. */
\r
225 if( bReleaseAfterSend != pdFALSE )
\r
227 vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
\r
232 /*-----------------------------------------------------------*/
\r
234 static pcap_if_t * prvPrintAvailableNetworkInterfaces( void )
\r
236 pcap_if_t * pxAllNetworkInterfaces = NULL, *xInterface;
\r
237 int32_t lInterfaceNumber = 1;
\r
238 char cBuffer[ 512 ];
\r
240 if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL, &pxAllNetworkInterfaces, cErrorBuffer ) == -1 )
\r
242 printf( "Could not obtain a list of network interfaces\n%s\n", cErrorBuffer );
\r
243 pxAllNetworkInterfaces = NULL;
\r
246 if( pxAllNetworkInterfaces != NULL )
\r
248 /* Print out the list of network interfaces. The first in the list
\r
249 is interface '1', not interface '0'. */
\r
250 for( xInterface = pxAllNetworkInterfaces; xInterface != NULL; xInterface = xInterface->next )
\r
252 /* The descriptions of the devices can be full of spaces, clean them
\r
253 a little. printf() can only be used here because the network is not
\r
254 up yet - so no other network tasks will be running. */
\r
255 printf( "%d. %s\n", lInterfaceNumber, prvRemoveSpaces( cBuffer, sizeof( cBuffer ), xInterface->name ) );
\r
256 printf( " (%s)\n", prvRemoveSpaces(cBuffer, sizeof( cBuffer ), xInterface->description ? xInterface->description : "No description" ) );
\r
258 lInterfaceNumber++;
\r
262 if( lInterfaceNumber == 1 )
\r
264 /* The interface number was never incremented, so the above for() loop
\r
265 did not execute meaning no interfaces were found. */
\r
266 printf( " \nNo network interfaces were found.\n" );
\r
267 pxAllNetworkInterfaces = NULL;
\r
270 printf( "The interface that will be opened is set by\n" );
\r
271 printf( "\"configNETWORK_INTERFACE_TO_USE\" which should be defined in FreeRTOSConfig.h\n" );
\r
272 printf( "Attempting to open interface number %d.\n", xConfigNextworkInterfaceToUse );
\r
274 if( ( xConfigNextworkInterfaceToUse < 1L ) || ( xConfigNextworkInterfaceToUse > lInterfaceNumber ) )
\r
276 printf( "configNETWORK_INTERFACE_TO_USE is not in the valid range.\n" );
\r
278 if( pxAllNetworkInterfaces != NULL )
\r
280 /* Free the device list, as no devices are going to be opened. */
\r
281 pcap_freealldevs( pxAllNetworkInterfaces );
\r
282 pxAllNetworkInterfaces = NULL;
\r
286 return pxAllNetworkInterfaces;
\r
288 /*-----------------------------------------------------------*/
\r
290 static void prvOpenInterface( const char *pucName )
\r
292 static char pucInterfaceName[ 256 ];
\r
294 if( pucName != NULL )
\r
296 strncpy( pucInterfaceName, pucName, sizeof( pucInterfaceName ) );
\r
299 pxOpenedInterfaceHandle = pcap_open( pucInterfaceName, /* The name of the selected interface. */
\r
300 ipTOTAL_ETHERNET_FRAME_SIZE, /* The size of the packet to capture. */
\r
301 PCAP_OPENFLAG_PROMISCUOUS, /* Open in promiscuous mode as the MAC and
\r
302 IP address is going to be "simulated", and
\r
303 not be the real MAC and IP address. This allows
\r
304 traffic to the simulated IP address to be routed
\r
305 to uIP, and traffic to the real IP address to be
\r
306 routed to the Windows TCP/IP stack. */
\r
308 NULL, /* No authentication is required as this is
\r
309 not a remote capture session. */
\r
313 if ( pxOpenedInterfaceHandle == NULL )
\r
315 printf( "\n%s is not supported by WinPcap and cannot be opened\n", pucInterfaceName );
\r
319 /* Configure the capture filter to allow blocking reads, and to filter
\r
320 out packets that are not of interest to this demo. */
\r
321 prvConfigureCaptureBehaviour();
\r
324 /*-----------------------------------------------------------*/
\r
326 static void prvOpenSelectedNetworkInterface( pcap_if_t *pxAllNetworkInterfaces )
\r
328 pcap_if_t *xInterface;
\r
331 /* Walk the list of devices until the selected device is located. */
\r
332 xInterface = pxAllNetworkInterfaces;
\r
333 for( x = 0L; x < ( xConfigNextworkInterfaceToUse - 1L ); x++ )
\r
335 xInterface = xInterface->next;
\r
338 /* Open the selected interface. */
\r
339 prvOpenInterface( xInterface->name );
\r
341 /* The device list is no longer required. */
\r
342 pcap_freealldevs( pxAllNetworkInterfaces );
\r
344 /*-----------------------------------------------------------*/
\r
346 static void prvConfigureCaptureBehaviour( void )
\r
348 struct bpf_program xFilterCode;
\r
349 uint32_t ulNetMask;
\r
351 /* Set up a filter so only the packets of interest are passed to the IP
\r
352 stack. cErrorBuffer is used for convenience to create the string. Don't
\r
353 confuse this with an error message. */
\r
354 sprintf( cErrorBuffer, "broadcast or multicast or ether host %x:%x:%x:%x:%x:%x",
\r
355 ucMACAddress[0], ucMACAddress[1], ucMACAddress[2], ucMACAddress[3], ucMACAddress[4], ucMACAddress[5] );
\r
357 ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0;
\r
359 if( pcap_compile( pxOpenedInterfaceHandle, &xFilterCode, cErrorBuffer, 1, ulNetMask ) < 0 )
\r
361 printf( "\nThe packet filter string is invalid\n" );
\r
365 if( pcap_setfilter( pxOpenedInterfaceHandle, &xFilterCode ) < 0 )
\r
367 printf( "\nAn error occurred setting the packet filter.\n" );
\r
371 /* Create the buffers used to pass packets between the FreeRTOS simulator
\r
372 and the Win32 threads that are handling WinPCAP. */
\r
373 prvCreateThreadSafeBuffers();
\r
375 if( pvSendEvent == NULL )
\r
377 /* Create event used to signal the Win32 WinPCAP Tx thread. */
\r
378 pvSendEvent = CreateEvent( NULL, FALSE, TRUE, NULL );
\r
380 /* Create the Win32 thread that handles WinPCAP Rx. */
\r
381 vWinPcapRecvThreadHandle = CreateThread(
\r
382 NULL, /* Pointer to thread security attributes. */
\r
383 0, /* Initial thread stack size, in bytes. */
\r
384 prvWinPcapRecvThread, /* Pointer to thread function. */
\r
385 NULL, /* Argument for new thread. */
\r
386 0, /* Creation flags. */
\r
389 /* Use the cores that are not used by the FreeRTOS tasks. */
\r
390 SetThreadAffinityMask( vWinPcapRecvThreadHandle, ~0x01u );
\r
392 /* Create the Win32 thread that handlers WinPCAP Tx. */
\r
393 vWinPcapSendThreadHandle = CreateThread(
\r
394 NULL, /* Pointer to thread security attributes. */
\r
395 0, /* initial thread stack size, in bytes. */
\r
396 prvWinPcapSendThread, /* Pointer to thread function. */
\r
397 NULL, /* Argument for new thread. */
\r
398 0, /* Creation flags. */
\r
401 /* Use the cores that are not used by the FreeRTOS tasks. */
\r
402 SetThreadAffinityMask( vWinPcapSendThreadHandle, ~0x01u );
\r
404 /* Create a task that simulates an interrupt in a real system. This will
\r
405 block waiting for packets, then send a message to the IP task when data
\r
407 xTaskCreate( prvInterruptSimulatorTask, "MAC_ISR", configMINIMAL_STACK_SIZE, NULL, configMAC_ISR_SIMULATOR_PRIORITY, NULL );
\r
410 /*-----------------------------------------------------------*/
\r
412 /* WinPCAP function. */
\r
413 void pcap_callback( u_char *user, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data )
\r
417 /* THIS IS CALLED FROM A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS
\r
418 OR TO PRINT OUT MESSAGES HERE. */
\r
420 /* Pass data to the FreeRTOS simulator on a thread safe circular buffer. */
\r
421 if( ( pkt_header->caplen <= ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ) ) &&
\r
422 ( uxStreamBufferGetSpace( xRecvBuffer ) >= ( ( ( size_t ) pkt_header->caplen ) + sizeof( *pkt_header ) ) ) )
\r
424 uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t* ) pkt_header, sizeof( *pkt_header ) );
\r
425 uxStreamBufferAdd( xRecvBuffer, 0, ( const uint8_t* ) pkt_data, ( size_t ) pkt_header->caplen );
\r
428 /*-----------------------------------------------------------*/
\r
430 DWORD WINAPI prvWinPcapRecvThread ( void *pvParam )
\r
434 /* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
\r
435 OUT MESSAGES HERE. */
\r
439 pcap_dispatch( pxOpenedInterfaceHandle, 1, pcap_callback, ( u_char * ) "mydata" );
\r
442 /*-----------------------------------------------------------*/
\r
444 DWORD WINAPI prvWinPcapSendThread( void *pvParam )
\r
447 uint8_t ucBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ];
\r
448 static char cErrorMessage[ 1024 ];
\r
449 const DWORD xMaxMSToWait = 1000;
\r
451 /* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
\r
452 OUT MESSAGES HERE. */
\r
454 /* Remove compiler warnings about unused parameters. */
\r
459 /* Wait until notified of something to send. */
\r
460 WaitForSingleObject( pvSendEvent, xMaxMSToWait );
\r
462 /* Is there more than the length value stored in the circular buffer
\r
463 used to pass data from the FreeRTOS simulator into this Win32 thread? */
\r
464 while( uxStreamBufferGetSize( xSendBuffer ) > sizeof( xLength ) )
\r
466 uxStreamBufferGet( xSendBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE );
\r
467 uxStreamBufferGet( xSendBuffer, 0, ( uint8_t* ) ucBuffer, xLength, pdFALSE );
\r
468 if( pcap_sendpacket( pxOpenedInterfaceHandle, ucBuffer, xLength ) != 0 )
\r
470 ulWinPCAPSendFailures++;
\r
475 /*-----------------------------------------------------------*/
\r
477 static void prvInterruptSimulatorTask( void *pvParameters )
\r
479 struct pcap_pkthdr xHeader;
\r
480 static struct pcap_pkthdr *pxHeader;
\r
481 const uint8_t *pucPacketData;
\r
482 uint8_t ucRecvBuffer[ ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER ];
\r
483 NetworkBufferDescriptor_t *pxNetworkBuffer;
\r
484 IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL };
\r
485 eFrameProcessingResult_t eResult;
\r
487 /* Remove compiler warnings about unused parameters. */
\r
488 ( void ) pvParameters;
\r
492 /* Does the circular buffer used to pass data from the Win32 thread that
\r
493 handles WinPCAP Rx into the FreeRTOS simulator contain another packet? */
\r
494 if( uxStreamBufferGetSize( xRecvBuffer ) > sizeof( xHeader ) )
\r
496 /* Get the next packet. */
\r
497 uxStreamBufferGet( xRecvBuffer, 0, (uint8_t*)&xHeader, sizeof( xHeader ), pdFALSE );
\r
498 uxStreamBufferGet( xRecvBuffer, 0, (uint8_t*)ucRecvBuffer, ( size_t ) xHeader.len, pdFALSE );
\r
499 pucPacketData = ucRecvBuffer;
\r
500 pxHeader = &xHeader;
\r
502 iptraceNETWORK_INTERFACE_RECEIVE();
\r
504 eResult = ipCONSIDER_FRAME_FOR_PROCESSING( pucPacketData );
\r
505 if( eResult == eProcessBuffer )
\r
507 /* Will the data fit into the frame buffer? */
\r
508 if( pxHeader->len <= ipTOTAL_ETHERNET_FRAME_SIZE )
\r
510 /* Obtain a buffer into which the data can be placed. This
\r
511 is only an interrupt simulator, not a real interrupt, so it
\r
512 is ok to call the task level function here, but note that
\r
513 some buffer implementations cannot be called from a real
\r
515 pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( pxHeader->len, 0 );
\r
517 if( pxNetworkBuffer != NULL )
\r
519 memcpy( pxNetworkBuffer->pucEthernetBuffer, pucPacketData, pxHeader->len );
\r
520 pxNetworkBuffer->xDataLength = ( size_t ) pxHeader->len;
\r
522 #if( niDISRUPT_PACKETS == 1 )
\r
524 pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData );
\r
526 #endif /* niDISRUPT_PACKETS */
\r
528 if( pxNetworkBuffer != NULL )
\r
530 xRxEvent.pvData = ( void * ) pxNetworkBuffer;
\r
532 /* Data was received and stored. Send a message to
\r
533 the IP task to let it know. */
\r
534 if( xSendEventStructToIPTask( &xRxEvent, ( TickType_t ) 0 ) == pdFAIL )
\r
536 /* The buffer could not be sent to the stack so
\r
537 must be released again. This is only an
\r
538 interrupt simulator, not a real interrupt, so it
\r
539 is ok to use the task level function here, but
\r
540 note no all buffer implementations will allow
\r
541 this function to be executed from a real
\r
543 vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
\r
544 iptraceETHERNET_RX_EVENT_LOST();
\r
549 /* The packet was already released or stored inside
\r
550 vRxFaultInjection(). Don't release it here. */
\r
555 iptraceETHERNET_RX_EVENT_LOST();
\r
560 /* Log that a packet was dropped because it would have
\r
561 overflowed the buffer, but there may be more buffers to
\r
568 /* There is no real way of simulating an interrupt. Make sure
\r
569 other tasks can run. */
\r
570 vTaskDelay( configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY );
\r
574 /*-----------------------------------------------------------*/
\r
576 static const char *prvRemoveSpaces( char *pcBuffer, int aBuflen, const char *pcMessage )
\r
578 char *pcTarget = pcBuffer;
\r
580 /* Utility function used to formap messages being printed only. */
\r
581 while( ( *pcMessage != 0 ) && ( pcTarget < ( pcBuffer + aBuflen - 1 ) ) )
\r
583 *( pcTarget++ ) = *pcMessage;
\r
585 if( isspace( *pcMessage ) != pdFALSE )
\r
587 while( isspace( *pcMessage ) != pdFALSE )
\r