FreeRTOS-Kernel/FreeRTOS-Plus/Test/CBMC/proofs/parsing/ProcessIPPacket/ProcessIPPacket_harness.c
markrtuttle cdf6d93cb9
Modify CBMC proofs to make assumptions about malloc explicit. (#312)
Some proofs assume that some pointers returned by malloc are not
NULL. This patch modifies those proofs to make these assumptions
explicit with `__CPROVER_assume(pointer != NULL)` for all such
pointers.

Co-authored-by: Mark R. Tuttle <mrtuttle@amazon.com>
Co-authored-by: Aniruddha Kanhere <60444055+AniruddhaKanhere@users.noreply.github.com>
2020-10-02 18:18:16 -04:00

36 lines
1.5 KiB
C

/* FreeRTOS includes. */
#include "FreeRTOS.h"
#include "queue.h"
/* FreeRTOS+TCP includes. */
#include "FreeRTOS_IP.h"
#include "FreeRTOS_IP_Private.h"
/* 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);
void harness() {
NetworkBufferDescriptor_t * const pxNetworkBuffer = malloc(sizeof(NetworkBufferDescriptor_t));
__CPROVER_assume(pxNetworkBuffer != NULL);
/* Pointer to the start of the Ethernet frame. It should be able to access the whole Ethernet frame.*/
pxNetworkBuffer->pucEthernetBuffer = malloc(ipTOTAL_ETHERNET_FRAME_SIZE);
__CPROVER_assume(pxNetworkBuffer->pucEthernetBuffer != NULL);
/* 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);
IPPacket_t * const pxIPPacket = malloc(sizeof(IPPacket_t));
__CPROVER_assume(pxIPPacket != NULL);
publicProcessIPPacket(pxIPPacket, pxNetworkBuffer);
}