add initial Setup

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
niklasschoeningandClaude Opus 5.5 committed 2026-10-16 18:25:42 +02:00
commit bdb5db2009
1955 files changed
+1004711

No files matched your search

@@ -0,0 +1,55 @@
{
"ENTRY": "ReadNameField",
################################################################
#Enable DNS callbacks or else ReadNameField is not defined
"callbacks": "1",
################################################################
# This is the network buffer size. Set to any positive value.
"NETWORK_BUFFER_SIZE" : "10",
################################################################
# This is the size of the buffer into which the name is copied.
# Set to any positive value.
# In the source, NAME_SIZE=254 and NETWORK_BUFFER_SIZE >> NAME_SIZE
# In the proof, NAME_SIZE >= 4 required for good coverage.
"NAME_SIZE": "6",
################################################################
# Loop prvReadNameField.0:
# should be min of buffer size and name size
# but loop must be unwound at least once, so max of this and 1+1
"READLOOP0": "DNS_ReadNameField.0",
"READLOOP0_UNWIND": "__eval max(2, min({NETWORK_BUFFER_SIZE}, {NAME_SIZE}+1))",
################################################################
# Loop prvReadNameField.1:
# should be min of buffer size and name size
# but loop must be unwound at least twice, so max of this and 2+1
"READLOOP1": "DNS_ReadNameField.1",
"READLOOP1_UNWIND": "__eval max(3, min({NETWORK_BUFFER_SIZE}, {NAME_SIZE}))",
################################################################
"CBMCFLAGS":
[
"--unwind 1",
"--unwindset {READLOOP0}:{READLOOP0_UNWIND},{READLOOP1}:{READLOOP1_UNWIND}"
],
"OBJS":
[
"$(ENTRY)_harness.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_DNS.goto",
"$(FREERTOS_PLUS_TCP)/source/FreeRTOS_DNS_Parser.goto"
],
"DEF":
[
"NETWORK_BUFFER_SIZE={NETWORK_BUFFER_SIZE}",
"NAME_SIZE={NAME_SIZE}",
"ipconfigDNS_USE_CALLBACKS={callbacks}",
"ipconfigDNS_CACHE_NAME_LENGTH=254"
]
}
@@ -0,0 +1,98 @@
/* Standard includes. */
#include <stdint.h>
/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "list.h"
#include "semphr.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_IP_Private.h"
#include "FreeRTOS_UDP_IP.h"
#include "FreeRTOS_DNS.h"
#include "NetworkBufferManagement.h"
#include "NetworkInterface.h"
#include "IPTraceMacroDefaults.h"
#include "cbmc.h"
/****************************************************************
* Signature of function under test
****************************************************************/
size_t DNS_ReadNameField( ParseSet_t * pxSet,
size_t uxDestLen );
/****************************************************************
* The function under test is not defined in all configurations
****************************************************************/
#if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 )
/* DNS_ReadNameField is defined in this configuration */
#else
/* DNS_ReadNameField is not defined in this configuration, stub it. */
size_t DNS_ReadNameField( ParseSet_t * pxSet,
size_t uxDestLen );
{
__CPROVER_assert( pxSet != NULL,
"pxSet should not be NULL" );
return 0;
}
#endif /* if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) */
/****************************************************************
* Proof of DNS_ReadNameField function contract
****************************************************************/
void harness()
{
__CPROVER_assert( NETWORK_BUFFER_SIZE < CBMC_MAX_OBJECT_SIZE,
"NETWORK_BUFFER_SIZE < CBMC_MAX_OBJECT_SIZE" );
__CPROVER_assert( NAME_SIZE < CBMC_MAX_OBJECT_SIZE,
"NAME_SIZE < CBMC_MAX_OBJECT_SIZE" );
__CPROVER_assert( NAME_SIZE >= 4,
"NAME_SIZE >= 4 required for good coverage." );
size_t uxDestLen;
ParseSet_t pxSet;
pxSet.pucByte = malloc( pxSet.uxSourceBytesRemaining );
/* Preconditions */
__CPROVER_assume( pxSet.uxSourceBytesRemaining < CBMC_MAX_OBJECT_SIZE );
__CPROVER_assume( uxDestLen < CBMC_MAX_OBJECT_SIZE );
__CPROVER_assume( pxSet.uxSourceBytesRemaining <= NETWORK_BUFFER_SIZE );
__CPROVER_assume( uxDestLen <= NAME_SIZE );
__CPROVER_assume( pxSet.pucByte != NULL );
/* Avoid overflow on uxSourceLen - 1U with uxSourceLen == uxRemainingBytes */
/*__CPROVER_assume(uxRemainingBytes > 0); */
/* Avoid overflow on uxDestLen - 1U */
__CPROVER_assume( uxDestLen > 0 );
size_t index = DNS_ReadNameField( &pxSet,
uxDestLen );
/* Postconditions */
__CPROVER_assert( index <= uxDestLen + 1 && index <= pxSet.uxSourceBytesRemaining,
"DNS_ReadNameField : index <= uxDestLen+1" );
}