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 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Neighbor Discovery Cache                                            */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define NX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "nx_api.h"
29 #include "nx_nd_cache.h"
30 #ifdef FEATURE_NX_IPV6
31 #include "nx_ipv6.h"
32 #endif /* FEATURE_NX_IPV6 */
33 
34 
35 /**************************************************************************/
36 /*                                                                        */
37 /*  FUNCTION                                               RELEASE        */
38 /*                                                                        */
39 /*    _nxd_nd_cache_invalidate                            PORTABLE C      */
40 /*                                                           6.1          */
41 /*  AUTHOR                                                                */
42 /*                                                                        */
43 /*    Yuxin Zhou, Microsoft Corporation                                   */
44 /*                                                                        */
45 /*  DESCRIPTION                                                           */
46 /*                                                                        */
47 /*    This function invalidates the entire IPv6 Neighbor Discovery cache. */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    ip_ptr                                Pointer to IP instance        */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    NX_SUCCESS                            Successful completion status  */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    tx_mutex_get                          Obtain protection mutex       */
60 /*    tx_mutex_put                          Release protection mutex      */
61 /*    _nxd_nd_cache_invalidate_internal     Actual cache table invalidate */
62 /*                                          service                       */
63 /*                                                                        */
64 /*  CALLED BY                                                             */
65 /*                                                                        */
66 /*    Application Code                                                    */
67 /*                                                                        */
68 /*  RELEASE HISTORY                                                       */
69 /*                                                                        */
70 /*    DATE              NAME                      DESCRIPTION             */
71 /*                                                                        */
72 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
73 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
74 /*                                            resulting in version 6.1    */
75 /*                                                                        */
76 /**************************************************************************/
_nxd_nd_cache_invalidate(NX_IP * ip_ptr)77 UINT _nxd_nd_cache_invalidate(NX_IP *ip_ptr)
78 {
79 
80 #ifdef FEATURE_NX_IPV6
81 INT idx;
82 
83     /* If trace is enabled, insert this event into the trace buffer.  */
84     NX_TRACE_IN_LINE_INSERT(NXD_TRACE_ND_CACHE_INVALIDATE, ip_ptr, 0, 0, 0, NX_TRACE_ARP_EVENTS, 0, 0);
85 
86     /* Obtain the protection. */
87     tx_mutex_get(&ip_ptr -> nx_ip_protection, TX_WAIT_FOREVER);
88 
89     /* Invalidate all entries. */
90     for (idx = 0; idx < NX_IPV6_NEIGHBOR_CACHE_SIZE; idx++)
91     {
92         _nx_nd_cache_delete_internal(ip_ptr, &(ip_ptr -> nx_ipv6_nd_cache[idx]));
93     }
94 
95     /* Release the protection. */
96     tx_mutex_put(&ip_ptr -> nx_ip_protection);
97 
98     return(NX_SUCCESS);
99 
100 #else /* !FEATURE_NX_IPV6 */
101 
102     NX_PARAMETER_NOT_USED(ip_ptr);
103 
104     return(NX_NOT_SUPPORTED);
105 
106 #endif /* FEATURE_NX_IPV6 */
107 }
108 
109