mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-23 21:27:45 -04:00
Sync FreeRTOS-Labs -CLI -TCP -Trace with the version in FreeRTOS-Plus.
Projects under FreeRTOS-Labs directory are in beta, developers updating projects please make sure you are using the correct version of -CLI -TCP -Trace. If you must edit -CLI -TCP and -Trace, please ensure the copies are synced.
This commit is contained in:
parent
ec6f3d77c3
commit
9fdfbf33e9
58 changed files with 4129 additions and 4415 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* FreeRTOS+TCP 191100 experimental
|
||||
* Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
* 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
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
|
|
@ -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 */
|
||||
|
|
@ -1421,7 +1424,7 @@ FreeRTOS_Socket_t *pxSocket;
|
|||
break;
|
||||
#endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */
|
||||
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK != 0 ) || ( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT != 0 )
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK != 0 )
|
||||
case FREERTOS_SO_WAKEUP_CALLBACK:
|
||||
{
|
||||
/* Each socket can have a callback function that is executed
|
||||
|
|
@ -1433,16 +1436,6 @@ FreeRTOS_Socket_t *pxSocket;
|
|||
break;
|
||||
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */
|
||||
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT != 0 )
|
||||
case FREERTOS_SO_WAKE_CALLBACK_CONTEXT:
|
||||
{
|
||||
/* Each socket wake callback may be passed a user context. */
|
||||
pxSocket->pvUserWakeCallbackContext = ( void * ) pvOptionValue;
|
||||
xReturn = 0;
|
||||
}
|
||||
break;
|
||||
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT */
|
||||
|
||||
case FREERTOS_SO_SET_LOW_HIGH_WATER:
|
||||
{
|
||||
LowHighWater_t *pxLowHighWater = ( LowHighWater_t * ) pvOptionValue;
|
||||
|
|
@ -1664,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
|
||||
|
|
@ -1685,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. */
|
||||
|
|
@ -1904,16 +1885,7 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t *pxSocket )
|
|||
pxSocket->pxUserWakeCallback( pxSocket );
|
||||
}
|
||||
}
|
||||
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */
|
||||
|
||||
#if( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT == 1 )
|
||||
{
|
||||
if( pxSocket->pxUserWakeCallback != NULL )
|
||||
{
|
||||
pxSocket->pxUserWakeCallback( pxSocket, pxSocket->pvUserWakeCallbackContext );
|
||||
}
|
||||
}
|
||||
#endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK_WITH_CONTEXT */
|
||||
#endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */
|
||||
|
||||
#if( ipconfigSUPPORT_SELECT_FUNCTION == 1 )
|
||||
{
|
||||
|
|
@ -2432,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;
|
||||
}
|
||||
|
|
@ -2472,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;
|
||||
|
|
@ -2923,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 */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
@ -3100,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue