xref: /titanic_41/usr/src/lib/libnwam/common/libnwam.h (revision c39526b769298791ff5b0b6c5e761f49aabaeb4e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * This file contains data structures and APIs of libnwam.
28  * Implementation is MT safe.
29  */
30 #ifndef _LIBNWAM_H
31 #define	_LIBNWAM_H
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include <bsm/adt.h>
38 #include <net/if.h>
39 #include <inet/ip.h>
40 #include <inet/ip6.h>
41 #include <sys/types.h>
42 #include <sys/socket.h>
43 
44 /*
45  * Note - several interface functions below are not utilized in ON, but are
46  * used by the GNOME nwam-manager.  One example is nwam_enm_get_name().
47  */
48 
49 /*
50  * Common definitions
51  */
52 
53 /* nwam FMRI and properties */
54 #define	NWAM_FMRI		"svc:/network/physical:nwam"
55 #define	NWAM_PG			"nwamd"
56 #define	NWAM_PROP_ACTIVE_NCP	"active_ncp"
57 
58 /* nwam flags used for read/commit */
59 /* Block waiting for commit if necessary */
60 #define	NWAM_FLAG_BLOCKING		0x00000001
61 /* Committed object must be new */
62 #define	NWAM_FLAG_CREATE		0x00000002
63 /* Tell destroy functions not to free handle */
64 #define	NWAM_FLAG_DO_NOT_FREE		0x00000004
65 /* Object is being enabled/disabled */
66 #define	NWAM_FLAG_ENTITY_ENABLE		0x00000008
67 /* Known WLAN being read, committed or destroyed */
68 #define	NWAM_FLAG_ENTITY_KNOWN_WLAN	0x00000010
69 
70 /* nwam flags used for selecting ncu type for walk */
71 #define	NWAM_FLAG_NCU_TYPE_LINK		0x00000001ULL << 32
72 #define	NWAM_FLAG_NCU_TYPE_INTERFACE	0x00000002ULL << 32
73 #define	NWAM_FLAG_NCU_TYPE_ALL		(NWAM_FLAG_NCU_TYPE_LINK | \
74 					NWAM_FLAG_NCU_TYPE_INTERFACE)
75 
76 /* nwam flags used for selecting ncu class for walk */
77 #define	NWAM_FLAG_NCU_CLASS_PHYS		0x00000100ULL << 32
78 #define	NWAM_FLAG_NCU_CLASS_IP			0x00010000ULL << 32
79 #define	NWAM_FLAG_NCU_CLASS_ALL_LINK		NWAM_FLAG_NCU_CLASS_PHYS
80 #define	NWAM_FLAG_NCU_CLASS_ALL_INTERFACE	NWAM_FLAG_NCU_CLASS_IP
81 #define	NWAM_FLAG_NCU_CLASS_ALL		(NWAM_FLAG_NCU_CLASS_ALL_INTERFACE | \
82 					NWAM_FLAG_NCU_CLASS_ALL_LINK)
83 #define	NWAM_FLAG_NCU_TYPE_CLASS_ALL		(NWAM_FLAG_NCU_CLASS_ALL | \
84 						NWAM_FLAG_NCU_TYPE_ALL)
85 
86 /* flags used for selecting activation for walk */
87 #define	NWAM_FLAG_ACTIVATION_MODE_MANUAL		0x000000001ULL << 32
88 #define	NWAM_FLAG_ACTIVATION_MODE_SYSTEM		0x000000002ULL << 32
89 #define	NWAM_FLAG_ACTIVATION_MODE_PRIORITIZED		0x000000004ULL << 32
90 #define	NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ANY	0x000000008ULL << 32
91 #define	NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ALL	0x000000010ULL << 32
92 #define	NWAM_FLAG_ACTIVATION_MODE_ALL	(NWAM_FLAG_ACTIVATION_MODE_MANUAL |\
93 					NWAM_FLAG_ACTIVATION_MODE_SYSTEM |\
94 					NWAM_FLAG_ACTIVATION_MODE_PRIORITIZED |\
95 				NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ANY |\
96 				NWAM_FLAG_ACTIVATION_MODE_CONDITIONAL_ALL)
97 
98 /* Walk known WLANs in order of priority (lowest first) */
99 #define	NWAM_FLAG_KNOWN_WLAN_WALK_PRIORITY_ORDER	0x000010000ULL << 32
100 /* Do not perform priority collision checking for known WLANs */
101 #define	NWAM_FLAG_KNOWN_WLAN_NO_COLLISION_CHECK		0x000020000ULL << 32
102 
103 /* nwam return codes */
104 typedef enum {
105 	NWAM_SUCCESS,			/* No error occured */
106 	NWAM_LIST_END,			/* End of list reached */
107 	NWAM_INVALID_HANDLE,		/* Entity handle is invalid */
108 	NWAM_HANDLE_UNBOUND,		/* Handle not bound to entity */
109 	NWAM_INVALID_ARG,		/* Argument is invalid */
110 	NWAM_PERMISSION_DENIED,		/* Insufficient privileges for action */
111 	NWAM_NO_MEMORY,			/* Out of memory */
112 	NWAM_ENTITY_EXISTS,		/* Entity already exists */
113 	NWAM_ENTITY_IN_USE,		/* Entity in use */
114 	NWAM_ENTITY_COMMITTED,		/* Entity already committed */
115 	NWAM_ENTITY_NOT_FOUND,		/* Entity not found */
116 	NWAM_ENTITY_TYPE_MISMATCH,	/* Entity type mismatch */
117 	NWAM_ENTITY_INVALID,		/* Validation of entity failed */
118 	NWAM_ENTITY_INVALID_MEMBER,	/* Entity member invalid */
119 	NWAM_ENTITY_INVALID_STATE,	/* Entity is not in appropriate state */
120 	NWAM_ENTITY_INVALID_VALUE,	/* Validation of entity value failed */
121 	NWAM_ENTITY_MISSING_MEMBER,	/* Required member is missing */
122 	NWAM_ENTITY_NO_VALUE,		/* No value associated with entity */
123 	NWAM_ENTITY_MULTIPLE_VALUES,	/* Multiple values for entity */
124 	NWAM_ENTITY_READ_ONLY,		/* Entity is marked read only */
125 	NWAM_ENTITY_NOT_DESTROYABLE,	/* Entity cannot be destroyed */
126 	NWAM_ENTITY_NOT_MANUAL,	/* Entity cannot be manually enabled/disabled */
127 	NWAM_WALK_HALTED,		/* Callback function returned nonzero */
128 	NWAM_ERROR_BIND,		/* Could not bind to backend */
129 	NWAM_ERROR_BACKEND_INIT,	/* Could not initialize backend */
130 	NWAM_ERROR_INTERNAL		/* Internal error */
131 } nwam_error_t;
132 
133 #define	NWAM_MAX_NAME_LEN		128
134 #define	NWAM_MAX_VALUE_LEN		256
135 #define	NWAM_MAX_FMRI_LEN		NWAM_MAX_VALUE_LEN
136 #define	NWAM_MAX_NUM_VALUES		32
137 #define	NWAM_MAX_NUM_PROPERTIES		32
138 
139 /* used for getting and setting of properties */
140 typedef enum {
141 	NWAM_VALUE_TYPE_BOOLEAN,
142 	NWAM_VALUE_TYPE_INT64,
143 	NWAM_VALUE_TYPE_UINT64,
144 	NWAM_VALUE_TYPE_STRING,
145 	NWAM_VALUE_TYPE_UNKNOWN
146 } nwam_value_type_t;
147 
148 /* Holds values of various types for getting and setting of properties */
149 /* Forward definition */
150 struct nwam_value;
151 typedef struct nwam_value *nwam_value_t;
152 
153 /* Value-related functions. */
154 extern nwam_error_t nwam_value_create_boolean(boolean_t, nwam_value_t *);
155 extern nwam_error_t nwam_value_create_boolean_array(boolean_t *, uint_t,
156     nwam_value_t *);
157 extern nwam_error_t nwam_value_create_int64(int64_t, nwam_value_t *);
158 extern nwam_error_t nwam_value_create_int64_array(int64_t *, uint_t,
159     nwam_value_t *);
160 extern nwam_error_t nwam_value_create_uint64(uint64_t, nwam_value_t *);
161 extern nwam_error_t nwam_value_create_uint64_array(uint64_t *, uint_t,
162     nwam_value_t *);
163 extern nwam_error_t nwam_value_create_string(char *, nwam_value_t *);
164 extern nwam_error_t nwam_value_create_string_array(char **, uint_t,
165     nwam_value_t *);
166 
167 extern nwam_error_t nwam_value_get_boolean(nwam_value_t, boolean_t *);
168 extern nwam_error_t nwam_value_get_boolean_array(nwam_value_t, boolean_t **,
169     uint_t *);
170 extern nwam_error_t nwam_value_get_int64(nwam_value_t, int64_t *);
171 extern nwam_error_t nwam_value_get_int64_array(nwam_value_t, int64_t **,
172     uint_t *);
173 extern nwam_error_t nwam_value_get_uint64(nwam_value_t, uint64_t *);
174 extern nwam_error_t nwam_value_get_uint64_array(nwam_value_t, uint64_t **,
175     uint_t *);
176 extern nwam_error_t nwam_value_get_string(nwam_value_t, char **);
177 extern nwam_error_t nwam_value_get_string_array(nwam_value_t, char ***,
178     uint_t *);
179 
180 extern nwam_error_t nwam_value_get_type(nwam_value_t, nwam_value_type_t *);
181 extern nwam_error_t nwam_value_get_numvalues(nwam_value_t, uint_t *);
182 
183 extern void nwam_value_free(nwam_value_t);
184 extern nwam_error_t nwam_value_copy(nwam_value_t, nwam_value_t *);
185 
186 extern nwam_error_t nwam_uint64_get_value_string(const char *, uint64_t,
187     const char **);
188 extern nwam_error_t nwam_value_string_get_uint64(const char *, const char *,
189     uint64_t *);
190 
191 /*
192  * To retrieve a localized error string
193  */
194 extern const char *nwam_strerror(nwam_error_t);
195 
196 /*
197  * State and auxiliary state describe the state of ENMs, NCUs and locations.
198  */
199 typedef enum {
200 	NWAM_STATE_UNINITIALIZED = 0x0,
201 	NWAM_STATE_INITIALIZED = 0x1,
202 	NWAM_STATE_OFFLINE = 0x2,
203 	NWAM_STATE_OFFLINE_TO_ONLINE = 0x4,
204 	NWAM_STATE_ONLINE_TO_OFFLINE = 0x8,
205 	NWAM_STATE_ONLINE = 0x10,
206 	NWAM_STATE_MAINTENANCE = 0x20,
207 	NWAM_STATE_DEGRADED = 0x40,
208 	NWAM_STATE_DISABLED = 0x80
209 } nwam_state_t;
210 
211 #define	NWAM_STATE_ANY	(NWAM_STATE_UNINITIALIZED | \
212 			NWAM_STATE_INITIALIZED | \
213 			NWAM_STATE_OFFLINE | \
214 			NWAM_STATE_OFFLINE_TO_ONLINE | \
215 			NWAM_STATE_ONLINE_TO_OFFLINE | \
216 			NWAM_STATE_ONLINE | \
217 			NWAM_STATE_MAINTENANCE | \
218 			NWAM_STATE_DEGRADED | \
219 			NWAM_STATE_DISABLED)
220 
221 /*
222  * The auxiliary state denotes specific reasons why an object is in a particular
223  * state (e.g. "script failed", "disabled by administrator", "waiting for DHCP
224  * response").
225  */
226 typedef enum {
227 	/* General auxiliary states */
228 	NWAM_AUX_STATE_UNINITIALIZED,
229 	NWAM_AUX_STATE_INITIALIZED,
230 	NWAM_AUX_STATE_CONDITIONS_NOT_MET,
231 	NWAM_AUX_STATE_MANUAL_DISABLE,
232 	NWAM_AUX_STATE_METHOD_FAILED,
233 	NWAM_AUX_STATE_METHOD_MISSING,
234 	NWAM_AUX_STATE_METHOD_RUNNING,
235 	NWAM_AUX_STATE_INVALID_CONFIG,
236 	NWAM_AUX_STATE_ACTIVE,
237 	/* Link-specific auxiliary states */
238 	NWAM_AUX_STATE_LINK_WIFI_SCANNING,
239 	NWAM_AUX_STATE_LINK_WIFI_NEED_SELECTION,
240 	NWAM_AUX_STATE_LINK_WIFI_NEED_KEY,
241 	NWAM_AUX_STATE_LINK_WIFI_CONNECTING,
242 	/* IP interface-specific auxiliary states */
243 	NWAM_AUX_STATE_IF_WAITING_FOR_ADDR,
244 	NWAM_AUX_STATE_IF_DHCP_TIMED_OUT,
245 	NWAM_AUX_STATE_IF_DUPLICATE_ADDR,
246 	/* Common link/interface auxiliary states */
247 	NWAM_AUX_STATE_UP,
248 	NWAM_AUX_STATE_DOWN,
249 	NWAM_AUX_STATE_NOT_FOUND
250 } nwam_aux_state_t;
251 
252 /* Activation modes */
253 typedef enum {
254 	NWAM_ACTIVATION_MODE_MANUAL,
255 	NWAM_ACTIVATION_MODE_SYSTEM,
256 	NWAM_ACTIVATION_MODE_CONDITIONAL_ANY,
257 	NWAM_ACTIVATION_MODE_CONDITIONAL_ALL,
258 	NWAM_ACTIVATION_MODE_PRIORITIZED
259 } nwam_activation_mode_t;
260 
261 /*
262  * Conditions are of the form
263  *
264  * ncu|enm|loc name is|is-not active
265  * ip-address is|is-not|is-in-range|is-not-in-range ipaddr[/prefixlen]
266  * advertised-domain is|is-not|contains|does-not-contain string
267  * system-domain is|is-not|contains|does-not-contain string
268  * essid is|is-not|contains|does-not-contain string
269  * bssid is|is-not <string>
270  */
271 
272 typedef enum {
273 	NWAM_CONDITION_IS,
274 	NWAM_CONDITION_IS_NOT,
275 	NWAM_CONDITION_IS_IN_RANGE,
276 	NWAM_CONDITION_IS_NOT_IN_RANGE,
277 	NWAM_CONDITION_CONTAINS,
278 	NWAM_CONDITION_DOES_NOT_CONTAIN
279 } nwam_condition_t;
280 
281 typedef enum {
282 	NWAM_CONDITION_OBJECT_TYPE_NCP,
283 	NWAM_CONDITION_OBJECT_TYPE_NCU,
284 	NWAM_CONDITION_OBJECT_TYPE_ENM,
285 	NWAM_CONDITION_OBJECT_TYPE_LOC,
286 	NWAM_CONDITION_OBJECT_TYPE_IP_ADDRESS,
287 	NWAM_CONDITION_OBJECT_TYPE_ADV_DOMAIN,
288 	NWAM_CONDITION_OBJECT_TYPE_SYS_DOMAIN,
289 	NWAM_CONDITION_OBJECT_TYPE_ESSID,
290 	NWAM_CONDITION_OBJECT_TYPE_BSSID
291 } nwam_condition_object_type_t;
292 
293 /*
294  * Activation condition-related functions that convert activation
295  * values to an appropriate string and back.
296  */
297 extern nwam_error_t nwam_condition_to_condition_string(
298     nwam_condition_object_type_t, nwam_condition_t, const char *, char **);
299 extern nwam_error_t nwam_condition_string_to_condition(const char *,
300     nwam_condition_object_type_t *, nwam_condition_t *, char **);
301 
302 /*
303  * Only one location can be active at one time. As a
304  * consequence, if the activation conditions of multiple
305  * locations are satisfied, we need to compare activation
306  * conditions to see if one is more specific than another.
307  *
308  * The following heuristics are applied to rate an
309  * activation condition:
310  * - "is" is the most specific condition
311  * - it is followed by "is-in-range" and "contains"
312  * - "is-not-in-range" and "does-not-contain" are next
313  * - finally "is-not" is least specific
314  *
315  * Regarding the objects these conditions apply to:
316  * - NCU, ENM and locations are most specific
317  * - system-domain is next
318  * - advertised-domain is next
319  * - IP address is next
320  * - wireless BSSID is next
321  * - wireless ESSID is least specific
322  *
323  */
324 extern nwam_error_t nwam_condition_rate(nwam_condition_object_type_t,
325     nwam_condition_t, uint64_t *);
326 
327 /*
328  * Location definitions.
329  */
330 
331 #define	NWAM_LOC_NAME_AUTOMATIC		"Automatic"
332 #define	NWAM_LOC_NAME_NO_NET		"NoNet"
333 #define	NWAM_LOC_NAME_LEGACY		"Legacy"
334 
335 #define	NWAM_LOC_NAME_PRE_DEFINED(name)	\
336 			(strcasecmp(name, NWAM_LOC_NAME_AUTOMATIC) == 0 || \
337 			strcasecmp(name, NWAM_LOC_NAME_NO_NET) == 0 || \
338 			strcasecmp(name, NWAM_LOC_NAME_LEGACY) == 0)
339 
340 /* Forward definition */
341 struct nwam_handle;
342 
343 typedef struct nwam_handle *nwam_loc_handle_t;
344 
345 /* Location properties */
346 
347 typedef enum {
348 	NWAM_NAMESERVICES_DNS,
349 	NWAM_NAMESERVICES_FILES,
350 	NWAM_NAMESERVICES_NIS,
351 	NWAM_NAMESERVICES_LDAP
352 } nwam_nameservices_t;
353 
354 typedef enum {
355 	NWAM_CONFIGSRC_MANUAL,
356 	NWAM_CONFIGSRC_DHCP
357 } nwam_configsrc_t;
358 
359 #define	NWAM_LOC_PROP_ACTIVATION_MODE		"activation-mode"
360 #define	NWAM_LOC_PROP_CONDITIONS		"conditions"
361 #define	NWAM_LOC_PROP_ENABLED			"enabled"
362 
363 /* Nameservice location properties */
364 #define	NWAM_LOC_PROP_NAMESERVICES		"nameservices"
365 #define	NWAM_LOC_PROP_NAMESERVICES_CONFIG_FILE	"nameservices-config-file"
366 #define	NWAM_LOC_PROP_DNS_NAMESERVICE_CONFIGSRC	"dns-nameservice-configsrc"
367 #define	NWAM_LOC_PROP_DNS_NAMESERVICE_DOMAIN	"dns-nameservice-domain"
368 #define	NWAM_LOC_PROP_DNS_NAMESERVICE_SERVERS	"dns-nameservice-servers"
369 #define	NWAM_LOC_PROP_DNS_NAMESERVICE_SEARCH	"dns-nameservice-search"
370 #define	NWAM_LOC_PROP_NIS_NAMESERVICE_CONFIGSRC	"nis-nameservice-configsrc"
371 #define	NWAM_LOC_PROP_NIS_NAMESERVICE_SERVERS	"nis-nameservice-servers"
372 #define	NWAM_LOC_PROP_LDAP_NAMESERVICE_CONFIGSRC "ldap-nameservice-configsrc"
373 #define	NWAM_LOC_PROP_LDAP_NAMESERVICE_SERVERS	"ldap-nameservice-servers"
374 #define	NWAM_LOC_PROP_DEFAULT_DOMAIN		"default-domain"
375 
376 /* NFSv4 domain */
377 #define	NWAM_LOC_PROP_NFSV4_DOMAIN		"nfsv4-domain"
378 
379 /* IPfilter configuration */
380 #define	NWAM_LOC_PROP_IPFILTER_CONFIG_FILE	"ipfilter-config-file"
381 #define	NWAM_LOC_PROP_IPFILTER_V6_CONFIG_FILE	"ipfilter-v6-config-file"
382 #define	NWAM_LOC_PROP_IPNAT_CONFIG_FILE		"ipnat-config-file"
383 #define	NWAM_LOC_PROP_IPPOOL_CONFIG_FILE	"ippool-config-file"
384 
385 /* IPsec configuration */
386 #define	NWAM_LOC_PROP_IKE_CONFIG_FILE		"ike-config-file"
387 #define	NWAM_LOC_PROP_IPSECPOLICY_CONFIG_FILE	"ipsecpolicy-config-file"
388 
389 /*
390  * NCP/NCU definitions.
391  */
392 
393 #define	NWAM_NCP_NAME_AUTOMATIC		"Automatic"
394 #define	NWAM_NCP_NAME_USER		"User"
395 
396 #define	NWAM_NCP_AUTOMATIC(name)	\
397 			(strcasecmp(name, NWAM_NCP_NAME_AUTOMATIC) == 0)
398 
399 typedef struct nwam_handle *nwam_ncp_handle_t;
400 
401 typedef struct nwam_handle *nwam_ncu_handle_t;
402 
403 typedef enum {
404 	NWAM_NCU_TYPE_UNKNOWN = -1,
405 	NWAM_NCU_TYPE_LINK,
406 	NWAM_NCU_TYPE_INTERFACE,
407 	NWAM_NCU_TYPE_ANY
408 } nwam_ncu_type_t;
409 
410 typedef enum {
411 	NWAM_NCU_CLASS_UNKNOWN = -1,
412 	NWAM_NCU_CLASS_PHYS,
413 	NWAM_NCU_CLASS_IP,
414 	NWAM_NCU_CLASS_ANY
415 } nwam_ncu_class_t;
416 
417 typedef enum {
418 	NWAM_ADDRSRC_DHCP,
419 	NWAM_ADDRSRC_AUTOCONF,
420 	NWAM_ADDRSRC_STATIC
421 } nwam_addrsrc_t;
422 
423 typedef enum {
424 	NWAM_PRIORITY_MODE_EXCLUSIVE,
425 	NWAM_PRIORITY_MODE_SHARED,
426 	NWAM_PRIORITY_MODE_ALL
427 } nwam_priority_mode_t;
428 
429 /* NCU properties common to all type/classes */
430 #define	NWAM_NCU_PROP_TYPE			"type"
431 #define	NWAM_NCU_PROP_CLASS			"class"
432 #define	NWAM_NCU_PROP_PARENT_NCP		"parent"
433 #define	NWAM_NCU_PROP_ACTIVATION_MODE		"activation-mode"
434 #define	NWAM_NCU_PROP_ENABLED			"enabled"
435 #define	NWAM_NCU_PROP_PRIORITY_GROUP		"priority-group"
436 #define	NWAM_NCU_PROP_PRIORITY_MODE		"priority-mode"
437 
438 /* Link NCU properties */
439 #define	NWAM_NCU_PROP_LINK_MAC_ADDR		"link-mac-addr"
440 #define	NWAM_NCU_PROP_LINK_AUTOPUSH		"link-autopush"
441 #define	NWAM_NCU_PROP_LINK_MTU			"link-mtu"
442 
443 /* IP NCU properties */
444 #define	NWAM_NCU_PROP_IP_VERSION		"ip-version"
445 #define	NWAM_NCU_PROP_IPV4_ADDRSRC		"ipv4-addrsrc"
446 #define	NWAM_NCU_PROP_IPV4_ADDR			"ipv4-addr"
447 #define	NWAM_NCU_PROP_IPV4_DEFAULT_ROUTE	"ipv4-default-route"
448 #define	NWAM_NCU_PROP_IPV6_ADDRSRC		"ipv6-addrsrc"
449 #define	NWAM_NCU_PROP_IPV6_ADDR			"ipv6-addr"
450 #define	NWAM_NCU_PROP_IPV6_DEFAULT_ROUTE	"ipv6-default-route"
451 
452 /* Some properties should only be set on creation */
453 #define	NWAM_NCU_PROP_SETONCE(prop)	\
454 				(strcmp(prop, NWAM_NCU_PROP_TYPE) == 0 || \
455 				strcmp(prop, NWAM_NCU_PROP_CLASS) == 0 || \
456 				strcmp(prop, NWAM_NCU_PROP_PARENT_NCP) == 0)
457 /*
458  * ENM definitions
459  */
460 
461 typedef struct nwam_handle *nwam_enm_handle_t;
462 
463 #define	NWAM_ENM_PROP_ACTIVATION_MODE	"activation-mode"
464 #define	NWAM_ENM_PROP_CONDITIONS	"conditions"
465 #define	NWAM_ENM_PROP_ENABLED		"enabled"
466 
467 /* FMRI associated with ENM */
468 #define	NWAM_ENM_PROP_FMRI		"fmri"
469 
470 /* Start/stop scripts associated with ENM */
471 #define	NWAM_ENM_PROP_START		"start"
472 #define	NWAM_ENM_PROP_STOP		"stop"
473 
474 /*
475  * Known Wireless LAN info (known WLAN) definitions.
476  */
477 
478 typedef struct nwam_handle *nwam_known_wlan_handle_t;
479 
480 #define	NWAM_KNOWN_WLAN_PROP_BSSIDS		"bssids"
481 #define	NWAM_KNOWN_WLAN_PROP_PRIORITY		"priority"
482 #define	NWAM_KNOWN_WLAN_PROP_KEYNAME		"keyname"
483 #define	NWAM_KNOWN_WLAN_PROP_KEYSLOT		"keyslot"
484 #define	NWAM_KNOWN_WLAN_PROP_SECURITY_MODE	"security-mode"
485 
486 /*
487  * Location Functions
488  */
489 
490 /* Create a location */
491 extern nwam_error_t nwam_loc_create(const char *, nwam_loc_handle_t *);
492 
493 /* Copy a location */
494 extern nwam_error_t nwam_loc_copy(nwam_loc_handle_t, const char *,
495     nwam_loc_handle_t *);
496 
497 /* Read a location from persistent storage */
498 extern nwam_error_t nwam_loc_read(const char *, uint64_t,
499     nwam_loc_handle_t *);
500 
501 /* Validate in-memory representation of a location */
502 extern nwam_error_t nwam_loc_validate(nwam_loc_handle_t, const char **);
503 
504 /* Commit in-memory representation of a location to persistent storage */
505 extern nwam_error_t nwam_loc_commit(nwam_loc_handle_t, uint64_t);
506 
507 /* Destroy a location in persistent storage */
508 extern nwam_error_t nwam_loc_destroy(nwam_loc_handle_t, uint64_t);
509 
510 /* Free in-memory representation of a location */
511 extern void nwam_loc_free(nwam_loc_handle_t);
512 
513 /* read all locs from persistent storage and walk through each at a time */
514 extern nwam_error_t nwam_walk_locs(int (*)(nwam_loc_handle_t, void *), void *,
515     uint64_t, int *);
516 
517 /* get/set loc name */
518 extern nwam_error_t nwam_loc_get_name(nwam_loc_handle_t, char **);
519 extern nwam_error_t nwam_loc_set_name(nwam_loc_handle_t, const char *);
520 extern boolean_t nwam_loc_can_set_name(nwam_loc_handle_t);
521 
522 /* activate/deactivate loc */
523 extern nwam_error_t nwam_loc_enable(nwam_loc_handle_t);
524 extern nwam_error_t nwam_loc_disable(nwam_loc_handle_t);
525 
526 /* walk all properties of an in-memory loc */
527 extern nwam_error_t nwam_loc_walk_props(nwam_loc_handle_t,
528 	int (*)(const char *, nwam_value_t, void *),
529 	void *, uint64_t, int *);
530 
531 /* delete/get/set validate loc property */
532 extern nwam_error_t nwam_loc_delete_prop(nwam_loc_handle_t,
533     const char *);
534 extern nwam_error_t nwam_loc_get_prop_value(nwam_loc_handle_t,
535     const char *, nwam_value_t *);
536 extern nwam_error_t nwam_loc_set_prop_value(nwam_loc_handle_t,
537     const char *, nwam_value_t);
538 extern nwam_error_t nwam_loc_validate_prop(nwam_loc_handle_t, const char *,
539     nwam_value_t);
540 
541 /* Get the read-only value for a particular loc property */
542 extern nwam_error_t nwam_loc_prop_read_only(const char *, boolean_t *);
543 
544 /* Whether the property is multi-valued or not */
545 extern nwam_error_t nwam_loc_prop_multivalued(const char *, boolean_t *);
546 
547 /* Retrieve data type */
548 extern nwam_error_t nwam_loc_get_prop_type(const char *, nwam_value_type_t *);
549 
550 /* Retrieve description */
551 extern nwam_error_t nwam_loc_get_prop_description(const char *, const char **);
552 
553 /* get default loc props */
554 extern nwam_error_t nwam_loc_get_default_proplist(const char ***, uint_t *);
555 
556 /* get sstate of loc from nwamd */
557 extern nwam_error_t nwam_loc_get_state(nwam_loc_handle_t, nwam_state_t *,
558 	nwam_aux_state_t *);
559 
560 /* Get whether the loc has manual activation-mode or not */
561 extern nwam_error_t nwam_loc_is_manual(nwam_loc_handle_t, boolean_t *);
562 
563 /*
564  * NCP/NCU functions
565  */
566 
567 /* Create an ncp */
568 extern nwam_error_t nwam_ncp_create(const char *, uint64_t,
569 	nwam_ncp_handle_t *);
570 
571 /* Read an ncp from persistent storage */
572 extern nwam_error_t nwam_ncp_read(const char *, uint64_t, nwam_ncp_handle_t *);
573 
574 /* Make a copy of existing ncp */
575 extern nwam_error_t nwam_ncp_copy(nwam_ncp_handle_t, const char *,
576 	nwam_ncp_handle_t *);
577 
578 /* Walk ncps */
579 extern nwam_error_t nwam_walk_ncps(int (*)(nwam_ncp_handle_t, void *),
580 	void *, uint64_t, int *);
581 
582 /* Get ncp name */
583 extern nwam_error_t nwam_ncp_get_name(nwam_ncp_handle_t, char **);
584 
585 /* Get the read-only value for this ncp */
586 extern nwam_error_t nwam_ncp_get_read_only(nwam_ncp_handle_t, boolean_t *);
587 
588 /* Destroy ncp */
589 extern nwam_error_t nwam_ncp_destroy(nwam_ncp_handle_t, uint64_t);
590 
591 /*
592  * Walk all ncus associated with ncp.  Specific types/classes of ncu can
593  * be selected via flags, or all via NWAM_FLAG_ALL.
594  */
595 extern nwam_error_t nwam_ncp_walk_ncus(nwam_ncp_handle_t,
596     int(*)(nwam_ncu_handle_t, void *), void *, uint64_t, int *);
597 
598 /* Activate ncp */
599 extern nwam_error_t nwam_ncp_enable(nwam_ncp_handle_t);
600 
601 /* Free in-memory representation of ncp */
602 extern void nwam_ncp_free(nwam_ncp_handle_t);
603 
604 /* Get state of NCP from nwamd */
605 extern nwam_error_t nwam_ncp_get_state(nwam_ncp_handle_t, nwam_state_t *,
606 	nwam_aux_state_t *);
607 
608 /* Get the active priority-group */
609 extern nwam_error_t nwam_ncp_get_active_priority_group(int64_t *);
610 
611 /* Create an ncu or read it from persistent storage */
612 extern nwam_error_t nwam_ncu_create(nwam_ncp_handle_t, const char *,
613 	nwam_ncu_type_t, nwam_ncu_class_t, nwam_ncu_handle_t *);
614 extern nwam_error_t nwam_ncu_read(nwam_ncp_handle_t, const char *,
615 	nwam_ncu_type_t, uint64_t, nwam_ncu_handle_t *);
616 
617 /* Destroy an ncu in persistent storage or free the in-memory representation */
618 extern nwam_error_t nwam_ncu_destroy(nwam_ncu_handle_t, uint64_t);
619 extern void nwam_ncu_free(nwam_ncu_handle_t);
620 
621 /* make a copy of existing ncu */
622 extern nwam_error_t nwam_ncu_copy(nwam_ncu_handle_t, const char *,
623 	nwam_ncu_handle_t *);
624 
625 /* Commit ncu changes to persistent storage */
626 extern nwam_error_t nwam_ncu_commit(nwam_ncu_handle_t, uint64_t);
627 
628 /* activate/deactivate an individual NCU (must be part of the active NCP) */
629 extern nwam_error_t nwam_ncu_enable(nwam_ncu_handle_t);
630 extern nwam_error_t nwam_ncu_disable(nwam_ncu_handle_t);
631 
632 /* Get state of NCU from nwamd */
633 extern nwam_error_t nwam_ncu_get_state(nwam_ncu_handle_t, nwam_state_t *,
634 	nwam_aux_state_t *);
635 
636 /* Get NCU type */
637 extern nwam_error_t nwam_ncu_get_ncu_type(nwam_ncu_handle_t, nwam_ncu_type_t *);
638 
639 /* Get NCU class */
640 extern nwam_error_t nwam_ncu_get_ncu_class(nwam_ncu_handle_t,
641 	nwam_ncu_class_t *);
642 
643 /* Validate ncu content */
644 extern nwam_error_t nwam_ncu_validate(nwam_ncu_handle_t, const char **);
645 
646 /* Walk all properties in in-memory representation of ncu */
647 extern nwam_error_t nwam_ncu_walk_props(nwam_ncu_handle_t,
648 	int (*)(const char *, nwam_value_t, void *),
649 	void *, uint64_t, int *);
650 
651 /* Get/set name of ncu, get parent ncp */
652 extern nwam_error_t nwam_ncu_get_name(nwam_ncu_handle_t, char **);
653 extern nwam_error_t nwam_ncu_name_to_typed_name(const char *, nwam_ncu_type_t,
654     char **);
655 extern nwam_error_t nwam_ncu_typed_name_to_name(const char *, nwam_ncu_type_t *,
656     char **);
657 extern nwam_error_t nwam_ncu_get_default_proplist(nwam_ncu_type_t,
658     nwam_ncu_class_t, const char ***, uint_t *);
659 extern nwam_error_t nwam_ncu_get_ncp(nwam_ncu_handle_t, nwam_ncp_handle_t *);
660 
661 /* delete/get/set/validate property from/in in-memory representation of ncu */
662 extern nwam_error_t nwam_ncu_delete_prop(nwam_ncu_handle_t,
663 	const char *);
664 extern nwam_error_t nwam_ncu_get_prop_value(nwam_ncu_handle_t,
665 	const char *, nwam_value_t *);
666 extern nwam_error_t nwam_ncu_set_prop_value(nwam_ncu_handle_t,
667 	const char *, nwam_value_t);
668 
669 extern nwam_error_t nwam_ncu_validate_prop(nwam_ncu_handle_t, const char *,
670 	nwam_value_t);
671 
672 /* Retrieve data type */
673 extern nwam_error_t nwam_ncu_get_prop_type(const char *, nwam_value_type_t *);
674 /* Retrieve prop description */
675 extern nwam_error_t nwam_ncu_get_prop_description(const char *, const char **);
676 
677 /* Get the read-only value from the handle or parent NCP */
678 extern nwam_error_t nwam_ncu_get_read_only(nwam_ncu_handle_t, boolean_t *);
679 
680 /* Get the read-only value for a particular NCU property */
681 extern nwam_error_t nwam_ncu_prop_read_only(const char *, boolean_t *);
682 
683 /* Whether the property is multi-valued or not */
684 extern nwam_error_t nwam_ncu_prop_multivalued(const char *, boolean_t *);
685 
686 /* Get whether the NCU has manual activation-mode or not */
687 extern nwam_error_t nwam_ncu_is_manual(nwam_ncu_handle_t, boolean_t *);
688 
689 /* Get the flag from the given class for walks */
690 extern uint64_t nwam_ncu_class_to_flag(nwam_ncu_class_t);
691 
692 /* Get the NCU type from the given class */
693 extern nwam_ncu_type_t nwam_ncu_class_to_type(nwam_ncu_class_t);
694 
695 /* ENM functions */
696 /*
697  * Obtain a specific enm handle, either be creating a new enm
698  * or reading an existing one from persistent storage.
699  */
700 extern nwam_error_t nwam_enm_create(const char *, const char *,
701 	nwam_enm_handle_t *);
702 extern nwam_error_t nwam_enm_read(const char *, uint64_t, nwam_enm_handle_t *);
703 
704 /* Make a copy of existing enm */
705 extern nwam_error_t nwam_enm_copy(nwam_enm_handle_t, const char *,
706 	nwam_enm_handle_t *);
707 
708 /*
709  * Obtain handles for all existing enms.  Caller-specified callback
710  * function will be called once for each enm, passing the handle and
711  * the caller-specified arg.
712  */
713 extern nwam_error_t nwam_walk_enms(int (*)(nwam_enm_handle_t, void *), void *,
714 	uint64_t, int *);
715 
716 /*
717  * Commit an enm to persistent storage.  Does not free the handle.
718  */
719 extern nwam_error_t nwam_enm_commit(nwam_enm_handle_t, uint64_t);
720 
721 /*
722  * Remove an enm from persistent storage.
723  */
724 extern nwam_error_t nwam_enm_destroy(nwam_enm_handle_t, uint64_t);
725 
726 /*
727  * Free an enm handle
728  */
729 extern void nwam_enm_free(nwam_enm_handle_t);
730 
731 /*
732  * Validate an enm, or a specific enm property.  If validating
733  * an entire enm, the invalid property type is returned.
734  */
735 extern nwam_error_t nwam_enm_validate(nwam_enm_handle_t, const char **);
736 extern nwam_error_t nwam_enm_validate_prop(nwam_enm_handle_t, const char *,
737 	nwam_value_t);
738 
739 /* Retrieve data type */
740 extern nwam_error_t nwam_enm_get_prop_type(const char *, nwam_value_type_t *);
741 /* Retrieve prop description */
742 extern nwam_error_t nwam_enm_get_prop_description(const char *, const char **);
743 
744 /*
745  * Delete/get/set enm property values.
746  */
747 extern nwam_error_t nwam_enm_delete_prop(nwam_enm_handle_t,
748 	const char *);
749 extern nwam_error_t nwam_enm_get_prop_value(nwam_enm_handle_t,
750 	const char *, nwam_value_t *);
751 extern nwam_error_t nwam_enm_set_prop_value(nwam_enm_handle_t,
752 	const char *, nwam_value_t);
753 
754 extern nwam_error_t nwam_enm_get_default_proplist(const char ***, uint_t *);
755 
756 /* Get the read-only value for a particular ENM property */
757 extern nwam_error_t nwam_enm_prop_read_only(const char *, boolean_t *);
758 
759 /* Whether the property is multi-valued or not */
760 extern nwam_error_t nwam_enm_prop_multivalued(const char *, boolean_t *);
761 
762 /*
763  * Walk all properties of a specific enm.  For each property, specified
764  * callback function is called.  Caller is responsible for freeing memory
765  * allocated for each property.
766  */
767 extern nwam_error_t nwam_enm_walk_props(nwam_enm_handle_t,
768     int (*)(const char *, nwam_value_t, void *),
769     void *, uint64_t, int *);
770 
771 /*
772  * Get/set the name of an enm.  When getting the name, the library will
773  * allocate a buffer; the caller is responsible for freeing the memory.
774  */
775 extern nwam_error_t nwam_enm_get_name(nwam_enm_handle_t, char **);
776 extern nwam_error_t nwam_enm_set_name(nwam_enm_handle_t, const char *);
777 extern boolean_t nwam_enm_can_set_name(nwam_enm_handle_t);
778 
779 /*
780  * Start/stop an enm.
781  */
782 extern nwam_error_t nwam_enm_enable(nwam_enm_handle_t);
783 extern nwam_error_t nwam_enm_disable(nwam_enm_handle_t);
784 
785 /*
786  * Get state of ENM from nwamd.
787  */
788 extern nwam_error_t nwam_enm_get_state(nwam_enm_handle_t, nwam_state_t *,
789 	nwam_aux_state_t *);
790 
791 /*
792  * Get whether the ENM has manual activation-mode or not.
793  */
794 extern nwam_error_t nwam_enm_is_manual(nwam_enm_handle_t, boolean_t *);
795 
796 /*
797  * Known Wireless LAN (WLAN) info.
798  */
799 
800 /* Create a known WLAN */
801 extern nwam_error_t nwam_known_wlan_create(const char *,
802     nwam_known_wlan_handle_t *);
803 
804 /* Read a known WLAN from persistent storage */
805 extern nwam_error_t nwam_known_wlan_read(const char *, uint64_t,
806     nwam_known_wlan_handle_t *);
807 
808 /*
809  * Destroy a known WLAN in persistent storage or free the in-memory
810  * representation.
811  */
812 extern nwam_error_t nwam_known_wlan_destroy(nwam_known_wlan_handle_t, uint64_t);
813 extern void nwam_known_wlan_free(nwam_known_wlan_handle_t);
814 
815 /* make a copy of existing known WLAN */
816 extern nwam_error_t nwam_known_wlan_copy(nwam_known_wlan_handle_t, const char *,
817     nwam_known_wlan_handle_t *);
818 
819 /* Commit known WLAN changes to persistent storage */
820 extern nwam_error_t nwam_known_wlan_commit(nwam_known_wlan_handle_t, uint64_t);
821 
822 /* Validate known WLAN content */
823 extern nwam_error_t nwam_known_wlan_validate(nwam_known_wlan_handle_t,
824     const char **);
825 
826 /* Walk known WLANs */
827 extern nwam_error_t nwam_walk_known_wlans
828 	(int(*)(nwam_known_wlan_handle_t, void *), void *, uint64_t, int *);
829 
830 /* get/set known WLAN name */
831 extern nwam_error_t nwam_known_wlan_get_name(nwam_known_wlan_handle_t, char **);
832 extern nwam_error_t nwam_known_wlan_set_name(nwam_known_wlan_handle_t,
833     const char *);
834 extern boolean_t nwam_known_wlan_can_set_name(nwam_known_wlan_handle_t);
835 
836 /* walk all properties of an in-memory known WLAN */
837 extern nwam_error_t nwam_known_wlan_walk_props(nwam_known_wlan_handle_t,
838     int (*)(const char *, nwam_value_t, void *),
839     void *, uint64_t, int *);
840 
841 /* delete/get/set/validate known WLAN property */
842 extern nwam_error_t nwam_known_wlan_delete_prop(nwam_known_wlan_handle_t,
843     const char *);
844 extern nwam_error_t nwam_known_wlan_get_prop_value(nwam_known_wlan_handle_t,
845     const char *, nwam_value_t *);
846 extern nwam_error_t nwam_known_wlan_set_prop_value(nwam_known_wlan_handle_t,
847     const char *, nwam_value_t);
848 extern nwam_error_t nwam_known_wlan_validate_prop(nwam_known_wlan_handle_t,
849     const char *, nwam_value_t);
850 
851 /* Retrieve data type */
852 extern nwam_error_t nwam_known_wlan_get_prop_type(const char *,
853     nwam_value_type_t *);
854 /* Retrieve prop description */
855 extern nwam_error_t nwam_known_wlan_get_prop_description(const char *,
856     const char **);
857 
858 /* get default known WLAN props */
859 extern nwam_error_t nwam_known_wlan_get_default_proplist(const char ***,
860     uint_t *);
861 
862 /* Whether the property is multi-valued or not */
863 extern nwam_error_t nwam_known_wlan_prop_multivalued(const char *, boolean_t *);
864 
865 /* Add a bssid to the known WLANs */
866 extern nwam_error_t nwam_known_wlan_add_to_known_wlans(const char *,
867     const char *, uint32_t, uint_t, const char *);
868 
869 /* Remove a bssid from known WLANs */
870 extern nwam_error_t nwam_known_wlan_remove_from_known_wlans(const char *,
871     const char *, const char *);
872 
873 /*
874  * nwam_wlan_t is used for scan/need choice/need key events and by
875  * nwam_wlan_get_scan_results().  The following fields are valid:
876  *
877  * - for scan and need choice event, ESSID, BSSID, signal strength, security
878  * mode, speed, channel, bsstype, key index, and if we already have a key
879  * (have_key), if the WLAN is the current selection (selected) and
880  * if the current WLAN is connected (connected).
881  * - for need key events, ESSID, security mode, have_key, selected and connected
882  * values are set.  The rest of the fields are not set since multiple WLANs
883  * may match the ESSID and have different speeds, channels etc.  If an
884  * ESSID/BSSID selection is specified, the BSSID will be set also.
885  *
886  */
887 typedef struct {
888 	char nww_essid[NWAM_MAX_NAME_LEN];
889 	char nww_bssid[NWAM_MAX_NAME_LEN];
890 	char nww_signal_strength[NWAM_MAX_NAME_LEN];
891 	uint32_t nww_security_mode; /* a dladm_wlan_secmode_t */
892 	uint32_t nww_speed; /* a dladm_wlan_speed_t */
893 	uint32_t nww_channel; /* a dladm_wlan_channel_t */
894 	uint32_t nww_bsstype; /* a dladm_wlan_bsstype_t */
895 	uint_t nww_keyindex;
896 	boolean_t nww_have_key;
897 	boolean_t nww_selected;
898 	boolean_t nww_connected;
899 } nwam_wlan_t;
900 
901 /*
902  * Active WLAN definitions. Used to scan WLANs/choose a WLAN/set a WLAN key.
903  */
904 extern nwam_error_t nwam_wlan_scan(const char *);
905 extern nwam_error_t nwam_wlan_get_scan_results(const char *, uint_t *,
906     nwam_wlan_t **);
907 extern nwam_error_t nwam_wlan_select(const char *, const char *, const char *,
908     uint32_t, boolean_t);
909 extern nwam_error_t nwam_wlan_set_key(const char *, const char *, const char *,
910     uint32_t, uint_t, const char *);
911 
912 /*
913  * Event notification definitions
914  */
915 #define	NWAM_EVENT_TYPE_NOOP			0
916 #define	NWAM_EVENT_TYPE_INIT			1
917 #define	NWAM_EVENT_TYPE_SHUTDOWN		2
918 #define	NWAM_EVENT_TYPE_OBJECT_ACTION		3
919 #define	NWAM_EVENT_TYPE_OBJECT_STATE		4
920 #define	NWAM_EVENT_TYPE_PRIORITY_GROUP		5
921 #define	NWAM_EVENT_TYPE_INFO			6
922 #define	NWAM_EVENT_TYPE_WLAN_SCAN_REPORT	7
923 #define	NWAM_EVENT_TYPE_WLAN_NEED_CHOICE	8
924 #define	NWAM_EVENT_TYPE_WLAN_NEED_KEY		9
925 #define	NWAM_EVENT_TYPE_WLAN_CONNECTION_REPORT	10
926 #define	NWAM_EVENT_TYPE_IF_ACTION		11
927 #define	NWAM_EVENT_TYPE_IF_STATE		12
928 #define	NWAM_EVENT_TYPE_LINK_ACTION		13
929 #define	NWAM_EVENT_TYPE_LINK_STATE		14
930 #define	NWAM_EVENT_MAX				NWAM_EVENT_TYPE_LINK_STATE
931 
932 #define	NWAM_EVENT_STATUS_OK			0
933 #define	NWAM_EVENT_STATUS_NOT_HANDLED		1
934 
935 #define	NWAM_EVENT_NETWORK_OBJECT_UNDEFINED	0
936 #define	NWAM_EVENT_NETWORK_OBJECT_LINK		1
937 #define	NWAM_EVENT_NETWORK_OBJECT_INTERFACE	2
938 
939 #define	NWAM_EVENT_REQUEST_UNDEFINED		0
940 #define	NWAM_EVENT_REQUEST_WLAN			1
941 #define	NWAM_EVENT_REQUEST_KEY			2
942 
943 /*
944  * Actions for nwamd to perform, used in conjunction with
945  * nwam_request_type_t in nwam_door_arg_t.
946  * Add string representations to nwam_action_to_string() in libnwam_util.c.
947  */
948 typedef enum {
949 	NWAM_ACTION_UNKNOWN = -1,
950 	NWAM_ACTION_ADD,
951 	NWAM_ACTION_REMOVE,
952 	NWAM_ACTION_REFRESH,
953 	NWAM_ACTION_ENABLE,
954 	NWAM_ACTION_DISABLE,
955 	NWAM_ACTION_DESTROY
956 } nwam_action_t;
957 
958 typedef enum {
959 	NWAM_OBJECT_TYPE_UNKNOWN = -1,
960 	NWAM_OBJECT_TYPE_NCP = 0,
961 	NWAM_OBJECT_TYPE_NCU = 1,
962 	NWAM_OBJECT_TYPE_LOC = 2,
963 	NWAM_OBJECT_TYPE_ENM = 3,
964 	NWAM_OBJECT_TYPE_KNOWN_WLAN = 4
965 } nwam_object_type_t;
966 
967 typedef struct nwam_event *nwam_event_t;
968 struct nwam_event {
969 	int nwe_type;
970 	uint32_t nwe_size;
971 
972 	union {
973 		struct nwam_event_object_action {
974 			nwam_object_type_t nwe_object_type;
975 			char nwe_name[NWAM_MAX_NAME_LEN];
976 			char nwe_parent[NWAM_MAX_NAME_LEN];
977 			nwam_action_t nwe_action;
978 		} nwe_object_action;
979 
980 		struct nwam_event_object_state {
981 			nwam_object_type_t nwe_object_type;
982 			char nwe_name[NWAM_MAX_NAME_LEN];
983 			char nwe_parent[NWAM_MAX_NAME_LEN];
984 			nwam_state_t nwe_state;
985 			nwam_aux_state_t nwe_aux_state;
986 		} nwe_object_state;
987 
988 		struct nwam_event_priority_group_info {
989 			int64_t nwe_priority;
990 		} nwe_priority_group_info;
991 
992 		struct nwam_event_info {
993 			char nwe_message[NWAM_MAX_VALUE_LEN];
994 		} nwe_info;
995 
996 		/*
997 		 * wlan_info stores both scan results and the single
998 		 * WLAN we require a key for in the case of _WLAN_NEED_KEY
999 		 * events.  For _WLAN_CONNECTION_REPORT events, it stores
1000 		 * the WLAN the connection succeeded/failed for, indicating
1001 		 * success/failure using the 'connected' boolean.
1002 		 */
1003 		struct nwam_event_wlan_info {
1004 			char nwe_name[NWAM_MAX_NAME_LEN];
1005 			boolean_t nwe_connected;
1006 			uint16_t nwe_num_wlans;
1007 			nwam_wlan_t nwe_wlans[1];
1008 			/*
1009 			 * space may be allocated by user here for the
1010 			 * number of wlans
1011 			 */
1012 		} nwe_wlan_info;
1013 
1014 		struct nwam_event_if_action {
1015 			char nwe_name[NWAM_MAX_NAME_LEN];
1016 			nwam_action_t nwe_action;
1017 		} nwe_if_action;
1018 
1019 		struct nwam_event_if_state {
1020 			char nwe_name[NWAM_MAX_NAME_LEN];
1021 			uint32_t nwe_flags;
1022 			uint32_t nwe_index;
1023 			uint32_t nwe_addr_valid; /* boolean */
1024 			uint32_t nwe_addr_added; /* boolean */
1025 			struct sockaddr_storage nwe_addr;
1026 			/* might be longer then sizeof(if_state) for addr */
1027 		} nwe_if_state;
1028 
1029 		struct nwam_event_link_state {
1030 			char nwe_name[NWAM_MAX_NAME_LEN];
1031 			boolean_t nwe_link_up;
1032 			/* link_state_t from sys/mac.h */
1033 		} nwe_link_state;
1034 
1035 		struct nwam_event_link_action {
1036 			char nwe_name[NWAM_MAX_NAME_LEN];
1037 			nwam_action_t nwe_action;
1038 		} nwe_link_action;
1039 	} nwe_data;
1040 };
1041 
1042 /* NWAM client functions, used to register/unregister and receive events */
1043 extern nwam_error_t nwam_events_init(void);
1044 extern void nwam_events_fini(void);
1045 extern nwam_error_t nwam_event_wait(nwam_event_t *);
1046 extern void nwam_event_free(nwam_event_t);
1047 
1048 /* Event-related string conversion functions */
1049 extern const char *nwam_action_to_string(nwam_action_t);
1050 extern const char *nwam_event_type_to_string(int);
1051 extern const char *nwam_state_to_string(nwam_state_t);
1052 extern const char *nwam_aux_state_to_string(nwam_aux_state_t);
1053 
1054 extern const char *nwam_object_type_to_string(nwam_object_type_t);
1055 extern nwam_object_type_t nwam_string_to_object_type(const char *);
1056 
1057 /* Utility strtok_r-like function */
1058 extern char *nwam_tokenize_by_unescaped_delim(char *, char, char **);
1059 
1060 #ifdef	__cplusplus
1061 }
1062 #endif
1063 
1064 #endif	/* _LIBNWAM_H */
1065