1*6ba597c5SAnurag S. Maskey /*
2*6ba597c5SAnurag S. Maskey  * CDDL HEADER START
3*6ba597c5SAnurag S. Maskey  *
4*6ba597c5SAnurag S. Maskey  * The contents of this file are subject to the terms of the
5*6ba597c5SAnurag S. Maskey  * Common Development and Distribution License (the "License").
6*6ba597c5SAnurag S. Maskey  * You may not use this file except in compliance with the License.
7*6ba597c5SAnurag S. Maskey  *
8*6ba597c5SAnurag S. Maskey  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*6ba597c5SAnurag S. Maskey  * or http://www.opensolaris.org/os/licensing.
10*6ba597c5SAnurag S. Maskey  * See the License for the specific language governing permissions
11*6ba597c5SAnurag S. Maskey  * and limitations under the License.
12*6ba597c5SAnurag S. Maskey  *
13*6ba597c5SAnurag S. Maskey  * When distributing Covered Code, include this CDDL HEADER in each
14*6ba597c5SAnurag S. Maskey  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*6ba597c5SAnurag S. Maskey  * If applicable, add the following below this CDDL HEADER, with the
16*6ba597c5SAnurag S. Maskey  * fields enclosed by brackets "[]" replaced with your own identifying
17*6ba597c5SAnurag S. Maskey  * information: Portions Copyright [yyyy] [name of copyright owner]
18*6ba597c5SAnurag S. Maskey  *
19*6ba597c5SAnurag S. Maskey  * CDDL HEADER END
20*6ba597c5SAnurag S. Maskey  */
21*6ba597c5SAnurag S. Maskey /*
22*6ba597c5SAnurag S. Maskey  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
23*6ba597c5SAnurag S. Maskey  * Use is subject to license terms.
24*6ba597c5SAnurag S. Maskey  */
25*6ba597c5SAnurag S. Maskey 
26*6ba597c5SAnurag S. Maskey /*
27*6ba597c5SAnurag S. Maskey  * This file contains private data structures and APIs of libnwam.  Currently
28*6ba597c5SAnurag S. Maskey  * these are used by nwamd (nwam_event_*() and nwam_record_audit_event()) and
29*6ba597c5SAnurag S. Maskey  * netcfgd (nwam_backend_*()) only, supporting the event messaging, audit
30*6ba597c5SAnurag S. Maskey  * and backend configuration access that nwamd and netcfgd supply.
31*6ba597c5SAnurag S. Maskey  *
32*6ba597c5SAnurag S. Maskey  * Implementation is MT safe.
33*6ba597c5SAnurag S. Maskey  */
34*6ba597c5SAnurag S. Maskey #ifndef _LIBNWAM_PRIV_H
35*6ba597c5SAnurag S. Maskey #define	_LIBNWAM_PRIV_H
36*6ba597c5SAnurag S. Maskey 
37*6ba597c5SAnurag S. Maskey #ifdef	__cplusplus
38*6ba597c5SAnurag S. Maskey extern "C" {
39*6ba597c5SAnurag S. Maskey #endif
40*6ba597c5SAnurag S. Maskey 
41*6ba597c5SAnurag S. Maskey #include <libnwam.h>
42*6ba597c5SAnurag S. Maskey 
43*6ba597c5SAnurag S. Maskey /* Name of directory containing the doors */
44*6ba597c5SAnurag S. Maskey #define	NWAM_DOOR_DIR		"/etc/svc/volatile/nwam"
45*6ba597c5SAnurag S. Maskey 
46*6ba597c5SAnurag S. Maskey /* Name of door used to communicate with libnwam backend (in netcfgd) */
47*6ba597c5SAnurag S. Maskey #define	NWAM_BACKEND_DOOR_FILE	NWAM_DOOR_DIR "/nwam_backend_door"
48*6ba597c5SAnurag S. Maskey 
49*6ba597c5SAnurag S. Maskey /* Name of door used to communicate with nwamd */
50*6ba597c5SAnurag S. Maskey #define	NWAM_DOOR		NWAM_DOOR_DIR "/nwam_door"
51*6ba597c5SAnurag S. Maskey 
52*6ba597c5SAnurag S. Maskey /* Requests to nwamd door */
53*6ba597c5SAnurag S. Maskey typedef enum {
54*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_NOOP,
57*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_ACTION,
58*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_STATE,
60*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_WLAN_SCAN,
62*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_WLAN_SELECT,
63*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_TYPE_WLAN_SET_KEY
64*6ba597c5SAnurag S. Maskey } nwam_request_type_t;
65*6ba597c5SAnurag S. Maskey 
66*6ba597c5SAnurag S. Maskey /* Status returned by nwamd door */
67*6ba597c5SAnurag S. Maskey typedef enum {
68*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_STATUS_OK,
69*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_STATUS_FAILED,
70*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_STATUS_UNKNOWN,
71*6ba597c5SAnurag S. Maskey 	NWAM_REQUEST_STATUS_ALREADY
72*6ba597c5SAnurag S. Maskey } nwam_request_status_t;
73*6ba597c5SAnurag S. Maskey 
74*6ba597c5SAnurag S. Maskey #define	NWAMD_MAX_NUM_WLANS	64
75*6ba597c5SAnurag S. Maskey 
76*6ba597c5SAnurag S. Maskey typedef union {
77*6ba597c5SAnurag S. Maskey 	/* Used for EVENT_[UN]REGISTER requests */
78*6ba597c5SAnurag S. Maskey 	struct {
79*6ba597c5SAnurag S. Maskey 		char nwdad_name[MAXPATHLEN];
80*6ba597c5SAnurag S. Maskey 	} nwdad_register_info;
81*6ba597c5SAnurag S. Maskey 
82*6ba597c5SAnurag S. Maskey 	/* Used for ACTION requests */
83*6ba597c5SAnurag S. Maskey 	struct {
84*6ba597c5SAnurag S. Maskey 		nwam_object_type_t nwdad_object_type;
85*6ba597c5SAnurag S. Maskey 		char nwdad_name[NWAM_MAX_NAME_LEN];
86*6ba597c5SAnurag S. Maskey 		char nwdad_parent[NWAM_MAX_NAME_LEN];
87*6ba597c5SAnurag S. Maskey 		nwam_action_t nwdad_action;
88*6ba597c5SAnurag S. Maskey 	} nwdad_object_action;
89*6ba597c5SAnurag S. Maskey 
90*6ba597c5SAnurag S. Maskey 	/* Used for STATE requests */
91*6ba597c5SAnurag S. Maskey 	struct {
92*6ba597c5SAnurag S. Maskey 		nwam_object_type_t nwdad_object_type;
93*6ba597c5SAnurag S. Maskey 		char nwdad_name[NWAM_MAX_NAME_LEN];
94*6ba597c5SAnurag S. Maskey 		char nwdad_parent[NWAM_MAX_NAME_LEN];
95*6ba597c5SAnurag S. Maskey 		nwam_state_t nwdad_state;
96*6ba597c5SAnurag S. Maskey 		nwam_aux_state_t nwdad_aux_state;
97*6ba597c5SAnurag S. Maskey 	} nwdad_object_state;
98*6ba597c5SAnurag S. Maskey 
99*6ba597c5SAnurag S. Maskey 	/* Used for PRIORITY_GROUP requests */
100*6ba597c5SAnurag S. Maskey 	struct {
101*6ba597c5SAnurag S. Maskey 		int64_t nwdad_priority;
102*6ba597c5SAnurag S. Maskey 	} nwdad_priority_group_info;
103*6ba597c5SAnurag S. Maskey 
104*6ba597c5SAnurag S. Maskey 	/* Used for WLAN request/responses */
105*6ba597c5SAnurag S. Maskey 	struct {
106*6ba597c5SAnurag S. Maskey 		char nwdad_name[NWAM_MAX_NAME_LEN];
107*6ba597c5SAnurag S. Maskey 		char nwdad_essid[NWAM_MAX_NAME_LEN];
108*6ba597c5SAnurag S. Maskey 		char nwdad_bssid[NWAM_MAX_NAME_LEN];
109*6ba597c5SAnurag S. Maskey 		uint32_t nwdad_security_mode;
110*6ba597c5SAnurag S. Maskey 		char nwdad_key[NWAM_MAX_NAME_LEN];
111*6ba597c5SAnurag S. Maskey 		uint_t nwdad_keyslot;
112*6ba597c5SAnurag S. Maskey 		boolean_t nwdad_add_to_known_wlans;
113*6ba597c5SAnurag S. Maskey 		uint_t nwdad_num_wlans;
114*6ba597c5SAnurag S. Maskey 		nwam_wlan_t nwdad_wlans[NWAMD_MAX_NUM_WLANS];
115*6ba597c5SAnurag S. Maskey 	} nwdad_wlan_info;
116*6ba597c5SAnurag S. Maskey 
117*6ba597c5SAnurag S. Maskey } nwamd_door_arg_data_t;
118*6ba597c5SAnurag S. Maskey 
119*6ba597c5SAnurag S. Maskey typedef struct {
120*6ba597c5SAnurag S. Maskey 	nwam_request_type_t nwda_type;
121*6ba597c5SAnurag S. Maskey 	nwam_request_status_t nwda_status;
122*6ba597c5SAnurag S. Maskey 	nwam_error_t nwda_error;
123*6ba597c5SAnurag S. Maskey 	nwamd_door_arg_data_t nwda_data;
124*6ba597c5SAnurag S. Maskey } nwamd_door_arg_t;
125*6ba597c5SAnurag S. Maskey 
126*6ba597c5SAnurag S. Maskey typedef enum {
127*6ba597c5SAnurag S. Maskey 	NWAM_BACKEND_DOOR_CMD_READ_REQ,
128*6ba597c5SAnurag S. Maskey 	NWAM_BACKEND_DOOR_CMD_UPDATE_REQ,
129*6ba597c5SAnurag S. Maskey 	NWAM_BACKEND_DOOR_CMD_REMOVE_REQ
130*6ba597c5SAnurag S. Maskey } nwam_backend_door_cmd_t;
131*6ba597c5SAnurag S. Maskey 
132*6ba597c5SAnurag S. Maskey typedef struct nwam_backend_door_arg {
133*6ba597c5SAnurag S. Maskey 	nwam_backend_door_cmd_t nwbda_cmd;
134*6ba597c5SAnurag S. Maskey 	char nwbda_dbname[MAXPATHLEN];			/* config filename */
135*6ba597c5SAnurag S. Maskey 	char nwbda_object[NWAM_MAX_NAME_LEN];		/* config object */
136*6ba597c5SAnurag S. Maskey 	size_t nwbda_datalen;				/* data follows arg */
137*6ba597c5SAnurag S. Maskey 	nwam_error_t nwbda_result;			/* return code */
138*6ba597c5SAnurag S. Maskey 	uint64_t nwbda_flags;
139*6ba597c5SAnurag S. Maskey } nwam_backend_door_arg_t;
140*6ba597c5SAnurag S. Maskey 
141*6ba597c5SAnurag S. Maskey /*
142*6ba597c5SAnurag S. Maskey  * Functions needed to initialize/stop processing of libnwam backend data
143*6ba597c5SAnurag S. Maskey  * (used in netcfgd).
144*6ba597c5SAnurag S. Maskey  */
145*6ba597c5SAnurag S. Maskey extern nwam_error_t nwam_backend_init(void);
146*6ba597c5SAnurag S. Maskey extern void nwam_backend_fini(void);
147*6ba597c5SAnurag S. Maskey 
148*6ba597c5SAnurag S. Maskey /*
149*6ba597c5SAnurag S. Maskey  * create audit session, report event, end session.  Used by nwamd.
150*6ba597c5SAnurag S. Maskey  */
151*6ba597c5SAnurag S. Maskey extern void nwam_record_audit_event(const ucred_t *, au_event_t, char *, char *,
152*6ba597c5SAnurag S. Maskey     int, int);
153*6ba597c5SAnurag S. Maskey 
154*6ba597c5SAnurag S. Maskey /*
155*6ba597c5SAnurag S. Maskey  * NWAM daemon functions, used to send, stop sending, initialize or finish
156*6ba597c5SAnurag S. Maskey  * event IPC.  Used by nwamd.
157*6ba597c5SAnurag S. Maskey  */
158*6ba597c5SAnurag S. Maskey extern nwam_error_t nwam_event_send(nwam_event_t);
159*6ba597c5SAnurag S. Maskey extern void nwam_event_send_fini(void);
160*6ba597c5SAnurag S. Maskey extern nwam_error_t nwam_event_queue_init(const char *);
161*6ba597c5SAnurag S. Maskey extern void nwam_event_queue_fini(const char *);
162*6ba597c5SAnurag S. Maskey 
163*6ba597c5SAnurag S. Maskey #ifdef	__cplusplus
164*6ba597c5SAnurag S. Maskey }
165*6ba597c5SAnurag S. Maskey #endif
166*6ba597c5SAnurag S. Maskey 
167*6ba597c5SAnurag S. Maskey #endif	/* _LIBNWAM_PRIV_H */