Skip to content

Commit

Permalink
Merge branch 'main' into dev-ip-build-sep
Browse files Browse the repository at this point in the history
  • Loading branch information
ActoryOu authored Oct 1, 2024
2 parents 5fc03b7 + fa073ea commit d93e085
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 23 deletions.
4 changes: 1 addition & 3 deletions source/FreeRTOS_IPv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,7 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons
( FreeRTOS_FindEndPointOnIP_IPv4( ulDestinationIPAddress ) == NULL ) &&
/* Is it an IPv4 broadcast address x.x.x.255 ? */
( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) &&
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) &&
/* Or (during DHCP negotiation) we have no IP-address yet? */
( FreeRTOS_IsNetworkUp() != pdFALSE ) )
( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) )
{
/* Packet is not for this node, release it */
eReturn = eReleaseBuffer;
Expand Down
1 change: 0 additions & 1 deletion source/FreeRTOS_Routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ struct xIPv6_Couple
#endif
{
if( ( ulIPAddress == 0U ) ||
( pxEndPoint->ipv4_settings.ulIPAddress == 0U ) ||
( pxEndPoint->ipv4_settings.ulIPAddress == ulIPAddress ) )
{
break;
Expand Down
10 changes: 6 additions & 4 deletions source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
static BaseType_t xGMACWaitLS( TickType_t xMaxTime );

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
void vGMACGenerateChecksum( uint8_t * apBuffer );
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );
#endif

/*
Expand Down Expand Up @@ -405,9 +406,10 @@ static BaseType_t xGMACWaitLS( TickType_t xMaxTime )

/*#if( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 ) */

void vGMACGenerateChecksum( uint8_t * apBuffer )
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength )
{
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) apBuffer;
ProtocolPacket_t * xProtPacket = ( ProtocolPacket_t * ) pucBuffer;

if( xProtPacket->xTCPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE )
{
Expand All @@ -419,7 +421,7 @@ void vGMACGenerateChecksum( uint8_t * apBuffer )
pxIPHeader->usHeaderChecksum = ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum );

/* Calculate the TCP checksum for an outgoing packet. */
usGenerateProtocolChecksum( ( uint8_t * ) apBuffer, pdTRUE );
usGenerateProtocolChecksum( ( uint8_t * ) pucBuffer, uxLength, pdTRUE );
}
}

Expand Down
5 changes: 3 additions & 2 deletions source/portable/NetworkInterface/ATSAM4E/gmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,8 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev,
}


extern void vGMACGenerateChecksum( uint8_t * apBuffer );
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );

/**
* \brief Send ulLength bytes from pcFrom. This copies the buffer to one of the
Expand Down Expand Up @@ -715,7 +716,7 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev,
memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size );
}
#endif /* ipconfigZERO_COPY_TX_DRIVER */
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr );
vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr, ( size_t ) ul_size );
}

#if ( GMAC_USES_TX_CALLBACK != 0 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static BaseType_t xPHY_Write( BaseType_t xAddress,
uint32_t ulValue );

#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) && ( ipconfigHAS_TX_CRC_OFFLOADING == 0 )
void vGMACGenerateChecksum( uint8_t * apBuffer,
void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );
#endif

Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/DriverSAM/gmac_SAM.h
Original file line number Diff line number Diff line change
Expand Up @@ -1539,7 +1539,7 @@

/* The SAM4E has problems offloading checksums for transmission.
* The SAME70 does not set the CRC for ICMP packets (ping). */
extern void vGMACGenerateChecksum( uint8_t * apBuffer,
extern void vGMACGenerateChecksum( uint8_t * pucBuffer,
size_t uxLength );

/*/ @cond 0 */
Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/RX/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
* this software. By using this software, you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* https://www.renesas.com/en/document/oth/disclaimer8
*
* Copyright (C) 2020 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion source/portable/NetworkInterface/RX/ether_callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Renesas reserves the right, without notice, to make changes to this software and to discontinue the availability of
* this software. By using this software, you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* https://www.renesas.com/en/document/oth/disclaimer8
*
* Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
***********************************************************************************************************************/
Expand Down
3 changes: 0 additions & 3 deletions test/unit-test/FreeRTOS_IPv4/FreeRTOS_IPv4_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ void test_prvAllowIPPacketIPv4_NotMatchingIP( void )
pxIPHeader->ulDestinationIPAddress = pxEndpoint->ipv4_settings.ulIPAddress + 1;

FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); /* From prvAllowIPPacketIPv4() */
FreeRTOS_IsNetworkUp_ExpectAndReturn( pdTRUE );

eResult = prvAllowIPPacketIPv4( pxIPPacket, pxNetworkBuffer, uxHeaderLength );

Expand Down Expand Up @@ -417,7 +416,6 @@ void test_prvAllowIPPacketIPv4_SourceIPBrdCast_NoLocalIP( void )


FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); /* From prvAllowIPPacketIPv4() */
FreeRTOS_IsNetworkUp_ExpectAndReturn( pdFALSE );

eResult = prvAllowIPPacketIPv4( pxIPPacket, pxNetworkBuffer, uxHeaderLength );

Expand Down Expand Up @@ -455,7 +453,6 @@ void test_prvAllowIPPacketIPv4_DestMACBrdCast_DestIPUnicast( void )


FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); /* From prvAllowIPPacketIPv4() */
FreeRTOS_IsNetworkUp_ExpectAndReturn( pdTRUE );

eResult = prvAllowIPPacketIPv4( pxIPPacket, pxNetworkBuffer, uxHeaderLength );

Expand Down
20 changes: 14 additions & 6 deletions test/unit-test/FreeRTOS_Routing/FreeRTOS_Routing_utest.c
Original file line number Diff line number Diff line change
Expand Up @@ -1443,25 +1443,33 @@ void test_FreeRTOS_FindEndPointOnIP_IPv4_AnyEndpoint( void )
* pxNetworkEndPoints is a global variable using in FreeRTOS_Routing as link list head of all endpoints.
*
* Test step:
* - Create 1 endpoint with IP address 0 and add it to the list.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with IPV4_DEFAULT_ADDRESS.
* - Create 1 endpoint with IP address 0xAB12CD34 and add it to the list.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with 0xAB12CD34.
* - Check if returned endpoint is same.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with IPV4_DEFAULT_GATEWAY.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with 0.
* - Check if returned endpoint is same.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with IPV4_DEFAULT_ADDRESS.
* - Check if returned endpoint is NULL.
* - Call FreeRTOS_FindEndPointOnIP_IPv4 to query with IPV4_DEFAULT_GATEWAY.
* - Check if returned endpoint is NULL.
*/
void test_FreeRTOS_FindEndPointOnIP_IPv4_ZeroAddressEndpoint( void )
{
NetworkEndPoint_t xEndPoint;
NetworkEndPoint_t * pxEndPoint = NULL;

memset( &xEndPoint, 0, sizeof( NetworkEndPoint_t ) );
xEndPoint.ipv4_settings.ulIPAddress = 0;
xEndPoint.ipv4_settings.ulIPAddress = 0xAB12CD34;
pxNetworkEndPoints = &xEndPoint;

pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( IPV4_DEFAULT_ADDRESS );
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( 0xAB12CD34 );
TEST_ASSERT_EQUAL( &xEndPoint, pxEndPoint );
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( IPV4_DEFAULT_GATEWAY );
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( 0 );
TEST_ASSERT_EQUAL( &xEndPoint, pxEndPoint );
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( IPV4_DEFAULT_ADDRESS );
TEST_ASSERT_EQUAL( NULL, pxEndPoint );
pxEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( IPV4_DEFAULT_GATEWAY );
TEST_ASSERT_EQUAL( NULL, pxEndPoint );
}

/**
Expand Down

0 comments on commit d93e085

Please sign in to comment.