P2P: More complete persistent group management over D-Bus
[mech_eap.git] / wpa_supplicant / dbus / dbus_new.h
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 #include "p2p/p2p.h"
20
21 struct wpa_global;
22 struct wpa_supplicant;
23 struct wpa_ssid;
24 struct wps_event_m2d;
25 struct wps_event_fail;
26 struct wps_credential;
27 enum wpa_states;
28
29 enum wpas_dbus_prop {
30         WPAS_DBUS_PROP_AP_SCAN,
31         WPAS_DBUS_PROP_SCANNING,
32         WPAS_DBUS_PROP_STATE,
33         WPAS_DBUS_PROP_CURRENT_BSS,
34         WPAS_DBUS_PROP_CURRENT_NETWORK,
35         WPAS_DBUS_PROP_CURRENT_AUTH_MODE,
36         WPAS_DBUS_PROP_BSSS,
37 };
38
39 enum wpas_dbus_bss_prop {
40         WPAS_DBUS_BSS_PROP_SIGNAL,
41         WPAS_DBUS_BSS_PROP_FREQ,
42         WPAS_DBUS_BSS_PROP_MODE,
43         WPAS_DBUS_BSS_PROP_PRIVACY,
44         WPAS_DBUS_BSS_PROP_RATES,
45         WPAS_DBUS_BSS_PROP_WPA,
46         WPAS_DBUS_BSS_PROP_RSN,
47         WPAS_DBUS_BSS_PROP_IES,
48 };
49
50 #define WPAS_DBUS_OBJECT_PATH_MAX 150
51
52 #define WPAS_DBUS_NEW_SERVICE           "fi.w1.wpa_supplicant1"
53 #define WPAS_DBUS_NEW_PATH              "/fi/w1/wpa_supplicant1"
54 #define WPAS_DBUS_NEW_INTERFACE         "fi.w1.wpa_supplicant1"
55
56 #define WPAS_DBUS_NEW_PATH_INTERFACES   WPAS_DBUS_NEW_PATH "/Interfaces"
57 #define WPAS_DBUS_NEW_IFACE_INTERFACE   WPAS_DBUS_NEW_INTERFACE ".Interface"
58 #define WPAS_DBUS_NEW_IFACE_WPS WPAS_DBUS_NEW_IFACE_INTERFACE ".WPS"
59
60 #define WPAS_DBUS_NEW_NETWORKS_PART "Networks"
61 #define WPAS_DBUS_NEW_IFACE_NETWORK WPAS_DBUS_NEW_INTERFACE ".Network"
62
63 #define WPAS_DBUS_NEW_BSSIDS_PART "BSSs"
64 #define WPAS_DBUS_NEW_IFACE_BSS WPAS_DBUS_NEW_INTERFACE ".BSS"
65
66 #define WPAS_DBUS_NEW_IFACE_P2PDEVICE   \
67                 WPAS_DBUS_NEW_IFACE_INTERFACE ".P2PDevice"
68
69 /*
70  * Groups correspond to P2P groups where this device is a GO (owner)
71  */
72 #define WPAS_DBUS_NEW_P2P_GROUPS_PART   "Groups"
73 #define WPAS_DBUS_NEW_IFACE_P2P_GROUP WPAS_DBUS_NEW_INTERFACE ".Group"
74
75 /*
76  * Different dbus object for persistent groups so they do not get confused
77  * with regular (configured) network objects.
78  */
79 #define WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "PersistentGroups"
80 #define WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP \
81         WPAS_DBUS_NEW_INTERFACE ".PersistentGroup"
82
83 #define WPAS_DBUS_NEW_P2P_PEERS_PART    "Peers"
84 #define WPAS_DBUS_NEW_IFACE_P2P_PEER WPAS_DBUS_NEW_INTERFACE ".Peer"
85
86 #define WPAS_DBUS_NEW_P2P_GROUPMEMBERS_PART     "Members"
87 #define WPAS_DBUS_NEW_IFACE_P2P_GROUPMEMBER \
88         WPAS_DBUS_NEW_INTERFACE ".GroupMember"
89
90 /* Errors */
91 #define WPAS_DBUS_ERROR_UNKNOWN_ERROR \
92         WPAS_DBUS_NEW_INTERFACE ".UnknownError"
93 #define WPAS_DBUS_ERROR_INVALID_ARGS \
94         WPAS_DBUS_NEW_INTERFACE ".InvalidArgs"
95
96 #define WPAS_DBUS_ERROR_IFACE_EXISTS \
97         WPAS_DBUS_NEW_INTERFACE ".InterfaceExists"
98 #define WPAS_DBUS_ERROR_IFACE_UNKNOWN \
99         WPAS_DBUS_NEW_INTERFACE ".InterfaceUnknown"
100
101 #define WPAS_DBUS_ERROR_NOT_CONNECTED \
102         WPAS_DBUS_NEW_INTERFACE ".NotConnected"
103 #define WPAS_DBUS_ERROR_NETWORK_UNKNOWN \
104         WPAS_DBUS_NEW_INTERFACE ".NetworkUnknown"
105
106 #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE \
107         WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnavailable"
108 #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED \
109         WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnsupported"
110 #define WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR \
111         WPAS_DBUS_NEW_INTERFACE ".ConnectUnspecifiedError"
112
113 #define WPAS_DBUS_ERROR_BLOB_EXISTS \
114         WPAS_DBUS_NEW_INTERFACE ".BlobExists"
115 #define WPAS_DBUS_ERROR_BLOB_UNKNOWN \
116         WPAS_DBUS_NEW_INTERFACE ".BlobUnknown"
117
118
119 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW
120
121 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv);
122 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface);
123
124 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s);
125 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s);
126 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
127                                    enum wpas_dbus_prop property);
128 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s,
129                                        enum wpas_dbus_bss_prop property,
130                                        unsigned int id);
131 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s,
132                                               struct wpa_ssid *ssid);
133 void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id);
134 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success);
135 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
136                                const struct wps_credential *cred);
137 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
138                                     struct wps_event_m2d *m2d);
139 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
140                                      struct wps_event_fail *fail);
141 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s);
142 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
143                                struct wpa_ssid *ssid);
144 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid);
145 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
146                              u8 bssid[ETH_ALEN], unsigned int id);
147 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
148                            u8 bssid[ETH_ALEN], unsigned int id);
149 void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
150                                  const char *name);
151 void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
152                                    const char *name);
153 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global);
154 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
155 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
156
157 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr);
158 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
159                                            const u8 *dev_addr);
160 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
161                                   const u8 *dev_addr);
162 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
163                                            const u8 *dev_addr);
164 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
165                                         const char *role);
166 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
167                                               const u8 *dev_addr, int request,
168                                               enum p2p_prov_disc_status status,
169                                               u16 config_methods,
170                                               unsigned int generated_pin);
171 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
172                                      const u8 *src, u16 dev_passwd_id);
173 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
174                                         const struct wpa_ssid *ssid,
175                                         int client, int network_id);
176 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
177                                   struct wpa_ssid *ssid);
178 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status);
179 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
180                                     const struct wpa_ssid *ssid);
181 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
182                                         struct wpa_ssid *ssid);
183 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
184                                           int nid);
185 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
186                                             int status, const u8 *bssid);
187 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
188                                         const u8 *p2p_if_addr);
189 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
190                                           const u8 *p2p_if_addr);
191 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
192                                             const u8 *member);
193 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
194                                      int freq, const u8 *sa, u8 dialog_token,
195                                      u16 update_indic, const u8 *tlvs,
196                                      size_t tlvs_len);
197 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
198                                       const u8 *sa, u16 update_indic,
199                                       const u8 *tlvs, size_t tlvs_len);
200 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
201                                 const u8 *member);
202
203 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
204
205 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
206 {
207         return 0;
208 }
209
210 static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
211 {
212         return 0;
213 }
214
215 #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0)
216
217 static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
218                                                  enum wpas_dbus_prop property)
219 {
220 }
221
222 static inline void wpas_dbus_bss_signal_prop_changed(
223         struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property,
224         unsigned int id)
225 {
226 }
227
228 static inline void wpas_dbus_signal_network_enabled_changed(
229         struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
230 {
231 }
232
233 static inline void wpas_dbus_signal_network_selected(
234         struct wpa_supplicant *wpa_s, int id)
235 {
236 }
237
238 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
239                                               int success)
240 {
241 }
242
243 static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
244                                              const struct wps_credential *cred)
245 {
246 }
247
248 static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
249                                                   struct wps_event_m2d *m2d)
250 {
251 }
252
253 static inline void wpas_dbus_signal_wps_event_fail(
254         struct wpa_supplicant *wpa_s, struct wps_event_fail *fail)
255 {
256 }
257
258 static inline void wpas_dbus_signal_wps_event_success(
259         struct wpa_supplicant *wpa_s)
260 {
261 }
262
263 static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
264                                              struct wpa_ssid *ssid)
265 {
266         return 0;
267 }
268
269 static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s,
270                                                int nid)
271 {
272         return 0;
273 }
274
275 static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
276                                            u8 bssid[ETH_ALEN], unsigned int id)
277 {
278         return 0;
279 }
280
281 static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
282                                          u8 bssid[ETH_ALEN], unsigned int id)
283 {
284         return 0;
285 }
286
287 static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
288                                                const char *name)
289 {
290 }
291
292 static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
293                                                  const char *name)
294 {
295 }
296
297 static inline void wpas_dbus_signal_debug_level_changed(
298         struct wpa_global *global)
299 {
300 }
301
302 static inline void wpas_dbus_signal_debug_timestamp_changed(
303         struct wpa_global *global)
304 {
305 }
306
307 static inline void wpas_dbus_signal_debug_show_keys_changed(
308         struct wpa_global *global)
309 {
310 }
311
312 static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s,
313                                           const u8 *dev_addr)
314 {
315         return 0;
316 }
317
318 static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
319                                             const u8 *dev_addr)
320 {
321         return 0;
322 }
323
324 static inline void
325 wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
326                                    const char *role)
327 {
328 }
329
330 static inline void
331 wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
332                                          const u8 *dev_addr, int request,
333                                          enum p2p_prov_disc_status status,
334                                          u16 config_methods,
335                                          unsigned int generated_pin)
336 {
337 }
338
339 static inline void wpas_dbus_signal_p2p_go_neg_req(
340                                 struct wpa_supplicant *wpa_s,
341                                 const u8 *src,
342                                 u16 dev_passwd_id)
343 {
344 }
345
346 static inline void
347 wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
348                                    const struct wpa_ssid *ssid,
349                                    int client, int network_id)
350 {
351 }
352
353 static inline void
354 wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
355                              struct wpa_ssid *ssid)
356 {
357 }
358
359 static inline int wpas_dbus_register_persistent_group(
360         struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
361 {
362         return 0;
363 }
364
365 static inline int wpas_dbus_unregister_persistent_group(
366         struct wpa_supplicant *wpa_s, int nid)
367 {
368         return 0;
369 }
370
371 static inline void
372 wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status)
373 {
374 }
375
376 static inline void
377 wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
378                                const struct wpa_ssid *ssid)
379 {
380 }
381
382 static inline void wpas_dbus_signal_p2p_invitation_result(
383                                 struct wpa_supplicant *wpa_s, int status,
384                                 const u8 *bssid)
385 {
386 }
387
388 static inline void
389 wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
390                                    const u8 *p2p_if_addr)
391 {
392 }
393
394 static inline void
395 wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq,
396                                 const u8 *sa, u8 dialog_token, u16 update_indic,
397                                 const u8 *tlvs, size_t tlvs_len)
398 {
399 }
400
401 static inline void
402 wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
403                                  const u8 *sa, u16 update_indic,
404                                  const u8 *tlvs, size_t tlvs_len)
405 {
406 }
407
408 static inline void
409 wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
410                                      const u8 *p2p_if_addr)
411 {
412 }
413
414 static inline void
415 wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
416                                  const u8 *member)
417 {
418 }
419
420 static inline void
421 wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
422                                    const u8 *dev_addr)
423 {
424 }
425
426 static inline void
427 wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
428                                   const u8 *dev_addr)
429 {
430 }
431
432 static inline void
433 wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
434                                        const u8 *member)
435 {
436 }
437 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
438
439 #endif /* CTRL_IFACE_DBUS_H_NEW */