Print this page
7388 Support DHCP Client FQDN. Allow IAID/DUID for all v4.
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/cmd-inet/lib/nwamd/ncu.h
+++ new/usr/src/cmd/cmd-inet/lib/nwamd/ncu.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
24 + * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
24 25 */
25 26
26 27 #ifndef _NCU_H
27 28 #define _NCU_H
28 29
29 30 #include <dhcpagent_ipc.h>
30 31 #include <dhcpagent_util.h>
31 32 #include <libdladm.h>
32 33 #include <libdlpi.h>
33 34 #include <libdlwlan.h>
34 35 #include <libinetutil.h>
35 36 #include <libipadm.h>
36 37 #include <libnwam.h>
37 38 #include <libnwam_priv.h>
38 39 #include <libuutil.h>
39 40 #include <pthread.h>
40 41 #include <sys/mac.h>
41 42
42 43 #include "events.h"
43 44
44 45 extern pthread_mutex_t active_ncp_mutex;
45 46 extern pthread_mutex_t active_loc_mutex;
46 47 extern char active_loc[];
47 48 extern uint64_t wireless_scan_interval;
48 49 extern dladm_wlan_strength_t wireless_scan_level;
49 50 extern boolean_t wireless_autoconf;
50 51 extern boolean_t wireless_strict_bssid;
51 52
52 53 /*
53 54 * NCPs are collections of NCUs. At the moment there is one NCP in the system
54 55 * and its expected there will never be many. There is a lock on the NCP which
55 56 * must be obtained to add or remove anything from the NCP.
56 57 *
57 58 * NCUs are also kept in a uu list for easy walking. Each NCU has a lock which
58 59 * is used to protect manipulation of its contents. One of its members is a
59 60 * reference count which is initialized to 1 when its placed on the NCP. As
60 61 * references are passed around that should be manipulated as necessary
61 62 * (helper functions YYY provided). It is removed from the NCP by
62 63 * ncu_destroy() but the memory containing it is not returned to the free pool
63 64 * until the reference count falls to 0.
64 65 *
65 66 * As we add
66 67 * more complex system objects their relationship becomes more complex. That
67 68 * is represented by the links within the NCUs. Reference counts should be
68 69 * used to maintain the consistency of these links. Care should be used when
69 70 * walking more complex structures that might contain cycles.
70 71 */
71 72
72 73 /* Stores details of last/current WiFi scans */
73 74 typedef struct nwamd_wifi_scan {
74 75 char nwamd_wifi_scan_link[NWAM_MAX_NAME_LEN];
75 76 nwam_wlan_t nwamd_wifi_scan_last[NWAMD_MAX_NUM_WLANS];
76 77 uint_t nwamd_wifi_scan_last_num;
77 78 nwam_wlan_t nwamd_wifi_scan_curr[NWAMD_MAX_NUM_WLANS];
78 79 uint_t nwamd_wifi_scan_curr_num;
79 80 boolean_t nwamd_wifi_scan_changed;
80 81 uint32_t nwamd_wifi_scan_last_time;
81 82 } nwamd_wifi_scan_t;
82 83
83 84 typedef struct nwamd_link {
84 85 pthread_mutex_t nwamd_link_wifi_mutex;
85 86 pthread_t nwamd_link_wifi_scan_thread;
86 87 pthread_t nwamd_link_wifi_monitor_thread;
87 88 char nwamd_link_wifi_essid[DLADM_STRSIZE];
88 89 char nwamd_link_wifi_bssid[DLADM_STRSIZE];
89 90 char nwamd_link_wifi_keyname[DLADM_STRSIZE];
90 91 char nwamd_link_wifi_signal_strength[DLADM_STRSIZE];
91 92 boolean_t nwamd_link_wifi_add_to_known_wlans;
92 93 boolean_t nwamd_link_wifi_connected;
93 94 uint32_t nwamd_link_wifi_security_mode;
94 95 dladm_wlan_key_t *nwamd_link_wifi_key;
95 96 nwamd_wifi_scan_t nwamd_link_wifi_scan;
96 97 uint64_t nwamd_link_wifi_priority;
97 98 boolean_t nwamd_link_wifi_autoconf;
98 99 uint32_t nwamd_link_id;
99 100 uint32_t nwamd_link_media;
100 101 uint64_t nwamd_link_flags;
101 102 dlpi_handle_t nwamd_link_dhp;
102 103 pthread_t nwamd_link_dlpi_thread;
103 104 uint64_t nwamd_link_activation_mode;
104 105 uint64_t nwamd_link_priority_mode;
105 106 uint64_t nwamd_link_priority_group;
106 107 char *nwamd_link_mac_addr;
107 108 size_t nwamd_link_mac_addr_len;
108 109 uint64_t nwamd_link_mtu;
109 110 char **nwamd_link_autopush;
110 111 uint_t nwamd_link_num_autopush;
111 112 } nwamd_link_t;
112 113
113 114 struct nwamd_if_address {
114 115 sa_family_t family;
115 116 ipadm_addr_type_t ipaddr_atype;
116 117 ipadm_addrobj_t ipaddr;
117 118 boolean_t configured;
118 119 struct sockaddr_storage conf_addr; /* address configured for */
119 120 struct sockaddr_storage conf_stateless_addr; /* this nwamd_if_address */
120 121 struct nwamd_if_address *next;
121 122 };
122 123
123 124 typedef struct nwamd_if {
124 125 boolean_t nwamd_if_dhcp_requested;
125 126 boolean_t nwamd_if_dhcp_configured;
126 127 boolean_t nwamd_if_stateful_requested;
127 128 boolean_t nwamd_if_stateful_configured;
128 129 boolean_t nwamd_if_stateless_requested;
129 130 boolean_t nwamd_if_stateless_configured;
130 131 struct nwamd_if_address *nwamd_if_list;
131 132 struct sockaddr_in nwamd_if_ipv4_default_route;
132 133 boolean_t nwamd_if_ipv4_default_route_set;
133 134 struct sockaddr_in6 nwamd_if_ipv6_default_route;
134 135 boolean_t nwamd_if_ipv6_default_route_set;
135 136 boolean_t nwamd_if_ipv4;
136 137 boolean_t nwamd_if_ipv6;
137 138 } nwamd_if_t;
138 139
139 140 typedef struct nwamd_ncu {
140 141 nwam_ncu_type_t ncu_type;
141 142 char *ncu_name;
142 143 char ncu_parent[NWAM_MAX_NAME_LEN];
143 144 boolean_t ncu_enabled; /* whether NCU has been enabled or not */
144 145 union {
145 146 nwamd_link_t u_link;
146 147 nwamd_if_t u_if;
147 148 } ncu_node;
148 149 } nwamd_ncu_t;
149 150
150 151 #define ncu_link ncu_node.u_link
151 152 #define ncu_if ncu_node.u_if
152 153
153 154 #define LOOPBACK_IF "lo0"
154 155
155 156 struct nwamd_dhcp_thread_arg {
156 157 char *name;
157 158 dhcp_ipc_type_t type;
158 159 ipadm_addrobj_t ipaddr;
159 160 volatile uint32_t *guard;
160 161 };
161 162
162 163 #define WIRELESS_SCAN_INTERVAL_DEFAULT 120
163 164 #define WIRELESS_SCAN_INTERVAL_MIN 30
164 165 #define WIRELESS_SCAN_REQUESTED_INTERVAL_MIN 10
165 166 #define WIRELESS_MONITOR_SIGNAL_INTERVAL 10
166 167 #define WIRELESS_RETRY_INTERVAL 30
167 168 #define WIRELESS_SCAN_LEVEL_DEFAULT DLADM_WLAN_STRENGTH_WEAK
168 169 #define NWAMD_DHCP_RETRIES 5
169 170 #define NWAMD_DHCP_RETRY_WAIT_TIME 10
170 171 #define NWAMD_READONLY_RETRY_INTERVAL 5
171 172
172 173 /*
173 174 * This dladm and ipadm handles are opened before interfaces are initialized
174 175 * and closed only when nwamd shuts down.
175 176 */
176 177 extern dladm_handle_t dld_handle;
177 178 extern ipadm_handle_t ipadm_handle;
178 179
179 180 extern nwamd_object_t nwamd_ncu_object_find(nwam_ncu_type_t, const char *);
180 181 extern void nwamd_log_ncus(void);
181 182 extern void nwamd_ncu_free(nwamd_ncu_t *);
182 183
183 184 /* WLAN functions */
184 185 extern void nwamd_set_selected_connected(nwamd_ncu_t *, boolean_t, boolean_t);
185 186 extern nwam_error_t nwamd_wlan_select(const char *, const char *, const char *,
186 187 uint32_t, boolean_t);
187 188 extern nwam_error_t nwamd_wlan_set_key(const char *, const char *, const char *,
188 189 uint32_t, uint_t, char *);
189 190 extern nwam_error_t nwamd_wlan_scan(const char *);
190 191 extern void nwamd_wlan_connect(const char *);
191 192 extern boolean_t nwamd_wlan_connected(nwamd_object_t);
192 193 extern void nwamd_wlan_monitor_signal(const char *);
193 194 extern void nwamd_ncu_create_periodic_scan_event(nwamd_object_t);
194 195 extern dladm_wlan_key_t *nwamd_wlan_get_key_named(const char *, uint32_t);
195 196 extern void nwamd_set_key_name(const char *, const char *, char *, size_t);
196 197
197 198 /* Link functions */
198 199 extern link_state_t nwamd_get_link_state(const char *);
199 200 extern const char *nwamd_sockaddr_to_str(const struct sockaddr *, char *,
200 201 size_t);
201 202 extern void nwamd_propogate_link_up_down_to_ip(const char *, boolean_t);
202 203 extern void nwamd_set_unset_link_properties(nwamd_ncu_t *, boolean_t);
203 204 /* DLPI event hooking */
204 205 extern void nwamd_dlpi_add_link(nwamd_object_t);
205 206 extern void nwamd_dlpi_delete_link(nwamd_object_t);
206 207
207 208 /* IP functions */
208 209 extern boolean_t nwamd_static_addresses_configured(nwamd_ncu_t *, sa_family_t);
209 210 extern void nwamd_plumb_interface(nwamd_ncu_t *, sa_family_t);
210 211 extern void nwamd_unplumb_interface(nwamd_ncu_t *, sa_family_t);
211 212 extern boolean_t nwamd_dhcp_managing(int, nwamd_ncu_t *);
212 213 extern void nwamd_configure_interface_addresses(nwamd_ncu_t *);
213 214 extern char *nwamd_get_dhcpinfo_data(const char *, char *);
214 215 extern void nwamd_dhcp_release(const char *);
215 216 extern void nwamd_add_default_routes(nwamd_ncu_t *);
216 217 extern void nwamd_add_route(struct sockaddr *, struct sockaddr *,
217 218 struct sockaddr *, const char *);
|
↓ open down ↓ |
184 lines elided |
↑ open up ↑ |
218 219
219 220 /* NCU value set/get functions */
220 221 extern nwam_error_t nwamd_set_ncu_uint(nwam_ncu_handle_t, uint64_t *, uint_t,
221 222 const char *);
222 223 extern nwam_error_t nwamd_set_ncu_string(nwam_ncu_handle_t, char **, uint_t,
223 224 const char *);
224 225 extern nwam_error_t nwamd_get_ncu_uint(nwam_ncu_handle_t, nwam_value_t *,
225 226 uint64_t **, uint_t *, const char *);
226 227 extern nwam_error_t nwamd_get_ncu_string(nwam_ncu_handle_t, nwam_value_t *,
227 228 char ***, uint_t *, const char *);
229 +extern nwam_error_t nwamd_get_ncu_boolean(nwam_ncu_handle_t, nwam_value_t *,
230 + boolean_t **, uint_t *, const char *);
228 231
229 232 extern void nwamd_walk_physical_configuration(void);
230 233
231 234 #endif /* _NCU_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX