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 /** */
15 /** NetX Component */
16 /** */
17 /** Neighbor Discovery Cache */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define NX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "nx_api.h"
28 #include "nx_nd_cache.h"
29 #ifdef FEATURE_NX_IPV6
30 #include "nx_ipv6.h"
31 #endif /* FEATURE_NX_IPV6 */
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _nxd_nd_cache_entry_delete PORTABLE C */
38 /* 6.1 */
39 /* AUTHOR */
40 /* */
41 /* Yuxin Zhou, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function deletes an entry in the ND cache table. */
46 /* */
47 /* INPUT */
48 /* */
49 /* ip_ptr Pointer to IP instance */
50 /* dest_ip Pointer to IP address to */
51 /* be deleted */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* status Completion status */
56 /* */
57 /* CALLS */
58 /* */
59 /* tx_mutex_get Obtain protection mutex */
60 /* tx_mutex_put Release protection mutex */
61 /* _nx_nd_cache_delete_internal Actual function to add an */
62 /* entry to the cache. */
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_entry_delete(NX_IP * ip_ptr,ULONG * dest_ip)77 UINT _nxd_nd_cache_entry_delete(NX_IP *ip_ptr, ULONG *dest_ip)
78 {
79 #ifdef FEATURE_NX_IPV6
80 UINT status;
81 ND_CACHE_ENTRY *entry;
82
83 /* Obtain the protection. */
84 tx_mutex_get(&ip_ptr -> nx_ip_protection, TX_WAIT_FOREVER);
85
86 /* If trace is enabled, insert this event into the trace buffer. */
87 NX_TRACE_IN_LINE_INSERT(NXD_TRACE_ND_CACHE_DELETE, dest_ip[3], 0, 0, 0, NX_TRACE_ARP_EVENTS, 0, 0);
88
89 /* If not found in the ND cache return an error status. */
90 if (_nx_nd_cache_find_entry(ip_ptr, dest_ip, &entry) != NX_SUCCESS)
91 {
92
93 /* Release the protection. */
94 tx_mutex_put(&ip_ptr -> nx_ip_protection);
95 return(NX_ENTRY_NOT_FOUND);
96 }
97
98 /*lint -e{644} suppress variable might not be initialized, since "entry" was initialized as long as previous call is NX_SUCCESS. */
99 status = _nx_nd_cache_delete_internal(ip_ptr, entry);
100
101 /* Release the protection. */
102 tx_mutex_put(&ip_ptr -> nx_ip_protection);
103
104 return(status);
105
106 #else /* !FEATURE_NX_IPV6 */
107 NX_PARAMETER_NOT_USED(ip_ptr);
108 NX_PARAMETER_NOT_USED(dest_ip);
109
110 return(NX_NOT_SUPPORTED);
111
112 #endif /* FEATURE_NX_IPV6 */
113 }
114
115