Skip to content

Commit

Permalink
resolve most warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Feb 4, 2024
1 parent 826e261 commit ba0d494
Show file tree
Hide file tree
Showing 71 changed files with 1,022 additions and 976 deletions.
30 changes: 15 additions & 15 deletions source/FreeRTOS_ARP.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,15 @@ static TickType_t xLastGratuitousARPTime = 0U;
iptraceDROPPED_INVALID_ARP_PACKET( pxARPHeader );
}
/* Check whether there is a clash with another device for this IP address. */
else if( ( pxTargetEndPoint != NULL ) && ( ulSenderProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress ) )
else if( ( pxTargetEndPoint != NULL ) && ( ulSenderProtocolAddress == pxTargetEndPoint->u.ipv4_settings.ulIPAddress ) )
{
if( uxARPClashCounter < arpIP_CLASH_MAX_RETRIES )
{
/* Increment the counter. */
uxARPClashCounter++;

/* Send out a defensive ARP request. */
FreeRTOS_OutputARPRequest( pxTargetEndPoint->ipv4_settings.ulIPAddress );
FreeRTOS_OutputARPRequest( pxTargetEndPoint->u.ipv4_settings.ulIPAddress );

/* Since an ARP Request for this IP was just sent, do not send a gratuitous
* ARP for arpGRATUITOUS_ARP_PERIOD. */
Expand All @@ -245,7 +245,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
{
NetworkEndPoint_t * pxSourceEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulSenderProtocolAddress, 2 );

if( ( pxSourceEndPoint != NULL ) && ( pxSourceEndPoint->ipv4_settings.ulIPAddress == ulSenderProtocolAddress ) )
if( ( pxSourceEndPoint != NULL ) && ( pxSourceEndPoint->u.ipv4_settings.ulIPAddress == ulSenderProtocolAddress ) )
{
xARPHadIPClash = pdTRUE;
/* Remember the MAC-address of the other device which has the same IP-address. */
Expand All @@ -265,7 +265,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
FreeRTOS_debug_printf( ( "ipARP_REPLY from %xip to %xip end-point %xip\n",
( unsigned ) FreeRTOS_ntohl( ulSenderProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ulTargetProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->ipv4_settings.ulIPAddress : 0U ) ) );
( unsigned ) FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->u.ipv4_settings.ulIPAddress : 0U ) ) );
}
#endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) */

Expand All @@ -277,7 +277,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
FreeRTOS_debug_printf( ( "ipARP_REQUEST from %xip to %xip end-point %xip\n",
( unsigned ) FreeRTOS_ntohl( ulSenderProtocolAddress ),
( unsigned ) FreeRTOS_ntohl( ulTargetProtocolAddress ),
( unsigned ) ( FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->ipv4_settings.ulIPAddress : 0U ) ) ) );
( unsigned ) ( FreeRTOS_ntohl( ( pxTargetEndPoint != NULL ) ? pxTargetEndPoint->u.ipv4_settings.ulIPAddress : 0U ) ) ) );
}
#endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) */

