From 3e6376510a17398574fe6469e069ff6753764cd7 Mon Sep 17 00:00:00 2001 From: Stefan Baltruweit Date: Thu, 12 Sep 2024 13:54:04 +0200 Subject: [PATCH] Fix Zynq7000 EMAC MAC address setup Set solicited-node addresses independent of LLMNR. For mDNS set IPv4/6 MAC depending on ipconfigUSE_IPv6. --- .../NetworkInterface/Zynq/NetworkInterface.c | 55 +++++++++++-------- 1 file changed, 32 insertions(+), 23 deletions(-) diff --git a/source/portable/NetworkInterface/Zynq/NetworkInterface.c b/source/portable/NetworkInterface/Zynq/NetworkInterface.c index 21ad820ce..7cf063df6 100644 --- a/source/portable/NetworkInterface/Zynq/NetworkInterface.c +++ b/source/portable/NetworkInterface/Zynq/NetworkInterface.c @@ -256,43 +256,52 @@ static BaseType_t xZynqNetworkInterfaceInitialise( NetworkInterface_t * pxInterf #if ( ipconfigUSE_LLMNR == 1 ) { - /* Also add LLMNR multicast MAC address. */ #if ( ipconfigUSE_IPv6 == 0 ) { XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddress.ucBytes ); } #else { - NetworkEndPoint_t * pxEndPoint; - NetworkInterface_t * pxInterface = pxMyInterfaces[ xEMACIndex ]; - - for( pxEndPoint = FreeRTOS_FirstEndPoint( pxInterface ); - pxEndPoint != NULL; - pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ) ) - { - if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - unsigned char ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress ); - } - } - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes ); } #endif /* if ( ipconfigUSE_IPv6 == 0 ) */ } #endif /* ipconfigUSE_LLMNR == 1 */ - #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes ); - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes ); - #endif + #if ( ipconfigUSE_MDNS == 1 ) + { + #if ( ipconfigUSE_IPv6 == 0 ) + { + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes ); + } + #else + { + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddressIPv6.ucBytes ); + } + #endif /* if ( ipconfigUSE_IPv6 == 0 ) */ + } + #endif /* ( ipconfigUSE_MDNS == 1 ) */ - pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ); + #if ( ipconfigUSE_IPv6 != 0 ) + { + /* set the solicited-node multicast address */ + for( NetworkEndPoint_t * pxEndPointIter = FreeRTOS_FirstEndPoint( pxInterface ); + pxEndPointIter != NULL; + pxEndPointIter = FreeRTOS_NextEndPoint( pxInterface, pxEndPointIter ) ) + { + if( pxEndPointIter->bits.bIPv6 != pdFALSE_UNSIGNED ) + { + unsigned char ucSsolicitedNodeMAC[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + ucSsolicitedNodeMAC[ 3 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucSsolicitedNodeMAC[ 4 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucSsolicitedNodeMAC[ 5 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucSsolicitedNodeMAC ); + } + } + } + #endif /* if ( ipconfigUSE_IPv6 == 0 ) */ + pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ); if( pxEndPoint != NULL ) { /* If there is a second end-point, store the MAC