xref: /freebsd/contrib/wpa/wpa_supplicant/dbus/dbus_new.h (revision bb15ca603fa442c72dde3f3cb8b46db6970e3950)
1 /*
2  * WPA Supplicant / dbus-based control interface
3  * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4  * Copyright (c) 2009-2010, Witold Sowa <witold.sowa@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15 
16 #ifndef CTRL_IFACE_DBUS_NEW_H
17 #define CTRL_IFACE_DBUS_NEW_H
18 
19 struct wpa_global;
20 struct wpa_supplicant;
21 struct wpa_ssid;
22 struct wps_event_m2d;
23 struct wps_event_fail;
24 struct wps_credential;
25 enum wpa_states;
26 
27 enum wpas_dbus_prop {
28 	WPAS_DBUS_PROP_AP_SCAN,
29 	WPAS_DBUS_PROP_SCANNING,
30 	WPAS_DBUS_PROP_STATE,
31 	WPAS_DBUS_PROP_CURRENT_BSS,
32 	WPAS_DBUS_PROP_CURRENT_NETWORK,
33 };
34 
35 enum wpas_dbus_bss_prop {
36 	WPAS_DBUS_BSS_PROP_SIGNAL,
37 	WPAS_DBUS_BSS_PROP_FREQ,
38 	WPAS_DBUS_BSS_PROP_MODE,
39 	WPAS_DBUS_BSS_PROP_PRIVACY,
40 	WPAS_DBUS_BSS_PROP_RATES,
41 	WPAS_DBUS_BSS_PROP_WPA,
42 	WPAS_DBUS_BSS_PROP_RSN,
43 	WPAS_DBUS_BSS_PROP_IES,
44 };
45 
46 #define WPAS_DBUS_OBJECT_PATH_MAX 150
47 
48 #define WPAS_DBUS_NEW_SERVICE		"fi.w1.wpa_supplicant1"
49 #define WPAS_DBUS_NEW_PATH		"/fi/w1/wpa_supplicant1"
50 #define WPAS_DBUS_NEW_INTERFACE		"fi.w1.wpa_supplicant1"
51 
52 #define WPAS_DBUS_NEW_PATH_INTERFACES	WPAS_DBUS_NEW_PATH "/Interfaces"
53 #define WPAS_DBUS_NEW_IFACE_INTERFACE	WPAS_DBUS_NEW_INTERFACE ".Interface"
54 #define WPAS_DBUS_NEW_IFACE_WPS WPAS_DBUS_NEW_IFACE_INTERFACE ".WPS"
55 
56 #define WPAS_DBUS_NEW_NETWORKS_PART "Networks"
57 #define WPAS_DBUS_NEW_IFACE_NETWORK WPAS_DBUS_NEW_INTERFACE ".Network"
58 
59 #define WPAS_DBUS_NEW_BSSIDS_PART "BSSs"
60 #define WPAS_DBUS_NEW_IFACE_BSS	WPAS_DBUS_NEW_INTERFACE ".BSS"
61 
62 
63 /* Errors */
64 #define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
65 	WPAS_DBUS_NEW_INTERFACE ".UnknownError"
66 #define WPAS_DBUS_ERROR_INVALID_ARGS \
67 	WPAS_DBUS_NEW_INTERFACE ".InvalidArgs"
68 
69 #define WPAS_DBUS_ERROR_IFACE_EXISTS \
70 	WPAS_DBUS_NEW_INTERFACE ".InterfaceExists"
71 #define WPAS_DBUS_ERROR_IFACE_UNKNOWN \
72 	WPAS_DBUS_NEW_INTERFACE ".InterfaceUnknown"
73 
74 #define WPAS_DBUS_ERROR_NOT_CONNECTED \
75 	WPAS_DBUS_NEW_INTERFACE ".NotConnected"
76 #define WPAS_DBUS_ERROR_NETWORK_UNKNOWN \
77 	WPAS_DBUS_NEW_INTERFACE ".NetworkUnknown"
78 
79 #define WPAS_DBUS_ERROR_BLOB_EXISTS \
80 	WPAS_DBUS_NEW_INTERFACE ".BlobExists"
81 #define WPAS_DBUS_ERROR_BLOB_UNKNOWN \
82 	WPAS_DBUS_NEW_INTERFACE ".BlobUnknown"
83 
84 
85 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
86 
87 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv);
88 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface);
89 
90 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s);
91 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s);
92 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
93 				   enum wpas_dbus_prop property);
94 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
95 				       enum wpas_dbus_bss_prop property,
96 				       unsigned int id);
97 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
98 					      struct wpa_ssid *ssid);
99 void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id);
100 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success);
101 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
102 			       const struct wps_credential *cred);
103 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
104 				    struct wps_event_m2d *m2d);
105 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
106 				     struct wps_event_fail *fail);
107 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s);
108 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
109 			       struct wpa_ssid *ssid);
110 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid);
111 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
112 			     u8 bssid[ETH_ALEN], unsigned int id);
113 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
114 			   u8 bssid[ETH_ALEN], unsigned int id);
115 void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
116 				 const char *name);
117 void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
118 				   const char *name);
119 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global);
120 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
121 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
122 
123 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
124 
125 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
126 {
127 	return 0;
128 }
129 
130 static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
131 {
132 	return 0;
133 }
134 
135 #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0)
136 
137 static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
138 						 enum wpas_dbus_prop property)
139 {
140 }
141 
142 static inline void wpas_dbus_bss_signal_prop_changed(
143 	struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property,
144 	unsigned int id)
145 {
146 }
147 
148 static inline void wpas_dbus_signal_network_enabled_changed(
149 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
150 {
151 }
152 
153 static inline void wpas_dbus_signal_network_selected(
154 	struct wpa_supplicant *wpa_s, int id)
155 {
156 }
157 
158 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
159 					      int success)
160 {
161 }
162 
163 static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
164 					     const struct wps_credential *cred)
165 {
166 }
167 
168 static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
169 						  struct wps_event_m2d *m2d)
170 {
171 }
172 
173 static inline void wpas_dbus_signal_wps_event_fail(
174 	struct wpa_supplicant *wpa_s, struct wps_event_fail *fail)
175 {
176 }
177 
178 static inline void wpas_dbus_signal_wps_event_success(
179 	struct wpa_supplicant *wpa_s)
180 {
181 }
182 
183 static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
184 					     struct wpa_ssid *ssid)
185 {
186 	return 0;
187 }
188 
189 static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s,
190 					       int nid)
191 {
192 	return 0;
193 }
194 
195 static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
196 					   u8 bssid[ETH_ALEN], unsigned int id)
197 {
198 	return 0;
199 }
200 
201 static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
202 					 u8 bssid[ETH_ALEN], unsigned int id)
203 {
204 	return 0;
205 }
206 
207 static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
208 					       const char *name)
209 {
210 }
211 
212 static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
213 						 const char *name)
214 {
215 }
216 
217 static inline void wpas_dbus_signal_debug_level_changed(
218 	struct wpa_global *global)
219 {
220 }
221 
222 static inline void wpas_dbus_signal_debug_timestamp_changed(
223 	struct wpa_global *global)
224 {
225 }
226 
227 static inline void wpas_dbus_signal_debug_show_keys_changed(
228 	struct wpa_global *global)
229 {
230 }
231 
232 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
233 
234 #endif /* CTRL_IFACE_DBUS_H_NEW */
235