Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ActoryOu authored Jan 10, 2024
2 parents 5f62ebc + 7af0bfe commit 8e1b930
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 238 deletions.
46 changes: 3 additions & 43 deletions source/FreeRTOS_DNS_Parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,6 @@

#if ( ipconfigUSE_DNS != 0 )

/** @brief The list of all callback structures. */


#if ( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) )

/**
* @brief Find the best matching end-point given a reply that was received.
* @param[in] pxNetworkBuffer The Ethernet packet that was received.
* @return An end-point.
*/
static NetworkEndPoint_t * prvFindEndPointOnNetMask( NetworkBufferDescriptor_t * pxNetworkBuffer )
{
NetworkEndPoint_t * pxEndPoint = NULL;

#if ( ipconfigUSE_IPv6 != 0 )
IPPacket_IPv6_t * xIPPacket_IPv6 = ( ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer );

if( xIPPacket_IPv6->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE )
{
pxEndPoint = FreeRTOS_FindEndPointOnNetMask_IPv6( &xIPPacket_IPv6->xIPHeader.xSourceAddress );
}
else
#endif /* ( ipconfigUSE_IPv6 != 0 ) */

#if ( ipconfigUSE_IPv4 != 0 )
{
IPPacket_t * xIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer );

pxEndPoint = FreeRTOS_FindEndPointOnNetMask( xIPPacket->xIPHeader.ulSourceIPAddress, 6 );
}
#endif /* ( ipconfigUSE_IPv4 != 0 ) */

if( pxEndPoint != NULL )
{
pxNetworkBuffer->pxEndPoint = pxEndPoint;
}

return pxEndPoint;
}
#endif /* ( ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) ) */
/*-----------------------------------------------------------*/

/**
* @brief Read the Name field out of a DNS response packet.
Expand Down Expand Up @@ -911,9 +870,10 @@
IPHeader_t * pxIPHeader;
UDPHeader_t * pxUDPHeader;
size_t uxDataLength;
NetworkEndPoint_t * pxEndPoint = prvFindEndPointOnNetMask( pxNetworkBuffer );
NetworkEndPoint_t * pxEndPoint = pxNetworkBuffer->pxEndPoint;
const size_t uxIPHeaderLength = uxIPHeaderSizePacket( pxNetworkBuffer );

configASSERT( pxEndPoint != NULL );
pxUDPPacket = ( ( UDPPacket_t * )
pxNetworkBuffer->pucEthernetBuffer );
pxIPHeader = &pxUDPPacket->xIPHeader;
Expand Down Expand Up @@ -959,7 +919,7 @@
pxIPHeader->ucTimeToLive = ipconfigUDP_TIME_TO_LIVE;
}

pxIPHeader->ulSourceIPAddress = ( pxEndPoint != NULL ) ? pxEndPoint->ipv4_settings.ulIPAddress : 0U;
pxIPHeader->ulSourceIPAddress = pxEndPoint->ipv4_settings.ulIPAddress;
pxIPHeader->usIdentification = FreeRTOS_htons( usPacketIdentifier );

/* The stack doesn't support fragments, so the fragment offset field must always be zero.
Expand Down
70 changes: 35 additions & 35 deletions source/FreeRTOS_Sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -5408,41 +5408,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 @@ -5819,6 +5784,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
Loading

0 comments on commit 8e1b930

Please sign in to comment.