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