From 88e14753788d37b86ed5cb638656b36f8a5ee897 Mon Sep 17 00:00:00 2001 From: Holden <68555040+HTRamsey@users.noreply.github.com> Date: Wed, 20 Mar 2024 01:09:47 -0400 Subject: [PATCH] Remove macros ipLOCAL_MAC_ADDRESS and ipLOCAL_IP_ADDRESS_POINTER (#1097) * remove deprecated ipLOCAL_MAC_ADDRESS * remove ipLOCAL_IP_ADDRESS_POINTER * remove xDefaultPartUDPPacketHeader * Uncrustify: triggered by comment. * switch remote to local address * Address Review Comments --------- Co-authored-by: GitHub Action Co-authored-by: Tony Josi --- source/FreeRTOS_DHCP.c | 4 - source/FreeRTOS_IP_Utils.c | 4 - source/FreeRTOS_TCP_State_Handling.c | 3 +- source/FreeRTOS_TCP_Transmission_IPv4.c | 1 - source/FreeRTOS_TCP_Transmission_IPv6.c | 1 - source/FreeRTOS_UDP_IP.c | 26 ---- source/FreeRTOS_UDP_IPv4.c | 25 +++- source/FreeRTOS_UDP_IPv6.c | 4 - source/include/FreeRTOS_ICMP.h | 18 --- source/include/FreeRTOS_IP_Private.h | 19 --- .../MPS2_AN385/NetworkInterface.c | 4 +- .../STM32Fxx/NetworkInterface.c | 13 -- .../NetworkInterface/linux/NetworkInterface.c | 12 +- .../FreeRTOS_ARP/FreeRTOS_ARP_stubs.c | 21 --- .../FreeRTOS_ARP/FreeRTOS_ARP_utest.c | 96 +++++++------- ...eRTOS_ARP_DataLenLessThanMinPacket_stubs.c | 21 --- .../FreeRTOS_DHCP/FreeRTOS_DHCP_stubs.c | 24 +--- .../FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c | 123 +++++++++--------- .../FreeRTOS_DNS_Cache_stubs.c | 19 --- .../FreeRTOS_DNS_Callback_stubs.c | 19 --- .../FreeRTOS_DNS_Networking_stubs.c | 19 --- .../FreeRTOS_DNS_Parser_stubs.c | 19 --- .../FreeRTOS_DNS_Parser_utest.c | 14 -- .../FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c | 24 +--- .../FreeRTOS_ICMP/FreeRTOS_ICMP_utest.c | 5 +- .../FreeRTOS_ICMP_wo_assert_stubs.c | 21 --- .../unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c | 21 --- .../FreeRTOS_IP_DiffConfig_stubs.c | 21 +-- .../FreeRTOS_IP_DiffConfig_utest.c | 18 +-- .../FreeRTOS_IP_DiffConfig1_stubs.c | 21 +-- .../FreeRTOS_IP_DiffConfig1_utest.c | 21 ++- .../FreeRTOS_IP_DiffConfig2_stubs.c | 21 --- .../FreeRTOS_IP_DiffConfig2_utest.c | 6 +- .../FreeRTOS_IP_DiffConfig3_stubs.c | 21 --- .../FreeRTOS_IP_Timers_stubs.c | 21 --- .../FreeRTOS_IP_Utils_stubs.c | 21 --- .../FreeRTOS_IP_Utils_DiffConfig_stubs.c | 22 ---- .../FreeRTOS_Sockets_IPv6_stubs.c | 21 --- .../FreeRTOS_TCP_State_Handling_utest.c | 4 + .../FreeRTOS_TCP_Transmission_stubs.c | 1 - .../FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_stubs.c | 22 ---- .../FreeRTOS_Tiny_TCP_stubs.c | 22 ---- 42 files changed, 169 insertions(+), 674 deletions(-) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index e44c7644b8..1f95b6e41c 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -505,10 +505,6 @@ EP_IPv4_SETTINGS.ulBroadcastAddress = EP_DHCPData.ulOfferedIPAddress | ~( EP_IPv4_SETTINGS.ulNetMask ); EP_DHCPData.eDHCPState = eLeasedAddress; - /* _HT_ This macro must be removed later. - * It is enough to set 'EP_IPv4_SETTINGS.ulIPAddress'. */ - *ipLOCAL_IP_ADDRESS_POINTER = EP_IPv4_SETTINGS.ulIPAddress; - iptraceDHCP_SUCCEEDED( EP_DHCPData.ulOfferedIPAddress ); /* DHCP failed, the default configured IP-address will be used diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index dd7210ac7e..459d6ee648 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -951,10 +951,6 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) break; } - #if ( ipconfigUSE_IPv4 != 0 ) - *ipLOCAL_IP_ADDRESS_POINTER = pxEndPoint->ipv4_settings.ulIPAddress; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - /* DHCP or Router Advertisement are not enabled for this end-point. * Perform any necessary 'network up' processing. */ vIPNetworkUpCalls( pxEndPoint ); diff --git a/source/FreeRTOS_TCP_State_Handling.c b/source/FreeRTOS_TCP_State_Handling.c index a897eae011..af569bf54b 100644 --- a/source/FreeRTOS_TCP_State_Handling.c +++ b/source/FreeRTOS_TCP_State_Handling.c @@ -990,8 +990,7 @@ #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ /* And bind it to the same local port as its parent. */ - /*TODO xAddress.sin_address.ulIP_IPv4 = *ipLOCAL_IP_ADDRESS_POINTER; */ - xAddress.sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); + ( void ) FreeRTOS_GetLocalAddress( pxSocket, &xAddress ); #if ( ipconfigTCP_HANG_PROTECTION == 1 ) { diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index 00dd3fb0ba..ed9e92a23e 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -259,7 +259,6 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, * compliant with MISRA Rule 21.15. These should be * optimized away. */ - /* The source MAC addresses is fixed to 'ipLOCAL_MAC_ADDRESS'. */ pvCopySource = pxNetworkBuffer->pxEndPoint->xMACAddress.ucBytes; pvCopyDest = &pxEthernetHeader->xSourceAddress; ( void ) memcpy( pvCopyDest, pvCopySource, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index 03c2ef3027..4a72e99539 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -253,7 +253,6 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, * compliant with MISRA Rule 21.15. These should be * optimized away. */ - /* The source MAC addresses is fixed to 'ipLOCAL_MAC_ADDRESS'. */ pvCopySource = pxNetworkBuffer->pxEndPoint->xMACAddress.ucBytes; pvCopyDest = &pxEthernetHeader->xSourceAddress; ( void ) memcpy( pvCopyDest, pvCopySource, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); diff --git a/source/FreeRTOS_UDP_IP.c b/source/FreeRTOS_UDP_IP.c index 5dc967d8f7..d5ea687a73 100644 --- a/source/FreeRTOS_UDP_IP.c +++ b/source/FreeRTOS_UDP_IP.c @@ -60,32 +60,6 @@ #include "FreeRTOS_DNS.h" #endif -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -/** @brief Part of the Ethernet and IP headers are always constant when sending an IPv4 - * UDP packet. This array defines the constant parts, allowing this part of the - * packet to be filled in using a simple memcpy() instead of individual writes. */ -/*lint -e708 (Info -- union initialization). */ -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; -/*-----------------------------------------------------------*/ - /** * @brief Process the generated UDP packet and do other checks before sending the * packet such as ARP cache check and address resolution. diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index 28df47cdf9..ceed53e93d 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -64,9 +64,6 @@ #if( ipconfigUSE_IPv4 != 0 ) /* *INDENT-ON* */ -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - /*-----------------------------------------------------------*/ /** @@ -117,6 +114,24 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor { if( eReturned == eARPCacheHit ) { + /* Part of the Ethernet and IP headers are always constant when sending an IPv4 + * UDP packet. This array defines the constant parts, allowing this part of the + * packet to be filled in using a simple memcpy() instead of individual writes. */ + static const uint8_t ucDefaultPartUDPPacketHeader[] = + { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Ethernet source MAC address. */ + 0x08, 0x00, /* Ethernet frame type. */ + ipIPV4_VERSION_HEADER_LENGTH_MIN, /* ucVersionHeaderLength. */ + 0x00, /* ucDifferentiatedServicesCode. */ + 0x00, 0x00, /* usLength. */ + 0x00, 0x00, /* usIdentification. */ + 0x00, 0x00, /* usFragmentOffset. */ + ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ + ipPROTOCOL_UDP, /* ucProtocol. */ + 0x00, 0x00, /* usHeaderChecksum. */ + 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ + }; + #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) uint8_t ucSocketOptions; #endif @@ -175,10 +190,10 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor * compliant with MISRA Rule 21.15. These should be * optimized away. */ - pvCopySource = xDefaultPartUDPPacketHeader.ucBytes; + pvCopySource = ucDefaultPartUDPPacketHeader; /* The Ethernet source address is at offset 6. */ pvCopyDest = &pxNetworkBuffer->pucEthernetBuffer[ sizeof( MACAddress_t ) ]; - ( void ) memcpy( pvCopyDest, pvCopySource, sizeof( xDefaultPartUDPPacketHeader ) ); + ( void ) memcpy( pvCopyDest, pvCopySource, sizeof( ucDefaultPartUDPPacketHeader ) ); #if ipconfigSUPPORT_OUTGOING_PINGS == 1 if( pxNetworkBuffer->usPort == ( uint16_t ) ipPACKET_CONTAINS_ICMP_DATA ) diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 0557f47253..80762bd9ca 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -65,10 +65,6 @@ #if( ipconfigUSE_IPv6 != 0 ) /* *INDENT-ON* */ - -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - /*-----------------------------------------------------------*/ /* _HT_ this is a temporary aid while testing. In case an end-0point is not found, diff --git a/source/include/FreeRTOS_ICMP.h b/source/include/FreeRTOS_ICMP.h index fa7cd8bb1b..45eaf79639 100644 --- a/source/include/FreeRTOS_ICMP.h +++ b/source/include/FreeRTOS_ICMP.h @@ -33,27 +33,9 @@ #ifndef FREERTOS_ICMP_H #define FREERTOS_ICMP_H -/* Standard includes. */ -#include -#include -#include - -/* FreeRTOS includes. */ -#include "FreeRTOS.h" -#include "task.h" -#include "queue.h" -#include "semphr.h" - /* FreeRTOS+TCP includes. */ #include "FreeRTOS_IP.h" -#include "FreeRTOS_Sockets.h" #include "FreeRTOS_IP_Private.h" -#include "FreeRTOS_ARP.h" -#include "FreeRTOS_UDP_IP.h" -#include "FreeRTOS_DHCP.h" -#include "NetworkInterface.h" -#include "NetworkBufferManagement.h" -#include "FreeRTOS_DNS.h" /* *INDENT-OFF* */ #ifdef __cplusplus diff --git a/source/include/FreeRTOS_IP_Private.h b/source/include/FreeRTOS_IP_Private.h index a198788663..b594582fc9 100644 --- a/source/include/FreeRTOS_IP_Private.h +++ b/source/include/FreeRTOS_IP_Private.h @@ -327,17 +327,6 @@ extern uint16_t usPacketIdentifier; */ extern List_t xBoundUDPSocketsList; -/** - * Define a default UDP packet header (declared in FreeRTOS_UDP_IP.c) - */ -typedef union xUDPPacketHeader -{ - uint8_t ucBytes[ 24 ]; /**< Member: 8-bit array */ - uint32_t ulWords[ 6 ]; /**< Member: 32-bit array */ -} UDPPacketHeader_t; -extern UDPPacketHeader_t xDefaultPartUDPPacketHeader; - - /* True when BufferAllocation_1.c was included, false for BufferAllocation_2.c */ extern const BaseType_t xBufferAllocFixedSize; @@ -357,14 +346,6 @@ extern struct xNetworkInterface * pxNetworkInterfaces; extern List_t xBoundTCPSocketsList; #endif -/* The local IP address is accessed from within xDefaultPartUDPPacketHeader, - * rather than duplicated in its own variable. */ -#define ipLOCAL_IP_ADDRESS_POINTER ( ( uint32_t * ) &( xDefaultPartUDPPacketHeader.ulWords[ 20U / sizeof( uint32_t ) ] ) ) - -/* The local MAC address is accessed from within xDefaultPartUDPPacketHeader, - * rather than duplicated in its own variable. */ -#define ipLOCAL_MAC_ADDRESS ( xDefaultPartUDPPacketHeader.ucBytes ) - /* ICMP packets are sent using the same function as UDP packets. The port * number is used to distinguish between the two, as 0 is an invalid UDP port. */ #define ipPACKET_CONTAINS_ICMP_DATA ( 0 ) diff --git a/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c b/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c index e6e6c41a32..951d332666 100644 --- a/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c +++ b/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c @@ -132,8 +132,8 @@ static void prvSetMACAddress( void ) /* Using local variables to make sure the right alignment is used. The MAC * address is 6 bytes, hence the copy of 4 bytes followed by 2 bytes. */ - memcpy( ( void * ) &ucMACLow, ( void * ) ipLOCAL_MAC_ADDRESS, 4 ); - memcpy( ( void * ) &ucMACHigh, ( void * ) ( ipLOCAL_MAC_ADDRESS + 4 ), 2 ); + memcpy( ( void * ) &ucMACLow, ( void * ) pxMyInterface->pxEndPoint->xMACAddress.ucBytes, 4 ); + memcpy( ( void * ) &ucMACHigh, ( void * ) ( pxMyInterface->pxEndPoint->xMACAddress.ucBytes + 4 ), 2 ); if( smsc9220_mac_regwrite( dev, SMSC9220_MAC_REG_OFFSET_ADDRL, ucMACLow ) != 0 ) { diff --git a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c index 6db5587a30..8d2ed7f48e 100644 --- a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c @@ -982,19 +982,6 @@ static BaseType_t xMayAcceptPacket( uint8_t * pucEthernetBuffer ) ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - /* Is the packet for this node? */ - if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && - /* Is it a broadcast address x.x.x.255 ? */ - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xff ) != 0xff ) && - #if ( ipconfigUSE_LLMNR == 1 ) - ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && - #endif - ( *ipLOCAL_IP_ADDRESS_POINTER != 0 ) ) - { - FreeRTOS_debug_printf( ( "Drop IP %lxip\n", FreeRTOS_ntohl( ulDestinationIPAddress ) ) ); - return pdFALSE; - } - if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) { #if ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) || ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_DNS == 1 ) diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index af1842175c..a198be31cb 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -709,12 +709,12 @@ static int prvConfigureCaptureBehaviour( void ) * stack. errbuf is used for convenience to create the string. Don't * confuse this with an error message. */ sprintf( pcap_filter, "broadcast or multicast or ether host %x:%x:%x:%x:%x:%x", - ipLOCAL_MAC_ADDRESS[ 0 ], - ipLOCAL_MAC_ADDRESS[ 1 ], - ipLOCAL_MAC_ADDRESS[ 2 ], - ipLOCAL_MAC_ADDRESS[ 3 ], - ipLOCAL_MAC_ADDRESS[ 4 ], - ipLOCAL_MAC_ADDRESS[ 5 ] ); + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 0 ], + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 1 ], + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 2 ], + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 3 ], + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 4 ], + pxMyInterface->pxEndPoint->xMACAddress.ucBytes[ 5 ] ); FreeRTOS_debug_printf( ( "pcap filter to compile: %s\n", pcap_filter ) ); ulNetMask = FreeRTOS_inet_addr_quick( configNET_MASK0, configNET_MASK1, configNET_MASK2, configNET_MASK3 ); diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_stubs.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_stubs.c index b23b9ff866..829eaa17e7 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_stubs.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_stubs.c @@ -19,27 +19,6 @@ NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer = NULL; volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /** @brief For convenience, a MAC address of all 0xffs is defined const for quick * reference. */ const MACAddress_t xBroadcastMACAddress = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; diff --git a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c index 5d829bee58..7a35020383 100644 --- a/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c +++ b/test/unit-test/FreeRTOS_ARP/FreeRTOS_ARP_utest.c @@ -84,8 +84,6 @@ void test_eARPProcessPacket_DifferentHardwareAddress( void ) pxARPFrame->xARPHeader.usHardwareType = ipARP_HARDWARE_TYPE_ETHERNET + 1; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; - /* When the local IP address is 0, we should not process any ARP Packets. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0UL; eResult = eARPProcessPacket( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); /* =================================================== */ @@ -108,8 +106,6 @@ void test_eARPProcessPacket_DifferentProtocolType( void ) pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); - /* When the local IP address is 0, we should not process any ARP Packets. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0UL; eResult = eARPProcessPacket( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); /* =================================================== */ @@ -133,8 +129,6 @@ void test_eARPProcessPacket_DifferentHardwareLength( void ) pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); - /* When the local IP address is 0, we should not process any ARP Packets. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0UL; eResult = eARPProcessPacket( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); /* =================================================== */ @@ -160,8 +154,6 @@ void test_eARPProcessPacket_DifferentProtocolLength( void ) pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); - /* When the local IP address is 0, we should not process any ARP Packets. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0UL; eResult = eARPProcessPacket( pxNetworkBuffer ); TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); /* =================================================== */ @@ -334,11 +326,11 @@ void test_eARPProcessPacket_InvalidOperation( void ) pxARPFrame->xARPHeader.usProtocolType = ipARP_PROTOCOL_TYPE; pxARPFrame->xARPHeader.ucHardwareAddressLength = ipMAC_ADDRESS_LENGTH_BYTES; pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); /* What if some invalid option is sent in the ARP Packet? */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Add invalid operation */ pxARPFrame->xARPHeader.usOperation = ipARP_REQUEST | ipARP_REPLY; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; @@ -370,7 +362,7 @@ void test_eARPProcessPacket_Request_DifferentIP( void ) xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REQUEST; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) pxARPFrame; pxNetworkBuffer->xDataLength = sizeof( ARPPacket_t ); pxNetworkBuffer->pxEndPoint = &xEndPoint; @@ -400,8 +392,8 @@ void test_eARPProcessPacket_Request_SenderMACSameAsLocalMAC( void ) pxARPFrame->xARPHeader.ucHardwareAddressLength = ipMAC_ADDRESS_LENGTH_BYTES; pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; - memset( ipLOCAL_MAC_ADDRESS, 0x22, sizeof( MACAddress_t ) ); - memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memset( xEndPoint.xMACAddress.ucBytes, 0x22, sizeof( MACAddress_t ) ); + memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), xEndPoint.xMACAddress.ucBytes, sizeof( MACAddress_t ) ); xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ @@ -414,7 +406,7 @@ void test_eARPProcessPacket_Request_SenderMACSameAsLocalMAC( void ) FreeRTOS_FindEndPointOnNetMask_IgnoreAndReturn( &xEndPoint ); eResult = eARPProcessPacket( pxNetworkBuffer ); - TEST_ASSERT_EQUAL( eReturnEthernetFrame, eResult ); + TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); } void test_eARPProcessPacket_Request_SenderAndTargetDifferent( void ) @@ -970,13 +962,13 @@ void test_eARPProcessPacket_Reply_TargetIPSameAsLocalIP( void ) pxARPFrame->xARPHeader.ucHardwareAddressLength = ipMAC_ADDRESS_LENGTH_BYTES; pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; - memset( ipLOCAL_MAC_ADDRESS, 0x22, sizeof( MACAddress_t ) ); - memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memset( xEndPoint.xMACAddress.ucBytes, 0x22, sizeof( MACAddress_t ) ); + memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), xEndPoint.xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress; uint32_t ulSenderProtocolAddress = 0xFFAAEEBB; @@ -988,7 +980,7 @@ void test_eARPProcessPacket_Reply_TargetIPSameAsLocalIP( void ) FreeRTOS_FindEndPointOnNetMask_ExpectAnyArgsAndReturn( NULL ); xEndPoint.bits.bEndPointUp = pdTRUE_UNSIGNED; - xEndPoint.ipv4_settings.ulIPAddress = *ipLOCAL_IP_ADDRESS_POINTER; + xEndPoint.ipv4_settings.ulIPAddress = xEndPoint.ipv4_settings.ulIPAddress; xNetworkBuffer.pucEthernetBuffer = ( uint8_t * ) pxARPFrame; xNetworkBuffer.xDataLength = sizeof( ARPPacket_t ); xNetworkBuffer.pxEndPoint = &xEndPoint; @@ -1017,13 +1009,13 @@ void test_eARPProcessPacket_Reply_TargetIPNotSameAsLocalIP_ButEntryInCache( void pxARPFrame->xARPHeader.ucHardwareAddressLength = ipMAC_ADDRESS_LENGTH_BYTES; pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; - memset( ipLOCAL_MAC_ADDRESS, 0x22, sizeof( MACAddress_t ) ); - memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memset( xEndPoint.xMACAddress.ucBytes, 0x22, sizeof( MACAddress_t ) ); + memcpy( &( pxARPFrame->xARPHeader.xSenderHardwareAddress ), xEndPoint.xMACAddress.ucBytes, sizeof( MACAddress_t ) ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 1; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 1; uint32_t ulSenderProtocolAddress = 0xFFAAEEBB; @@ -1159,10 +1151,10 @@ void test_eARPProcessPacket_Reply_DifferentIP( void ) pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; /* Process an ARP reply - not meant for this node. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); /* Reset the private variable uxARPClashCounter. */ @@ -1204,10 +1196,10 @@ void test_eARPProcessPacket_Reply_DifferentIP_WaitingBufferNonNull( void ) pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; /* Process an ARP reply - not meant for this node. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); /* Reset the private variable uxARPClashCounter. */ @@ -1251,10 +1243,10 @@ void test_eARPProcessPacket_Reply_WaitingBufferIncorrectHeaderSize( void ) pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; /* Process an ARP reply - not meant for this node. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); /* Reset the private variable uxARPClashCounter. */ @@ -1301,10 +1293,10 @@ void test_eARPProcessPacket_Reply_WaitingBufferNonNull_MatchingAddress1( void ) pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; /* Process an ARP reply - not meant for this node. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); memcpy( &( pxARPWaitingIPHeader->ulSourceIPAddress ), pxARPFrame->xARPHeader.ucSenderProtocolAddress, sizeof( pxARPWaitingIPHeader->ulSourceIPAddress ) ); @@ -1358,10 +1350,10 @@ void test_eARPProcessPacket_Reply_WaitingBufferNonNull_MatchingAddress2( void ) pxARPFrame->xARPHeader.ucProtocolAddressLength = ipIP_ADDRESS_LENGTH_BYTES; /* Process an ARP reply - not meant for this node. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCDD; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCDD; /* Fill in the request option. */ pxARPFrame->xARPHeader.usOperation = ipARP_REPLY; - pxARPFrame->xARPHeader.ulTargetProtocolAddress = *ipLOCAL_IP_ADDRESS_POINTER + 0x11; + pxARPFrame->xARPHeader.ulTargetProtocolAddress = xEndPoint.ipv4_settings.ulIPAddress + 0x11; memcpy( pxARPFrame->xARPHeader.ucSenderProtocolAddress, &( pxARPFrame->xARPHeader.ulTargetProtocolAddress ), sizeof( pxARPFrame->xARPHeader.ulTargetProtocolAddress ) ); memcpy( &( pxARPWaitingIPHeader->ulSourceIPAddress ), pxARPFrame->xARPHeader.ucSenderProtocolAddress, sizeof( pxARPWaitingIPHeader->ulSourceIPAddress ) ); @@ -1472,13 +1464,13 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; xNetworkBuffer.pxEndPoint = &xEndPoint; /* Make sure there is no match. */ - pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); + pxIPHeader->ulSourceIPAddress = ~( xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask ); uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv4_HEADER ); @@ -1501,13 +1493,13 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_InvalidHeader( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; xNetworkBuffer.pxEndPoint = &xEndPoint; /* Make sure there is no match. */ - pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); + pxIPHeader->ulSourceIPAddress = ~( xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask ); uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER + ipSIZE_OF_IPv4_HEADER ); @@ -1530,13 +1522,13 @@ void test_xCheckRequiresARPResolution_NotOnLocalNetwork_IPv6( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; xNetworkBuffer.pxEndPoint = &xEndPoint; /* Make sure there is no match. */ - pxIPHeader->ulSourceIPAddress = ~( *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask ); + pxIPHeader->ulSourceIPAddress = ~( xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask ); uxIPHeaderSizePacket_IgnoreAndReturn( ipSIZE_OF_IPv6_HEADER ); @@ -1611,14 +1603,14 @@ void test_xCheckRequiresARPResolution_OnLocalNetwork_NotInCache( void ) IPPacket_t * pxIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); IPHeader_t * pxIPHeader = &( pxIPPacket->xIPHeader ); - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD1234; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD1234; xEndPoint.ipv4_settings.ulNetMask = 0xFFFFFF00; xNetworkBuffer.pxEndPoint = &xEndPoint; /* Make sure there is a match. */ - pxIPHeader->ulSourceIPAddress = *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask; - xEndPoint.ipv4_settings.ulIPAddress = *ipLOCAL_IP_ADDRESS_POINTER & xEndPoint.ipv4_settings.ulNetMask; + pxIPHeader->ulSourceIPAddress = xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask; + xEndPoint.ipv4_settings.ulIPAddress = xEndPoint.ipv4_settings.ulIPAddress & xEndPoint.ipv4_settings.ulNetMask; xEndPoint.bits.bIPv6 = pdFALSE_UNSIGNED; /* And that the IP is not in ARP cache. */ @@ -1876,7 +1868,7 @@ void test_vARPRefreshCacheEntry_IPOnADifferentSubnet( void ) /* Set a MAC address which will match */ memset( xARPCache[ xUseEntry ].xMACAddress.ucBytes, 0x11, sizeof( xMACAddress.ucBytes ) ); /* Set a local IP address */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xAABBCCEF; + xEndPoint.ipv4_settings.ulIPAddress = 0xAABBCCEF; /* The IP address being passed should not be on the same subnet. */ ulIPAddress = 0x00BBCCEE; @@ -2196,7 +2188,7 @@ void test_eARPGetCacheEntry_MatchingInvalidEntry( void ) /* =================================================== */ ulIPAddress = 0x4321; /* Make both values (IP address and local IP pointer) different. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x1234; + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; /* Add the IP address in the cache so that we'll have a cache hit. */ xARPCache[ 1 ].ulIPAddress = xNetworkAddressing.ulGatewayAddress; /* But reset the valid bit. */ @@ -2225,7 +2217,7 @@ void test_eARPGetCacheEntry_MatchingValidEntry( void ) /* =================================================== */ ulIPAddress = 0x4321; /* Make both values (IP address and local IP pointer) different. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x1234; + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; /* Add the IP address in the cache so that we'll have a cache hit. */ xARPCache[ 1 ].ulIPAddress = xNetworkAddressing.ulGatewayAddress; /* Now try with a set valid bit. */ @@ -2259,7 +2251,7 @@ void test_eARPGetCacheEntry_GatewayAddressZero( void ) xARPCache[ i ].ucValid = ( uint8_t ) pdFALSE; } - *ipLOCAL_IP_ADDRESS_POINTER = 0x1234; + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; ulIPAddress = 0x4321; /* Not worried about what these functions do. */ @@ -2287,7 +2279,8 @@ void test_eARPGetCacheEntry_AddressNotOnLocalAddress( void ) ulIPAddress = 0; /* Make both values (IP address and local IP pointer) different. */ /* Get any address on the same netmask. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x00000034; + xEndPoint.ipv4_settings.ulIPAddress = 0x00000034; + pxNetworkEndPoints = &xEndPoint; /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); @@ -2324,7 +2317,8 @@ void test_eARPGetCacheEntry_NoCacheHit( void ) /* Make both values (IP address and local IP pointer) different * and on different net masks. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x1234; + xEndPoint.ipv4_settings.ulIPAddress = 0x1234; + pxNetworkEndPoints = &xEndPoint; /* Not worried about what these functions do. */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); xIsIPv4Multicast_ExpectAndReturn( ulIPAddress, 0UL ); @@ -2676,7 +2670,7 @@ void test_xARPWaitResolution_GNWFailsNoTimeout( void ) ulIPAddress = 0x00000031; /* Make both values (IP address and local IP pointer) different. */ /* Get any address on the same netmask. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x00000034; + xEndPoint.ipv4_settings.ulIPAddress = 0x00000034; /* Assertion on calling from IP-task */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); @@ -2727,7 +2721,7 @@ void test_xARPWaitResolution( void ) ulIPAddress = 0x00000031; /* Make both values (IP address and local IP pointer) different. */ /* Get any address on the same netmask. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x00000034; + xEndPoint.ipv4_settings.ulIPAddress = 0x00000034; /* Assertion on calling from IP-task */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); @@ -2775,7 +2769,7 @@ void test_xARPWaitResolution( void ) ulIPAddress = 0x00000031; /* Make both values (IP address and local IP pointer) different. */ /* Get any address on the same netmask. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0x00000034; + xEndPoint.ipv4_settings.ulIPAddress = 0x00000034; /* Assertion on calling from IP-task */ FreeRTOS_FindEndPointOnIP_IPv4_ExpectAnyArgsAndReturn( NULL ); diff --git a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c index 2841466ccf..a8f3bca4e7 100644 --- a/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c +++ b/test/unit-test/FreeRTOS_ARP_DataLenLessThanMinPacket/FreeRTOS_ARP_DataLenLessThanMinPacket_stubs.c @@ -18,27 +18,6 @@ NetworkBufferDescriptor_t * pxARPWaitingNetworkBuffer = NULL; volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /** @brief For convenience, a MAC address of all 0xffs is defined const for quick * reference. */ const MACAddress_t xBroadcastMACAddress = { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; diff --git a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_stubs.c b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_stubs.c index 276141db45..0556507109 100644 --- a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_stubs.c +++ b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_stubs.c @@ -20,10 +20,9 @@ DHCPData_t xDHCPData; volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) +const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; -#define xSizeofUDPBuffer 300 +#define xSizeofUDPBuffer 300 Socket_t xDHCPSocket; extern Socket_t xDHCPv4Socket; @@ -57,25 +56,6 @@ static uint8_t DHCP_header[] = 0x00, 0xAA, 0xAA, 0xAA /**< Gateway IP address in case the server client are on different subnets. */ }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - - /* * IP-clash detection is currently only used internally. When DHCP doesn't respond, the * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a diff --git a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c index b87c6e7216..7da21e3584 100644 --- a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c +++ b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c @@ -366,7 +366,6 @@ void test_vDHCPProcess_CorrectStateDHCPHookFailsDHCPSocketNULL( void ) /* The state should indicate that we are not using leased address. */ TEST_ASSERT_EQUAL( eNotUsingLeasedAddress, pxEndPoint->xDHCPData.eDHCPState ); /* Make sure that the Endpoint IP address pointer indicates that. */ - /*TEST_ASSERT_EQUAL( pxEndPoint->ipv4_defaults.ulIPAddress, *ipLOCAL_IP_ADDRESS_POINTER ); */ TEST_ASSERT_EQUAL( pxEndPoint->ipv4_defaults.ulIPAddress, pxEndPoint->ipv4_settings.ulIPAddress ); } @@ -1990,9 +1989,7 @@ void test_vDHCPProcess_eWaitingOfferRecvfromSuccess_CorrectAddrLen_LocalMACNotma pxNetworkEndPoints = pxEndPoint; - memcpy( &xBackup, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - - memset( ipLOCAL_MAC_ADDRESS, 0xAA, sizeof( MACAddress_t ) ); + memcpy( &xBackup, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Get a stub. */ FreeRTOS_recvfrom_Stub( FreeRTOS_recvfrom_eWaitingOfferRecvfromSuccess_LocalMACAddrNotMatching ); @@ -2005,8 +2002,6 @@ void test_vDHCPProcess_eWaitingOfferRecvfromSuccess_CorrectAddrLen_LocalMACNotma vDHCPProcessEndPoint( pdFALSE, pdTRUE, pxEndPoint ); - memcpy( ipLOCAL_MAC_ADDRESS, &xBackup, sizeof( MACAddress_t ) ); - /* DHCP socket should be allocated */ TEST_ASSERT_EQUAL( &xTestSocket, xDHCPv4Socket ); TEST_ASSERT_EQUAL( &xTestSocket, pxEndPoint->xDHCPData.xDHCPSocket ); @@ -2024,7 +2019,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageWithoutOptionsNoTimeout( v memset( DHCPMsg, 0, sizeof( DHCPMsg ) ); memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; ucGenericPtr = DHCPMsg; ulGenericLength = sizeof( DHCPMsg ); @@ -2081,7 +2076,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageIncorrectOptionsNoTimeout( /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2146,7 +2141,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageMissingLengthByteNoTimeout /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2212,7 +2207,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageIncorrectLengthByteNoTimeo /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2280,7 +2275,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageGetNACKNoTimeout( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2350,7 +2345,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageGetNACKNoTimeout_MatchingM /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2384,7 +2379,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageGetNACKNoTimeout_MatchingM /* Set the transaction ID which will match. */ pxEndPoint->xDHCPData.ulTransactionId = 0x01ABCDEF; /* Set the MAC address that matches. */ - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkEndPoints = pxEndPoint; @@ -2422,7 +2417,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageGetACKNoTimeout( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2492,7 +2487,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageOneOptionNoTimeout( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2525,7 +2520,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageOneOptionNoTimeout( void ) pxEndPoint->xDHCPData.xUseBroadcast = pdFALSE; /* Set the transaction ID which will match. */ pxEndPoint->xDHCPData.ulTransactionId = 0x01ABCDEF; - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkEndPoints = pxEndPoint; @@ -2563,7 +2558,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageOneOptionNoTimeout2( void /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2637,7 +2632,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsSendFails( void /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2683,7 +2678,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsSendFails( void /* Set the transaction ID which will match. */ pxEndPoint->xDHCPData.ulTransactionId = 0x01ABCDEF; /* Make sure that the address matches. */ - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkEndPoints = pxEndPoint; @@ -2733,8 +2728,8 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsSendSucceeds( vo /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2835,8 +2830,8 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsDHCPHookReturnDe /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2935,7 +2930,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsDHCPHookReturnEr /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -2981,7 +2976,7 @@ void test_vDHCPProcess_eWaitingOfferCorrectDHCPMessageTwoOptionsDHCPHookReturnEr /* Set the transaction ID which will match. */ pxEndPoint->xDHCPData.ulTransactionId = 0x01ABCDEF; /* Make sure that the address matches. */ - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Get a stub. */ @@ -3035,7 +3030,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerNoTimeout( vo /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3120,7 +3115,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutGNBfai /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3210,7 +3205,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutGNBSuc /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3305,7 +3300,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutPeriod /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3390,7 +3385,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutPeriod /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3476,7 +3471,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsCorrectServerLeaseTimeZero( /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3520,7 +3515,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsCorrectServerLeaseTimeZero( /* Put correct address. */ pxEndPoint->xDHCPData.ulDHCPServerAddress = DHCPServerAddress; /* Make sure that the address matches. */ - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Reset the lease time so that it will be set to default * value later. */ @@ -3576,8 +3571,8 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsCorrectServerLeaseTimeLessTh /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3675,8 +3670,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_TwoOptions_CorrectServer_AptLeaseTime /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3773,8 +3768,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_TwoOptions_NACK( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3860,8 +3855,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_TwoOptions_OFFER( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -3962,8 +3957,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_AllOptionsCorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4108,8 +4103,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_AllOptionsCorrectLength2( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4255,8 +4250,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_DNSIncorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4401,8 +4396,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_DNSIncorrectLength2( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4547,8 +4542,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_IncorrectDNSServerAddress( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4693,8 +4688,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_IncorrectDNSServerAddress2( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4836,8 +4831,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_IPv4ServerIncorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -4953,8 +4948,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_SubnetMaskIncorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -5069,8 +5064,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_GatewayIncorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -5194,8 +5189,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_LeaseTimeIncorrectLength( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -5327,8 +5322,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_LeaseTimeIncorrectLength2( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; @@ -5436,8 +5431,8 @@ void test_vDHCPProcess_eWaitingAcknowledge_IncorrectLengthOfPacket( void ) /* Copy the header here. */ memcpy( DHCPMsg, DHCP_header, sizeof( DHCP_header ) ); /* Make sure that the address matches. */ - memcpy( pxDHCPMessage->ucClientHardwareAddress, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); - memcpy( &( pxEndPoint->xMACAddress.ucBytes ), ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxDHCPMessage->ucClientHardwareAddress, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( &( pxEndPoint->xMACAddress.ucBytes ), xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); /* Add the expected cookie. */ pxDHCPMessage->ulDHCPCookie = dhcpCOOKIE; diff --git a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_stubs.c b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_stubs.c index 4d27b46d28..3ff0cf2260 100644 --- a/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_stubs.c +++ b/test/unit-test/FreeRTOS_DNS_Cache/FreeRTOS_DNS_Cache_stubs.c @@ -62,22 +62,3 @@ BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint, { return pdFALSE; } - -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; diff --git a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_stubs.c b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_stubs.c index cc2f56b179..b7ad3e2d0d 100644 --- a/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_stubs.c +++ b/test/unit-test/FreeRTOS_DNS_Callback/FreeRTOS_DNS_Callback_stubs.c @@ -54,22 +54,3 @@ BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint, const char * pcName ) { } - -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; diff --git a/test/unit-test/FreeRTOS_DNS_Networking/FreeRTOS_DNS_Networking_stubs.c b/test/unit-test/FreeRTOS_DNS_Networking/FreeRTOS_DNS_Networking_stubs.c index 48eaacbf6e..f65fde89e5 100644 --- a/test/unit-test/FreeRTOS_DNS_Networking/FreeRTOS_DNS_Networking_stubs.c +++ b/test/unit-test/FreeRTOS_DNS_Networking/FreeRTOS_DNS_Networking_stubs.c @@ -55,22 +55,3 @@ BaseType_t xApplicationDNSQueryHook_Multi( struct xNetworkEndPoint * pxEndPoint, const char * pcName ) { } - -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; diff --git a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_stubs.c b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_stubs.c index 52cd6b0728..63926601e7 100644 --- a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_stubs.c +++ b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_stubs.c @@ -49,25 +49,6 @@ uint16_t usPacketIdentifier; struct freertos_addrinfo pucAddrBuffer[ 2 ]; struct freertos_sockaddr pucSockAddrBuffer[ 1 ]; -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ======================== Stub Callback Functions ========================= */ void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c index a9bb891923..87ed60b969 100644 --- a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c +++ b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c @@ -91,20 +91,6 @@ extern struct freertos_sockaddr pucSockAddrBuffer[ 1 ]; void setUp( void ) { xBufferAllocFixedSize = pdFALSE; - xDefaultPartUDPPacketHeader.ucBytes[ 0 ] = 1; - xDefaultPartUDPPacketHeader.ucBytes[ 1 ] = 2; - xDefaultPartUDPPacketHeader.ucBytes[ 2 ] = 3; - xDefaultPartUDPPacketHeader.ucBytes[ 3 ] = 4; - xDefaultPartUDPPacketHeader.ucBytes[ 4 ] = 5; - xDefaultPartUDPPacketHeader.ulWords[ 0 ] = 6; - xDefaultPartUDPPacketHeader.ulWords[ 1 ] = 7; - xDefaultPartUDPPacketHeader.ulWords[ 2 ] = 8; - xDefaultPartUDPPacketHeader.ulWords[ 3 ] = 9; - xDefaultPartUDPPacketHeader.ulWords[ 4 ] = 10; - xDefaultPartUDPPacketHeader.ulWords[ 5 ] = 11; - xDefaultPartUDPPacketHeader.ulWords[ 6 ] = 12; - xDefaultPartUDPPacketHeader.ulWords[ 7 ] = 13; - xDefaultPartUDPPacketHeader.ulWords[ 8 ] = 14; callback_called = 0; } diff --git a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c index ce7fa9c1b6..102afab0a5 100644 --- a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c +++ b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c @@ -40,31 +40,13 @@ #include "FreeRTOS_IP.h" #include "FreeRTOS_IP_Private.h" -volatile BaseType_t xInsideInterrupt = pdFALSE; +/** @brief A list of all network end-points. Each element has a next pointer. */ +struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) +volatile BaseType_t xInsideInterrupt = pdFALSE; const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_utest.c b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_utest.c index c1b8131250..b51b26a220 100644 --- a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_utest.c +++ b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_utest.c @@ -103,6 +103,9 @@ void test_ProcessICMPPacket_EchoRequest( void ) IPHeader_t * pxIPHeader; ICMPPacket_t * pxICMPPacket; ICMPHeader_t * pxICMPHeader; + NetworkEndPoint_t xEndPoint = { 0 }; + + pxNetworkEndPoints = &xEndPoint; pxNetworkBuffer = &xNetworkBuffer; pxNetworkBuffer->pucEthernetBuffer = ucEthBuffer; @@ -127,7 +130,7 @@ void test_ProcessICMPPacket_EchoRequest( void ) TEST_ASSERT_EQUAL( eReturnEthernetFrame, eResult ); TEST_ASSERT_EQUAL( ( uint8_t ) ipICMP_ECHO_REPLY, pxICMPHeader->ucTypeOfMessage ); TEST_ASSERT_EQUAL( pxIPHeader->ulSourceIPAddress, pxIPHeader->ulDestinationIPAddress ); - TEST_ASSERT_EQUAL( *ipLOCAL_IP_ADDRESS_POINTER, pxIPHeader->ulSourceIPAddress ); + TEST_ASSERT_EQUAL( xEndPoint.ipv4_settings.ulIPAddress, pxIPHeader->ulSourceIPAddress ); TEST_ASSERT_EQUAL( ipconfigICMP_TIME_TO_LIVE, pxIPHeader->ucTimeToLive ); TEST_ASSERT_EQUAL( 0, pxIPHeader->usFragmentOffset ); TEST_ASSERT_EQUAL( ( uint16_t ) ~FreeRTOS_htons( 0xAA ), pxIPHeader->usHeaderChecksum ); diff --git a/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c b/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c index ce7fa9c1b6..e792908f52 100644 --- a/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c +++ b/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c @@ -42,29 +42,8 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c index 4caeb375ee..f25be869e9 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c @@ -51,29 +51,8 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c index 0ab6842348..3b13966be3 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c @@ -50,28 +50,9 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; +const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c index 60b42ee010..9a530d1ec8 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_utest.c @@ -53,7 +53,7 @@ #include "FreeRTOS_IP.h" -/*#include "FreeRTOS_IP_stubs.c" */ +#include "FreeRTOS_IP_DiffConfig_stubs.c" #include "catch_assert.h" #include "FreeRTOSIPConfig.h" @@ -370,7 +370,7 @@ void test_vReturnEthernetFrame_DuplicationSuccess( void ) memset( &pxEthernetHeader->xDestinationAddress, 0x11, sizeof( pxEthernetHeader->xDestinationAddress ) ); memset( &pxEthernetHeader->xSourceAddress, 0x22, sizeof( pxEthernetHeader->xSourceAddress ) ); - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkBuffer->pxEndPoint = &xEndPoint; xEndPoint.pxNetworkInterface = &xInterfaces[ 0 ]; xInterfaces->pfOutput = &NetworkInterfaceOutputFunction_Stub; @@ -392,7 +392,7 @@ void test_vReturnEthernetFrame_DuplicationSuccess( void ) TEST_ASSERT_EQUAL( ipconfigETHERNET_MINIMUM_PACKET_BYTES, pxNetworkBuffer->xDataLength ); TEST_ASSERT_EQUAL( xNetworkBuffer.xDataLength, xDuplicateNetworkBuffer.xDataLength ); TEST_ASSERT_EACH_EQUAL_UINT8( 0x22, &pxEthernetHeader->xDestinationAddress, sizeof( pxEthernetHeader->xDestinationAddress ) ); - TEST_ASSERT_EQUAL_MEMORY( ipLOCAL_MAC_ADDRESS, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); + TEST_ASSERT_EQUAL_MEMORY( xDefault_MacAddress.ucBytes, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); } @@ -425,7 +425,7 @@ void test_vReturnEthernetFrame_DuplicationSuccessCacheHit( void ) memset( &pxEthernetHeader->xDestinationAddress, 0x11, sizeof( pxEthernetHeader->xDestinationAddress ) ); memset( &pxEthernetHeader->xSourceAddress, 0x22, sizeof( pxEthernetHeader->xSourceAddress ) ); - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkBuffer->pxEndPoint = &xEndPoint; xEndPoint.pxNetworkInterface = &xInterfaces[ 0 ]; xInterfaces->pfOutput = &NetworkInterfaceOutputFunction_Stub; @@ -448,7 +448,7 @@ void test_vReturnEthernetFrame_DuplicationSuccessCacheHit( void ) TEST_ASSERT_EQUAL( ipconfigETHERNET_MINIMUM_PACKET_BYTES, pxNetworkBuffer->xDataLength ); TEST_ASSERT_EQUAL( xNetworkBuffer.xDataLength, xDuplicateNetworkBuffer.xDataLength ); TEST_ASSERT_EQUAL_MEMORY( xCacheMACAddress.ucBytes, &pxEthernetHeader->xDestinationAddress, sizeof( pxEthernetHeader->xDestinationAddress ) ); - TEST_ASSERT_EQUAL_MEMORY( ipLOCAL_MAC_ADDRESS, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); + TEST_ASSERT_EQUAL_MEMORY( xDefault_MacAddress.ucBytes, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); } @@ -473,7 +473,7 @@ void test_vReturnEthernetFrame_xReleaseAfterSend( void ) pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; memset( &pxEthernetHeader->xDestinationAddress, 0x11, sizeof( pxEthernetHeader->xDestinationAddress ) ); memset( &pxEthernetHeader->xSourceAddress, 0x22, sizeof( pxEthernetHeader->xSourceAddress ) ); - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkBuffer->xDataLength = ipconfigETHERNET_MINIMUM_PACKET_BYTES - 10; pxNetworkBuffer->pxEndPoint = &xEndPoint; @@ -490,7 +490,7 @@ void test_vReturnEthernetFrame_xReleaseAfterSend( void ) TEST_ASSERT_EQUAL( ipconfigETHERNET_MINIMUM_PACKET_BYTES, pxNetworkBuffer->xDataLength ); TEST_ASSERT_EACH_EQUAL_UINT8( 0, &ucEthBuffer[ ipconfigETHERNET_MINIMUM_PACKET_BYTES - 10 ], 10 ); TEST_ASSERT_EACH_EQUAL_UINT8( 0x22, &pxEthernetHeader->xDestinationAddress, sizeof( pxEthernetHeader->xDestinationAddress ) ); - TEST_ASSERT_EQUAL_MEMORY( ipLOCAL_MAC_ADDRESS, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); + TEST_ASSERT_EQUAL_MEMORY( xDefault_MacAddress.ucBytes, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); } @@ -516,7 +516,7 @@ void test_vReturnEthernetFrame_DataLenMoreThanRequired( void ) pxEthernetHeader = ( EthernetHeader_t * ) pxNetworkBuffer->pucEthernetBuffer; memset( &pxEthernetHeader->xDestinationAddress, 0x11, sizeof( pxEthernetHeader->xDestinationAddress ) ); memset( &pxEthernetHeader->xSourceAddress, 0x22, sizeof( pxEthernetHeader->xSourceAddress ) ); - memcpy( pxEndPoint->xMACAddress.ucBytes, ipLOCAL_MAC_ADDRESS, sizeof( MACAddress_t ) ); + memcpy( pxEndPoint->xMACAddress.ucBytes, xDefault_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxNetworkBuffer->xDataLength = ipconfigETHERNET_MINIMUM_PACKET_BYTES; pxNetworkBuffer->pxEndPoint = &xEndPoint; @@ -533,7 +533,7 @@ void test_vReturnEthernetFrame_DataLenMoreThanRequired( void ) TEST_ASSERT_EQUAL( ipconfigETHERNET_MINIMUM_PACKET_BYTES, pxNetworkBuffer->xDataLength ); TEST_ASSERT_EACH_EQUAL_UINT8( 0xAA, &ucEthBuffer[ ipconfigETHERNET_MINIMUM_PACKET_BYTES - 10 ], 10 ); TEST_ASSERT_EACH_EQUAL_UINT8( 0x22, &pxEthernetHeader->xDestinationAddress, sizeof( pxEthernetHeader->xDestinationAddress ) ); - TEST_ASSERT_EQUAL_MEMORY( ipLOCAL_MAC_ADDRESS, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); + TEST_ASSERT_EQUAL_MEMORY( xDefault_MacAddress.ucBytes, &pxEthernetHeader->xSourceAddress, sizeof( pxEthernetHeader->xSourceAddress ) ); TEST_ASSERT_EQUAL( 1, NetworkInterfaceOutputFunction_Stub_Called ); } diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c index 4caeb375ee..5968e321ca 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c @@ -51,28 +51,9 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; +const MACAddress_t xDefault_MacAddress = { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 } }; void vPortEnterCritical( void ) { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c index c597fb091f..f420447d65 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_utest.c @@ -200,7 +200,8 @@ void test_FreeRTOS_IPInit_HappyPath( void ) NetworkInterface_t * pxNetworkInterface = &xNetworkInterface; /* Set the local IP to something other than 0. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD; + xFirstEndPoint.ipv4_settings.ulIPAddress = 0xABCD; + pxNetworkEndPoints = &xFirstEndPoint; FreeRTOS_FillEndPoint_Ignore(); FreeRTOS_FirstNetworkInterface_IgnoreAndReturn( pxNetworkInterface ); @@ -254,15 +255,13 @@ void test_FreeRTOS_IPInit_QueueCreationFails( void ) NetworkInterface_t * pxNetworkInterface = &xNetworkInterface; /* Set the local IP to something other than 0. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD; + xFirstEndPoint.ipv4_settings.ulIPAddress = 0xABCD; + pxNetworkEndPoints = &xFirstEndPoint; FreeRTOS_FillEndPoint_Ignore(); FreeRTOS_FirstNetworkInterface_IgnoreAndReturn( pxNetworkInterface ); pxFillInterfaceDescriptor_IgnoreAndReturn( pxNetworkInterface ); - /* Clear default values. */ - memset( ipLOCAL_MAC_ADDRESS, 0, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - vPreCheckConfigs_Expect(); #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -296,15 +295,13 @@ void test_FreeRTOS_IPInit_BufferCreationFails( void ) NetworkInterface_t * pxNetworkInterface = &xNetworkInterface; /* Set the local IP to something other than 0. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD; + xFirstEndPoint.ipv4_settings.ulIPAddress = 0xABCD; + pxNetworkEndPoints = &xFirstEndPoint; FreeRTOS_FillEndPoint_Ignore(); FreeRTOS_FirstNetworkInterface_IgnoreAndReturn( pxNetworkInterface ); pxFillInterfaceDescriptor_IgnoreAndReturn( pxNetworkInterface ); - /* Clear default values. */ - memset( ipLOCAL_MAC_ADDRESS, 0, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - vPreCheckConfigs_Expect(); #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) @@ -346,15 +343,13 @@ void test_FreeRTOS_IPInit_TaskCreationFails( void ) NetworkInterface_t * pxNetworkInterface = &xNetworkInterface; /* Set the local IP to something other than 0. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD; + xFirstEndPoint.ipv4_settings.ulIPAddress = 0xABCD; + pxNetworkEndPoints = &xFirstEndPoint; FreeRTOS_FillEndPoint_Ignore(); FreeRTOS_FirstNetworkInterface_IgnoreAndReturn( pxNetworkInterface ); pxFillInterfaceDescriptor_IgnoreAndReturn( pxNetworkInterface ); - /* Clear default values. */ - memset( ipLOCAL_MAC_ADDRESS, 0, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); - vPreCheckConfigs_Expect(); #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c index d7eb64001a..f35bef3063 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c @@ -49,29 +49,8 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c index 06a271fc9a..15bfe29cc9 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_utest.c @@ -50,7 +50,7 @@ #include "FreeRTOS_IP.h" -/*#include "FreeRTOS_IP_stubs.c" */ +#include "FreeRTOS_IP_DiffConfig2_stubs.c" #include "catch_assert.h" #include "FreeRTOSIPConfig.h" @@ -114,9 +114,11 @@ void test_FreeRTOS_IPInit_HappyPathDHCP( void ) BaseType_t xReturn; QueueHandle_t ulPointerToQueue = ( QueueHandle_t ) 0x1234ABCD; NetworkInterface_t * pxNetworkInterface; + NetworkEndPoint_t xEndPoint = { 0 }; /* Set the local IP to something other than 0. */ - *ipLOCAL_IP_ADDRESS_POINTER = 0xABCD; + xEndPoint.ipv4_settings.ulIPAddress = 0xABCD; + pxNetworkEndPoints = &xEndPoint; FreeRTOS_FillEndPoint_Ignore(); FreeRTOS_FirstNetworkInterface_IgnoreAndReturn( pxNetworkInterface ); diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c index 0ab6842348..ddaffbd0a7 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c @@ -50,29 +50,8 @@ struct xNetworkInterface * pxNetworkInterfaces = NULL; /** @brief A list of all network end-points. Each element has a next pointer. */ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c index 4df9845007..656ced2525 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c @@ -49,31 +49,10 @@ BaseType_t xProcessedTCPMessage; struct xNetworkEndPoint * pxNetworkEndPoints; struct xNetworkInterface * pxNetworkInterfaces; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; QueueHandle_t xNetworkEventQueue; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - void vPortEnterCritical( void ) { } diff --git a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_stubs.c b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_stubs.c index 550f180469..36bc696f2b 100644 --- a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_stubs.c @@ -46,29 +46,8 @@ NetworkInterface_t xInterfaces[ 1 ]; BaseType_t xCallEventHook; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - QueueHandle_t xNetworkEventQueue; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ============================ Stubs Functions =========================== */ BaseType_t xNetworkInterfaceInitialise_returnTrue( NetworkInterface_t * xInterface ) diff --git a/test/unit-test/FreeRTOS_IP_Utils_DiffConfig/FreeRTOS_IP_Utils_DiffConfig_stubs.c b/test/unit-test/FreeRTOS_IP_Utils_DiffConfig/FreeRTOS_IP_Utils_DiffConfig_stubs.c index 0e062aeef0..9415d64743 100644 --- a/test/unit-test/FreeRTOS_IP_Utils_DiffConfig/FreeRTOS_IP_Utils_DiffConfig_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Utils_DiffConfig/FreeRTOS_IP_Utils_DiffConfig_stubs.c @@ -48,30 +48,8 @@ NetworkInterface_t xInterfaces[ 1 ]; BaseType_t xCallEventHook; #endif - -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - QueueHandle_t xNetworkEventQueue; -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ============================ Stubs Functions =========================== */ static BaseType_t xNetworkInterfaceInitialise_test( struct xNetworkInterface * pxDescriptor ) diff --git a/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_stubs.c b/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_stubs.c index 93ce05f992..4f7ffe493c 100644 --- a/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_stubs.c +++ b/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_stubs.c @@ -46,27 +46,6 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; QueueHandle_t xNetworkEventQueue = NULL; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - /* ======================== Stub Callback Functions ========================= */ void vPortEnterCritical( void ) diff --git a/test/unit-test/FreeRTOS_TCP_State_Handling/FreeRTOS_TCP_State_Handling_utest.c b/test/unit-test/FreeRTOS_TCP_State_Handling/FreeRTOS_TCP_State_Handling_utest.c index ea726378f1..41cd1a78ce 100644 --- a/test/unit-test/FreeRTOS_TCP_State_Handling/FreeRTOS_TCP_State_Handling_utest.c +++ b/test/unit-test/FreeRTOS_TCP_State_Handling/FreeRTOS_TCP_State_Handling_utest.c @@ -1774,6 +1774,8 @@ void test_prvTCPSocketCopy_NullSocketSet( void ) pxSocket->pxSocketSet = NULL; pxSocket->xSelectBits = eSELECT_READ; + FreeRTOS_GetLocalAddress_ExpectAndReturn( pxSocket, NULL, pdTRUE ); + FreeRTOS_GetLocalAddress_IgnoreArg_pxAddress(); vSocketBind_ExpectAnyArgsAndReturn( 0 ); Result = prvTCPSocketCopy( &MockReturnSocket, pxSocket ); @@ -1799,6 +1801,8 @@ void test_prvTCPSocketCopy_BindError( void ) pxSocket->pxSocketSet = ( struct xSOCKET_SET * ) 0x1111111; pxSocket->xSelectBits = eSELECT_READ; + FreeRTOS_GetLocalAddress_ExpectAndReturn( pxSocket, NULL, pdTRUE ); + FreeRTOS_GetLocalAddress_IgnoreArg_pxAddress(); vSocketBind_ExpectAnyArgsAndReturn( 1 ); vSocketClose_ExpectAnyArgsAndReturn( NULL ); diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_stubs.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_stubs.c index 126b0f71bf..14958490f5 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_stubs.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_stubs.c @@ -43,7 +43,6 @@ /* ========================= EXTERN VARIABLES ========================= */ /** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) uint16_t usPacketIdentifier; BaseType_t xTCPWindowLoggingLevel; BaseType_t xBufferAllocFixedSize = pdFALSE; diff --git a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_stubs.c b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_stubs.c index ed2baf5ef5..1177c3d519 100644 --- a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_stubs.c +++ b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_stubs.c @@ -14,28 +14,6 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - - /* * IP-clash detection is currently only used internally. When DHCP doesn't respond, the * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a diff --git a/test/unit-test/FreeRTOS_Tiny_TCP/FreeRTOS_Tiny_TCP_stubs.c b/test/unit-test/FreeRTOS_Tiny_TCP/FreeRTOS_Tiny_TCP_stubs.c index d0001cbc63..13f0ee5351 100644 --- a/test/unit-test/FreeRTOS_Tiny_TCP/FreeRTOS_Tiny_TCP_stubs.c +++ b/test/unit-test/FreeRTOS_Tiny_TCP/FreeRTOS_Tiny_TCP_stubs.c @@ -14,28 +14,6 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; -/** @brief The expected IP version and header length coded into the IP header itself. */ -#define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) - -UDPPacketHeader_t xDefaultPartUDPPacketHeader = -{ - /* .ucBytes : */ - { - 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, /* Ethernet source MAC address. */ - 0x08, 0x00, /* Ethernet frame type. */ - ipIP_VERSION_AND_HEADER_LENGTH_BYTE, /* ucVersionHeaderLength. */ - 0x00, /* ucDifferentiatedServicesCode. */ - 0x00, 0x00, /* usLength. */ - 0x00, 0x00, /* usIdentification. */ - 0x00, 0x00, /* usFragmentOffset. */ - ipconfigUDP_TIME_TO_LIVE, /* ucTimeToLive */ - ipPROTOCOL_UDP, /* ucProtocol. */ - 0x00, 0x00, /* usHeaderChecksum. */ - 0x00, 0x00, 0x00, 0x00 /* Source IP address. */ - } -}; - - /* * IP-clash detection is currently only used internally. When DHCP doesn't respond, the * driver can try out a random LinkLayer IP address (169.254.x.x). It will send out a