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 #define NX_SOURCE_CODE
12 
13 
14 /* Include necessary system files.  */
15 
16 #include "nx_api.h"
17 #include "nx_ipv6.h"
18 #include "nx_nd_cache.h"
19 
20 
21 
22 
23 #ifdef FEATURE_NX_IPV6
24 /**************************************************************************/
25 /**************************************************************************/
26 /**                                                                       */
27 /** NetX Component                                                        */
28 /**                                                                       */
29 /**   Internet Protocol version 6 Prefix Table (IPv6 prefix table)        */
30 /**                                                                       */
31 /**************************************************************************/
32 /**************************************************************************/
33 
34 
35 
36 
37 /**************************************************************************/
38 /*                                                                        */
39 /*  FUNCTION                                               RELEASE        */
40 /*                                                                        */
41 /*    _nx_ipv6_prefix_list_delete                         PORTABLE C      */
42 /*                                                           6.1          */
43 /*  AUTHOR                                                                */
44 /*                                                                        */
45 /*    Yuxin Zhou, Microsoft Corporation                                   */
46 /*                                                                        */
47 /*  DESCRIPTION                                                           */
48 /*                                                                        */
49 /*    This internal function deletes an entry from the prefix list based  */
50 /*    on the given prefix.                                                */
51 /*                                                                        */
52 /*                                                                        */
53 /*  INPUT                                                                 */
54 /*                                                                        */
55 /*    ip_ptr                                Pointer to IP control block   */
56 /*    prefix                                128-bit IPv6 prefix.          */
57 /*    prefix_length                         Length of the prefix.         */
58 /*                                                                        */
59 /*  OUTPUT                                                                */
60 /*                                                                        */
61 /*    None                                                                */
62 /*                                                                        */
63 /*  CALLS                                                                 */
64 /*                                                                        */
65 /*    _nx_ipv6_prefix_list_delete_entry     Delete IPv6 prefix entry      */
66 /*                                                                        */
67 /*  CALLED BY                                                             */
68 /*                                                                        */
69 /*    _nx_icmpv6_process_ra                 ICMPv6 Router Advertisement   */
70 /*                                          process routine.              */
71 /*                                                                        */
72 /*  NOTE                                                                  */
73 /*                                                                        */
74 /*    This function cannot be called from ISR.                            */
75 /*                                                                        */
76 /*  RELEASE HISTORY                                                       */
77 /*                                                                        */
78 /*    DATE              NAME                      DESCRIPTION             */
79 /*                                                                        */
80 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
81 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
82 /*                                            resulting in version 6.1    */
83 /*                                                                        */
84 /**************************************************************************/
_nx_ipv6_prefix_list_delete(NX_IP * ip_ptr,ULONG * prefix,INT prefix_length)85 VOID _nx_ipv6_prefix_list_delete(NX_IP *ip_ptr, ULONG *prefix, INT prefix_length)
86 {
87 
88 NX_IPV6_PREFIX_ENTRY *current;
89 
90 
91     /* Quick reference to the head of the prefix list. */
92     current = ip_ptr -> nx_ipv6_prefix_list_ptr;
93 
94     /* Go through all the entries. */
95     while (current)
96     {
97 
98         /* If prefix length matches, and the prefix addresses also match...*/
99         if ((current -> nx_ipv6_prefix_entry_prefix_length == (ULONG)prefix_length) &&
100             CHECK_IPV6_ADDRESSES_SAME(prefix, current -> nx_ipv6_prefix_entry_network_address))
101         {
102 
103             /* Delete this entry. */
104             _nx_ipv6_prefix_list_delete_entry(ip_ptr, current);
105 
106             /* All done. return */
107             return;
108         }
109         /* Move to the next entry. */
110         current = current -> nx_ipv6_prefix_entry_next;
111     }
112 
113     /* No match was found. */
114     return;
115 }
116 
117 
118 #endif /* FEATURE_NX_IPV6 */
119 
120