diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index 2a2a22dfa..07b8f60e4 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -1715,13 +1715,16 @@ static eFrameProcessingResult_t prvProcessUDPPacket( NetworkBufferDescriptor_t * { eReturn = eReleaseBuffer; } - else if( ( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && - ( xBadIPv4Loopback( &( pxUDPPacket->xIPHeader ) ) != pdFALSE ) ) - { - /* The local loopback addresses must never appear outside a host. See RFC 1122 - * section 3.2.1.3. */ - eReturn = eReleaseBuffer; - } + + #if ( ipconfigUSE_IPv4 != 0 ) + else if( ( pxUDPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && + ( xBadIPv4Loopback( &( pxUDPPacket->xIPHeader ) ) != pdFALSE ) ) + { + /* The local loopback addresses must never appear outside a host. See RFC 1122 + * section 3.2.1.3. */ + eReturn = eReleaseBuffer; + } + #endif else if( ( pxNetworkBuffer->xDataLength >= uxMinSize ) && ( uxLength >= sizeof( UDPHeader_t ) ) ) { diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index 34fa47a67..82c49e2f4 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -1432,47 +1432,47 @@ struct xIPv6_Couple * @returns The IP type of the given address. */ #if ( ipconfigUSE_IPv6 != 0 ) -IPv6_Type_t xIPv6_GetIPType( const IPv6_Address_t * pxAddress ) -{ - IPv6_Type_t eResult = eIPv6_Unknown; - BaseType_t xIndex; - static const struct xIPv6_Couple xIPCouples[] = - { - /* IP-type Mask Value */ - { eIPv6_Global, 0xE000U, 0x2000U }, /* 001 */ - { eIPv6_LinkLocal, 0xFFC0U, 0xFE80U }, /* 1111 1110 10 */ - { eIPv6_SiteLocal, 0xFFC0U, 0xFEC0U }, /* 1111 1110 11 */ - { eIPv6_Multicast, 0xFF00U, 0xFF00U }, /* 1111 1111 */ - { eIPv6_Loopback, 0xFFFFU, 0x0000U }, /* 0000 0000 ::1 */ - }; - - if( pxAddress != NULL ) + IPv6_Type_t xIPv6_GetIPType( const IPv6_Address_t * pxAddress ) { - for( xIndex = 0; xIndex < ARRAY_SIZE_X( xIPCouples ); xIndex++ ) + IPv6_Type_t eResult = eIPv6_Unknown; + BaseType_t xIndex; + static const struct xIPv6_Couple xIPCouples[] = { - uint16_t usAddress = - ( uint16_t ) ( ( ( ( uint16_t ) pxAddress->ucBytes[ 0 ] ) << 8 ) | - ( ( uint16_t ) pxAddress->ucBytes[ 1 ] ) ); - - if( xIPCouples[ xIndex ].eType == eIPv6_Loopback ) + /* IP-type Mask Value */ + { eIPv6_Global, 0xE000U, 0x2000U }, /* 001 */ + { eIPv6_LinkLocal, 0xFFC0U, 0xFE80U }, /* 1111 1110 10 */ + { eIPv6_SiteLocal, 0xFFC0U, 0xFEC0U }, /* 1111 1110 11 */ + { eIPv6_Multicast, 0xFF00U, 0xFF00U }, /* 1111 1111 */ + { eIPv6_Loopback, 0xFFFFU, 0x0000U }, /* 0000 0000 ::1 */ + }; + + if( pxAddress != NULL ) + { + for( xIndex = 0; xIndex < ARRAY_SIZE_X( xIPCouples ); xIndex++ ) { - if( xIsIPv6Loopback( pxAddress ) != pdFALSE ) + uint16_t usAddress = + ( uint16_t ) ( ( ( ( uint16_t ) pxAddress->ucBytes[ 0 ] ) << 8 ) | + ( ( uint16_t ) pxAddress->ucBytes[ 1 ] ) ); + + if( xIPCouples[ xIndex ].eType == eIPv6_Loopback ) { - eResult = eIPv6_Loopback; - break; + if( xIsIPv6Loopback( pxAddress ) != pdFALSE ) + { + eResult = eIPv6_Loopback; + break; + } } - } - if( ( usAddress & xIPCouples[ xIndex ].usMask ) == xIPCouples[ xIndex ].usExpected ) - { - eResult = xIPCouples[ xIndex ].eType; - break; + if( ( usAddress & xIPCouples[ xIndex ].usMask ) == xIPCouples[ xIndex ].usExpected ) + { + eResult = xIPCouples[ xIndex ].eType; + break; + } } } - } - return eResult; -} + return eResult; + } #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ /*-----------------------------------------------------------*/