Skip to content

Commit

Permalink
use cache helper
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Feb 3, 2024
1 parent 4990e5e commit 95f5ceb
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 86 deletions.
4 changes: 4 additions & 0 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,10 @@ eARPLookupResult_t eGetCacheEntry( IPv46_Address_t * pxIPAddress,
struct xNetworkEndPoint ** ppxEndPoint )
{
eARPLookupResult_t eResult = eARPCacheMiss;
configASSERT( pxIPAddress != NULL );
configASSERT( pxMACAddress != NULL );
configASSERT( ppxEndPoint != NULL );
configASSERT( *ppxEndPoint != NULL );

if( pxIPAddress->xIs_IPv6 == pdTRUE )
{
Expand Down
21 changes: 8 additions & 13 deletions source/FreeRTOS_TCP_Transmission.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,9 @@

if( xDestinationIPAddress.xIs_IPv6 == pdTRUE )
{
IPv6_Address_t xTempAddress;
( void ) memcpy( xTempAddress.ucBytes, pxIPHeader->xIPHeaderIPv6.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( xDestinationIPAddress.xIPAddress.xIP_IPv6.ucBytes, pxIPHeader->xIPHeaderIPv6.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxIPHeader->xIPHeaderIPv6.xDestinationAddress.ucBytes, pxIPHeader->xIPHeaderIPv6.xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxIPHeader->xIPHeaderIPv6.xSourceAddress.ucBytes, xTempAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxIPHeader->xIPHeaderIPv6.xSourceAddress.ucBytes, xDestinationIPAddress.xIPAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
}
else
{
Expand Down Expand Up @@ -440,18 +439,14 @@
if( xDestinationIPAddress.xIs_IPv6 == pdTRUE )
{
( void ) memcpy( xDestinationIPAddress.xIPAddress.xIP_IPv6.ucBytes, pxIPHeader->xIPHeaderIPv6.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
#if ipconfigIS_ENABLED( ipconfigUSE_IPv6 )
eResult = eNDGetCacheEntry( &( xDestinationIPAddress.xIPAddress.xIP_IPv6 ), &xMACAddress, &pxEndPoint );
#endif
}
else
{
xDestinationIPAddress.xIPAddress.ulIP_IPv4 = pxIPHeader->xIPHeader.ulDestinationIPAddress;
#if ipconfigIS_ENABLED( ipconfigUSE_IPv4 )
eResult = eARPGetCacheEntry( &( xDestinationIPAddress.xIPAddress.ulIP_IPv4 ), &xMACAddress, &pxEndPoint );
#endif
}

eResult = eGetCacheEntry( &xDestinationIPAddress, &xMACAddress, &pxEndPoint );

if( eResult == eARPCacheHit )
{
pvCopySource = &xMACAddress;
Expand Down Expand Up @@ -979,7 +974,7 @@
}
else
{
FreeRTOS_printf( ( "prvTCPReturnPacket: No pxEndPoint yet?\n" ) );
FreeRTOS_debug_printf( ( "prvTCPReturnPacket: No pxEndPoint yet?\n" ) );

switch( uxIPHeaderSize )
{
Expand All @@ -996,7 +991,7 @@

if( pxNetworkBuffer->pxEndPoint == NULL )
{
FreeRTOS_printf( ( "prvTCPReturnPacket: no such end-point %xip => %xip\n",
FreeRTOS_debug_printf( ( "prvTCPReturnPacket: no such end-point %xip => %xip\n",
( unsigned int ) FreeRTOS_ntohl( pxIPHeader->ulSourceIPAddress ),
( unsigned int ) FreeRTOS_ntohl( pxIPHeader->ulDestinationIPAddress ) ) );
}
Expand All @@ -1013,7 +1008,7 @@

if( pxNetworkBuffer->pxEndPoint == NULL )
{
FreeRTOS_printf( ( "prvTCPReturnPacket: no such end-point %pip => %pip\n",
FreeRTOS_debug_printf( ( "prvTCPReturnPacket: no such end-point %pip => %pip\n",
( void * ) pxIPHeader_IPv6->xSourceAddress.ucBytes,
( void * ) pxIPHeader_IPv6->xDestinationAddress.ucBytes ) );
}
Expand All @@ -1028,7 +1023,7 @@

if( pxNetworkBuffer->pxEndPoint != NULL )
{
FreeRTOS_printf( ( "prvTCPReturnPacket: packet's end-point %02x-%02x\n",
FreeRTOS_debug_printf( ( "prvTCPReturnPacket: packet's end-point %02x-%02x\n",
pxNetworkBuffer->pxEndPoint->xMACAddress.ucBytes[ 4 ],
pxNetworkBuffer->pxEndPoint->xMACAddress.ucBytes[ 5 ] ) );
}
Expand Down
Loading

0 comments on commit 95f5ceb

Please sign in to comment.