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 /* FUNCTION RELEASE */
37 /* */
38 /* _nxd_nd_cache_entry_delete PORTABLE C */
39 /* 6.1 */
40 /* AUTHOR */
41 /* */
42 /* Yuxin Zhou, Microsoft Corporation */
43 /* */
44 /* DESCRIPTION */
45 /* */
46 /* This function deletes an entry in the ND cache table. */
47 /* */
48 /* INPUT */
49 /* */
50 /* ip_ptr Pointer to IP instance */
51 /* dest_ip Pointer to IP address to */
52 /* be deleted */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* status Completion status */
57 /* */
58 /* CALLS */
59 /* */
60 /* tx_mutex_get Obtain protection mutex */
61 /* tx_mutex_put Release protection mutex */
62 /* _nx_nd_cache_delete_internal Actual function to add an */
63 /* entry to the cache. */
64 /* */
65 /* CALLED BY */
66 /* */
67 /* Application Code */
68 /* */
69 /* RELEASE HISTORY */
70 /* */
71 /* DATE NAME DESCRIPTION */
72 /* */
73 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
74 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
75 /* resulting in version 6.1 */
76 /* */
77 /**************************************************************************/
_nxd_nd_cache_entry_delete(NX_IP * ip_ptr,ULONG * dest_ip)78 UINT _nxd_nd_cache_entry_delete(NX_IP *ip_ptr, ULONG *dest_ip)
79 {
80 #ifdef FEATURE_NX_IPV6
81 UINT status;
82 ND_CACHE_ENTRY *entry;
83
84 /* Obtain the protection. */
85 tx_mutex_get(&ip_ptr -> nx_ip_protection, TX_WAIT_FOREVER);
86
87 /* If trace is enabled, insert this event into the trace buffer. */
88 NX_TRACE_IN_LINE_INSERT(NXD_TRACE_ND_CACHE_DELETE, dest_ip[3], 0, 0, 0, NX_TRACE_ARP_EVENTS, 0, 0);
89
90 /* If not found in the ND cache return an error status. */
91 if (_nx_nd_cache_find_entry(ip_ptr, dest_ip, &entry) != NX_SUCCESS)
92 {
93
94 /* Release the protection. */
95 tx_mutex_put(&ip_ptr -> nx_ip_protection);
96 return(NX_ENTRY_NOT_FOUND);
97 }
98
99 /*lint -e{644} suppress variable might not be initialized, since "entry" was initialized as long as previous call is NX_SUCCESS. */
100 status = _nx_nd_cache_delete_internal(ip_ptr, entry);
101
102 /* Release the protection. */
103 tx_mutex_put(&ip_ptr -> nx_ip_protection);
104
105 return(status);
106
107 #else /* !FEATURE_NX_IPV6 */
108 NX_PARAMETER_NOT_USED(ip_ptr);
109 NX_PARAMETER_NOT_USED(dest_ip);
110
111 return(NX_NOT_SUPPORTED);
112
113 #endif /* FEATURE_NX_IPV6 */
114 }
115
116