[修改] 增加freeRTOS
1. 版本FreeRTOSv202212.01,命名为kernel;
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
#
|
||||
# FreeRTOS memory safety proofs with CBMC.
|
||||
# Copyright (C) 2022 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 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
|
||||
#
|
||||
|
||||
{
|
||||
"ENTRY": "TCPHandleState",
|
||||
"TX_DRIVER":1,
|
||||
"RX_MESSAGES":1,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset prvWinScaleFactor.0:2",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP_Utils.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP_Timers.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"ipconfigZERO_COPY_TX_DRIVER={TX_DRIVER}",
|
||||
"ipconfigUSE_LINKED_RX_MESSAGES={RX_MESSAGES}",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION"
|
||||
],
|
||||
"INSTFLAGS":
|
||||
[
|
||||
"--remove-function-body prvTCPPrepareSend",
|
||||
"--remove-function-body prvTCPReturnPacket"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
This is the memory safety proof for prvTCPHandleState.
|
||||
|
||||
This proof is a work-in-progress. Proof assumptions are described in
|
||||
the harness. The proof also assumes the following functions are
|
||||
memory safe and have no side effects relevant to the memory safety of
|
||||
this function:
|
||||
|
||||
* prvTCPPrepareSend (proved independently)
|
||||
* prvTCPReturnPacket (proved independently)
|
||||
|
||||
* lTCPAddRxdata
|
||||
* lTCPWindowRxCheck
|
||||
* lTCPWindowTxAdd
|
||||
* ulTCPWindowTxAck
|
||||
* vTCPWindowInit
|
||||
* xTCPWindowRxEmpty
|
||||
* xTCPWindowTxDone
|
||||
|
||||
* uxStreamBufferGet
|
||||
* vReleaseNetworkBufferAndDescriptor
|
||||
* vSocketWakeUpUser
|
||||
* xTaskGetTickCount
|
||||
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* FreeRTOS memory safety proofs with CBMC.
|
||||
* Copyright (C) 2022 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 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
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
#include "FreeRTOS_TCP_IP.h"
|
||||
|
||||
#include "../../utility/memory_assignments.c"
|
||||
|
||||
/* Abstraction of xTaskGetCurrentTaskHandle */
|
||||
TaskHandle_t xTaskGetCurrentTaskHandle( void )
|
||||
{
|
||||
static int xIsInit = 0;
|
||||
static TaskHandle_t pxCurrentTCB;
|
||||
TaskHandle_t xRandomTaskHandle; /* not initialized on purpose */
|
||||
|
||||
if( xIsInit == 0 )
|
||||
{
|
||||
pxCurrentTCB = xRandomTaskHandle;
|
||||
xIsInit = 1;
|
||||
}
|
||||
|
||||
return pxCurrentTCB;
|
||||
}
|
||||
|
||||
/* This proof assumes that prvTCPPrepareSend and prvTCPReturnPacket are correct.
|
||||
* These functions are proved to be correct separately. */
|
||||
|
||||
BaseType_t publicTCPHandleState( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t ** ppxNetworkBuffer );
|
||||
|
||||
void harness()
|
||||
{
|
||||
FreeRTOS_Socket_t * pxSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
size_t socketSize = sizeof( FreeRTOS_Socket_t );
|
||||
|
||||
if( ensure_memory_is_valid( pxSocket, socketSize ) )
|
||||
{
|
||||
/* ucOptionLength is the number of valid bytes in ulOptionsData[].
|
||||
* ulOptionsData[] is initialized as uint32_t ulOptionsData[ipSIZE_TCP_OPTIONS/sizeof(uint32_t)].
|
||||
* This assumption is required for a memcpy function that copies uxOptionsLength
|
||||
* data from pxTCPHeader->ucOptdata to pxTCPWindow->ulOptionsData.*/
|
||||
__CPROVER_assume( pxSocket->u.xTCP.xTCPWindow.ucOptionLength == sizeof( uint32_t ) * ipSIZE_TCP_OPTIONS / sizeof( uint32_t ) );
|
||||
/* uxRxWinSize is initialized as size_t. This assumption is required to terminate `while(uxWinSize > 0xfffful)` loop.*/
|
||||
__CPROVER_assume( pxSocket->u.xTCP.uxRxWinSize >= 0 && pxSocket->u.xTCP.uxRxWinSize <= sizeof( size_t ) );
|
||||
/* uxRxWinSize is initialized as uint16_t. This assumption is required to terminate `while(uxWinSize > 0xfffful)` loop.*/
|
||||
__CPROVER_assume( pxSocket->u.xTCP.usMSS == sizeof( uint16_t ) );
|
||||
|
||||
if( xIsCallingFromIPTask() == pdFALSE )
|
||||
{
|
||||
__CPROVER_assume( pxSocket->u.xTCP.bits.bPassQueued == pdFALSE_UNSIGNED );
|
||||
__CPROVER_assume( pxSocket->u.xTCP.bits.bPassAccept == pdFALSE_UNSIGNED );
|
||||
}
|
||||
}
|
||||
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();
|
||||
size_t bufferSize = sizeof( NetworkBufferDescriptor_t );
|
||||
|
||||
if( ensure_memory_is_valid( pxNetworkBuffer, bufferSize ) )
|
||||
{
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( sizeof( TCPPacket_t ) );
|
||||
}
|
||||
|
||||
if( ensure_memory_is_valid( pxSocket, socketSize ) &&
|
||||
ensure_memory_is_valid( pxNetworkBuffer, bufferSize ) &&
|
||||
ensure_memory_is_valid( pxNetworkBuffer->pucEthernetBuffer, sizeof( TCPPacket_t ) ) &&
|
||||
ensure_memory_is_valid( pxSocket->u.xTCP.pxPeerSocket, socketSize ) )
|
||||
{
|
||||
publicTCPHandleState( pxSocket, &pxNetworkBuffer );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
#
|
||||
# FreeRTOS memory safety proofs with CBMC.
|
||||
# Copyright (C) 2022 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 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
|
||||
#
|
||||
|
||||
{
|
||||
"ENTRY": "TCPPrepareSend",
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
This is the memory safety proof for prvTCPPrepareSend.
|
||||
|
||||
This proof is a work-in-progress. Proof assumptions are described in
|
||||
the harness. The proof also assumes the following functions are
|
||||
memory safe and have no side effects relevant to the memory safety of
|
||||
this function:
|
||||
|
||||
* ulTCPWindowTxGet
|
||||
* xTCPWindowTxDone
|
||||
|
||||
* xTaskGetTickCount
|
||||
|
||||
* uxStreamBufferGet
|
||||
* vReleaseNetworkBufferAndDescriptor
|
||||
* vSocketWakeUpUser
|
||||
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* FreeRTOS memory safety proofs with CBMC.
|
||||
* Copyright (C) 2022 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 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
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
#include "FreeRTOS_TCP_IP.h"
|
||||
#include "FreeRTOS_Stream_Buffer.h"
|
||||
|
||||
#include "../../utility/memory_assignments.c"
|
||||
|
||||
/* This proof assumes that pxGetNetworkBufferWithDescriptor is implemented correctly. */
|
||||
int32_t publicTCPPrepareSend( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t ** ppxNetworkBuffer,
|
||||
UBaseType_t uxOptionsLength );
|
||||
|
||||
/* Abstraction of pxGetNetworkBufferWithDescriptor. It creates a buffer. */
|
||||
NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes,
|
||||
TickType_t xBlockTimeTicks )
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();
|
||||
size_t bufferSize = sizeof( NetworkBufferDescriptor_t );
|
||||
|
||||
if( ensure_memory_is_valid( pxBuffer, bufferSize ) )
|
||||
{
|
||||
/* The code does not expect pucEthernetBuffer to be equal to NULL if
|
||||
* pxBuffer is not NULL. */
|
||||
pxBuffer->pucEthernetBuffer = malloc( xRequestedSizeBytes );
|
||||
__CPROVER_assume( pxBuffer->pucEthernetBuffer != NULL );
|
||||
pxBuffer->xDataLength = xRequestedSizeBytes;
|
||||
}
|
||||
|
||||
return pxBuffer;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
FreeRTOS_Socket_t * pxSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();
|
||||
size_t socketSize = sizeof( FreeRTOS_Socket_t );
|
||||
size_t bufferSize = sizeof( TCPPacket_t );
|
||||
|
||||
if( ensure_memory_is_valid( pxNetworkBuffer, sizeof( *pxNetworkBuffer ) ) )
|
||||
{
|
||||
pxNetworkBuffer->xDataLength = bufferSize;
|
||||
|
||||
/* The code does not expect pucEthernetBuffer to be equal to NULL if
|
||||
* pxNetworkBuffer is not NULL. */
|
||||
pxNetworkBuffer->pucEthernetBuffer = malloc( bufferSize );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
}
|
||||
|
||||
UBaseType_t uxOptionsLength;
|
||||
|
||||
if( pxSocket )
|
||||
{
|
||||
publicTCPPrepareSend( pxSocket, &pxNetworkBuffer, uxOptionsLength );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
#
|
||||
# FreeRTOS memory safety proofs with CBMC.
|
||||
# Copyright (C) 2022 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 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
|
||||
#
|
||||
|
||||
{
|
||||
"ENTRY": "TCPReturnPacket",
|
||||
"RX_MESSAGES":1,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_Stream_Buffer.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"ipconfigUSE_LINKED_RX_MESSAGES={RX_MESSAGES}",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
This is the memory safety proof for prvTCPReturnPacket.
|
||||
|
||||
This proof is a work-in-progress. Proof assumptions are described in
|
||||
the harness. The proof also assumes the following functions are
|
||||
memory safe and have no side effects relevant to the memory safety of
|
||||
this function:
|
||||
|
||||
* usGenerateChecksum
|
||||
* usGenerateProtocolChecksum
|
||||
* xNetworkInterfaceOutput
|
||||
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* FreeRTOS memory safety proofs with CBMC.
|
||||
* Copyright (C) 2022 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 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
|
||||
*/
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
#include "FreeRTOS_TCP_IP.h"
|
||||
|
||||
#include "../../utility/memory_assignments.c"
|
||||
|
||||
#include "cbmc.h"
|
||||
|
||||
/* This proof assumes that pxDuplicateNetworkBufferWithDescriptor is implemented correctly. */
|
||||
void publicTCPReturnPacket( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer,
|
||||
uint32_t ulLen,
|
||||
BaseType_t xReleaseAfterSend );
|
||||
|
||||
/* Abstraction of pxDuplicateNetworkBufferWithDescriptor*/
|
||||
NetworkBufferDescriptor_t * pxDuplicateNetworkBufferWithDescriptor( const NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
size_t xNewLength )
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();
|
||||
|
||||
if( ensure_memory_is_valid( pxNetworkBuffer, sizeof( *pxNetworkBuffer ) ) )
|
||||
{
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( sizeof( TCPPacket_t ) );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer );
|
||||
}
|
||||
|
||||
return pxNetworkBuffer;
|
||||
}
|
||||
|
||||
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * pxDescriptor,
|
||||
BaseType_t xReleaseAfterSend )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assert( pxDescriptor != NULL, "The descriptor cannot be NULL" );
|
||||
__CPROVER_assert( pxDescriptor->pucEthernetBuffer != NULL, "The ethernet buffer cannot be NULL" );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer,
|
||||
size_t uxBufferLength,
|
||||
BaseType_t xOutgoingPacket )
|
||||
{
|
||||
__CPROVER_assert( pucEthernetBuffer != NULL, "The ethernet buffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pucEthernetBuffer, uxBufferLength ), "pucEthernetBuffer should be readable." );
|
||||
|
||||
uint16_t usReturn;
|
||||
return usReturn;
|
||||
}
|
||||
|
||||
uint16_t usGenerateChecksum( uint16_t usSum,
|
||||
const uint8_t * pucNextData,
|
||||
size_t uxByteCount )
|
||||
{
|
||||
__CPROVER_assert( pucNextData != NULL, "The next data pointer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pucNextData, uxByteCount ), "The pucNextData should be readable." );
|
||||
|
||||
uint16_t usReturn;
|
||||
return usReturn;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
FreeRTOS_Socket_t * pxSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = ensure_FreeRTOS_NetworkBuffer_is_allocated();
|
||||
|
||||
/* The code does not expect both of these to be equal to NULL at the same time. */
|
||||
__CPROVER_assume( pxSocket != NULL || pxNetworkBuffer != NULL );
|
||||
|
||||
uint32_t ulLen;
|
||||
|
||||
/* If network buffer is properly created. */
|
||||
if( ensure_memory_is_valid( pxNetworkBuffer, sizeof( *pxNetworkBuffer ) ) )
|
||||
{
|
||||
/* Assume that the length is proper. */
|
||||
__CPROVER_assume( ( ulLen >= sizeof( TCPPacket_t ) ) && ( ulLen < ipconfigNETWORK_MTU ) );
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( ulLen + ipSIZE_OF_ETH_HEADER );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer );
|
||||
}
|
||||
/* If not. */
|
||||
else
|
||||
{
|
||||
/* Assume that the length is proper. The length should be between this range. It
|
||||
* is made so by the functions up the call tree. Essentially, this is equal to a
|
||||
* TCP packet header with and without TCP options. */
|
||||
__CPROVER_assume( ( ulLen >= ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER ) &&
|
||||
( ulLen <= ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + 40 /* Maximum option bytes. */ ) );
|
||||
}
|
||||
|
||||
BaseType_t xReleaseAfterSend;
|
||||
|
||||
publicTCPReturnPacket( pxSocket, pxNetworkBuffer, ulLen, xReleaseAfterSend );
|
||||
}
|
||||
Reference in New Issue
Block a user