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 software may be distributed under the terms of the BSD license. 7 * See README for more details. 8 */ 9 10 #ifndef CTRL_IFACE_DBUS_NEW_H 11 #define CTRL_IFACE_DBUS_NEW_H 12 13 #include "common/defs.h" 14 #include "p2p/p2p.h" 15 16 struct wpa_global; 17 struct wpa_supplicant; 18 struct wpa_ssid; 19 struct wps_event_m2d; 20 struct wps_event_fail; 21 struct wps_credential; 22 23 enum wpas_dbus_prop { 24 WPAS_DBUS_PROP_AP_SCAN, 25 WPAS_DBUS_PROP_SCANNING, 26 WPAS_DBUS_PROP_STATE, 27 WPAS_DBUS_PROP_CURRENT_BSS, 28 WPAS_DBUS_PROP_CURRENT_NETWORK, 29 WPAS_DBUS_PROP_CURRENT_AUTH_MODE, 30 WPAS_DBUS_PROP_BSSS, 31 WPAS_DBUS_PROP_DISCONNECT_REASON, 32 }; 33 34 enum wpas_dbus_bss_prop { 35 WPAS_DBUS_BSS_PROP_SIGNAL, 36 WPAS_DBUS_BSS_PROP_FREQ, 37 WPAS_DBUS_BSS_PROP_MODE, 38 WPAS_DBUS_BSS_PROP_PRIVACY, 39 WPAS_DBUS_BSS_PROP_RATES, 40 WPAS_DBUS_BSS_PROP_WPA, 41 WPAS_DBUS_BSS_PROP_RSN, 42 WPAS_DBUS_BSS_PROP_WPS, 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 #define WPAS_DBUS_NEW_IFACE_P2PDEVICE \ 63 WPAS_DBUS_NEW_IFACE_INTERFACE ".P2PDevice" 64 65 /* 66 * Groups correspond to P2P groups where this device is a GO (owner) 67 */ 68 #define WPAS_DBUS_NEW_P2P_GROUPS_PART "Groups" 69 #define WPAS_DBUS_NEW_IFACE_P2P_GROUP WPAS_DBUS_NEW_INTERFACE ".Group" 70 71 /* 72 * Different dbus object for persistent groups so they do not get confused 73 * with regular (configured) network objects. 74 */ 75 #define WPAS_DBUS_NEW_PERSISTENT_GROUPS_PART "PersistentGroups" 76 #define WPAS_DBUS_NEW_IFACE_PERSISTENT_GROUP \ 77 WPAS_DBUS_NEW_INTERFACE ".PersistentGroup" 78 79 #define WPAS_DBUS_NEW_P2P_PEERS_PART "Peers" 80 #define WPAS_DBUS_NEW_IFACE_P2P_PEER WPAS_DBUS_NEW_INTERFACE ".Peer" 81 82 /* Top-level Errors */ 83 #define WPAS_DBUS_ERROR_UNKNOWN_ERROR \ 84 WPAS_DBUS_NEW_INTERFACE ".UnknownError" 85 #define WPAS_DBUS_ERROR_INVALID_ARGS \ 86 WPAS_DBUS_NEW_INTERFACE ".InvalidArgs" 87 88 #define WPAS_DBUS_ERROR_IFACE_EXISTS \ 89 WPAS_DBUS_NEW_INTERFACE ".InterfaceExists" 90 #define WPAS_DBUS_ERROR_IFACE_DISABLED \ 91 WPAS_DBUS_NEW_INTERFACE ".InterfaceDisabled" 92 #define WPAS_DBUS_ERROR_IFACE_UNKNOWN \ 93 WPAS_DBUS_NEW_INTERFACE ".InterfaceUnknown" 94 95 #define WPAS_DBUS_ERROR_NOT_CONNECTED \ 96 WPAS_DBUS_NEW_INTERFACE ".NotConnected" 97 #define WPAS_DBUS_ERROR_NETWORK_UNKNOWN \ 98 WPAS_DBUS_NEW_INTERFACE ".NetworkUnknown" 99 100 #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNAVAILABLE \ 101 WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnavailable" 102 #define WPAS_DBUS_ERROR_CONNECT_CHANNEL_UNSUPPORTED \ 103 WPAS_DBUS_NEW_INTERFACE ".ConnectChannelUnsupported" 104 #define WPAS_DBUS_ERROR_CONNECT_UNSPECIFIED_ERROR \ 105 WPAS_DBUS_NEW_INTERFACE ".ConnectUnspecifiedError" 106 107 #define WPAS_DBUS_ERROR_BLOB_EXISTS \ 108 WPAS_DBUS_NEW_INTERFACE ".BlobExists" 109 #define WPAS_DBUS_ERROR_BLOB_UNKNOWN \ 110 WPAS_DBUS_NEW_INTERFACE ".BlobUnknown" 111 112 #define WPAS_DBUS_ERROR_SUBSCRIPTION_IN_USE \ 113 WPAS_DBUS_NEW_INTERFACE ".SubscriptionInUse" 114 #define WPAS_DBUS_ERROR_NO_SUBSCRIPTION \ 115 WPAS_DBUS_NEW_INTERFACE ".NoSubscription" 116 #define WPAS_DBUS_ERROR_SUBSCRIPTION_EPERM \ 117 WPAS_DBUS_NEW_INTERFACE ".SubscriptionNotYou" 118 119 /* Interface-level errors */ 120 #define WPAS_DBUS_ERROR_IFACE_SCAN_ERROR \ 121 WPAS_DBUS_NEW_IFACE_INTERFACE ".ScanError" 122 123 void wpas_dbus_subscribe_noc(struct wpas_dbus_priv *priv); 124 void wpas_dbus_unsubscribe_noc(struct wpas_dbus_priv *priv); 125 126 127 #ifdef CONFIG_CTRL_IFACE_DBUS_NEW 128 129 int wpas_dbus_ctrl_iface_init(struct wpas_dbus_priv *priv); 130 void wpas_dbus_ctrl_iface_deinit(struct wpas_dbus_priv *iface); 131 132 int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s); 133 int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s); 134 void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, 135 enum wpas_dbus_prop property); 136 void wpas_dbus_bss_signal_prop_changed(struct wpa_supplicant *wpa_s, 137 enum wpas_dbus_bss_prop property, 138 unsigned int id); 139 void wpas_dbus_signal_network_enabled_changed(struct wpa_supplicant *wpa_s, 140 struct wpa_ssid *ssid); 141 void wpas_dbus_signal_network_selected(struct wpa_supplicant *wpa_s, int id); 142 void wpas_dbus_signal_network_request(struct wpa_supplicant *wpa_s, 143 struct wpa_ssid *ssid, 144 enum wpa_ctrl_req_type rtype, 145 const char *default_text); 146 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success); 147 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, 148 const struct wps_credential *cred); 149 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, 150 struct wps_event_m2d *m2d); 151 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s, 152 struct wps_event_fail *fail); 153 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s); 154 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s, 155 struct wpa_ssid *ssid); 156 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid); 157 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s, 158 u8 bssid[ETH_ALEN], unsigned int id); 159 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s, 160 u8 bssid[ETH_ALEN], unsigned int id); 161 void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s, 162 const char *name); 163 void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s, 164 const char *name); 165 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global); 166 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global); 167 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global); 168 169 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr); 170 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, 171 const u8 *dev_addr); 172 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s, 173 const u8 *dev_addr); 174 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s, 175 const u8 *dev_addr); 176 void wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s, 177 const u8 *dev_addr); 178 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s, 179 const char *role); 180 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s, 181 const u8 *dev_addr, int request, 182 enum p2p_prov_disc_status status, 183 u16 config_methods, 184 unsigned int generated_pin); 185 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s, 186 const u8 *src, u16 dev_passwd_id); 187 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s, 188 const struct wpa_ssid *ssid, 189 int client, int network_id); 190 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s, 191 struct wpa_ssid *ssid); 192 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, 193 struct p2p_go_neg_results *res); 194 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s, 195 const struct wpa_ssid *ssid); 196 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s, 197 struct wpa_ssid *ssid); 198 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s, 199 int nid); 200 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s, 201 int status, const u8 *bssid); 202 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s, 203 const u8 *member); 204 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, 205 int freq, const u8 *sa, u8 dialog_token, 206 u16 update_indic, const u8 *tlvs, 207 size_t tlvs_len); 208 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s, 209 const u8 *sa, u16 update_indic, 210 const u8 *tlvs, size_t tlvs_len); 211 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s, 212 const u8 *member); 213 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s, 214 struct wps_event_fail *fail); 215 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s, 216 int depth, const char *subject, 217 const char *cert_hash, 218 const struct wpabuf *cert); 219 void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s, 220 const u8 *addr, const u8 *dst, const u8 *bssid, 221 const u8 *ie, size_t ie_len, u32 ssi_signal); 222 void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, 223 const char *status, const char *parameter); 224 void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, 225 const u8 *sta); 226 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, 227 const u8 *sta); 228 229 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */ 230 231 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s) 232 { 233 return 0; 234 } 235 236 static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s) 237 { 238 return 0; 239 } 240 241 #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0) 242 243 static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s, 244 enum wpas_dbus_prop property) 245 { 246 } 247 248 static inline void wpas_dbus_bss_signal_prop_changed( 249 struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property, 250 unsigned int id) 251 { 252 } 253 254 static inline void wpas_dbus_signal_network_enabled_changed( 255 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) 256 { 257 } 258 259 static inline void wpas_dbus_signal_network_selected( 260 struct wpa_supplicant *wpa_s, int id) 261 { 262 } 263 264 static inline void wpas_dbus_signal_network_request( 265 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, 266 enum wpa_ctrl_req_type rtype, const char *default_txt) 267 { 268 } 269 270 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, 271 int success) 272 { 273 } 274 275 static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s, 276 const struct wps_credential *cred) 277 { 278 } 279 280 static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s, 281 struct wps_event_m2d *m2d) 282 { 283 } 284 285 static inline void wpas_dbus_signal_wps_event_fail( 286 struct wpa_supplicant *wpa_s, struct wps_event_fail *fail) 287 { 288 } 289 290 static inline void wpas_dbus_signal_wps_event_success( 291 struct wpa_supplicant *wpa_s) 292 { 293 } 294 295 static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s, 296 struct wpa_ssid *ssid) 297 { 298 return 0; 299 } 300 301 static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, 302 int nid) 303 { 304 return 0; 305 } 306 307 static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s, 308 u8 bssid[ETH_ALEN], unsigned int id) 309 { 310 return 0; 311 } 312 313 static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s, 314 u8 bssid[ETH_ALEN], unsigned int id) 315 { 316 return 0; 317 } 318 319 static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s, 320 const char *name) 321 { 322 } 323 324 static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s, 325 const char *name) 326 { 327 } 328 329 static inline void wpas_dbus_signal_debug_level_changed( 330 struct wpa_global *global) 331 { 332 } 333 334 static inline void wpas_dbus_signal_debug_timestamp_changed( 335 struct wpa_global *global) 336 { 337 } 338 339 static inline void wpas_dbus_signal_debug_show_keys_changed( 340 struct wpa_global *global) 341 { 342 } 343 344 static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, 345 const u8 *dev_addr) 346 { 347 return 0; 348 } 349 350 static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s, 351 const u8 *dev_addr) 352 { 353 return 0; 354 } 355 356 static inline void 357 wpas_dbus_signal_peer_groups_changed(struct wpa_supplicant *wpa_s, 358 const u8 *dev_addr) 359 { 360 } 361 362 static inline void 363 wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s, 364 const char *role) 365 { 366 } 367 368 static inline void 369 wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s, 370 const u8 *dev_addr, int request, 371 enum p2p_prov_disc_status status, 372 u16 config_methods, 373 unsigned int generated_pin) 374 { 375 } 376 377 static inline void wpas_dbus_signal_p2p_go_neg_req( 378 struct wpa_supplicant *wpa_s, 379 const u8 *src, 380 u16 dev_passwd_id) 381 { 382 } 383 384 static inline void 385 wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s, 386 const struct wpa_ssid *ssid, 387 int client, int network_id) 388 { 389 } 390 391 static inline void 392 wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s, 393 struct wpa_ssid *ssid) 394 { 395 } 396 397 static inline int wpas_dbus_register_persistent_group( 398 struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid) 399 { 400 return 0; 401 } 402 403 static inline int wpas_dbus_unregister_persistent_group( 404 struct wpa_supplicant *wpa_s, int nid) 405 { 406 return 0; 407 } 408 409 static inline void 410 wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s, 411 struct p2p_go_neg_results *res) 412 { 413 } 414 415 static inline void 416 wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s, 417 const struct wpa_ssid *ssid) 418 { 419 } 420 421 static inline void wpas_dbus_signal_p2p_invitation_result( 422 struct wpa_supplicant *wpa_s, int status, 423 const u8 *bssid) 424 { 425 } 426 427 static inline void 428 wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s, 429 const u8 *p2p_if_addr) 430 { 431 } 432 433 static inline void 434 wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq, 435 const u8 *sa, u8 dialog_token, u16 update_indic, 436 const u8 *tlvs, size_t tlvs_len) 437 { 438 } 439 440 static inline void 441 wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s, 442 const u8 *sa, u16 update_indic, 443 const u8 *tlvs, size_t tlvs_len) 444 { 445 } 446 447 static inline void 448 wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s, 449 const u8 *p2p_if_addr) 450 { 451 } 452 453 static inline void 454 wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s, 455 const u8 *member) 456 { 457 } 458 459 static inline void 460 wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s, 461 const u8 *dev_addr) 462 { 463 } 464 465 static inline void 466 wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s, 467 const u8 *dev_addr) 468 { 469 } 470 471 static inline void 472 wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s, 473 const u8 *member) 474 { 475 } 476 477 static inline void 478 wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s, 479 struct wps_event_fail *fail) 480 { 481 } 482 483 static inline void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s, 484 int depth, 485 const char *subject, 486 const char *cert_hash, 487 const struct wpabuf *cert) 488 { 489 } 490 491 static inline void wpas_dbus_signal_preq(struct wpa_supplicant *wpa_s, 492 const u8 *addr, const u8 *dst, 493 const u8 *bssid, 494 const u8 *ie, size_t ie_len, 495 u32 ssi_signal) 496 { 497 } 498 499 static inline void wpas_dbus_signal_eap_status(struct wpa_supplicant *wpa_s, 500 const char *status, 501 const char *parameter) 502 { 503 } 504 505 static inline 506 void wpas_dbus_signal_sta_authorized(struct wpa_supplicant *wpa_s, 507 const u8 *sta) 508 { 509 } 510 511 static inline 512 void wpas_dbus_signal_sta_deauthorized(struct wpa_supplicant *wpa_s, 513 const u8 *sta) 514 { 515 } 516 517 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */ 518 519 #endif /* CTRL_IFACE_DBUS_H_NEW */ 520