]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS-Labs/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c
Sync FreeRTOS-Labs -CLI -TCP -Trace with the version in FreeRTOS-Plus.
[freertos] / FreeRTOS-Labs / Source / FreeRTOS-Plus-TCP / FreeRTOS_ARP.c
index fb8a3b4f22b1124b9004aa191e8ec8657c829be5..c98a7e8703653d7d616713cf2f543a68419f403a 100644 (file)
@@ -1,6 +1,6 @@
 /*\r
- * FreeRTOS+TCP 191100 experimental\r
- * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
+ * FreeRTOS+TCP V2.2.0\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
@@ -580,8 +580,24 @@ NetworkBufferDescriptor_t *pxNetworkBuffer;
                        }\r
                }\r
                #endif\r
+               if( xIsCallingFromIPTask() != 0 )\r
+               {\r
+                       /* Only the IP-task is allowed to call this function directly. */\r
+                       xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE );\r
+               }\r
+               else\r
+               {\r
+               IPStackEvent_t xSendEvent;\r
 \r
-               xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE );\r
+                       /* Send a message to the IP-task to send this ARP packet. */\r
+                       xSendEvent.eEventType = eNetworkTxEvent;\r
+                       xSendEvent.pvData = ( void * ) pxNetworkBuffer;\r
+                       if( xSendEventStructToIPTask( &xSendEvent, ( TickType_t ) portMAX_DELAY ) == pdFAIL )\r
+                       {\r
+                               /* Failed to send the message, so release the network buffer. */\r
+                               vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );\r
+                       }\r
+               }\r
        }\r
 }\r
 \r
@@ -589,6 +605,12 @@ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffe
 {\r
 ARPPacket_t *pxARPPacket;\r
 \r
+       /* Buffer allocation ensures that buffers always have space\r
+       for an ARP packet. See buffer allocation implementations 1\r
+       and 2 under portable/BufferManagement. */\r
+       configASSERT( pxNetworkBuffer );\r
+       configASSERT( pxNetworkBuffer->xDataLength >= sizeof(ARPPacket_t) );\r
+\r
        pxARPPacket = ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;\r
 \r
        /* memcpy the const part of the header information into the correct\r