Home | History | Annotate | Download | only in dbus
      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 "common/defs.h"
     20 #include "p2p/p2p.h"
     21 
     22 struct wpa_global;
     23 struct wpa_supplicant;
     24 struct wpa_ssid;
     25 struct wps_event_m2d;
     26 struct wps_event_fail;
     27 struct wps_credential;
     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_network_request(struct wpa_supplicant *wpa_s,
    135 				      struct wpa_ssid *ssid,
    136 				      enum wpa_ctrl_req_type rtype,
    137 				      const char *default_text);
    138 void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s, int success);
    139 void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
    140 			       const struct wps_credential *cred);
    141 void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
    142 				    struct wps_event_m2d *m2d);
    143 void wpas_dbus_signal_wps_event_fail(struct wpa_supplicant *wpa_s,
    144 				     struct wps_event_fail *fail);
    145 void wpas_dbus_signal_wps_event_success(struct wpa_supplicant *wpa_s);
    146 int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
    147 			       struct wpa_ssid *ssid);
    148 int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s, int nid);
    149 int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
    150 			     u8 bssid[ETH_ALEN], unsigned int id);
    151 int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
    152 			   u8 bssid[ETH_ALEN], unsigned int id);
    153 void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
    154 				 const char *name);
    155 void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
    156 				   const char *name);
    157 void wpas_dbus_signal_debug_level_changed(struct wpa_global *global);
    158 void wpas_dbus_signal_debug_timestamp_changed(struct wpa_global *global);
    159 void wpas_dbus_signal_debug_show_keys_changed(struct wpa_global *global);
    160 
    161 int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s, const u8 *dev_addr);
    162 void wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
    163 					   const u8 *dev_addr);
    164 int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
    165 				  const u8 *dev_addr);
    166 void wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
    167 					   const u8 *dev_addr);
    168 void wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
    169 					const char *role);
    170 void wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
    171 					      const u8 *dev_addr, int request,
    172 					      enum p2p_prov_disc_status status,
    173 					      u16 config_methods,
    174 					      unsigned int generated_pin);
    175 void wpas_dbus_signal_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
    176 				     const u8 *src, u16 dev_passwd_id);
    177 void wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
    178 					const struct wpa_ssid *ssid,
    179 					int client, int network_id);
    180 void wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
    181 				  struct wpa_ssid *ssid);
    182 void wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
    183 				      struct p2p_go_neg_results *res);
    184 void wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
    185 				    const struct wpa_ssid *ssid);
    186 int wpas_dbus_register_persistent_group(struct wpa_supplicant *wpa_s,
    187 					struct wpa_ssid *ssid);
    188 int wpas_dbus_unregister_persistent_group(struct wpa_supplicant *wpa_s,
    189 					  int nid);
    190 void wpas_dbus_signal_p2p_invitation_result(struct wpa_supplicant *wpa_s,
    191 					    int status, const u8 *bssid);
    192 void wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
    193 					const u8 *p2p_if_addr);
    194 void wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
    195 					  const u8 *p2p_if_addr);
    196 void wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
    197 					    const u8 *member);
    198 void wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s,
    199 				     int freq, const u8 *sa, u8 dialog_token,
    200 				     u16 update_indic, const u8 *tlvs,
    201 				     size_t tlvs_len);
    202 void wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
    203 				      const u8 *sa, u16 update_indic,
    204 				      const u8 *tlvs, size_t tlvs_len);
    205 void wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
    206 				const u8 *member);
    207 void wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
    208 				     struct wps_event_fail *fail);
    209 void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
    210 				    int depth, const char *subject,
    211 				    const char *cert_hash,
    212 				    const struct wpabuf *cert);
    213 
    214 #else /* CONFIG_CTRL_IFACE_DBUS_NEW */
    215 
    216 static inline int wpas_dbus_register_interface(struct wpa_supplicant *wpa_s)
    217 {
    218 	return 0;
    219 }
    220 
    221 static inline int wpas_dbus_unregister_interface(struct wpa_supplicant *wpa_s)
    222 {
    223 	return 0;
    224 }
    225 
    226 #define wpas_dbus_signal_state_changed(w, n, o) do { } while (0)
    227 
    228 static inline void wpas_dbus_signal_prop_changed(struct wpa_supplicant *wpa_s,
    229 						 enum wpas_dbus_prop property)
    230 {
    231 }
    232 
    233 static inline void wpas_dbus_bss_signal_prop_changed(
    234 	struct wpa_supplicant *wpa_s, enum wpas_dbus_bss_prop property,
    235 	unsigned int id)
    236 {
    237 }
    238 
    239 static inline void wpas_dbus_signal_network_enabled_changed(
    240 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
    241 {
    242 }
    243 
    244 static inline void wpas_dbus_signal_network_selected(
    245 	struct wpa_supplicant *wpa_s, int id)
    246 {
    247 }
    248 
    249 static inline void wpas_dbus_signal_network_request(
    250 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid,
    251 	enum wpa_ctrl_req_type rtype, const char *default_txt)
    252 {
    253 }
    254 
    255 static inline void wpas_dbus_signal_scan_done(struct wpa_supplicant *wpa_s,
    256 					      int success)
    257 {
    258 }
    259 
    260 static inline void wpas_dbus_signal_wps_cred(struct wpa_supplicant *wpa_s,
    261 					     const struct wps_credential *cred)
    262 {
    263 }
    264 
    265 static inline void wpas_dbus_signal_wps_event_m2d(struct wpa_supplicant *wpa_s,
    266 						  struct wps_event_m2d *m2d)
    267 {
    268 }
    269 
    270 static inline void wpas_dbus_signal_wps_event_fail(
    271 	struct wpa_supplicant *wpa_s, struct wps_event_fail *fail)
    272 {
    273 }
    274 
    275 static inline void wpas_dbus_signal_wps_event_success(
    276 	struct wpa_supplicant *wpa_s)
    277 {
    278 }
    279 
    280 static inline int wpas_dbus_register_network(struct wpa_supplicant *wpa_s,
    281 					     struct wpa_ssid *ssid)
    282 {
    283 	return 0;
    284 }
    285 
    286 static inline int wpas_dbus_unregister_network(struct wpa_supplicant *wpa_s,
    287 					       int nid)
    288 {
    289 	return 0;
    290 }
    291 
    292 static inline int wpas_dbus_unregister_bss(struct wpa_supplicant *wpa_s,
    293 					   u8 bssid[ETH_ALEN], unsigned int id)
    294 {
    295 	return 0;
    296 }
    297 
    298 static inline int wpas_dbus_register_bss(struct wpa_supplicant *wpa_s,
    299 					 u8 bssid[ETH_ALEN], unsigned int id)
    300 {
    301 	return 0;
    302 }
    303 
    304 static inline void wpas_dbus_signal_blob_added(struct wpa_supplicant *wpa_s,
    305 					       const char *name)
    306 {
    307 }
    308 
    309 static inline void wpas_dbus_signal_blob_removed(struct wpa_supplicant *wpa_s,
    310 						 const char *name)
    311 {
    312 }
    313 
    314 static inline void wpas_dbus_signal_debug_level_changed(
    315 	struct wpa_global *global)
    316 {
    317 }
    318 
    319 static inline void wpas_dbus_signal_debug_timestamp_changed(
    320 	struct wpa_global *global)
    321 {
    322 }
    323 
    324 static inline void wpas_dbus_signal_debug_show_keys_changed(
    325 	struct wpa_global *global)
    326 {
    327 }
    328 
    329 static inline int wpas_dbus_register_peer(struct wpa_supplicant *wpa_s,
    330 					  const u8 *dev_addr)
    331 {
    332 	return 0;
    333 }
    334 
    335 static inline int wpas_dbus_unregister_peer(struct wpa_supplicant *wpa_s,
    336 					    const u8 *dev_addr)
    337 {
    338 	return 0;
    339 }
    340 
    341 static inline void
    342 wpas_dbus_signal_p2p_group_removed(struct wpa_supplicant *wpa_s,
    343 				   const char *role)
    344 {
    345 }
    346 
    347 static inline void
    348 wpas_dbus_signal_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
    349 					 const u8 *dev_addr, int request,
    350 					 enum p2p_prov_disc_status status,
    351 					 u16 config_methods,
    352 					 unsigned int generated_pin)
    353 {
    354 }
    355 
    356 static inline void wpas_dbus_signal_p2p_go_neg_req(
    357 				struct wpa_supplicant *wpa_s,
    358 				const u8 *src,
    359 				u16 dev_passwd_id)
    360 {
    361 }
    362 
    363 static inline void
    364 wpas_dbus_signal_p2p_group_started(struct wpa_supplicant *wpa_s,
    365 				   const struct wpa_ssid *ssid,
    366 				   int client, int network_id)
    367 {
    368 }
    369 
    370 static inline void
    371 wpas_dbus_register_p2p_group(struct wpa_supplicant *wpa_s,
    372 			     struct wpa_ssid *ssid)
    373 {
    374 }
    375 
    376 static inline int wpas_dbus_register_persistent_group(
    377 	struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid)
    378 {
    379 	return 0;
    380 }
    381 
    382 static inline int wpas_dbus_unregister_persistent_group(
    383 	struct wpa_supplicant *wpa_s, int nid)
    384 {
    385 	return 0;
    386 }
    387 
    388 static inline void
    389 wpas_dbus_signal_p2p_go_neg_resp(struct wpa_supplicant *wpa_s,
    390 				 struct p2p_go_neg_results *res)
    391 {
    392 }
    393 
    394 static inline void
    395 wpas_dbus_unregister_p2p_group(struct wpa_supplicant *wpa_s,
    396 			       const struct wpa_ssid *ssid)
    397 {
    398 }
    399 
    400 static inline void wpas_dbus_signal_p2p_invitation_result(
    401 				struct wpa_supplicant *wpa_s, int status,
    402 				const u8 *bssid)
    403 {
    404 }
    405 
    406 static inline void
    407 wpas_dbus_register_p2p_groupmember(struct wpa_supplicant *wpa_s,
    408 				   const u8 *p2p_if_addr)
    409 {
    410 }
    411 
    412 static inline void
    413 wpas_dbus_signal_p2p_sd_request(struct wpa_supplicant *wpa_s, int freq,
    414 				const u8 *sa, u8 dialog_token, u16 update_indic,
    415 				const u8 *tlvs, size_t tlvs_len)
    416 {
    417 }
    418 
    419 static inline void
    420 wpas_dbus_signal_p2p_sd_response(struct wpa_supplicant *wpa_s,
    421 				 const u8 *sa, u16 update_indic,
    422 				 const u8 *tlvs, size_t tlvs_len)
    423 {
    424 }
    425 
    426 static inline void
    427 wpas_dbus_unregister_p2p_groupmember(struct wpa_supplicant *wpa_s,
    428 				     const u8 *p2p_if_addr)
    429 {
    430 }
    431 
    432 static inline void
    433 wpas_dbus_signal_p2p_peer_joined(struct wpa_supplicant *wpa_s,
    434 				 const u8 *member)
    435 {
    436 }
    437 
    438 static inline void
    439 wpas_dbus_signal_peer_device_found(struct wpa_supplicant *wpa_s,
    440 				   const u8 *dev_addr)
    441 {
    442 }
    443 
    444 static inline void
    445 wpas_dbus_signal_peer_device_lost(struct wpa_supplicant *wpa_s,
    446 				  const u8 *dev_addr)
    447 {
    448 }
    449 
    450 static inline void
    451 wpas_dbus_signal_p2p_peer_disconnected(struct wpa_supplicant *wpa_s,
    452 				       const u8 *member)
    453 {
    454 }
    455 
    456 static inline void
    457 wpas_dbus_signal_p2p_wps_failed(struct wpa_supplicant *wpa_s,
    458 				struct wps_event_fail *fail)
    459 {
    460 }
    461 
    462 static inline void wpas_dbus_signal_certification(struct wpa_supplicant *wpa_s,
    463 						  int depth,
    464 						  const char *subject,
    465 						  const char *cert_hash,
    466 						  const struct wpabuf *cert)
    467 {
    468 }
    469 
    470 #endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
    471 
    472 #endif /* CTRL_IFACE_DBUS_H_NEW */
    473