Skip to content

Commit

Permalink
Make use of FreeRTOS_inet_addr_quick() when applicable (#1032)
Browse files Browse the repository at this point in the history
  • Loading branch information
htibosch authored Oct 5, 2023
1 parent d3ce35f commit 382ddb0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions source/include/FreeRTOS_Sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,17 +471,17 @@
/* Converts an IP address expressed as four separate numeric octets into an
* IP address expressed as a 32-bit number in network byte order */
#define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24UL ) | \
( ( ( uint32_t ) ( ucOctet2 ) ) << 16UL ) | \
( ( ( uint32_t ) ( ucOctet1 ) ) << 8UL ) | \
( ( ( ( uint32_t ) ( ucOctet3 ) ) << 24 ) | \
( ( ( uint32_t ) ( ucOctet2 ) ) << 16 ) | \
( ( ( uint32_t ) ( ucOctet1 ) ) << 8 ) | \
( ( uint32_t ) ( ucOctet0 ) ) )

#else /* ( ipconfigBYTE_ORDER == pdFREERTOS_BIG_ENDIAN ) */

#define FreeRTOS_inet_addr_quick( ucOctet0, ucOctet1, ucOctet2, ucOctet3 ) \
( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24UL ) | \
( ( ( uint32_t ) ( ucOctet1 ) ) << 16UL ) | \
( ( ( uint32_t ) ( ucOctet2 ) ) << 8UL ) | \
( ( ( ( uint32_t ) ( ucOctet0 ) ) << 24 ) | \
( ( ( uint32_t ) ( ucOctet1 ) ) << 16 ) | \
( ( ( uint32_t ) ( ucOctet2 ) ) << 8 ) | \
( ( uint32_t ) ( ucOctet3 ) ) )

#endif /* ( ipconfigBYTE_ORDER == pdFREERTOS_LITTLE_ENDIAN ) */
Expand Down
8 changes: 4 additions & 4 deletions source/portable/NetworkInterface/WinPCap/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ static void prvConfigureCaptureBehaviour( const NetworkInterface_t * pxInterface
snprintf( cErrorBuffer, sizeof( cErrorBuffer ), "broadcast or multicast or ether host %x:%x:%x:%x:%x:%x",
pucMAC[ 0 ], pucMAC[ 1 ], pucMAC[ 2 ], pucMAC[ 3 ], pucMAC[ 4 ], pucMAC[ 5 ] );

ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0;
ulNetMask = FreeRTOS_inet_addr_quick( configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );

if( pcap_compile( pxOpenedInterfaceHandle, &xFilterCode, cErrorBuffer, 1, ulNetMask ) < 0 )
{
Expand Down Expand Up @@ -697,7 +697,7 @@ DWORD WINAPI prvWinPcapRecvThread( void * pvParam )
{
( void ) pvParam;

/* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
/* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
* OUT MESSAGES HERE. */

for( ; ; )
Expand All @@ -714,7 +714,7 @@ DWORD WINAPI prvWinPcapSendThread( void * pvParam )
static char cErrorMessage[ 1024 ];
const DWORD xMaxMSToWait = 1000;

/* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
/* THIS IS A WINDOWS THREAD - DO NOT ATTEMPT ANY FREERTOS CALLS OR TO PRINT
* OUT MESSAGES HERE. */

/* Remove compiler warnings about unused parameters. */
Expand Down Expand Up @@ -829,7 +829,7 @@ static void prvInterruptSimulatorTask( void * pvParameters )
BaseType_t xBounced = xPacketBouncedBack( pucPacketData );

/* Obtain a buffer into which the data can be placed. This
* is only an interrupt simulator, not a real interrupt, so it
* is only an interrupt simulator, not a real interrupt, so it
* is ok to call the task level function here, but note that
* some buffer implementations cannot be called from a real
* interrupt. */
Expand Down
12 changes: 6 additions & 6 deletions source/portable/NetworkInterface/linux/NetworkInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,10 +589,10 @@ static int prvOpenInterface( const char * pucName )

/*!
* @brief Open the network interface. The number of the interface to be opened is
* set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h
* Calling this function will set the pxOpenedInterfaceHandle variable
* If, after calling this function, pxOpenedInterfaceHandle
* is equal to NULL, then the interface could not be opened.
* set by the configNETWORK_INTERFACE_TO_USE constant in FreeRTOSConfig.h
* Calling this function will set the pxOpenedInterfaceHandle variable
* If, after calling this function, pxOpenedInterfaceHandle
* is equal to NULL, then the interface could not be opened.
* @param [in] pxAllNetworkInterfaces network interface list to choose from
* @returns pdPASS on success or pdFAIL when something goes wrong
*/
Expand Down Expand Up @@ -717,7 +717,7 @@ static int prvConfigureCaptureBehaviour( void )
ipLOCAL_MAC_ADDRESS[ 5 ] );
FreeRTOS_debug_printf( ( "pcap filter to compile: %s\n", pcap_filter ) );

ulNetMask = ( configNET_MASK3 << 24UL ) | ( configNET_MASK2 << 16UL ) | ( configNET_MASK1 << 8L ) | configNET_MASK0;
ulNetMask = FreeRTOS_inet_addr_quick( configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 );

ret = pcap_compile( pxOpenedInterfaceHandle,
&xFilterCode,
Expand Down Expand Up @@ -960,7 +960,7 @@ static void prvInterruptSimulatorTask( void * pvParameters )
if( pxHeader->len <= ipTOTAL_ETHERNET_FRAME_SIZE )
{
/* Obtain a buffer into which the data can be placed. This
* is only an interrupt simulator, not a real interrupt, so it
* is only an interrupt simulator, not a real interrupt, so it
* is ok to call the task level function here, but note that
* some buffer implementations cannot be called from a real
* interrupt. */
Expand Down

0 comments on commit 382ddb0

Please sign in to comment.