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 /** Internet Protocol (IP) */
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_ip.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _nx_ip_gateway_address_clear PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function clears the IPv4 gateway address. */
44 /* */
45 /* INPUT */
46 /* */
47 /* ip_ptr IP control block pointer */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* status Completion status */
52 /* */
53 /* CALLS */
54 /* */
55 /* tx_mutex_get Obtain protection mutex */
56 /* tx_mutex_put Release protection mutex */
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_ip_gateway_address_clear(NX_IP * ip_ptr)71 UINT _nx_ip_gateway_address_clear(NX_IP *ip_ptr)
72 {
73
74 #ifndef NX_DISABLE_IPV4
75 TX_INTERRUPT_SAVE_AREA
76
77
78 /* If trace is enabled, insert this event into the trace buffer. */
79 NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_GATEWAY_ADDRESS_SET, ip_ptr, 0, 0, 0, NX_TRACE_IP_EVENTS, 0, 0);
80
81 /* Obtain the IP internal mutex so the Gateway IP address can be cleared. */
82 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
83
84 /* Disable interrupts. */
85 TX_DISABLE
86
87 /* Clear the Gateway IP address. */
88 ip_ptr -> nx_ip_gateway_address = 0;
89
90 ip_ptr -> nx_ip_gateway_interface = NX_NULL;
91
92 /* Restore interrupts. */
93 TX_RESTORE
94
95 /* Release the protection mutex. */
96 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
97
98 /* Return completion status. */
99 return(NX_SUCCESS);
100 #else /* NX_DISABLE_IPV4 */
101 NX_PARAMETER_NOT_USED(ip_ptr);
102
103 return(NX_NOT_SUPPORTED);
104 #endif /* !NX_DISABLE_IPV4 */
105 }
106
107