Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@
{
/* This is called from the context of the IP event task, so a block time
* must not be used. */
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( sizeof( ARPPacket_t ), ( TickType_t ) 0U );
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ( ( sizeof( ARPPacket_t ) > ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) ? sizeof( ARPPacket_t ) : ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ), ( TickType_t ) 0U );

if( pxNetworkBuffer != NULL )
{
Expand Down
22 changes: 12 additions & 10 deletions source/FreeRTOS_ND.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,18 @@
size_t uxICMPSize;
BaseType_t xCompare;
const NetworkEndPoint_t * pxTargetedEndPoint = pxEndPoint;
const NetworkEndPoint_t * pxEndPointInSameSubnet = FreeRTOS_InterfaceEPInSameSubnet_IPv6( pxNetworkBuffer->pxInterface, &( pxICMPHeader_IPv6->xIPv6Address ) );
const NetworkEndPoint_t * pxEndPointInSameSubnet;

uxICMPSize = sizeof( ICMPHeader_IPv6_t );
uxNeededSize = ( size_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + uxICMPSize );

if( uxNeededSize > pxNetworkBuffer->xDataLength )
{
FreeRTOS_printf( ( "Too small\n" ) );
break;
}

pxEndPointInSameSubnet = FreeRTOS_InterfaceEPInSameSubnet_IPv6( pxNetworkBuffer->pxInterface, &( pxICMPHeader_IPv6->xIPv6Address ) );

if( pxEndPointInSameSubnet != NULL )
{
Expand All @@ -1121,15 +1132,6 @@
pxICMPHeader_IPv6->xIPv6Address.ucBytes ) );
}

uxICMPSize = sizeof( ICMPHeader_IPv6_t );
uxNeededSize = ( size_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + uxICMPSize );

if( uxNeededSize > pxNetworkBuffer->xDataLength )
{
FreeRTOS_printf( ( "Too small\n" ) );
break;
}

xCompare = memcmp( pxICMPHeader_IPv6->xIPv6Address.ucBytes, pxTargetedEndPoint->ipv6_settings.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );

FreeRTOS_printf( ( "ND NS for %pip endpoint %pip %s\n",
Expand Down
34 changes: 17 additions & 17 deletions test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ void test_eARPProcessPacket_Request_SenderAndTargetSame( void )
/* Reset the private variable uxARPClashCounter. */
vResetARPClashCounter();

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );

xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
xSendEventStructToIPTask_IgnoreAndReturn( pdFAIL );
Expand Down Expand Up @@ -1081,7 +1081,7 @@ void test_eARPProcessPacket_Reply_SenderAndTargetSame( void )
xNetworkBuffer.xDataLength = sizeof( ARPPacket_t );
xNetworkBuffer.pxEndPoint = &xEndPoint;

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );

xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
xSendEventStructToIPTask_IgnoreAndReturn( pdFAIL );
Expand Down Expand Up @@ -2445,7 +2445,7 @@ void test_vARPAgeCache( void )

/* The function which calls 'pxGetNetworkBufferWithDescriptor' is 'FreeRTOS_OutputARPRequest'.
* It doesn't return anything and will be tested separately. */
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );


vARPAgeCache();
Expand All @@ -2463,14 +2463,14 @@ void test_vARPAgeCache( void )

/* The function which calls 'pxGetNetworkBufferWithDescriptor' is 'FreeRTOS_OutputARPRequest'.
* It doesn't return anything and will be tested separately. */
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );

/* Let the value returned first time be 100. */
xTaskGetTickCount_ExpectAndReturn( 100 );

/* The function which calls 'pxGetNetworkBufferWithDescriptor' is 'FreeRTOS_OutputARPRequest'.
* It doesn't return anything and will be tested separately. */
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );

vARPAgeCache();
/* =================================================== */
Expand All @@ -2486,7 +2486,7 @@ void test_vARPAgeCache( void )

/* The function which calls 'pxGetNetworkBufferWithDescriptor' is 'FreeRTOS_OutputARPRequest'.
* It doesn't return anything and will be tested separately. */
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );

/* Let the value returned first time be 100. */
xTaskGetTickCount_ExpectAndReturn( 100 );
Expand All @@ -2507,7 +2507,7 @@ void test_vARPAgeCache( void )

/* The function which calls 'pxGetNetworkBufferWithDescriptor' is 'FreeRTOS_OutputARPRequest'.
* It doesn't return anything and will be tested separately. */
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );

vARPAgeCache();
/* =================================================== */
Expand Down Expand Up @@ -2590,7 +2590,7 @@ void test_FreeRTOS_OutputARPRequest( void )

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );

xIsCallingFromIPTask_IgnoreAndReturn( pdTRUE );

Expand All @@ -2603,7 +2603,7 @@ void test_FreeRTOS_OutputARPRequest( void )

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );

xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
xSendEventStructToIPTask_IgnoreAndReturn( pdFAIL );
Expand All @@ -2617,7 +2617,7 @@ void test_FreeRTOS_OutputARPRequest( void )
xNetworkInterfaceOutput_ARP_STUB_CallCount = 0;
FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );
xIsCallingFromIPTask_IgnoreAndReturn( pdFALSE );
xSendEventStructToIPTask_IgnoreAndReturn( pdPASS );

Expand All @@ -2633,7 +2633,7 @@ void test_FreeRTOS_OutputARPRequest( void )

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );
xIsCallingFromIPTask_IgnoreAndReturn( pdTRUE );

FreeRTOS_OutputARPRequest( ulIPAddress );
Expand All @@ -2648,7 +2648,7 @@ void test_FreeRTOS_OutputARPRequest( void )

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );

pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, &xNetworkBuffer );
xIsCallingFromIPTask_IgnoreAndReturn( pdTRUE );

FreeRTOS_OutputARPRequest( ulIPAddress );
Expand Down Expand Up @@ -2771,7 +2771,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void )
for( i = 0; i < ipconfigMAX_ARP_RETRANSMISSIONS; i++ )
{
FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
Expand Down Expand Up @@ -2824,7 +2824,7 @@ void test_xARPWaitResolution( void )
for( i = 0; i < ( ipconfigMAX_ARP_RETRANSMISSIONS - 1 ); i++ )
{
FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
Expand All @@ -2834,7 +2834,7 @@ void test_xARPWaitResolution( void )
}

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
Expand Down Expand Up @@ -2875,7 +2875,7 @@ void test_xARPWaitResolution( void )
for( i = 0; i < ( ipconfigMAX_ARP_RETRANSMISSIONS - 2 ); i++ )
{
FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL );
Expand All @@ -2885,7 +2885,7 @@ void test_xARPWaitResolution( void )
}

FreeRTOS_FindEndPointOnNetMask_ExpectAndReturn( ulIPAddress, &xEndPoint );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, NULL );
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES, 0, NULL );
vTaskDelay_Expect( pdMS_TO_TICKS( 250U ) );
xIsIPv4Loopback_ExpectAndReturn( ulIPAddress, 0UL );
xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 1UL );
Expand Down
2 changes: 0 additions & 2 deletions test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1667,8 +1667,6 @@ void test_prvProcessICMPMessage_IPv6_NeighborSolicitationIncorrectLen( void )
pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket;
pxNetworkBuffer->xDataLength = ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + 5;

FreeRTOS_InterfaceEPInSameSubnet_IPv6_ExpectAnyArgsAndReturn( &xEndPoint );

eReturn = prvProcessICMPMessage_IPv6( pxNetworkBuffer );

TEST_ASSERT_EQUAL( eReturn, eReleaseBuffer );
Expand Down
Loading