Skip to content

Commit

Permalink
Improve Default Macros (#782)
Browse files Browse the repository at this point in the history
* Delete duplicate default defines

* Remove errno definitions that exist in projdefs.h

* Clean & Organize FreeRTOSIPConfigDefaults.h

* Move deprecated definitions to their own file

* Definitions Documentation Improvements

* Tracing default definitions improvements

* Organize and add to deprecated definitions

* Remove FreeRTOS_errno_TCP.h

* Fixes for definitions updates

* Address review comments

* Start enforcing macro value limits and make some doc more succinct

* enforce ipconfig macro bounds

* repair config default and reduce unnecessary changes

* Add more descriptions of ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM (#947)

* Fixes mDNS over IPv6. (#949)

Co-authored-by: Emil Popov <[email protected]>
Co-authored-by: ActoryOu <[email protected]>
Co-authored-by: Monika Singh <[email protected]>

* remove enabled checks

* Remove enable checks from trace macros

* Update cmake sources

* add missing defines

* revert unnecessary changes

* formatting

* fix lexicon

* fix build issue and remove deprecated macro usage from tests

* fix build issues and formatting

* disable pdFREERTOS_ERRNO_EAFNOSUPPORT check

* update kernel submodule for tests

* macro definition fixes

* fix some test build issues

* Temporary passing state

* Fix unittest

* Fix CBMC

* Update CBMC proof

* Update Macro comments

* revert changes

* Fix MISRA 4.4

* Fix MISRA 20.7 violation

* Fix spell checker

* Update Hein's comment

---------

Co-authored-by: Holden <holden-zenithaerotech.com>
Co-authored-by: ActoryOu <[email protected]>
Co-authored-by: Emil Popov <[email protected]>
Co-authored-by: Emil Popov <[email protected]>
Co-authored-by: Monika Singh <[email protected]>
Co-authored-by: ActoryOu <[email protected]>
  • Loading branch information
6 people authored Nov 1, 2023
1 parent 1474378 commit be2555b
Show file tree
Hide file tree
Showing 73 changed files with 4,165 additions and 2,999 deletions.
1 change: 1 addition & 0 deletions .github/.cSpellWords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ DEAS
DEBR
DEBUGEN
DEBUGF
DECASECONDS
DEFFERRALCHECK
DEFR
Deglitchers
Expand Down
2 changes: 1 addition & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set_property(TARGET freertos_plus_tcp PROPERTY C_STANDARD 90)
target_sources( freertos_plus_tcp
PRIVATE
include/FreeRTOSIPConfigDefaults.h
include/FreeRTOSIPDeprecatedDefinitions.h
include/FreeRTOS_ARP.h
include/FreeRTOS_BitConfig.h
include/FreeRTOS_DHCP.h
Expand Down Expand Up @@ -40,7 +41,6 @@ target_sources( freertos_plus_tcp
include/FreeRTOS_TCP_Utils.h
include/FreeRTOS_TCP_WIN.h
include/FreeRTOS_UDP_IP.h
include/FreeRTOS_errno_TCP.h
include/IPTraceMacroDefaults.h
include/NetworkBufferManagement.h
include/NetworkInterface.h
Expand Down
2 changes: 1 addition & 1 deletion source/FreeRTOS_IP_Utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,7 @@ uint16_t usGenerateChecksum( uint16_t usSum,

/**
* @brief Utility function: Convert error number to a human readable
* string. Declaration in FreeRTOS_errno_TCP.h.
* string.
*
* @param[in] xErrnum The error number.
* @param[in] pcBuffer Buffer big enough to be filled with the human readable message.
Expand Down
12 changes: 5 additions & 7 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,10 +572,9 @@ static BaseType_t prvDetermineSocketSize( BaseType_t xDomain,
{
uint16_t usDifference = ipSIZE_OF_IPv6_HEADER - ipSIZE_OF_IPv4_HEADER;

if( pxSocket->u.xTCP.usMSS > usDifference )
{
pxSocket->u.xTCP.usMSS = ( uint16_t ) ( pxSocket->u.xTCP.usMSS - usDifference );
}
/* Because ipconfigTCP_MSS is guaranteed not less than tcpMINIMUM_SEGMENT_LENGTH by FreeRTOSIPConfigDefaults.h,
* it's unnecessary to check if xSocket->u.xTCP.usMSS is greater than difference. */
pxSocket->u.xTCP.usMSS = ( uint16_t ) ( pxSocket->u.xTCP.usMSS - usDifference );
}
#endif /* ipconfigUSE_IPv6 != 0 */

Expand Down Expand Up @@ -1259,8 +1258,7 @@ static int32_t prvRecvFrom_CopyPacket( uint8_t * pucEthernetBuffer,
* (24-bytes) for compatibility.
*
* @return The number of bytes received. Or else, an error code is returned. When it
* returns a negative value, the cause can be looked-up in
* 'FreeRTOS_errno_TCP.h'.
* returns a negative value, the cause can be looked-up in 'FreeRTOS-Kernel/projdefs.h'.
*/
int32_t FreeRTOS_recvfrom( const ConstSocket_t xSocket,
void * pvBuffer,
Expand Down Expand Up @@ -1570,7 +1568,7 @@ static int32_t prvSendTo_ActualSend( const FreeRTOS_Socket_t * pxSocket,
* Berkeley sockets standard. Else, it is not used.
*
* @return When positive: the total number of bytes sent, when negative an error
* has occurred: it can be looked-up in 'FreeRTOS_errno_TCP.h'.
* has occurred: it can be looked-up in 'FreeRTOS-Kernel/projdefs.h'.
*/
int32_t FreeRTOS_sendto( Socket_t xSocket,
const void * pvBuffer,
Expand Down
8 changes: 5 additions & 3 deletions source/FreeRTOS_TCP_IP.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,11 @@
{
/* A socket was in the connecting phase but something
* went wrong and it should be closed. */
FreeRTOS_debug_printf( ( "Move from %s to %s\n",
FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ),
FreeRTOS_GetTCPStateName( eTCPState ) ) );
#if ( ipconfigHAS_DEBUG_PRINTF != 0 )
FreeRTOS_debug_printf( ( "Move from %s to %s\n",
FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ),
FreeRTOS_GetTCPStateName( eTCPState ) ) );
#endif

/* Set the flag to show that it was connected before and that the
* status has changed now. This will cause the control flow to go
Expand Down
14 changes: 3 additions & 11 deletions source/FreeRTOS_TCP_Utils_IPv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,10 @@ void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket )
/* Compared to IPv4, an IPv6 header is 20 bytes longer.
* It must be subtracted from the MSS. */
size_t uxDifference = ipSIZE_OF_IPv6_HEADER - ipSIZE_OF_IPv4_HEADER;
/* Do not allow MSS smaller than tcpMINIMUM_SEGMENT_LENGTH. */
#if ( ipconfigTCP_MSS >= tcpMINIMUM_SEGMENT_LENGTH )
{
ulMSS = ipconfigTCP_MSS;
}
#else
{
ulMSS = tcpMINIMUM_SEGMENT_LENGTH;
}
#endif

ulMSS = ( uint32_t ) ( ulMSS - uxDifference );
/* Because ipconfigTCP_MSS is guaranteed not less than tcpMINIMUM_SEGMENT_LENGTH by FreeRTOSIPConfigDefaults.h,
* it's unnecessary to check if xSocket->u.xTCP.usMSS is greater than difference. */
ulMSS = ( uint32_t ) ( ipconfigTCP_MSS - uxDifference );
IPv6_Type_t eType = xIPv6_GetIPType( &( pxSocket->u.xTCP.xRemoteIP.xIP_IPv6 ) );

if( eType == eIPv6_Global )
Expand Down
Loading

0 comments on commit be2555b

Please sign in to comment.