Sync FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP with the version in GitHub at (23665258cabe49d5d68ba23968b6845a7c80eb34).

Notes: 
- header has version 2.2.0. 
- This sync did not bring in ./test directory, though we should. 
- New NetworkInterfaces are introduced by this merge.
- Keil compiler support. 
- FreeRTOS_IP.h new API xApplicationGetRandomNumber().
- FreeRTOS_IP_Private.h new eIPEvent_t eNetworkTxEvent. 
- FreeRTOS_Stream_Buffer.h removing static xStreamBufferIsEmpty() and xStreamBufferIsFull().
- FreeRTOSConfigDefaults.h provides default ipconfigDNS_RECEIVE_BLOCK_TIME_TICKS. 
- other type changes.
This commit is contained in:
Yuhui.Zheng
2020-01-31 00:07:53 +00:00
parent 0c1c85a9dd
commit ec6f3d77c3
54 changed files with 5688 additions and 1701 deletions

View File

@ -1,5 +1,5 @@
/*
* FreeRTOS+TCP V2.0.11
* FreeRTOS+TCP V2.2.0
* Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
@ -385,7 +385,7 @@ Socket_t xReturn;
}
}
return ( SocketSet_t * ) pxSocketSet;
return ( SocketSet_t ) pxSocketSet;
}
#endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */
@ -702,9 +702,11 @@ EventBits_t xEventBits = ( EventBits_t ) 0;
}
taskEXIT_CRITICAL();
/* The returned value is the data length, which may have been capped to
the receive buffer size. */
lReturn = ( int32_t ) pxNetworkBuffer->xDataLength;
/* The returned value is the length of the payload data, which is
calculated at the total packet size minus the headers.
The validity of `xDataLength` prvProcessIPPacket has been confirmed
in 'prvProcessIPPacket()'. */
lReturn = ( int32_t ) ( pxNetworkBuffer->xDataLength - sizeof( UDPPacket_t ) );
if( pxSourceAddress != NULL )
{
@ -833,7 +835,8 @@ FreeRTOS_Socket_t *pxSocket;
if( pxNetworkBuffer != NULL )
{
pxNetworkBuffer->xDataLength = xTotalDataLength;
/* xDataLength is the size of the total packet, including the Ethernet header. */
pxNetworkBuffer->xDataLength = xTotalDataLength + sizeof( UDPPacket_t );
pxNetworkBuffer->usPort = pxDestinationAddress->sin_port;
pxNetworkBuffer->usBoundPort = ( uint16_t ) socketGET_SOCKET_PORT( pxSocket );
pxNetworkBuffer->ulIPAddress = pxDestinationAddress->sin_addr;
@ -854,7 +857,7 @@ FreeRTOS_Socket_t *pxSocket;
{
if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleSent ) )
{
pxSocket->u.xUDP.pxHandleSent( (Socket_t *)pxSocket, xTotalDataLength );
pxSocket->u.xUDP.pxHandleSent( ( Socket_t )pxSocket, xTotalDataLength );
}
}
#endif /* ipconfigUSE_CALLBACKS */
@ -1654,7 +1657,6 @@ const uint16_t usEphemeralPortCount =
uint16_t usIterations = usEphemeralPortCount;
uint32_t ulRandomSeed = 0;
uint16_t usResult = 0;
BaseType_t xGotZeroOnce = pdFALSE;
const List_t *pxList;
#if ipconfigUSE_TCP == 1
@ -1675,21 +1677,10 @@ const List_t *pxList;
point. */
do
{
/* Generate a random seed. */
ulRandomSeed = ipconfigRAND32( );
/* Only proceed if the random number generator succeeded. */
if( 0 == ulRandomSeed )
if( xApplicationGetRandomNumber( &( ulRandomSeed ) ) == pdFALSE )
{
if( pdFALSE == xGotZeroOnce )
{
xGotZeroOnce = pdTRUE;
continue;
}
else
{
break;
}
break;
}
/* Map the random to a candidate port. */
@ -2413,8 +2404,8 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
xResult = -pdFREERTOS_ERRNO_ENOMEM;
}
else if( pxSocket->u.xTCP.ucTCPState == eCLOSED ||
pxSocket->u.xTCP.ucTCPState == eCLOSE_WAIT ||
pxSocket->u.xTCP.ucTCPState == eCLOSING )
pxSocket->u.xTCP.ucTCPState == eCLOSE_WAIT ||
pxSocket->u.xTCP.ucTCPState == eCLOSING )
{
xResult = -pdFREERTOS_ERRNO_ENOTCONN;
}
@ -2453,25 +2444,25 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
'*pxLength' will contain the number of bytes that may be written. */
uint8_t *FreeRTOS_get_tx_head( Socket_t xSocket, BaseType_t *pxLength )
{
uint8_t *pucReturn = NULL;
uint8_t *pucReturn = NULL;
FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * ) xSocket;
StreamBuffer_t *pxBuffer = NULL;
*pxLength = 0;
*pxLength = 0;
/* Confirm that this is a TCP socket before dereferencing structure
member pointers. */
if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdFALSE ) == pdTRUE )
{
pxBuffer = pxSocket->u.xTCP.txStream;
if( pxBuffer != NULL )
{
BaseType_t xSpace = ( BaseType_t )uxStreamBufferGetSpace( pxBuffer );
BaseType_t xRemain = ( BaseType_t )( pxBuffer->LENGTH - pxBuffer->uxHead );
/* Confirm that this is a TCP socket before dereferencing structure
member pointers. */
if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdFALSE ) == pdTRUE )
{
pxBuffer = pxSocket->u.xTCP.txStream;
if( pxBuffer != NULL )
{
BaseType_t xSpace = ( BaseType_t )uxStreamBufferGetSpace( pxBuffer );
BaseType_t xRemain = ( BaseType_t )( pxBuffer->LENGTH - pxBuffer->uxHead );
*pxLength = FreeRTOS_min_BaseType( xSpace, xRemain );
pucReturn = pxBuffer->ucArray + pxBuffer->uxHead;
}
*pxLength = FreeRTOS_min_BaseType( xSpace, xRemain );
pucReturn = pxBuffer->ucArray + pxBuffer->uxHead;
}
}
return pucReturn;
@ -2904,20 +2895,20 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
#if( ipconfigUSE_TCP == 1 )
const struct xSTREAM_BUFFER *FreeRTOS_get_rx_buf( Socket_t xSocket )
{
FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * )xSocket;
struct xSTREAM_BUFFER *pxReturn = NULL;
const struct xSTREAM_BUFFER *FreeRTOS_get_rx_buf( Socket_t xSocket )
{
FreeRTOS_Socket_t *pxSocket = ( FreeRTOS_Socket_t * )xSocket;
struct xSTREAM_BUFFER *pxReturn = NULL;
/* Confirm that this is a TCP socket before dereferencing structure
member pointers. */
if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdFALSE ) == pdTRUE )
{
pxReturn = pxSocket->u.xTCP.rxStream;
}
/* Confirm that this is a TCP socket before dereferencing structure
member pointers. */
if( prvValidSocket( pxSocket, FREERTOS_IPPROTO_TCP, pdFALSE ) == pdTRUE )
{
pxReturn = pxSocket->u.xTCP.rxStream;
}
return pxReturn;
}
return pxReturn;
}
#endif /* ipconfigUSE_TCP */
/*-----------------------------------------------------------*/
@ -3081,7 +3072,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
break;
}
pxSocket->u.xTCP.pxHandleReceive( (Socket_t *)pxSocket, ( void* )ucReadPtr, ( size_t ) ulCount );
pxSocket->u.xTCP.pxHandleReceive( ( Socket_t )pxSocket, ( void* )ucReadPtr, ( size_t ) ulCount );
uxStreamBufferGet( pxStream, 0ul, NULL, ( size_t ) ulCount, pdFALSE );
}
} else