Expand All @@ -292,7 +292,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
{
case ipARP_REQUEST:

if( ulTargetProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress )
if( ulTargetProtocolAddress == pxTargetEndPoint->u.ipv4_settings.ulIPAddress )
{
if( memcmp( pxTargetEndPoint->xMACAddress.ucBytes,
pxARPHeader->xSenderHardwareAddress.ucBytes,
Expand All @@ -304,7 +304,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
}
/* Check if its a Gratuitous ARP request and verify if it belongs to same subnet mask. */
else if( ( ulSenderProtocolAddress == ulTargetProtocolAddress ) &&
( ( ulSenderProtocolAddress & pxTargetEndPoint->ipv4_settings.ulNetMask ) == ( pxTargetEndPoint->ipv4_settings.ulNetMask & pxTargetEndPoint->ipv4_settings.ulIPAddress ) ) )
( ( ulSenderProtocolAddress & pxTargetEndPoint->u.ipv4_settings.ulNetMask ) == ( pxTargetEndPoint->u.ipv4_settings.ulNetMask & pxTargetEndPoint->u.ipv4_settings.ulIPAddress ) ) )
{
const MACAddress_t xGARPTargetAddress = { { 0, 0, 0, 0, 0, 0 } };

Expand Down Expand Up @@ -410,7 +410,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
pvCopySource = pxTargetEndPoint->xMACAddress.ucBytes;
pvCopyDest = pxARPHeader->xSenderHardwareAddress.ucBytes;
( void ) memcpy( pvCopyDest, pvCopySource, sizeof( MACAddress_t ) );
pvCopySource = &( pxTargetEndPoint->ipv4_settings.ulIPAddress );
pvCopySource = &( pxTargetEndPoint->u.ipv4_settings.ulIPAddress );
pvCopyDest = pxARPHeader->ucSenderProtocolAddress;
( void ) memcpy( pvCopyDest, pvCopySource, sizeof( pxARPHeader->ucSenderProtocolAddress ) );
}
Expand All @@ -430,7 +430,7 @@ static TickType_t xLastGratuitousARPTime = 0U;
uint32_t ulTargetProtocolAddress = pxARPHeader->ulTargetProtocolAddress;

/* If the packet is meant for this device or if the entry already exists. */
if( ( ulTargetProtocolAddress == pxTargetEndPoint->ipv4_settings.ulIPAddress ) ||
if( ( ulTargetProtocolAddress == pxTargetEndPoint->u.ipv4_settings.ulIPAddress ) ||
( xIsIPInARPCache( ulSenderProtocolAddress ) == pdTRUE ) )
{
iptracePROCESSING_RECEIVED_ARP_REPLY( ulTargetProtocolAddress );
Expand Down Expand Up @@ -530,7 +530,7 @@ BaseType_t xCheckRequiresARPResolution( const NetworkBufferDescriptor_t * pxNetw
/* coverity[misra_c_2012_rule_11_3_violation] */
const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );
const IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader );
const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->ipv4_settings );
const IPV4Parameters_t * pxIPv4Settings = &( pxNetworkBuffer->pxEndPoint->u.ipv4_settings );

if( ( pxIPHeader->ulSourceIPAddress & pxIPv4Settings->ulNetMask ) == ( pxIPv4Settings->ulIPAddress & pxIPv4Settings->ulNetMask ) )
{
Expand Down Expand Up @@ -1059,7 +1059,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress,
if( *( ppxEndPoint ) != NULL )
{
/* 'ipv4_settings' can be accessed safely, because 'ipTYPE_IPv4' was provided. */
ulAddressToLookup = ( *ppxEndPoint )->ipv4_settings.ulGatewayAddress;
ulAddressToLookup = ( *ppxEndPoint )->u.ipv4_settings.ulGatewayAddress;
}
else
{
Expand Down Expand Up @@ -1216,14 +1216,14 @@ void vARPAgeCache( void )

while( pxEndPoint != NULL )
{
if( ( pxEndPoint->bits.bEndPointUp != pdFALSE_UNSIGNED ) && ( pxEndPoint->ipv4_settings.ulIPAddress != 0U ) )
if( ( pxEndPoint->bits.bEndPointUp != pdFALSE_UNSIGNED ) && ( pxEndPoint->u.ipv4_settings.ulIPAddress != 0U ) )
{
/* Case default is never toggled because IPv6 flag can be TRUE or FALSE */
switch( pxEndPoint->bits.bIPv6 ) /* LCOV_EXCL_BR_LINE */
{
#if ( ipconfigUSE_IPv4 != 0 )
case pdFALSE_UNSIGNED:
FreeRTOS_OutputARPRequest( pxEndPoint->ipv4_settings.ulIPAddress );
FreeRTOS_OutputARPRequest( pxEndPoint->u.ipv4_settings.ulIPAddress );
break;
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

Expand Down Expand Up @@ -1282,7 +1282,7 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress )
pxEndPoint = FreeRTOS_NextEndPoint( NULL, pxEndPoint ) )
{
if( ( pxEndPoint->bits.bIPv6 == pdFALSE_UNSIGNED ) &&
( pxEndPoint->ipv4_settings.ulIPAddress != 0U ) )
( pxEndPoint->u.ipv4_settings.ulIPAddress != 0U ) )
{
/* This is called from the context of the IP event task, so a block time
* must not be used. */
Expand Down Expand Up @@ -1479,7 +1479,7 @@ void vARPGenerateRequestPacket( NetworkBufferDescriptor_t * const pxNetworkBuffe
pvCopyDest = pxARPPacket->xARPHeader.xSenderHardwareAddress.ucBytes;
( void ) memcpy( pvCopyDest, pvCopySource, ipMAC_ADDRESS_LENGTH_BYTES );

pvCopySource = &( pxNetworkBuffer->pxEndPoint->ipv4_settings.ulIPAddress );
pvCopySource = &( pxNetworkBuffer->pxEndPoint->u.ipv4_settings.ulIPAddress );
pvCopyDest = pxARPPacket->xARPHeader.ucSenderProtocolAddress;
( void ) memcpy( pvCopyDest, pvCopySource, sizeof( pxARPPacket->xARPHeader.ucSenderProtocolAddress ) );
pxARPPacket->xARPHeader.ulTargetProtocolAddress = pxNetworkBuffer->xIPAddress.ulIP_IPv4;
Expand Down
14 changes: 7 additions & 7 deletions source/FreeRTOS_DHCP.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#include "FreeRTOS_Routing.h"

#define EP_DHCPData pxEndPoint->xDHCPData /**< Temporary define to make /single source similar to /multi version. */
#define EP_IPv4_SETTINGS pxEndPoint->ipv4_settings /**< Temporary define to make /single source similar to /multi version. */
#define EP_IPv4_SETTINGS pxEndPoint->u.ipv4_settings /**< Temporary define to make /single source similar to /multi version. */



Expand Down Expand Up @@ -378,7 +378,7 @@
{
if( eAnswer == eDHCPUseDefaults )
{
( void ) memcpy( &( pxEndPoint->ipv4_settings ), &( pxEndPoint->ipv4_defaults ), sizeof( pxEndPoint->ipv4_settings ) );
( void ) memcpy( &( pxEndPoint->u.ipv4_settings ), &( pxEndPoint->u.ipv4_defaults ), sizeof( pxEndPoint->u.ipv4_settings ) );
}

/* The user indicates that the DHCP process does not continue. */
Expand Down Expand Up @@ -565,12 +565,12 @@
/* Ask the user if a DHCP discovery is required. */
#if ( ipconfigUSE_DHCP_HOOK != 0 )
#if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 )
eDHCPCallbackAnswer_t eAnswer = xApplicationDHCPHook( eDHCPPhasePreDiscover, pxEndPoint->ipv4_defaults.ulIPAddress );
eDHCPCallbackAnswer_t eAnswer = xApplicationDHCPHook( eDHCPPhasePreDiscover, pxEndPoint->u.ipv4_defaults.ulIPAddress );
#else /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */
IP_Address_t xIPAddress;
eDHCPCallbackAnswer_t eAnswer;

xIPAddress.ulIP_IPv4 = pxEndPoint->ipv4_defaults.ulIPAddress;
xIPAddress.ulIP_IPv4 = pxEndPoint->u.ipv4_defaults.ulIPAddress;
eAnswer = xApplicationDHCPHook_Multi( eDHCPPhasePreDiscover, pxEndPoint, &xIPAddress );
#endif /* ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) */

Expand Down Expand Up @@ -608,7 +608,7 @@
{
if( eAnswer == eDHCPUseDefaults )
{
( void ) memcpy( &( pxEndPoint->ipv4_settings ), &( pxEndPoint->ipv4_defaults ), sizeof( pxEndPoint->ipv4_settings ) );
( void ) memcpy( &( pxEndPoint->u.ipv4_settings ), &( pxEndPoint->u.ipv4_defaults ), sizeof( pxEndPoint->u.ipv4_settings ) );
}

/* The user indicates that the DHCP process does not continue. */
Expand Down Expand Up @@ -817,8 +817,8 @@
/* Revert to static IP address. */
taskENTER_CRITICAL();
{
EP_IPv4_SETTINGS.ulIPAddress = pxEndPoint->ipv4_defaults.ulIPAddress;
iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( pxEndPoint->ipv4_defaults.ulIPAddress );
EP_IPv4_SETTINGS.ulIPAddress = pxEndPoint->u.ipv4_defaults.ulIPAddress;
iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( pxEndPoint->u.ipv4_defaults.ulIPAddress );
}
taskEXIT_CRITICAL();

Expand Down
24 changes: 12 additions & 12 deletions source/FreeRTOS_DHCPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

#define EP_DHCPData pxEndPoint->xDHCPData
/** @brief Macro to access the IPv6 settings from the pxEndPoint */
#define EP_IPv6_SETTINGS pxEndPoint->ipv6_settings
#define EP_IPv6_SETTINGS pxEndPoint->u.ipv6_settings

/** @brief The maximum size of send buffer. */
#define DHCPv6_SEND_MAX_BUFFER_SIZE ( 256 )
Expand Down Expand Up @@ -407,7 +407,7 @@ void vDHCPv6Process( BaseType_t xReset,
/* Use static IP address. */
taskENTER_CRITICAL();
{
( void ) memcpy( EP_IPv6_SETTINGS.xIPAddress.ucBytes, pxEndPoint->ipv6_defaults.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( EP_IPv6_SETTINGS.xIPAddress.ucBytes, pxEndPoint->u.ipv6_defaults.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IPv6_ADDRESS( EP_IPv6_SETTINGS.xIPAddress );
}
taskEXIT_CRITICAL();
Expand Down Expand Up @@ -482,7 +482,7 @@ void vDHCPv6Stop( struct xNetworkEndPoint * pxEndPoint )

/**
* @brief The DHCP process is about ready: the server sends a confirmation that the
* assigned IPv6 address may be used. The settings will be copied to 'pxEndPoint->ipv6_settings'.
* assigned IPv6 address may be used. The settings will be copied to 'pxEndPoint->u.ipv6_settings'.
* @param[in] pxEndPoint The end-point that is asking for an IP-address.
* @param[in] pxDHCPMessage The reply received from the DHCP server.
*/
Expand All @@ -495,14 +495,14 @@ static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint,

/* DHCP completed. The IP address can now be used, and the
* timer set to the lease timeout time. */
pxEndPoint->ipv6_settings.uxPrefixLength = pxDHCPMessage->ucprefixLength; /* Number of valid bytes in the network prefix. */
( void ) memcpy( pxEndPoint->ipv6_settings.xIPAddress.ucBytes, pxDHCPMessage->xIPAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxEndPoint->ipv6_settings.xPrefix.ucBytes, pxDHCPMessage->xPrefixAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); /* The network prefix, e.g. fe80::/10 */
pxEndPoint->u.ipv6_settings.uxPrefixLength = pxDHCPMessage->ucprefixLength; /* Number of valid bytes in the network prefix. */
( void ) memcpy( pxEndPoint->u.ipv6_settings.xIPAddress.ucBytes, pxDHCPMessage->xIPAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxEndPoint->u.ipv6_settings.xPrefix.ucBytes, pxDHCPMessage->xPrefixAddress.xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); /* The network prefix, e.g. fe80::/10 */
/*pxEndPoint->xGatewayAddress; / * Gateway to the web. * / */

for( uxDNSIndex = 0; uxDNSIndex < pxDHCPMessage->uxDNSCount; uxDNSIndex++ )
{
( void ) memcpy( pxEndPoint->ipv6_settings.xDNSServerAddresses[ uxDNSIndex ].ucBytes, pxDHCPMessage->xDNSServers[ uxDNSIndex ].xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( pxEndPoint->u.ipv6_settings.xDNSServerAddresses[ uxDNSIndex ].ucBytes, pxDHCPMessage->xDNSServers[ uxDNSIndex ].xIP_IPv6.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
}

EP_DHCPData.eDHCPState = eLeasedAddress;
Expand Down Expand Up @@ -574,7 +574,7 @@ static BaseType_t xDHCPv6ProcessEndPoint_HandleAdvertise( NetworkEndPoint_t * px
{
if( eAnswer == eDHCPUseDefaults )
{
( void ) memcpy( &( pxEndPoint->ipv6_settings ), &( pxEndPoint->ipv6_defaults ), sizeof( pxEndPoint->ipv6_settings ) );
( void ) memcpy( &( pxEndPoint->u.ipv6_settings ), &( pxEndPoint->u.ipv6_defaults ), sizeof( pxEndPoint->u.ipv6_settings ) );
}

/* The user indicates that the DHCP process does not continue. */
Expand Down Expand Up @@ -643,7 +643,7 @@ static BaseType_t xDHCPv6ProcessEndPoint_HandleState( NetworkEndPoint_t * pxEndP
{
if( eAnswer == eDHCPUseDefaults )
{
( void ) memcpy( &( pxEndPoint->ipv6_settings ), &( pxEndPoint->ipv6_defaults ), sizeof( pxEndPoint->ipv6_settings ) );
( void ) memcpy( &( pxEndPoint->u.ipv6_settings ), &( pxEndPoint->u.ipv6_defaults ), sizeof( pxEndPoint->u.ipv6_settings ) );
}

/* The user indicates that the DHCP process does not continue. */
Expand Down Expand Up @@ -811,7 +811,7 @@ static void vDHCPv6ProcessEndPoint( BaseType_t xReset,
/* Revert to static IP address. */
taskENTER_CRITICAL();
{
( void ) memcpy( EP_IPv6_SETTINGS.xIPAddress.ucBytes, pxEndPoint->ipv6_defaults.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
( void ) memcpy( EP_IPv6_SETTINGS.xIPAddress.ucBytes, pxEndPoint->u.ipv6_defaults.xIPAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS );
iptraceDHCP_REQUESTS_FAILED_USING_DEFAULT_IPv6_ADDRESS( EP_IPv6_SETTINGS.xIPAddress );
}
taskEXIT_CRITICAL();
Expand Down Expand Up @@ -1058,14 +1058,14 @@ static void prvSendDHCPMessage( NetworkEndPoint_t * pxEndPoint )
/* DHCPv6_Option_IA_Prefix */
uint32_t ulPreferredLifeTime = 4500U;
uint32_t ulPValidLifeTime = 7200U;
uint8_t ucPrefixLength = ( uint8_t ) pxEndPoint->ipv6_settings.uxPrefixLength;
uint8_t ucPrefixLength = ( uint8_t ) pxEndPoint->u.ipv6_settings.uxPrefixLength;

vBitConfig_write_16( &( xMessage ), DHCPv6_Option_IA_Prefix ); /* usOption Option is 26 */
vBitConfig_write_16( &( xMessage ), 25 ); /* usLength length is 25 */
vBitConfig_write_32( &( xMessage ), ulPreferredLifeTime ); /* 4500 */
vBitConfig_write_32( &( xMessage ), ulPValidLifeTime ); /* e.g. 7200 seconds. */
vBitConfig_write_8( &( xMessage ), ucPrefixLength ); /* e.g. 64 bits */
vBitConfig_write_uc( &( xMessage ), pxEndPoint->ipv6_settings.xPrefix.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); /* 2001:0:0:fe00:: */
vBitConfig_write_uc( &( xMessage ), pxEndPoint->u.ipv6_settings.xPrefix.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); /* 2001:0:0:fe00:: */

vBitConfig_write_16( &( xMessage ), DHCPv6_Option_NonTemporaryAddress ); /* usOption Option is 3 */
vBitConfig_write_16( &( xMessage ), 12 ); /* usLength length is 12 */
Expand Down
Loading

0 comments on commit ba0d494

Please sign in to comment.