mirror of
https://github.com/FreeRTOS/FreeRTOS-Plus-TCP
synced 2025-10-23 01:18:54 +08:00

* 556 Initial Cmake Module definition. #557 * renaming variables that have conflicting names with MSC and *nix headers * fix build issue for posix port * Fix warning: -Waddress-of-packed-member when calculating checksum directly from network packets * fix warnings with prvInitialiseTCPFields declaration * removing macros that hides the structure fields * Updating build check enable all config to enable all config macros * CMake: Fix GIT_REPOSITORY and GIT_TAG (#742) * moving ipTRUE_BOOL and ipFALSE_BOOL out of #ifndef pdTRUE_SIGNED check as they are not defined in kernel * minor fix to the cmake files and main file * Uncrustify: triggered by comment. * adding doxygen comments to new functions * Uncrustify: triggered by comment * Add more warnings check and fix warnings * Uncrustify: triggered by comment * fix review feedback and more debug printf warnings fix * more warnings fix * fix misra issues * Uncrustify: triggered by comment * replace sin_addr with sin_address.ulIP_IPv4 in +TCP demos * replace sin_addr6 with sin_address.xIP_IPv6 in +TCP demos * replace freertos_sockaddr6 with freertos_sockaddr in +TCP demos * review feedback changes * removing duplicate def for prvStreamBufferAdd from winpcap * fix more warnings from MSVC * Uncrustify: triggered by comment * review feedback changes * Uncrustify: triggered by comment --------- Co-authored-by: phelter <paulheltera@gmail.com> Co-authored-by: Nikhil Kamath <110539926+amazonKamath@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
105 lines
3.8 KiB
C
105 lines
3.8 KiB
C
/*
|
|
* FreeRTOS+TCP <DEVELOPMENT BRANCH>
|
|
* Copyright (C) 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
* this software and associated documentation files (the "Software"), to deal in
|
|
* the Software without restriction, including without limitation the rights to
|
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
* the Software, and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* http://aws.amazon.com/freertos
|
|
* http://www.FreeRTOS.org
|
|
*/
|
|
|
|
/**
|
|
* @file FreeRTOS_TCP_Utils_IPV6.c
|
|
* @brief Module contains utility functions used by FreeRTOS+TCP module.
|
|
*
|
|
* Endianness: in this module all ports and IP addresses are stored in
|
|
* host byte-order, except fields in the IP-packets
|
|
*/
|
|
/* Standard includes. */
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
/* FreeRTOS includes. */
|
|
#include "FreeRTOS.h"
|
|
|
|
/* FreeRTOS+TCP includes. */
|
|
#include "FreeRTOS_IP.h"
|
|
#include "FreeRTOS_IP_Private.h"
|
|
|
|
#include "FreeRTOS_TCP_Utils.h"
|
|
|
|
/* Just make sure the contents doesn't get compiled if TCP is not enabled. */
|
|
#if ipconfigUSE_TCP == 1
|
|
|
|
/**
|
|
* @brief Set the MSS (Maximum segment size) associated with the given socket.
|
|
*
|
|
* @param[in] pxSocket: The socket whose MSS is to be set.
|
|
*/
|
|
void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket )
|
|
{
|
|
uint32_t ulMSS = ipconfigTCP_MSS;
|
|
|
|
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
|
|
char cIPv6Address[ 40 ];
|
|
#endif
|
|
|
|
const NetworkEndPoint_t * pxEndPoint = pxSocket->pxEndPoint;
|
|
|
|
if( pxEndPoint != NULL )
|
|
{
|
|
/* 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 -= uxDifference;
|
|
IPv6_Type_t eType = xIPv6_GetIPType( &( pxSocket->u.xTCP.xRemoteIP.xIP_IPv6 ) );
|
|
|
|
if( eType == eIPv6_Global )
|
|
{
|
|
/* The packet will travel through Internet, make the MSS
|
|
* smaller. */
|
|
ulMSS = FreeRTOS_min_uint32( ( uint32_t ) tcpREDUCED_MSS_THROUGH_INTERNET, ulMSS );
|
|
}
|
|
}
|
|
|
|
#if ( ipconfigHAS_DEBUG_PRINTF == 1 )
|
|
{
|
|
( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address, sizeof( cIPv6Address ) );
|
|
FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address, pxSocket->u.xTCP.usRemotePort ) );
|
|
}
|
|
#endif
|
|
|
|
pxSocket->u.xTCP.usMSS = ( uint16_t ) ulMSS;
|
|
}
|
|
/*-----------------------------------------------------------*/
|
|
|
|
#endif /* ipconfigUSE_TCP == 1 */
|