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 /** Internet Protocol (IP) */
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_ip.h"
30
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _nx_ip_address_get PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* Yuxin Zhou, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function retrieves the IP address and the network mask and */
45 /* returns them to the caller. */
46 /* */
47 /* INPUT */
48 /* */
49 /* ip_ptr IP control block pointer */
50 /* ip_address Pointer to IP address */
51 /* destination */
52 /* network_mask Pointer to network mask */
53 /* destination */
54 /* */
55 /* OUTPUT */
56 /* */
57 /* status Completion status */
58 /* */
59 /* CALLS */
60 /* */
61 /* tx_mutex_get Get protection mutex */
62 /* tx_mutex_put Put protection mutex */
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 /**************************************************************************/
_nx_ip_address_get(NX_IP * ip_ptr,ULONG * ip_address,ULONG * network_mask)77 UINT _nx_ip_address_get(NX_IP *ip_ptr, ULONG *ip_address, ULONG *network_mask)
78 {
79
80 #ifndef NX_DISABLE_IPV4
81 TX_INTERRUPT_SAVE_AREA
82
83 /* Get mutex protection. */
84 tx_mutex_get(&(ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER);
85
86 /* Disable interrupts. */
87 TX_DISABLE
88
89 /* Pickup the IP address and the network mask. This service assumes
90 the operation on the primary interface. */
91 *ip_address = ip_ptr -> nx_ip_interface[0].nx_interface_ip_address;
92 *network_mask = ip_ptr -> nx_ip_interface[0].nx_interface_ip_network_mask;
93
94 /* Restore interrupts. */
95 TX_RESTORE
96
97 /* Release mutex protection. */
98 tx_mutex_put(&(ip_ptr -> nx_ip_protection));
99
100 /* If trace is enabled, insert this event into the trace buffer. */
101 NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_ADDRESS_GET, ip_ptr, ip_ptr -> nx_ip_interface[0].nx_interface_ip_address,
102 ip_ptr -> nx_ip_interface[0].nx_interface_ip_network_mask, 0, NX_TRACE_IP_EVENTS, 0, 0);
103
104 /* Return completion status. */
105 return(NX_SUCCESS);
106 #else /* NX_DISABLE_IPV4 */
107 NX_PARAMETER_NOT_USED(ip_ptr);
108 NX_PARAMETER_NOT_USED(ip_address);
109 NX_PARAMETER_NOT_USED(network_mask);
110
111 return(NX_NOT_SUPPORTED);
112 #endif /* !NX_DISABLE_IPV4 */
113 }
114
115