X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=FreeRTOS-Plus%2FSource%2FFreeRTOS-Plus-TCP%2FFreeRTOS_ARP.c;fp=FreeRTOS-Plus%2FSource%2FFreeRTOS-Plus-TCP%2FFreeRTOS_ARP.c;h=c98a7e8703653d7d616713cf2f543a68419f403a;hb=e9388d7834fdede42a6cf93794dab4f3a302fcde;hp=ed34d9aac08d81bf0d0ce116e744b89930faba9c;hpb=d6457d5167afcaf663d7afc0d835e7bd5ab0964f;p=freertos diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c index ed34d9aac..c98a7e870 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_ARP.c @@ -1,5 +1,5 @@ /* - * FreeRTOS+TCP V2.0.11 + * FreeRTOS+TCP V2.2.0 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -580,8 +580,24 @@ NetworkBufferDescriptor_t *pxNetworkBuffer; } } #endif + if( xIsCallingFromIPTask() != 0 ) + { + /* Only the IP-task is allowed to call this function directly. */ + xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE ); + } + else + { + IPStackEvent_t xSendEvent; - xNetworkInterfaceOutput( pxNetworkBuffer, pdTRUE ); + /* Send a message to the IP-task to send this ARP packet. */ + xSendEvent.eEventType = eNetworkTxEvent; + xSendEvent.pvData = ( void * ) pxNetworkBuffer; + if( xSendEventStructToIPTask( &xSendEvent, ( TickType_t ) portMAX_DELAY ) == pdFAIL ) + { + /* Failed to send the message, so release the network buffer. */ + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + } + } } } @@ -589,6 +605,12 @@ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffe { ARPPacket_t *pxARPPacket; + /* Buffer allocation ensures that buffers always have space + for an ARP packet. See buffer allocation implementations 1 + and 2 under portable/BufferManagement. */ + configASSERT( pxNetworkBuffer ); + configASSERT( pxNetworkBuffer->xDataLength >= sizeof(ARPPacket_t) ); + pxARPPacket = ( ARPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer; /* memcpy the const part of the header information into the correct