xref: /titanic_41/usr/src/lib/libnwam/common/libnwam_priv.h (revision 6ba597c56d749c61b4f783157f63196d7b2445f0)
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 private data structures and APIs of libnwam.  Currently
28  * these are used by nwamd (nwam_event_*() and nwam_record_audit_event()) and
29  * netcfgd (nwam_backend_*()) only, supporting the event messaging, audit
30  * and backend configuration access that nwamd and netcfgd supply.
31  *
32  * Implementation is MT safe.
33  */
34 #ifndef _LIBNWAM_PRIV_H
35 #define	_LIBNWAM_PRIV_H
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 #include <libnwam.h>
42 
43 /* Name of directory containing the doors */
44 #define	NWAM_DOOR_DIR		"/etc/svc/volatile/nwam"
45 
46 /* Name of door used to communicate with libnwam backend (in netcfgd) */
47 #define	NWAM_BACKEND_DOOR_FILE	NWAM_DOOR_DIR "/nwam_backend_door"
48 
49 /* Name of door used to communicate with nwamd */
50 #define	NWAM_DOOR		NWAM_DOOR_DIR "/nwam_door"
51 
52 /* Requests to nwamd door */
53 typedef enum {
54 	NWAM_REQUEST_TYPE_NOOP,
55 	NWAM_REQUEST_TYPE_EVENT_REGISTER,
56 	NWAM_REQUEST_TYPE_EVENT_UNREGISTER,
57 	NWAM_REQUEST_TYPE_ACTION,
58 	NWAM_REQUEST_TYPE_STATE,
59 	NWAM_REQUEST_TYPE_PRIORITY_GROUP,
60 	NWAM_REQUEST_TYPE_WLAN_SCAN,
61 	NWAM_REQUEST_TYPE_WLAN_SCAN_RESULTS,
62 	NWAM_REQUEST_TYPE_WLAN_SELECT,
63 	NWAM_REQUEST_TYPE_WLAN_SET_KEY
64 } nwam_request_type_t;
65 
66 /* Status returned by nwamd door */
67 typedef enum {
68 	NWAM_REQUEST_STATUS_OK,
69 	NWAM_REQUEST_STATUS_FAILED,
70 	NWAM_REQUEST_STATUS_UNKNOWN,
71 	NWAM_REQUEST_STATUS_ALREADY
72 } nwam_request_status_t;
73 
74 #define	NWAMD_MAX_NUM_WLANS	64
75 
76 typedef union {
77 	/* Used for EVENT_[UN]REGISTER requests */
78 	struct {
79 		char nwdad_name[MAXPATHLEN];
80 	} nwdad_register_info;
81 
82 	/* Used for ACTION requests */
83 	struct {
84 		nwam_object_type_t nwdad_object_type;
85 		char nwdad_name[NWAM_MAX_NAME_LEN];
86 		char nwdad_parent[NWAM_MAX_NAME_LEN];
87 		nwam_action_t nwdad_action;
88 	} nwdad_object_action;
89 
90 	/* Used for STATE requests */
91 	struct {
92 		nwam_object_type_t nwdad_object_type;
93 		char nwdad_name[NWAM_MAX_NAME_LEN];
94 		char nwdad_parent[NWAM_MAX_NAME_LEN];
95 		nwam_state_t nwdad_state;
96 		nwam_aux_state_t nwdad_aux_state;
97 	} nwdad_object_state;
98 
99 	/* Used for PRIORITY_GROUP requests */
100 	struct {
101 		int64_t nwdad_priority;
102 	} nwdad_priority_group_info;
103 
104 	/* Used for WLAN request/responses */
105 	struct {
106 		char nwdad_name[NWAM_MAX_NAME_LEN];
107 		char nwdad_essid[NWAM_MAX_NAME_LEN];
108 		char nwdad_bssid[NWAM_MAX_NAME_LEN];
109 		uint32_t nwdad_security_mode;
110 		char nwdad_key[NWAM_MAX_NAME_LEN];
111 		uint_t nwdad_keyslot;
112 		boolean_t nwdad_add_to_known_wlans;
113 		uint_t nwdad_num_wlans;
114 		nwam_wlan_t nwdad_wlans[NWAMD_MAX_NUM_WLANS];
115 	} nwdad_wlan_info;
116 
117 } nwamd_door_arg_data_t;
118 
119 typedef struct {
120 	nwam_request_type_t nwda_type;
121 	nwam_request_status_t nwda_status;
122 	nwam_error_t nwda_error;
123 	nwamd_door_arg_data_t nwda_data;
124 } nwamd_door_arg_t;
125 
126 typedef enum {
127 	NWAM_BACKEND_DOOR_CMD_READ_REQ,
128 	NWAM_BACKEND_DOOR_CMD_UPDATE_REQ,
129 	NWAM_BACKEND_DOOR_CMD_REMOVE_REQ
130 } nwam_backend_door_cmd_t;
131 
132 typedef struct nwam_backend_door_arg {
133 	nwam_backend_door_cmd_t nwbda_cmd;
134 	char nwbda_dbname[MAXPATHLEN];			/* config filename */
135 	char nwbda_object[NWAM_MAX_NAME_LEN];		/* config object */
136 	size_t nwbda_datalen;				/* data follows arg */
137 	nwam_error_t nwbda_result;			/* return code */
138 	uint64_t nwbda_flags;
139 } nwam_backend_door_arg_t;
140 
141 /*
142  * Functions needed to initialize/stop processing of libnwam backend data
143  * (used in netcfgd).
144  */
145 extern nwam_error_t nwam_backend_init(void);
146 extern void nwam_backend_fini(void);
147 
148 /*
149  * create audit session, report event, end session.  Used by nwamd.
150  */
151 extern void nwam_record_audit_event(const ucred_t *, au_event_t, char *, char *,
152     int, int);
153 
154 /*
155  * NWAM daemon functions, used to send, stop sending, initialize or finish
156  * event IPC.  Used by nwamd.
157  */
158 extern nwam_error_t nwam_event_send(nwam_event_t);
159 extern void nwam_event_send_fini(void);
160 extern nwam_error_t nwam_event_queue_init(const char *);
161 extern void nwam_event_queue_fini(const char *);
162 
163 #ifdef	__cplusplus
164 }
165 #endif
166 
167 #endif	/* _LIBNWAM_PRIV_H */
168