1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 /**************************************************************************/ 12 /**************************************************************************/ 13 /** */ 14 /** NetX Component */ 15 /** */ 16 /** Internet Control Message Protocol (ICMP) */ 17 /** */ 18 /**************************************************************************/ 19 /**************************************************************************/ 20 21 #define NX_SOURCE_CODE 22 23 24 /* Include necessary system files. */ 25 #include "nx_api.h" 26 #include "nx_ipv6.h" 27 #include "nx_icmpv6.h" 28 29 #ifdef FEATURE_NX_IPV6 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _nx_invalidate_destination_entry PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Yuxin Zhou, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function invalidates all destination entries whose next hop */ 44 /* address matches the supplied IP address regardless of the */ 45 /* destination address. */ 46 /* */ 47 /* INPUT */ 48 /* */ 49 /* ip_ptr Pointer to IP */ 50 /* next_hop_ip The next hop address to find */ 51 /* */ 52 /* OUTPUT */ 53 /* */ 54 /* NONE */ 55 /* */ 56 /* CALLS */ 57 /* */ 58 /* */ 59 /* CALLED BY */ 60 /* */ 61 /* _nd_cache_delete Delete a neighbor cache. */ 62 /* */ 63 /* RELEASE HISTORY */ 64 /* */ 65 /* DATE NAME DESCRIPTION */ 66 /* */ 67 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 68 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 69 /* resulting in version 6.1 */ 70 /* */ 71 /**************************************************************************/ _nx_invalidate_destination_entry(NX_IP * ip_ptr,ULONG * next_hop_ip)72VOID _nx_invalidate_destination_entry(NX_IP *ip_ptr, ULONG *next_hop_ip) 73 { 74 75 UINT i, table_size; 76 77 /* Set a local variable for convenience. */ 78 table_size = ip_ptr -> nx_ipv6_destination_table_size; 79 80 /* Check if there have been any destinations in the table. */ 81 if (table_size == 0) 82 { 83 return; 84 } 85 86 /* Loop through the whole table to match the IP address. */ 87 for (i = 0; table_size && (i < NX_IPV6_DESTINATION_TABLE_SIZE); i++) 88 { 89 90 /* Skip over empty slots. */ 91 if (!ip_ptr -> nx_ipv6_destination_table[i].nx_ipv6_destination_entry_valid) 92 { 93 continue; 94 } 95 96 /* Keep track of valid entries we have checked. */ 97 table_size--; 98 99 /* Match the supplied next hop with the table entry next hop. */ 100 if (CHECK_IPV6_ADDRESSES_SAME(ip_ptr -> nx_ipv6_destination_table[i].nx_ipv6_destination_entry_next_hop, next_hop_ip)) 101 { 102 103 /* A matching entry is found. Mark the entry as invalid. */ 104 ip_ptr -> nx_ipv6_destination_table[i].nx_ipv6_destination_entry_valid = 0; 105 106 /* Decrease the count of available destinations. */ 107 ip_ptr -> nx_ipv6_destination_table_size--; 108 } 109 } 110 111 return; 112 } 113 114 #endif /* FEATURE_NX_IPV6 */ 115 116