Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix declaration of socket functions without TCP #1068

Merged
merged 6 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -5401,41 +5401,6 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket )

#if ( ipconfigUSE_TCP == 1 )


/**
* @brief Get the version of IP: either 'ipTYPE_IPv4' or 'ipTYPE_IPv6'.
*
* @param[in] xSocket The socket to be checked.
*
* @return Either ipTYPE_IPv4 or ipTYPE_IPv6.
*/
BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket )
{
const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) xSocket;
BaseType_t xResult = ( BaseType_t ) ipTYPE_IPv4;

switch( pxSocket->bits.bIsIPv6 ) /* LCOV_EXCL_BR_LINE Exclude this line because default case is not counted. */
{
#if ( ipconfigUSE_IPv4 != 0 )
case pdFALSE_UNSIGNED:
xResult = ( BaseType_t ) ipTYPE_IPv4;
break;
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

#if ( ipconfigUSE_IPv6 != 0 )
case pdTRUE_UNSIGNED:
xResult = ( BaseType_t ) ipTYPE_IPv6;
break;
#endif /* ( ipconfigUSE_IPv6 != 0 ) */

default:
/* MISRA 16.4 Compliance */
break;
}

return xResult;
}

/**
* @brief Check the number of bytes that may be added to txStream.
*
Expand Down Expand Up @@ -5812,6 +5777,41 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket )
}
/*-----------------------------------------------------------*/

/**
* @brief Get the version of IP: either 'ipTYPE_IPv4' or 'ipTYPE_IPv6'.
*
* @param[in] xSocket The socket to be checked.
*
* @return Either ipTYPE_IPv4 or ipTYPE_IPv6.
*/
BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket )
{
const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) xSocket;
BaseType_t xResult = ( BaseType_t ) ipTYPE_IPv4;

switch( pxSocket->bits.bIsIPv6 ) /* LCOV_EXCL_BR_LINE Exclude this line because default case is not counted. */
{
#if ( ipconfigUSE_IPv4 != 0 )
case pdFALSE_UNSIGNED:
xResult = ( BaseType_t ) ipTYPE_IPv4;
break;
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

#if ( ipconfigUSE_IPv6 != 0 )
case pdTRUE_UNSIGNED:
xResult = ( BaseType_t ) ipTYPE_IPv6;
break;
#endif /* ( ipconfigUSE_IPv6 != 0 ) */

default:
/* MISRA 16.4 Compliance */
break;
}

return xResult;
}
/*-----------------------------------------------------------*/

#if ( ( ipconfigHAS_PRINTF != 0 ) && ( ipconfigUSE_TCP == 1 ) )

/**
Expand Down
24 changes: 12 additions & 12 deletions source/include/FreeRTOS_Sockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@
BaseType_t * pxHigherPriorityTaskWoken );
#endif

/* This option adds the possibility to have a user-ID attached to a socket.
* The type of this ID is a void *. Both UDP and TCP sockets have
* this ID. It has a default value of NULL.
*/
BaseType_t xSocketSetSocketID( const Socket_t xSocket,
void * pvSocketID );

void * pvSocketGetSocketID( const ConstSocket_t xSocket );

/* Get the type of IP: either 'ipTYPE_IPv4' or 'ipTYPE_IPv6'. */
BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket );

/* End Common Socket Attributes */


Expand Down Expand Up @@ -352,9 +364,6 @@
BaseType_t FreeRTOS_GetRemoteAddress( ConstSocket_t xSocket,
struct freertos_sockaddr * pxAddress );

/* Get the type of IP: either 'ipTYPE_IPv4' or 'ipTYPE_IPv6'. */
BaseType_t FreeRTOS_GetIPType( ConstSocket_t xSocket );

/* Returns the number of bytes that may be added to txStream. */
BaseType_t FreeRTOS_maywrite( ConstSocket_t xSocket );

Expand Down Expand Up @@ -383,15 +392,6 @@

void FreeRTOS_netstat( void );

/* This option adds the possibility to have a user-ID attached to a socket.
* The type of this ID is a void *. Both UDP and TCP sockets have
* this ID. It has a default value of NULL.
*/
BaseType_t xSocketSetSocketID( const Socket_t xSocket,
void * pvSocketID );

void * pvSocketGetSocketID( const ConstSocket_t xSocket );

/* End TCP Socket Attributes. */

#endif /* ( ipconfigUSE_TCP == 1 ) */
Expand Down