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_interface_info_get PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* Yuxin Zhou, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function retrieves information related to a specified */
44 /* interface. */
45 /* */
46 /* INPUT */
47 /* */
48 /* ip_ptr IP control block pointer */
49 /* interface_index Index to the interface */
50 /* interface_name Name of the interface */
51 /* ip_address Pointer to interface IP */
52 /* address in host byte order */
53 /* network_mask Pointer to network mask */
54 /* destination, in host */
55 /* byte order */
56 /* mtu_size Pointer to storage space */
57 /* for MTU */
58 /* physical_address_msw Pointer to storage space for */
59 /* device phsyical address, MSW*/
60 /* physical_address_lsw Pointer to storage space for */
61 /* device phsyical address, LSW*/
62 /* */
63 /* OUTPUT */
64 /* */
65 /* status Completion status */
66 /* */
67 /* CALLS */
68 /* */
69 /* None */
70 /* */
71 /* CALLED BY */
72 /* */
73 /* Application Code */
74 /* */
75 /* RELEASE HISTORY */
76 /* */
77 /* DATE NAME DESCRIPTION */
78 /* */
79 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */
80 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
81 /* resulting in version 6.1 */
82 /* */
83 /**************************************************************************/
_nx_ip_interface_info_get(NX_IP * ip_ptr,UINT interface_index,CHAR ** interface_name,ULONG * ip_address,ULONG * network_mask,ULONG * mtu_size,ULONG * physical_address_msw,ULONG * physical_address_lsw)84 UINT _nx_ip_interface_info_get(NX_IP *ip_ptr, UINT interface_index, CHAR **interface_name,
85 ULONG *ip_address, ULONG *network_mask, ULONG *mtu_size,
86 ULONG *physical_address_msw, ULONG *physical_address_lsw)
87 {
88 NX_INTERFACE *nx_interface;
89
90 #ifdef NX_DISABLE_IPV4
91 NX_PARAMETER_NOT_USED(ip_address);
92 NX_PARAMETER_NOT_USED(network_mask);
93 #endif /* NX_DISABLE_IPV4 */
94
95 nx_interface = &(ip_ptr -> nx_ip_interface[interface_index]);
96
97 if (!nx_interface -> nx_interface_valid)
98 {
99 return(NX_INVALID_INTERFACE);
100 }
101
102 if (interface_name)
103 {
104 *interface_name = nx_interface -> nx_interface_name;
105 }
106
107 #ifndef NX_DISABLE_IPV4
108 if (ip_address)
109 {
110 *ip_address = nx_interface -> nx_interface_ip_address;
111 }
112
113 if (network_mask)
114 {
115 *network_mask = nx_interface -> nx_interface_ip_network_mask;
116 }
117 #endif /* !NX_DISABLE_IPV4 */
118
119 if (mtu_size)
120 {
121 *mtu_size = nx_interface -> nx_interface_ip_mtu_size;
122 }
123
124 if (physical_address_msw)
125 {
126 *physical_address_msw = nx_interface -> nx_interface_physical_address_msw;
127 }
128
129 if (physical_address_lsw)
130 {
131 *physical_address_lsw = nx_interface -> nx_interface_physical_address_lsw;
132 }
133
134 #ifndef NX_DISABLE_IPV4
135 /* If trace is enabled, insert this event into the trace buffer. */
136 NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_INTERFACE_INFO_GET, ip_ptr, nx_interface -> nx_interface_ip_address,
137 nx_interface -> nx_interface_physical_address_msw, nx_interface -> nx_interface_physical_address_lsw,
138 NX_TRACE_IP_EVENTS, 0, 0);
139 #else
140 /* If trace is enabled, insert this event into the trace buffer. */
141 NX_TRACE_IN_LINE_INSERT(NX_TRACE_IP_INTERFACE_INFO_GET, ip_ptr, 0,
142 nx_interface -> nx_interface_physical_address_msw, nx_interface -> nx_interface_physical_address_lsw,
143 NX_TRACE_IP_EVENTS, 0, 0);
144 #endif /* NX_DISABLE_IPV4 */
145
146
147 return(NX_SUCCESS);
148 }
149
150