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