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