@@ -658,10 +658,11 @@ struct xIPv6_Couple
658658 * @brief Check IP-type, IP- and MAC-address found in the network packet.
659659 */
660660 #define rMATCH_IP_ADDR 0 /**< Find an endpoint with a matching IP-address. */
661- #define rMATCH_IPv6_TYPE 1 /**< Find an endpoint with a matching IPv6 type (both global or non global). */
662- #define rMATCH_MAC_ADDR 2 /**< Find an endpoint with a matching MAC-address. */
663- #define rMATCH_IP_TYPE 3 /**< Find an endpoint with a matching IP-type, v4 or v6. */
664- #define rMATCH_COUNT 4 /**< The number of methods. */
661+ #define rMATCH_NETMASK 1 /**< Find an endpoint with a matching NetMask. */
662+ #define rMATCH_IPv6_TYPE 2 /**< Find an endpoint with a matching IPv6 type (both global or non global). */
663+ #define rMATCH_MAC_ADDR 3 /**< Find an endpoint with a matching MAC-address. */
664+ #define rMATCH_IP_TYPE 4 /**< Find an endpoint with a matching IP-type, v4 or v6. */
665+ #define rMATCH_COUNT 5 /**< The number of methods. */
665666
666667 NetworkEndPoint_t * pxEasyFit ( const NetworkInterface_t * pxNetworkInterface ,
667668 const uint16_t usFrameType ,
@@ -688,9 +689,9 @@ struct xIPv6_Couple
688689 {
689690 NetworkEndPoint_t * pxEndPoint ;
690691 NetworkEndPoint_t * pxReturn = NULL ;
691- /* endpoints found for IP-type, IP-address, and MAC-address. */
692- NetworkEndPoint_t * pxFound [ rMATCH_COUNT ] = { NULL , NULL , NULL , NULL };
693- BaseType_t xCount [ rMATCH_COUNT ] = { 0 , 0 , 0 , 0 };
692+ /* endpoints found for IP-type, IP-address, NetMask and MAC-address. */
693+ NetworkEndPoint_t * pxFound [ rMATCH_COUNT ] = { NULL , NULL , NULL , NULL , NULL };
694+ BaseType_t xCount [ rMATCH_COUNT ] = { 0 , 0 , 0 , 0 , 0 };
694695 BaseType_t xIndex ;
695696 BaseType_t xIsIPv6 = ( usFrameType == ipIPv6_FRAME_TYPE ) ? pdTRUE : pdFALSE ;
696697 BaseType_t xGatewayTarget = pdFALSE ;
@@ -778,6 +779,11 @@ struct xIPv6_Couple
778779 pxFound [ rMATCH_IP_ADDR ] = pxEndPoint ;
779780 xCount [ rMATCH_IP_ADDR ]++ ;
780781 }
782+ else if ( FreeRTOS_InterfaceEndPointOnNetMask ( pxNetworkInterface , pxIPAddressFrom -> ulIP_IPv4 ) == pxEndPoint )
783+ {
784+ pxFound [ rMATCH_NETMASK ] = pxEndPoint ;
785+ xCount [ rMATCH_NETMASK ]++ ;
786+ }
781787 else
782788 {
783789 /* do nothing, coverity happy */
@@ -907,25 +913,8 @@ struct xIPv6_Couple
907913 /* Handle ARP frame types if ipconfigUSE_IPv4 != 0 */
908914 #if ( ipconfigUSE_IPv4 != 0 )
909915 {
910- /* MISRA Ref 11.3.1 [Misaligned access] */
911- /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */
912- /* coverity[misra_c_2012_rule_11_3_violation] */
913- const ARPPacket_t * pxARPFrame = ( const ARPPacket_t * ) pucEthernetBuffer ;
914-
915- if ( pxARPFrame -> xARPHeader .usOperation == ( uint16_t ) ipARP_REQUEST )
916- {
917- ( void ) memcpy ( xIPAddressFrom .xIP_IPv6 .ucBytes , pxPacket -> xARPPacket .xARPHeader .ucSenderProtocolAddress , sizeof ( uint32_t ) );
918- xIPAddressTo .ulIP_IPv4 = pxPacket -> xARPPacket .xARPHeader .ulTargetProtocolAddress ;
919- }
920- else if ( pxARPFrame -> xARPHeader .usOperation == ( uint16_t ) ipARP_REPLY )
921- {
922- ( void ) memcpy ( xIPAddressTo .xIP_IPv6 .ucBytes , pxPacket -> xARPPacket .xARPHeader .ucSenderProtocolAddress , sizeof ( uint32_t ) );
923- xIPAddressFrom .ulIP_IPv4 = pxPacket -> xARPPacket .xARPHeader .ulTargetProtocolAddress ;
924- }
925- else
926- {
927- /* do nothing, coverity happy */
928- }
916+ ( void ) memcpy ( xIPAddressFrom .xIP_IPv6 .ucBytes , pxPacket -> xARPPacket .xARPHeader .ucSenderProtocolAddress , sizeof ( uint32_t ) );
917+ xIPAddressTo .ulIP_IPv4 = pxPacket -> xARPPacket .xARPHeader .ulTargetProtocolAddress ;
929918
930919 FreeRTOS_debug_printf ( ( "pxEasyFit: ARP %xip -> %xip\n" , ( unsigned ) FreeRTOS_ntohl ( xIPAddressFrom .ulIP_IPv4 ), ( unsigned ) FreeRTOS_ntohl ( xIPAddressTo .ulIP_IPv4 ) ) );
931920 }
0 commit comments