mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 10:17:45 -04:00
Merging IPv6 demo changes to main (#1028)
* Add IPv6 Demo (#937) * Add demo changes * Update kernel and library paths * Update main.c * Run uncrustify * Fix spell checker * CI check file headers update * Add IPv6/v4 UDP echo server with zero copy/non-zero copy versions * Add VS proj file changes to include the UDP echo sample code * readme update --------- Co-authored-by: Tony Josi <tonyjosi@amazon.com> * Update Backward Compatibility Flag (#954) * Update Backward Compatibility Flag * Update FreeRTOS_GetUDPPayloadBuffer_ByIPType * Update FreeRTOS_IPStart to FreeRTOS_IPInit_Multi * Update Application APIs * Remove ipconfigCOMPATIBLE_WITH_SINGLE * Update Static Lib files (#956) * Update Static Lib files * making vApplicationIPNetworkEventHook backward compatible in demos * Update CI check file headers --------- Co-authored-by: Tony Josi <tonyjosi@amazon.com> * Add WinPCap NetworkInterface Changes (#958) * Update winpcap network interface * Run uncrustify * Update function to include NetworkInterface_t parameters * Adding compatibility for xApplicationDNSQueryHook with latest dev branch for old demos (#957) * adding compatibility for xApplicationDNSQueryHook with latest dev branch * adding tcp echo server source * removing unused sub demos * fix build issues (#969) * Update demo to latest +TCP dev/IPv6_integration (#978) * remove macro namings * rename sin_addr to sin_address.ulIP_IPv4 for ipv6 demo * replace in6addr_any with FreeRTOS_in6addr_any * replace mainCREATE_UDP_ECHO_SERVER_TASK with mainCREATE_UDP_ECHO_TASKS_SINGLE * handle removal of sin_addr macro to sin_address.ulIP_IPv4 * updating +TCP repo to latest dev/IPv6_integration * minor update to more clear code * more sin_addr to sin_address.ulIP_IPv4 replacements * fix makefiles for qemu and posix demos * review feedback changes * Update FreeRTOS-Plus-TCP for RC2 * Change from PR (#994) * Update FreeRTOS-Plus-TCP for RC2 * Update copyright * Ignore WinPCap for files header check failure. * Update checker * Update manifest * Point manifest to latest commit * Fix Spell-checker * Update doxygen * Update xApplicationDHCPHook for backward compatibility (#999) * Update xApplicationDHCPHook for backward compatability * Update IPv6 * Update VisualStudio Static Project files * Update pxEndPoint error (#1002) * Update IPv6 demo ReadMe (#1004) * Update ReadMe * Update setup requirement * Update UDP demo info * Update comment * TCP demo changes post build separation (#1011) * adding sin_family to dest adddr for FreeRTOS_sendto * updating FreeRTOS_bind to input sin_family post build separation changes * updating FreeRTOS_connect to input sin_family post build separation changes * minor fix * updating copyright year * updating file headers * updating +TCP submodule * updating file headers * updating file headers * updating manifest file to have latest +TCP submodule hash * Fix issue with posix demo while running with ipconfigIPv4_BACKWARD_COMPATIBLE enabled for +TCP stack (#1027) * Update the submodule pointer to IPv6 main * Update manifest with latest TCP commit * Update file checker exception * Ignore Visual studio project file from file header checker --------- Co-authored-by: Tony Josi <tonyjosi@amazon.com>
This commit is contained in:
parent
8f3233e0a0
commit
301ed5881b
83 changed files with 12126 additions and 1074 deletions
|
@ -733,8 +733,18 @@ int32_t UdpTransport_Send( NetworkContext_t * pNetworkContext,
|
|||
struct freertos_sockaddr destinationAddress;
|
||||
int32_t bytesSent;
|
||||
|
||||
destinationAddress.sin_addr = FreeRTOS_htonl( serverAddr );
|
||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||
{
|
||||
destinationAddress.sin_address.ulIP_IPv4 = FreeRTOS_htonl( serverAddr );
|
||||
}
|
||||
#else
|
||||
{
|
||||
destinationAddress.sin_addr = FreeRTOS_htonl( serverAddr );
|
||||
}
|
||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||
|
||||
destinationAddress.sin_port = FreeRTOS_htons( serverPort );
|
||||
destinationAddress.sin_family = FREERTOS_AF_INET;
|
||||
|
||||
/* Send the buffer with ulFlags set to 0, so the FREERTOS_ZERO_COPY bit
|
||||
* is clear. */
|
||||
|
@ -787,15 +797,29 @@ static int32_t UdpTransport_Recv( NetworkContext_t * pNetworkContext,
|
|||
|
||||
/* If data is received from the network, discard the data if received from a different source than
|
||||
* the server. */
|
||||
if( ( bytesReceived > 0 ) && ( ( FreeRTOS_ntohl( sourceAddress.sin_addr ) != serverAddr ) ||
|
||||
( FreeRTOS_ntohs( sourceAddress.sin_port ) != serverPort ) ) )
|
||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||
if( ( bytesReceived > 0 ) && ( ( FreeRTOS_ntohl( sourceAddress.sin_address.ulIP_IPv4 ) != serverAddr ) ||
|
||||
( FreeRTOS_ntohs( sourceAddress.sin_port ) != serverPort ) ) )
|
||||
#else
|
||||
if( ( bytesReceived > 0 ) && ( ( FreeRTOS_ntohl( sourceAddress.sin_addr ) != serverAddr ) ||
|
||||
( FreeRTOS_ntohs( sourceAddress.sin_port ) != serverPort ) ) )
|
||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||
{
|
||||
bytesReceived = 0;
|
||||
|
||||
#if defined( LIBRARY_LOG_LEVEL ) && ( LIBRARY_LOG_LEVEL != LOG_NONE )
|
||||
/* Convert the IP address of the sender's address to string for logging. */
|
||||
char stringAddr[ 16 ];
|
||||
FreeRTOS_inet_ntoa( sourceAddress.sin_addr, stringAddr );
|
||||
|
||||
#if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 )
|
||||
{
|
||||
FreeRTOS_inet_ntoa( sourceAddress.sin_address.ulIP_IPv4, stringAddr );
|
||||
}
|
||||
#else
|
||||
{
|
||||
FreeRTOS_inet_ntoa( sourceAddress.sin_addr, stringAddr );
|
||||
}
|
||||
#endif /* defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 0 ) */
|
||||
|
||||
/* Log about reception of packet from unexpected sender. */
|
||||
LogWarn( ( "Received UDP packet from unexpected source: Addr=%s Port=%u",
|
||||
|
@ -1383,6 +1407,7 @@ static bool createUdpSocket( Socket_t * pSocket )
|
|||
* spoofing vulnerability from "network off-path" attackers. */
|
||||
uint16_t randomPort = ( generateRandomNumber() % UINT16_MAX );
|
||||
bindAddress.sin_port = FreeRTOS_htons( randomPort );
|
||||
bindAddress.sin_family = FREERTOS_AF_INET;
|
||||
|
||||
if( FreeRTOS_bind( *pSocket, &bindAddress, sizeof( bindAddress ) ) == 0 )
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue