mirror of
https://github.com/FreeRTOS/FreeRTOS-Plus-TCP
synced 2025-10-24 03:32:36 +08:00
* Change in UDP process flow to drop packet in case of invalid payload length for IPv4 * Uncrustify: triggered by comment. * Update FreeRTOS_IP.h --------- Co-authored-by: GitHub Action <action@github.com>
68 lines
2.1 KiB
C
68 lines
2.1 KiB
C
/* Include Unity header */
|
|
#include "unity.h"
|
|
|
|
/* Include standard libraries */
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <stdint.h>
|
|
|
|
#include "FreeRTOSIPConfig.h"
|
|
|
|
#include "mock_FreeRTOS_IP.h"
|
|
#include "mock_FreeRTOS_Routing.h"
|
|
#include "mock_FreeRTOS_IP_Timers.h"
|
|
#include "mock_FreeRTOS_IP_Private.h"
|
|
#include "mock_task.h"
|
|
#include "mock_NetworkBufferManagement.h"
|
|
#include "mock_NetworkInterface.h"
|
|
#include "mock_ARP_DataLenLessThanMinPacket_list_macros.h"
|
|
#include "FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c"
|
|
|
|
#include "FreeRTOS_ARP.h"
|
|
|
|
#include "catch_assert.h"
|
|
|
|
static uint32_t uInterfaceOut_Called = 0;
|
|
|
|
BaseType_t xNetworkInterfaceOutput_ARP_Stub( NetworkInterface_t * pxInterface,
|
|
NetworkBufferDescriptor_t * const pxNetworkBuffer,
|
|
BaseType_t bReleaseAfterSend )
|
|
{
|
|
uInterfaceOut_Called = 1;
|
|
|
|
return pdTRUE_UNSIGNED;
|
|
}
|
|
|
|
|
|
void test_FreeRTOS_OutputARPRequest_MinimumPacketSizeLessThanARPPacket( void )
|
|
{
|
|
NetworkEndPoint_t xEndPoint;
|
|
NetworkInterface_t xInterface;
|
|
uint8_t ucBuffer[ sizeof( ARPPacket_t ) + ipBUFFER_PADDING + ipconfigETHERNET_MINIMUM_PACKET_BYTES ];
|
|
NetworkBufferDescriptor_t xNetworkBuffer;
|
|
uint32_t ulIPAddress = 0xAAAAAAAA;
|
|
|
|
xNetworkBuffer.pucEthernetBuffer = ucBuffer;
|
|
xNetworkBuffer.xDataLength = sizeof( ARPPacket_t );
|
|
|
|
xInterface.pfOutput = xNetworkInterfaceOutput_ARP_Stub;
|
|
|
|
xEndPoint.pxNetworkInterface = &xInterface;
|
|
xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED;
|
|
xEndPoint.ipv4_settings.ulIPAddress = 0xC0C0C0C0;
|
|
|
|
/* =================================================== */
|
|
|
|
FreeRTOS_FirstEndPoint_ExpectAndReturn( NULL, &xEndPoint );
|
|
|
|
pxGetNetworkBufferWithDescriptor_ExpectAndReturn( sizeof( ARPPacket_t ), 0, &xNetworkBuffer );
|
|
xIsCallingFromIPTask_IgnoreAndReturn( pdTRUE );
|
|
|
|
FreeRTOS_NextEndPoint_ExpectAndReturn( NULL, &xEndPoint, NULL );
|
|
|
|
FreeRTOS_OutputARPRequest( ulIPAddress );
|
|
|
|
TEST_ASSERT_EQUAL( uInterfaceOut_Called, 1 );
|
|
/* =================================================== */
|
|
}
|