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 /** Reverse Address Resolution Protocol (RARP) */
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_rarp.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_rarp_disable PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function disables the RARP management component for the */
44 /* specified IP instance. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr IP instance pointer */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* status Completion status */
53 /* */
54 /* CALLS */
55 /* */
56 /* None */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* Application Code */
61 /* */
62 /* RELEASE HISTORY */
63 /* */
64 /* DATE NAME DESCRIPTION */
65 /* */
66 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
67 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
68 /* resulting in version 6.1 */
69 /* */
70 /**************************************************************************/
_nx_rarp_disable(NX_IP * ip_ptr)71 UINT _nx_rarp_disable(NX_IP *ip_ptr)
72 {
73
74 #ifndef NX_DISABLE_IPV4
75 TX_INTERRUPT_SAVE_AREA
76
77 /* If trace is enabled, insert this event into the trace buffer. */
78 NX_TRACE_IN_LINE_INSERT(NX_TRACE_RARP_DISABLE, ip_ptr, 0, 0, 0, NX_TRACE_RARP_EVENTS, 0, 0);
79
80 /* Get mutex protection. */
81 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
82
83 /* Disable interrupts. */
84 TX_DISABLE
85
86 /* Check to see if RARP is enabled. */
87 if (!ip_ptr -> nx_ip_rarp_periodic_update)
88 {
89
90 /* Error, IP instance already has RARP disabled. */
91
92 /* Restore interrupts. */
93 TX_RESTORE
94
95 /* Release protection. */
96 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
97
98 /* Return to caller. */
99 return(NX_NOT_ENABLED);
100 }
101
102 /* Clear the RARP periodic update routine. */
103 ip_ptr -> nx_ip_rarp_periodic_update = NX_NULL;
104
105 /* Clear the RARP queue process routine. */
106 ip_ptr -> nx_ip_rarp_queue_process = NX_NULL;
107
108 /* Restore interrupts. */
109 TX_RESTORE
110
111 /* Release protection. */
112 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
113
114 /* Return successful completion. */
115 return(NX_SUCCESS);
116 #else /* NX_DISABLE_IPV4 */
117 NX_PARAMETER_NOT_USED(ip_ptr);
118
119 return(NX_NOT_SUPPORTED);
120 #endif /* !NX_DISABLE_IPV4 */
121 }
122
123