add initial Setup
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
bdb5db2009
1955 files changed
+1004711
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"ENTRY": "ProcessIPPacket",
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset memcmp.0:7",
|
||||
"--unwindset FreeRTOS_AllEndPointsUp.0:2",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OPT":
|
||||
[
|
||||
"--export-file-local-symbols"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IPv4.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
{
|
||||
"ChecksumIncluded":
|
||||
[
|
||||
"ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM=1",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION",
|
||||
"ipconfigNETWORK_MTU=586"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ChecksumNotIncluded":
|
||||
[
|
||||
"ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM=0",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION",
|
||||
"ipconfigNETWORK_MTU=586"
|
||||
]
|
||||
}
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
+196
@@ -0,0 +1,196 @@
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
|
||||
NetworkEndPoint_t xEndpoint;
|
||||
|
||||
eFrameProcessingResult_t __CPROVER_file_local_FreeRTOS_IP_c_prvProcessIPPacket( const IPPacket_t * pxIPPacket,
|
||||
NetworkBufferDescriptor_t * const pxNetworkBuffer );
|
||||
|
||||
/* Check if input is a valid extension header ID. */
|
||||
BaseType_t xIsExtensionHeader( uint8_t ucCurrentHeader )
|
||||
{
|
||||
BaseType_t xReturn = pdFALSE;
|
||||
|
||||
switch( ucCurrentHeader )
|
||||
{
|
||||
case ipIPv6_EXT_HEADER_HOP_BY_HOP:
|
||||
case ipIPv6_EXT_HEADER_DESTINATION_OPTIONS:
|
||||
case ipIPv6_EXT_HEADER_ROUTING_HEADER:
|
||||
case ipIPv6_EXT_HEADER_FRAGMENT_HEADER:
|
||||
case ipIPv6_EXT_HEADER_AUTHEN_HEADER:
|
||||
case ipIPv6_EXT_HEADER_SECURE_PAYLOAD:
|
||||
case ipIPv6_EXT_HEADER_MOBILITY_HEADER:
|
||||
xReturn = pdTRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* Abstraction of xGetExtensionOrder. To ensure the result of prepared extension headers is same. */
|
||||
BaseType_t xGetExtensionOrder( uint8_t ucProtocol,
|
||||
uint8_t ucNextHeader )
|
||||
{
|
||||
return xIsExtensionHeader( ucProtocol );
|
||||
}
|
||||
|
||||
BaseType_t xCheckRequiresResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress,
|
||||
const uint32_t ulIPAddress )
|
||||
{
|
||||
__CPROVER_assert( pxMACAddress != NULL, "pxMACAddress cannot be NULL" );
|
||||
}
|
||||
|
||||
void vNDRefreshCacheEntry( const MACAddress_t * pxMACAddress,
|
||||
const IPv6_Address_t * pxIPAddress,
|
||||
NetworkEndPoint_t * pxEndPoint )
|
||||
{
|
||||
__CPROVER_assert( pxMACAddress != NULL, "pxMACAddress cannot be NULL" );
|
||||
__CPROVER_assert( pxIPAddress != NULL, "pxIPAddress cannot be NULL" );
|
||||
__CPROVER_assert( pxEndPoint != NULL, "pxEndPoint cannot be NULL" );
|
||||
}
|
||||
|
||||
NetworkEndPoint_t * FreeRTOS_FindEndPointOnIP_IPv4( uint32_t ulIPAddress )
|
||||
{
|
||||
NetworkEndPoint_t * pxEndpoint = NULL;
|
||||
|
||||
if( nondet_bool() )
|
||||
{
|
||||
pxEndpoint = pxNetworkEndPoints;
|
||||
}
|
||||
|
||||
return pxEndpoint;
|
||||
}
|
||||
|
||||
/* proof is done separately */
|
||||
eFrameProcessingResult_t ProcessICMPPacket( const NetworkBufferDescriptor_t * const pxNetworkBuffer )
|
||||
{
|
||||
eFrameProcessingResult_t xReturn;
|
||||
|
||||
__CPROVER_assert( pxNetworkBuffer != NULL, "pxEndPoint cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* proof is done separately */
|
||||
eFrameProcessingResult_t prvProcessICMPMessage_IPv6( NetworkBufferDescriptor_t * const pxNetworkBuffer )
|
||||
{
|
||||
eFrameProcessingResult_t xReturn;
|
||||
|
||||
__CPROVER_assert( pxNetworkBuffer != NULL, "pxEndPoint cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* proof is done separately */
|
||||
BaseType_t xProcessReceivedTCPPacket( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
}
|
||||
|
||||
/* proof is done separately */
|
||||
BaseType_t xProcessReceivedUDPPacket( NetworkBufferDescriptor_t * pxNetworkBuffer,
|
||||
uint16_t usPort )
|
||||
{
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress,
|
||||
const uint32_t ulIPAddress )
|
||||
{
|
||||
}
|
||||
|
||||
eFrameProcessingResult_t publicProcessIPPacket( IPPacket_t * const pxIPPacket,
|
||||
NetworkBufferDescriptor_t * const pxNetworkBuffer );
|
||||
|
||||
#if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 )
|
||||
|
||||
/* The checksum generation is stubbed out since the actual checksum
|
||||
* does not matter. The stub will return an indeterminate value each time. */
|
||||
uint16_t usGenerateChecksum( uint16_t usSum,
|
||||
const uint8_t * pucNextData,
|
||||
size_t uxByteCount )
|
||||
{
|
||||
uint16_t usReturn;
|
||||
|
||||
__CPROVER_assert( pucNextData != NULL, "Next data cannot be NULL" );
|
||||
|
||||
/* Return an indeterminate value. */
|
||||
return usReturn;
|
||||
}
|
||||
|
||||
/* The checksum generation is stubbed out since the actual checksum
|
||||
* does not matter. The stub will return an indeterminate value each time. */
|
||||
uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer,
|
||||
size_t uxBufferLength,
|
||||
BaseType_t xOutgoingPacket )
|
||||
{
|
||||
uint16_t usReturn;
|
||||
|
||||
__CPROVER_assert( pucEthernetBuffer != NULL, "Ethernet buffer cannot be NULL" );
|
||||
|
||||
/* Return an indeterminate value. */
|
||||
return usReturn;
|
||||
}
|
||||
#endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * const pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
uint8_t * pucEthernetBuffer = ( uint8_t * ) safeMalloc( ipTOTAL_ETHERNET_FRAME_SIZE + ipIP_TYPE_OFFSET );
|
||||
EthernetHeader_t * pxHeader;
|
||||
NetworkEndPoint_t xEndPoint;
|
||||
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
__CPROVER_assume( pucEthernetBuffer != NULL );
|
||||
|
||||
/* Points to ethernet buffer offset by ipIP_TYPE_OFFSET, this make sure the buffer allocation is similar
|
||||
* to the pxGetNetworkBufferWithDescriptor */
|
||||
pxNetworkBuffer->pucEthernetBuffer = &( pucEthernetBuffer[ ipIP_TYPE_OFFSET ] );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
/* prvProcessIPPacket is guranteed to receive a network buffer that has a valid
|
||||
* endpoint, hence no NULL checks are needed to be performed inside prvProcessIPPacket.
|
||||
* See the check:
|
||||
*
|
||||
* if( ( pxNetworkBuffer->pxInterface == NULL ) || ( pxNetworkBuffer->pxEndPoint == NULL ) )
|
||||
* {
|
||||
* break;
|
||||
* }
|
||||
*
|
||||
* inside the prvProcessEthernetPacket before which prvProcessIPPacket is called.
|
||||
*/
|
||||
pxNetworkBuffer->pxEndPoint = &xEndPoint;
|
||||
|
||||
/* Minimum length of the pxNetworkBuffer->xDataLength is at least the size of the IPPacket_t. */
|
||||
__CPROVER_assume( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_t ) && pxNetworkBuffer->xDataLength <= ipTOTAL_ETHERNET_FRAME_SIZE );
|
||||
|
||||
pxNetworkEndPoints = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
|
||||
__CPROVER_assume( pxNetworkEndPoints != NULL );
|
||||
__CPROVER_assume( pxNetworkEndPoints->pxNext == NULL );
|
||||
|
||||
/* In this test case, we only focus on IPv4. */
|
||||
pxHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||
__CPROVER_assume( pxHeader->usFrameType != ipIPv6_FRAME_TYPE );
|
||||
|
||||
IPPacket_t * const pxIPPacket = ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||
__CPROVER_file_local_FreeRTOS_IP_c_prvProcessIPPacket( pxIPPacket, pxNetworkBuffer );
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"ENTRY": "eHandleIPv6ExtensionHeaders",
|
||||
"MAX_EXT_HEADER_NUM": 21,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset usGetExtensionHeaderLength.0:{MAX_EXT_HEADER_NUM}",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OPT":
|
||||
[
|
||||
"--export-file-local-symbols"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IPv6.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IPv6_Utils.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"ipconfigNETWORK_MTU=200",
|
||||
"ipconfigTCP_MSS=586",
|
||||
"ipconfigUSE_DHCP=0"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IPv6.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
|
||||
/* In this test case, we configure ipconfigNETWORK_MTU to fasten the execution. */
|
||||
|
||||
void harness()
|
||||
{
|
||||
BaseType_t xDoRemove;
|
||||
NetworkBufferDescriptor_t * const pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
uint8_t * pucEthernetBuffer = ( uint8_t * ) safeMalloc( ipTOTAL_ETHERNET_FRAME_SIZE + ipIP_TYPE_OFFSET );
|
||||
|
||||
/* xDoRemove must be pdTRUE or pdFALSE. */
|
||||
__CPROVER_assume( xDoRemove == pdTRUE || xDoRemove == pdFALSE );
|
||||
|
||||
/* Network buffer must be valid, it's checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
/* Ethernet buffer in network buffer must be valid, the data length is checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pucEthernetBuffer != NULL );
|
||||
|
||||
/* Points to ethernet buffer offset by ipIP_TYPE_OFFSET, this make sure the buffer allocation is similar
|
||||
* to the pxGetNetworkBufferWithDescriptor */
|
||||
pxNetworkBuffer->pucEthernetBuffer = &( pucEthernetBuffer[ ipIP_TYPE_OFFSET ] );
|
||||
|
||||
/* Minimum length of the pxNetworkBuffer->xDataLength is at least the size of the IPPacket_IPv6_t. */
|
||||
__CPROVER_assume( ( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_IPv6_t ) ) &&
|
||||
( pxNetworkBuffer->xDataLength <= ipTOTAL_ETHERNET_FRAME_SIZE ) );
|
||||
|
||||
IPPacket_IPv6_t * pxIPv6Packet = ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||
/* Next protocol must be extension header. Checked in prvProcessIPPacket. */
|
||||
__CPROVER_assume( pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_HOP_BY_HOP ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_DESTINATION_OPTIONS ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_ROUTING_HEADER ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_FRAGMENT_HEADER ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_AUTHEN_HEADER ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_SECURE_PAYLOAD ||
|
||||
pxIPv6Packet->xIPHeader.ucNextHeader == ipIPv6_EXT_HEADER_MOBILITY_HEADER );
|
||||
|
||||
eHandleIPv6ExtensionHeaders( pxNetworkBuffer, xDoRemove );
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"ENTRY": "prvAllowIPPacketIPv6",
|
||||
"MAX_EXT_HEADER_PARSING_LOOP": 21,
|
||||
"IPV6_ADDRESS_LOOP": 17,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset memcmp.0:{IPV6_ADDRESS_LOOP}",
|
||||
"--unwindset memcmp.1:{IPV6_ADDRESS_LOOP}",
|
||||
"--unwindset __CPROVER_file_local_FreeRTOS_IPv6_c_xCheckIPv6SizeFields.0:{MAX_EXT_HEADER_PARSING_LOOP}",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OPT":
|
||||
[
|
||||
"--export-file-local-symbols"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IPv6.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
{
|
||||
"ChecksumIncluded":
|
||||
[
|
||||
"ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM=1",
|
||||
"ipconfigETHERNET_DRIVER_FILTERS_PACKE,TS=1",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION=1",
|
||||
"ipconfigNETWORK_MTU=200",
|
||||
"ipconfigTCP_MSS=586",
|
||||
"ipconfigUSE_DHCP=0"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ChecksumNotIncluded":
|
||||
[
|
||||
"ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM=0",
|
||||
"ipconfigETHERNET_DRIVER_FILTERS_PACKETS=0",
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION=1",
|
||||
"ipconfigNETWORK_MTU=200",
|
||||
"ipconfigTCP_MSS=586",
|
||||
"ipconfigUSE_DHCP=0"
|
||||
]
|
||||
}
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IPv6.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
|
||||
eFrameProcessingResult_t prvAllowIPPacketIPv6( const IPHeader_IPv6_t * const pxIPv6Header,
|
||||
const NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
||||
UBaseType_t uxHeaderLength );
|
||||
|
||||
/* Create an endpoint and return, real endpoint doesn't matter in this test. */
|
||||
NetworkEndPoint_t * FreeRTOS_FindEndPointOnIP_IPv6( const IPv6_Address_t * pxIPAddress )
|
||||
{
|
||||
NetworkEndPoint_t * pxReturn = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
|
||||
|
||||
__CPROVER_assert( pxIPAddress != NULL, "pxIPAddress shouldn't be NULL" );
|
||||
|
||||
return pxReturn;
|
||||
}
|
||||
|
||||
/* Return either pdTRUE or pdFALSE in FreeRTOS_IsNetworkUp. */
|
||||
BaseType_t FreeRTOS_IsNetworkUp( void )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* Create an endpoint and return, real endpoint doesn't matter in this test. */
|
||||
NetworkEndPoint_t * FreeRTOS_FindEndPointOnMAC( const MACAddress_t * pxMACAddress,
|
||||
const NetworkInterface_t * pxInterface )
|
||||
{
|
||||
NetworkEndPoint_t * pxReturn = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
|
||||
|
||||
__CPROVER_assert( pxMACAddress != NULL, "MAC address shouldn't be NULL" );
|
||||
|
||||
return pxReturn;
|
||||
}
|
||||
|
||||
/* The checksum generation is stubbed out since the actual checksum
|
||||
* does not matter. The stub will return an indeterminate value each time. */
|
||||
uint16_t usGenerateProtocolChecksum( const uint8_t * const pucEthernetBuffer,
|
||||
size_t uxBufferLength,
|
||||
BaseType_t xOutgoingPacket )
|
||||
{
|
||||
uint16_t usReturn;
|
||||
|
||||
__CPROVER_assert( pucEthernetBuffer != NULL, "Ethernet buffer cannot be NULL" );
|
||||
|
||||
/* Return an indeterminate value. */
|
||||
return usReturn;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * const pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
uint8_t * pucEthernetBuffer = ( uint8_t * ) safeMalloc( ipTOTAL_ETHERNET_FRAME_SIZE + ipIP_TYPE_OFFSET );
|
||||
|
||||
/* Network buffer must be valid, it's checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
/* Ethernet buffer in network buffer must be valid, the data length is checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pucEthernetBuffer != NULL );
|
||||
|
||||
/* Points to ethernet buffer offset by ipIP_TYPE_OFFSET, this make sure the buffer allocation is similar
|
||||
* to the pxGetNetworkBufferWithDescriptor */
|
||||
pxNetworkBuffer->pucEthernetBuffer = &( pucEthernetBuffer[ ipIP_TYPE_OFFSET ] );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
/* Minimum length of the pxNetworkBuffer->xDataLength is at least the size of the IPPacket_IPv6_t. */
|
||||
__CPROVER_assume( ( pxNetworkBuffer->xDataLength >= sizeof( IPPacket_IPv6_t ) ) &&
|
||||
( pxNetworkBuffer->xDataLength <= ipTOTAL_ETHERNET_FRAME_SIZE ) );
|
||||
|
||||
pxNetworkEndPoints = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
|
||||
__CPROVER_assume( pxNetworkEndPoints != NULL );
|
||||
|
||||
if( nondet_bool() )
|
||||
{
|
||||
pxNetworkEndPoints->pxNext = ( NetworkEndPoint_t * ) safeMalloc( sizeof( NetworkEndPoint_t ) );
|
||||
__CPROVER_assume( pxNetworkEndPoints->pxNext != NULL );
|
||||
pxNetworkEndPoints->pxNext->pxNext = NULL;
|
||||
pxNetworkEndPoints->pxNext->pxNetworkInterface = pxNetworkEndPoints->pxNetworkInterface;
|
||||
}
|
||||
else
|
||||
{
|
||||
pxNetworkEndPoints->pxNext = NULL;
|
||||
}
|
||||
|
||||
pxNetworkBuffer->pxEndPoint = pxNetworkEndPoints;
|
||||
|
||||
IPPacket_IPv6_t * const pxIPPacket = ( IPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||
|
||||
prvAllowIPPacketIPv6( &pxIPPacket->xIPHeader, pxNetworkBuffer, ipSIZE_OF_IPv6_HEADER );
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"ENTRY": "ProcessReceivedTCPPacket",
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset prvTCPSendRepeated.0:13",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_kernel_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP_Utils.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP_Timers.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP_IPv4.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_Transmission.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_Transmission_IPv4.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_State_Handling.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_Utils.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_Reception.goto"
|
||||
],
|
||||
"INSTFLAGS":
|
||||
[
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION",
|
||||
"CBMC_GETNETWORKBUFFER_FAILURE_BOUND"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
/* 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"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
#include "../../utility/memory_assignments.c"
|
||||
|
||||
/* This proof assumes pxTCPSocketLookup and pxGetNetworkBufferWithDescriptor
|
||||
* are implemented correctly.
|
||||
*
|
||||
* It also assumes prvSingleStepTCPHeaderOptions, prvCheckOptions, prvTCPPrepareSend,
|
||||
* prvTCPHandleState, prvHandleListen_IPV4 and prvTCPReturnPacket are correct. These functions are
|
||||
* proved to be correct separately. */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Abstraction of vTCPStateChange */
|
||||
void vTCPStateChange( FreeRTOS_Socket_t * pxSocket,
|
||||
enum eTCP_STATE eTCPState )
|
||||
{
|
||||
}
|
||||
|
||||
/* prvTCPReturnPacket is proven separately */
|
||||
void prvTCPReturnPacket( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t * pxDescriptor,
|
||||
uint32_t ulLen,
|
||||
BaseType_t xReleaseAfterSend )
|
||||
{
|
||||
__CPROVER_assert( pxSocket != NULL || pxDescriptor != NULL, "Either pxSocket or pxDescriptor must be non-NULL" );
|
||||
__CPROVER_assert( pxDescriptor->pucEthernetBuffer != NULL, "pucEthernetBuffer should not be NULL" );
|
||||
}
|
||||
|
||||
/* prvTCPPrepareSend is proven separately. */
|
||||
int32_t prvTCPPrepareSend( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t ** ppxNetworkBuffer,
|
||||
UBaseType_t uxOptionsLength )
|
||||
{
|
||||
int32_t ret = nondet_int32();
|
||||
|
||||
__CPROVER_assert( pxSocket != NULL, "pxSocket cannot be NULL" );
|
||||
__CPROVER_assert( *ppxNetworkBuffer != NULL, "*ppxNetworkBuffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( ( *ppxNetworkBuffer )->pucEthernetBuffer, ( *ppxNetworkBuffer )->xDataLength ), "Data in *ppxNetworkBuffer must be readable" );
|
||||
|
||||
__CPROVER_assume( ret >= 0 && ret <= ipconfigNETWORK_MTU );
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* prvTCPHandleState is proven separately. */
|
||||
BaseType_t prvTCPHandleState( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t ** ppxNetworkBuffer )
|
||||
{
|
||||
__CPROVER_assert( pxSocket != NULL, "pxSocket cannot be NULL" );
|
||||
__CPROVER_assert( *ppxNetworkBuffer != NULL, "*ppxNetworkBuffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( ( *ppxNetworkBuffer )->pucEthernetBuffer, ( *ppxNetworkBuffer )->xDataLength ), "Data in *ppxNetworkBuffer must be readable" );
|
||||
|
||||
return nondet_basetype();
|
||||
}
|
||||
|
||||
/* prvCheckOptions is proven separately. */
|
||||
BaseType_t prvCheckOptions( FreeRTOS_Socket_t * pxSocket,
|
||||
const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
__CPROVER_assert( pxSocket != NULL, "pxSocket cannot be NULL" );
|
||||
__CPROVER_assert( pxNetworkBuffer != NULL, "*ppxNetworkBuffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in *ppxNetworkBuffer must be readable" );
|
||||
|
||||
return nondet_basetype();
|
||||
}
|
||||
|
||||
BaseType_t xTCPWindowTxHasData( TCPWindow_t const * pxWindow,
|
||||
uint32_t ulWindowSize,
|
||||
TickType_t * pulDelay )
|
||||
{
|
||||
__CPROVER_assert( pxWindow != NULL, "pxWindow cannot be NULL" );
|
||||
__CPROVER_assert( pulDelay != NULL, "pulDelay cannot be NULL" );
|
||||
|
||||
return nondet_basetype();
|
||||
}
|
||||
|
||||
/* Abstraction of xSequenceLessThan */
|
||||
BaseType_t xSequenceLessThan( uint32_t a,
|
||||
uint32_t b )
|
||||
{
|
||||
return nondet_basetype();
|
||||
}
|
||||
|
||||
/* Abstraction of xSequenceGreaterThan */
|
||||
BaseType_t xSequenceGreaterThan( uint32_t a,
|
||||
uint32_t b )
|
||||
{
|
||||
return nondet_basetype();
|
||||
}
|
||||
|
||||
/* Abstraction of prvHandleListen_IPV4 */
|
||||
FreeRTOS_Socket_t * prvHandleListen_IPV4( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
FreeRTOS_Socket_t * xRetSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
|
||||
if( xRetSocket )
|
||||
{
|
||||
/* This test case is for IPv4. */
|
||||
__CPROVER_assume( xRetSocket->bits.bIsIPv6 == pdFALSE );
|
||||
}
|
||||
|
||||
return xRetSocket;
|
||||
}
|
||||
|
||||
/* Abstraction of pxTCPSocketLookup */
|
||||
FreeRTOS_Socket_t * pxTCPSocketLookup( uint32_t ulLocalIP,
|
||||
UBaseType_t uxLocalPort,
|
||||
IPv46_Address_t xRemoteIP,
|
||||
UBaseType_t uxRemotePort )
|
||||
{
|
||||
FreeRTOS_Socket_t * xRetSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
|
||||
if( xRetSocket )
|
||||
{
|
||||
/* This test case is for IPv4. */
|
||||
__CPROVER_assume( xRetSocket->bits.bIsIPv6 == pdFALSE );
|
||||
__CPROVER_assume( xRetSocket->u.xTCP.ucPeerWinScaleFactor <= tcpTCP_OPT_WSOPT_MAXIMUM_VALUE );
|
||||
}
|
||||
|
||||
return xRetSocket;
|
||||
}
|
||||
|
||||
/* Abstraction of pxGetNetworkBufferWithDescriptor */
|
||||
NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes,
|
||||
TickType_t xBlockTimeTicks )
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
|
||||
if( pxNetworkBuffer )
|
||||
{
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( xRequestedSizeBytes );
|
||||
pxNetworkBuffer->xDataLength = xRequestedSizeBytes;
|
||||
}
|
||||
|
||||
return pxNetworkBuffer;
|
||||
}
|
||||
|
||||
/* Abstraction of uxIPHeaderSizePacket. Because we're testing IPv4 in this test case, the network buffer is
|
||||
* guaranteed to be IPv4 packet. Thus returns IPv4 header size here directly. */
|
||||
size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
return ipSIZE_OF_IPv4_HEADER;
|
||||
}
|
||||
|
||||
/* Abstraction of uxIPHeaderSizePacket. Because we're testing IPv4 in this test case, all socket handlers returned
|
||||
* by functions are for IPv4. Thus returns IPv4 header size here directly. */
|
||||
size_t uxIPHeaderSizeSocket( const FreeRTOS_Socket_t * pxSocket )
|
||||
{
|
||||
return ipSIZE_OF_IPv4_HEADER;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer;
|
||||
size_t tcpPacketSize;
|
||||
|
||||
__CPROVER_assume( tcpPacketSize >= ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER + sizeof( TCPHeader_t ) ) );
|
||||
|
||||
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( tcpPacketSize, 0 );
|
||||
|
||||
|
||||
/* To avoid asserting on the network buffer being NULL. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
xProcessReceivedTCPPacket( pxNetworkBuffer );
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"ENTRY": "ProcessReceivedTCPPacket_IPv6",
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--unwindset prvTCPSendRepeated.0:13",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_kernel_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_TCP_IP.goto"
|
||||
],
|
||||
"INSTFLAGS":
|
||||
[
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"FREERTOS_TCP_ENABLE_VERIFICATION",
|
||||
"CBMC_GETNETWORKBUFFER_FAILURE_BOUND"
|
||||
],
|
||||
"INC":
|
||||
[
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/include"
|
||||
]
|
||||
}
|
||||
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/* 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"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
#include "../../utility/memory_assignments.c"
|
||||
|
||||
/* This proof assumes pxTCPSocketLookup, vTCPStateChange, prvTCPSocketIsActive, xIsCallingFromIPTask,
|
||||
* xSequenceGreaterThan, xSequenceLessThan, xTaskGetTickCount, vReleaseNetworkBufferAndDescriptor, xTCPWindowTxHasData and
|
||||
* pxGetNetworkBufferWithDescriptor are implemented correctly.
|
||||
*
|
||||
* It also assumes prvSingleStepTCPHeaderOptions, prvCheckOptions, prvTCPPrepareSend,
|
||||
* prvTCPHandleState, prvHandleListen_IPV6 and prvTCPReturnPacket are correct. These functions are
|
||||
* proved to be correct separately. */
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Abstraction of prvHandleListen */
|
||||
FreeRTOS_Socket_t * prvHandleListen( FreeRTOS_Socket_t * pxSocket,
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
FreeRTOS_Socket_t * xRetSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
|
||||
if( xRetSocket )
|
||||
{
|
||||
/* This test case is for IPv6. */
|
||||
__CPROVER_assume( xRetSocket->bits.bIsIPv6 == pdTRUE );
|
||||
}
|
||||
|
||||
return xRetSocket;
|
||||
}
|
||||
|
||||
/* Abstraction of pxTCPSocketLookup */
|
||||
FreeRTOS_Socket_t * pxTCPSocketLookup( uint32_t ulLocalIP,
|
||||
UBaseType_t uxLocalPort,
|
||||
IPv46_Address_t xRemoteIP,
|
||||
UBaseType_t uxRemotePort )
|
||||
{
|
||||
FreeRTOS_Socket_t * xRetSocket = ensure_FreeRTOS_Socket_t_is_allocated();
|
||||
|
||||
if( xRetSocket )
|
||||
{
|
||||
/* This test case is for IPv6. */
|
||||
__CPROVER_assume( xRetSocket->bits.bIsIPv6 == pdTRUE );
|
||||
__CPROVER_assume( xRetSocket->u.xTCP.ucPeerWinScaleFactor <= tcpTCP_OPT_WSOPT_MAXIMUM_VALUE );
|
||||
}
|
||||
|
||||
return xRetSocket;
|
||||
}
|
||||
|
||||
/* Abstraction of pxGetNetworkBufferWithDescriptor */
|
||||
NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes,
|
||||
TickType_t xBlockTimeTicks )
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
|
||||
if( pxNetworkBuffer )
|
||||
{
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( xRequestedSizeBytes );
|
||||
__CPROVER_assume( pxNetworkBuffer->xDataLength == ipSIZE_OF_ETH_HEADER + sizeof( int32_t ) );
|
||||
}
|
||||
|
||||
return pxNetworkBuffer;
|
||||
}
|
||||
|
||||
/* Abstraction of uxIPHeaderSizePacket. Because we're testing IPv6 in this test case, the network buffer is
|
||||
* guaranteed to be IPv6 packet. Thus returns IPv6 header size here directly. */
|
||||
size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
return ipSIZE_OF_IPv6_HEADER;
|
||||
}
|
||||
|
||||
/* Abstraction of uxIPHeaderSizePacket. Because we're testing IPv6 in this test case, all socket handlers returned
|
||||
* by functions are for IPv6. Thus returns IPv6 header size here directly. */
|
||||
size_t uxIPHeaderSizeSocket( const FreeRTOS_Socket_t * pxSocket )
|
||||
{
|
||||
return ipSIZE_OF_IPv6_HEADER;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer;
|
||||
EthernetHeader_t * pxEthernetHeader;
|
||||
size_t tcpPacketSize;
|
||||
|
||||
__CPROVER_assume( tcpPacketSize >= ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + sizeof( TCPHeader_t ) ) );
|
||||
|
||||
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( tcpPacketSize, 0 );
|
||||
|
||||
/* To avoid asserting on the ethernet buffer being NULL. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
/* In this test case, we focus on IPv6 packets. */
|
||||
pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer;
|
||||
__CPROVER_assume( pxEthernetHeader->usFrameType == ipIPv6_FRAME_TYPE );
|
||||
|
||||
xProcessReceivedTCPPacket( pxNetworkBuffer );
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"ENTRY": "ProcessReceivedUDPPacket",
|
||||
"MAX_RX_PACKETS":1,
|
||||
"USE_LLMNR":1,
|
||||
"USE_NBNS":1,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_kernel_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_UDP_IP.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_UDP_IPv4.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_IP.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"ipconfigUDP_MAX_RX_PACKETS={MAX_RX_PACKETS}",
|
||||
"ipconfigUSE_LLMNR={USE_LLMNR}",
|
||||
"ipconfigUSE_NBNS={USE_NBNS}"
|
||||
]
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
#include "FreeRTOS_ARP.h"
|
||||
#include "FreeRTOS_UDP_IP.h"
|
||||
#include "FreeRTOS_TCP_IP.h"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
|
||||
/*This proof assumes that pxUDPSocketLookup is implemented correctly. */
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress,
|
||||
const uint32_t ulIPAddress )
|
||||
{
|
||||
}
|
||||
|
||||
void vARPRefreshCacheEntryAge( const MACAddress_t * pxMACAddress,
|
||||
const uint32_t ulIPAddress )
|
||||
{
|
||||
__CPROVER_assert( pxMACAddress != NULL, "pxMACAddress cannot be NULL" );
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xIsDHCPSocket( Socket_t xSocket )
|
||||
{
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xDNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
/* xDNSHandlePacket always returns pdFAIL. */
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
uint32_t ulNBNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
/* ulNBNSHandlePacket always returns pdFAIL. */
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xCheckRequiresARPResolution( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assume( ( xReturn == pdTRUE ) || ( xReturn == pdFALSE ) );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* Abstraction of xSendDHCPEvent */
|
||||
BaseType_t xSendDHCPEvent( struct xNetworkEndPoint * pxEndPoint )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assume( ( xReturn == pdTRUE ) || ( xReturn == pdFALSE ) );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetworkBuffer,
|
||||
uint16_t usPort,
|
||||
BaseType_t * pxIsWaitingForARPResolution )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assume( ( xReturn == pdTRUE ) || ( xReturn == pdFALSE ) );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* Abstraction of pxUDPSocketLookup */
|
||||
FreeRTOS_Socket_t * pxUDPSocketLookup( UBaseType_t uxLocalPort )
|
||||
{
|
||||
return safeMalloc( sizeof( FreeRTOS_Socket_t ) );
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer;
|
||||
BaseType_t xIsWaitingForARPResolution;
|
||||
NetworkEndPoint_t xEndpoint;
|
||||
uint16_t usPort;
|
||||
EthernetHeader_t * pxHeader;
|
||||
|
||||
pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( sizeof( UDPPacket_t ), 0 );
|
||||
/* The network buffer must not be NULL, checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
pxNetworkBuffer->pxEndPoint = &xEndpoint;
|
||||
|
||||
/* In this test case, we only focus on IPv4. */
|
||||
pxHeader = ( ( const EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer );
|
||||
__CPROVER_assume( pxHeader->usFrameType != ipIPv6_FRAME_TYPE );
|
||||
|
||||
xIsWaitingForARPResolution = nondet_BaseType();
|
||||
xProcessReceivedUDPPacket( pxNetworkBuffer, usPort, &xIsWaitingForARPResolution );
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"ENTRY": "ProcessReceivedUDPPacket_IPv6",
|
||||
"MAX_RX_PACKETS":1,
|
||||
"USE_LLMNR":1,
|
||||
"USE_NBNS":1,
|
||||
"CBMCFLAGS":
|
||||
[
|
||||
"--unwind 1",
|
||||
"--nondet-static"
|
||||
],
|
||||
"OBJS":
|
||||
[
|
||||
"$(ENTRY)_harness.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/cbmc.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/test/cbmc/stubs/freertos_kernel_api.goto",
|
||||
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_UDP_IPv6.goto"
|
||||
],
|
||||
"DEF":
|
||||
[
|
||||
"ipconfigUDP_MAX_RX_PACKETS={MAX_RX_PACKETS}",
|
||||
"ipconfigUSE_LLMNR={USE_LLMNR}",
|
||||
"ipconfigUSE_NBNS={USE_NBNS}"
|
||||
]
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_IP.h"
|
||||
#include "FreeRTOS_IP_Private.h"
|
||||
|
||||
/* CBMC includes. */
|
||||
#include "cbmc.h"
|
||||
|
||||
/*This proof assumes that pxUDPSocketLookup is implemented correctly. */
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress,
|
||||
const uint32_t ulIPAddress )
|
||||
{
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xIsDHCPSocket( Socket_t xSocket )
|
||||
{
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xDNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
/* xDNSHandlePacket always returns pdFAIL. */
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
uint32_t ulNBNSHandlePacket( NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
/* ulNBNSHandlePacket always returns pdFAIL. */
|
||||
return pdFAIL;
|
||||
}
|
||||
|
||||
/* Abstraction of pxUDPSocketLookup */
|
||||
FreeRTOS_Socket_t * pxUDPSocketLookup( UBaseType_t uxLocalPort )
|
||||
{
|
||||
return safeMalloc( sizeof( FreeRTOS_Socket_t ) );
|
||||
}
|
||||
|
||||
/* This proof was done before. Hence we assume it to be correct here. */
|
||||
BaseType_t xCheckRequiresNDResolution( const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer cannot be NULL" );
|
||||
__CPROVER_assert( __CPROVER_r_ok( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ), "Data in pxNetworkBuffer must be readable" );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/* Abstraction of vNDRefreshCacheEntry */
|
||||
void vNDRefreshCacheEntry( const MACAddress_t * pxMACAddress,
|
||||
const IPv6_Address_t * pxIPAddress,
|
||||
NetworkEndPoint_t * pxEndPoint )
|
||||
{
|
||||
}
|
||||
|
||||
/* Abstraction of uxIPHeaderSizePacket */
|
||||
size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer )
|
||||
{
|
||||
/* To enter xProcessReceivedUDPPacket_IPv6, the frame type of ethernet header must be IPv6. */
|
||||
return ipSIZE_OF_IPv6_HEADER;
|
||||
}
|
||||
|
||||
/* Abstraction of xSendDHCPEvent */
|
||||
BaseType_t xSendDHCPEvent( struct xNetworkEndPoint * pxEndPoint )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
|
||||
__CPROVER_assume( ( xReturn == pdTRUE ) || ( xReturn == pdFALSE ) );
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
void harness()
|
||||
{
|
||||
NetworkBufferDescriptor_t * pxNetworkBuffer = safeMalloc( sizeof( NetworkBufferDescriptor_t ) );
|
||||
BaseType_t * pxIsWaitingForARPResolution;
|
||||
NetworkEndPoint_t xEndpoint;
|
||||
uint16_t usPort;
|
||||
|
||||
pxIsWaitingForARPResolution = safeMalloc( sizeof( BaseType_t ) );
|
||||
|
||||
/* The function under test is only called by the IP-task. The below pointer is an
|
||||
* address of a local variable which is being passed to the function under test.
|
||||
* Thus, it cannot ever be NULL. */
|
||||
__CPROVER_assume( pxIsWaitingForARPResolution != NULL );
|
||||
|
||||
/* The network buffer must not be NULL, checked in prvProcessEthernetPacket. */
|
||||
__CPROVER_assume( pxNetworkBuffer != NULL );
|
||||
|
||||
pxNetworkBuffer->pucEthernetBuffer = safeMalloc( sizeof( UDPPacket_IPv6_t ) );
|
||||
pxNetworkBuffer->pxEndPoint = &xEndpoint;
|
||||
pxNetworkBuffer->xDataLength = sizeof( UDPPacket_IPv6_t );
|
||||
|
||||
/* The ethernet buffer must be valid. */
|
||||
__CPROVER_assume( pxNetworkBuffer->pucEthernetBuffer != NULL );
|
||||
|
||||
xProcessReceivedUDPPacket_IPv6( pxNetworkBuffer, usPort, pxIsWaitingForARPResolution );
|
||||
}
|
||||
Reference in new issue
Block a user