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