1- #include "cbmc.h"
2-
31/* FreeRTOS includes. */
42#include "FreeRTOS.h"
53#include "queue.h"
108#include "FreeRTOS_ARP.h"
119#include "FreeRTOS_Routing.h"
1210
11+ /* CBMC includes. */
12+ #include "cbmc.h"
13+
1314/* This pointer is maintained by the IP-task. Defined in FreeRTOS_IP.c */
1415extern NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer ;
16+ NetworkEndPoint_t * pxNetworkEndPoint_Temp ;
17+
18+ /* Stub FreeRTOS_FindEndPointOnNetMask_IPv6 as its not relevant to the
19+ * correctness of the proof */
20+ NetworkEndPoint_t * FreeRTOS_FindEndPointOnNetMask_IPv6 ( const IPv6_Address_t * pxIPv6Address )
21+ {
22+ __CPROVER_assert ( pxIPv6Address != NULL , "Precondition: pxIPv6Address != NULL" );
23+
24+ /* Assume at least one end-point is available */
25+ return pxNetworkEndPoint_Temp ;
26+ }
27+
28+ /* Stub FreeRTOS_FindEndPointOnNetMask_IPv6 as its not relevant to the
29+ * correctness of the proof */
30+ NetworkEndPoint_t * FreeRTOS_FindEndPointOnNetMask ( uint32_t ulIPAddress ,
31+ uint32_t ulWhere )
32+ {
33+ /* Assume at least one end-point is available */
34+ return pxNetworkEndPoint_Temp ;
35+ }
36+
37+ /* Get rid of configASSERT in FreeRTOS_TCP_IP.c */
38+ BaseType_t xIsCallingFromIPTask ( void )
39+ {
40+ return pdTRUE ;
41+ }
1542
1643/* This is an output function and need not be tested with this proof. */
1744void FreeRTOS_OutputARPRequest_Multi ( NetworkEndPoint_t * pxEndPoint ,
@@ -36,9 +63,19 @@ eARPLookupResult_t eARPGetCacheEntry( uint32_t * pulIPAddress,
3663
3764void harness ()
3865{
39- NetworkBufferDescriptor_t xLocalBuffer ;
66+ NetworkBufferDescriptor_t * pxLocalBuffer ;
67+ NetworkBufferDescriptor_t * pxNetworkBuffer2 ;
68+ TickType_t xBlockTimeTicks ;
4069 uint16_t usEthernetBufferSize ;
4170
71+ /*
72+ * The assumption made here is that the buffer pointed by pucEthernetBuffer
73+ * is at least allocated to sizeof(ARPPacket_t) size but eventually an even larger buffer.
74+ * This is not checked inside eARPProcessPacket.
75+ */
76+ uint8_t ucBUFFER_SIZE ;
77+
78+
4279 /* Non deterministically determine whether the pxARPWaitingNetworkBuffer will
4380 * point to some valid data or will it be NULL. */
4481 if ( nondet_bool () )
@@ -47,48 +84,34 @@ void harness()
4784 * checked in the function as the pointer is stored by the IP-task itself
4885 * and therefore it will always be of the required size. */
4986 __CPROVER_assume ( usEthernetBufferSize >= sizeof ( IPPacket_t ) );
50-
51- /* Add matching data length to the network buffer descriptor. */
52- __CPROVER_assume ( xLocalBuffer .xDataLength == usEthernetBufferSize );
53-
54- xLocalBuffer .pucEthernetBuffer = malloc ( usEthernetBufferSize );
87+ pxLocalBuffer = pxGetNetworkBufferWithDescriptor ( usEthernetBufferSize , xBlockTimeTicks );
5588
5689 /* Since this pointer is maintained by the IP-task, either the pointer
57- * pxARPWaitingNetworkBuffer will be NULL or xLocalBuffer. pucEthernetBuffer
90+ * pxARPWaitingNetworkBuffer will be NULL or pxLocalBuffer-> pucEthernetBuffer
5891 * will be non-NULL. */
59- __CPROVER_assume ( xLocalBuffer .pucEthernetBuffer != NULL );
92+ __CPROVER_assume ( pxLocalBuffer != NULL );
93+ __CPROVER_assume ( pxLocalBuffer -> pucEthernetBuffer != NULL );
94+ __CPROVER_assume ( pxLocalBuffer -> xDataLength == usEthernetBufferSize );
6095
61- pxARPWaitingNetworkBuffer = & xLocalBuffer ;
96+ pxARPWaitingNetworkBuffer = pxLocalBuffer ;
6297 }
6398 else
6499 {
65100 pxARPWaitingNetworkBuffer = NULL ;
66101 }
67102
68- /*
69- * The assumption made here is that the buffer pointed by pucEthernetBuffer
70- * is at least allocated to sizeof(ARPPacket_t) size but eventually an even larger buffer.
71- * This is not checked inside eARPProcessPacket.
72- */
73- uint8_t ucBUFFER_SIZE ;
74-
75- void * xBuffer = malloc ( ucBUFFER_SIZE + sizeof ( ARPPacket_t ) );
76-
77- __CPROVER_assume ( xBuffer != NULL );
78-
79- NetworkBufferDescriptor_t xNetworkBuffer2 ;
80-
81- xNetworkBuffer2 .pucEthernetBuffer = xBuffer ;
82- xNetworkBuffer2 .xDataLength = ucBUFFER_SIZE + sizeof ( ARPPacket_t );
103+ pxNetworkBuffer2 = pxGetNetworkBufferWithDescriptor ( ucBUFFER_SIZE + sizeof ( ARPPacket_t ), xBlockTimeTicks );
104+ __CPROVER_assume ( pxNetworkBuffer2 != NULL );
105+ __CPROVER_assume ( pxNetworkBuffer2 -> pucEthernetBuffer != NULL );
83106
84107 /*
85108 * This proof assumes one end point is present.
86109 */
87- xNetworkBuffer2 . pxEndPoint = ( NetworkEndPoint_t * ) malloc ( sizeof ( NetworkEndPoint_t ) );
88- __CPROVER_assume ( xNetworkBuffer2 . pxEndPoint != NULL );
89- xNetworkBuffer2 . pxEndPoint -> pxNext = NULL ;
110+ pxNetworkBuffer2 -> pxEndPoint = ( NetworkEndPoint_t * ) safeMalloc ( sizeof ( NetworkEndPoint_t ) );
111+ __CPROVER_assume ( pxNetworkBuffer2 -> pxEndPoint != NULL );
112+ pxNetworkBuffer2 -> pxEndPoint -> pxNext = NULL ;
90113
91114 /* eARPProcessPacket will be called in the source code only after checking if
92- * xNetworkBuffer2. pucEthernetBuffer is not NULL, hence, __CPROVER_assume( xBuffer != NULL ); */
93- eARPProcessPacket ( & xNetworkBuffer2 );
115+ * pxNetworkBuffer2-> pucEthernetBuffer is not NULL, hence, __CPROVER_assume( xBuffer != NULL ); */
116+ eARPProcessPacket ( pxNetworkBuffer2 );
94117}
0 commit comments