1 /* 2 * WPA Supplicant / dbus-based control interface 3 * Copyright (c) 2006, Dan Williams <dcbw (at) redhat.com> and Red Hat, Inc. 4 * Copyright (c) 2009-2010, Witold Sowa <witold.sowa (at) 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 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s, 203 struct wps_event_fail *fail); 204 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s, 205 int depth, const char *subject, 206 const char *cert_hash, 207 const struct wpabuf *cert); 208 209 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ 210 211 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s) 212 { 213 return 0; 214 } 215 216 static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s) 217 { 218 return 0; 219 } 220 221 #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0) 222 223 static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, 224 enum wpas_dbus_prop property) 225 { 226 } 227 228 static inline void wpas_dbus_bss_signal_prop_changed( 229 struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property, 230 unsigned int id) 231 { 232 } 233 234 static inline void wpas_dbus_signal_network_enabled_changed( 235 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) 236 { 237 } 238 239 static inline void wpas_dbus_signal_network_selected( 240 struct wpa_supplicant *wpa_s, int id) 241 { 242 } 243 244 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, 245 int success) 246 { 247 } 248 249 static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, 250 const struct wps_credential *cred) 251 { 252 } 253 254 static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, 255 struct wps_event_m2d *m2d) 256 { 257 } 258 259 static inline void wpas_dbus_signal_wps_event_fail( 260 struct wpa_supplicant *wpa_s, struct wps_event_fail *fail) 261 { 262 } 263 264 static inline void wpas_dbus_signal_wps_event_success( 265 struct wpa_supplicant *wpa_s) 266 { 267 } 268 269 static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s, 270 struct wpa_ssid *ssid) 271 { 272 return 0; 273 } 274 275 static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, 276 int nid) 277 { 278 return 0; 279 } 280 281 static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s, 282 u8 bssid[ETH_ALEN], unsigned int id) 283 { 284 return 0; 285 } 286 287 static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s, 288 u8 bssid[ETH_ALEN], unsigned int id) 289 { 290 return 0; 291 } 292 293 static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s, 294 const char *name) 295 { 296 } 297 298 static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s, 299 const char *name) 300 { 301 } 302 303 static inline void wpas_dbus_signal_debug_level_changed( 304 struct wpa_global *global) 305 { 306 } 307 308 static inline void wpas_dbus_signal_debug_timestamp_changed( 309 struct wpa_global *global) 310 { 311 } 312 313 static inline void wpas_dbus_signal_debug_show_keys_changed( 314 struct wpa_global *global) 315 { 316 } 317 318 static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, 319 const u8 *dev_addr) 320 { 321 return 0; 322 } 323 324 static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s, 325 const u8 *dev_addr) 326 { 327 return 0; 328 } 329 330 static inline void 331 wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s, 332 const char *role) 333 { 334 } 335 336 static inline void 337 wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s, 338 const u8 *dev_addr, int request, 339 enum p2p_prov_disc_status status, 340 u16 config_methods, 341 unsigned int generated_pin) 342 { 343 } 344 345 static inline void wpas_dbus_signal_p2p_go_neg_req( 346 struct wpa_supplicant *wpa_s, 347 const u8 *src, 348 u16 dev_passwd_id) 349 { 350 } 351 352 static inline void 353 wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s, 354 const struct wpa_ssid *ssid, 355 int client, int network_id) 356 { 357 } 358 359 static inline void 360 wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s, 361 struct wpa_ssid *ssid) 362 { 363 } 364 365 static inline int wpas_dbus_register_persistent_group( 366 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) 367 { 368 return 0; 369 } 370 371 static inline int wpas_dbus_unregister_persistent_group( 372 struct wpa_supplicant *wpa_s, int nid) 373 { 374 return 0; 375 } 376 377 static inline void 378 wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, int status) 379 { 380 } 381 382 static inline void 383 wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s, 384 const struct wpa_ssid *ssid) 385 { 386 } 387 388 static inline void wpas_dbus_signal_p2p_invitation_result( 389 struct wpa_supplicant *wpa_s, int status, 390 const u8 *bssid) 391 { 392 } 393 394 static inline void 395 wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s, 396 const u8 *p2p_if_addr) 397 { 398 } 399 400 static inline void 401 wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq, 402 const u8 *sa, u8 dialog_token, u16 update_indic, 403 const u8 *tlvs, size_t tlvs_len) 404 { 405 } 406 407 static inline void 408 wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s, 409 const u8 *sa, u16 update_indic, 410 const u8 *tlvs, size_t tlvs_len) 411 { 412 } 413 414 static inline void 415 wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s, 416 const u8 *p2p_if_addr) 417 { 418 } 419 420 static inline void 421 wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s, 422 const u8 *member) 423 { 424 } 425 426 static inline void 427 wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, 428 const u8 *dev_addr) 429 { 430 } 431 432 static inline void 433 wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s, 434 const u8 *dev_addr) 435 { 436 } 437 438 static inline void 439 wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s, 440 const u8 *member) 441 { 442 } 443 444 static inline void 445 wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s, 446 struct wps_event_fail *fail) 447 { 448 } 449 450 static inline void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s, 451 int depth, 452 const char *subject, 453 const char *cert_hash, 454 const struct wpabuf *cert) 455 { 456 } 457 458 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ 459 460 #endif /* CTRL_IFACE_DBUS_H_NEW */ 461