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  *
      5  * This software may be distributed under the terms of the BSD license.
      6  * See README for more details.
      7  */
      8 
      9 #ifndef CTRL_IFACE_DBUS_H
     10 #define CTRL_IFACE_DBUS_H
     11 
     12 struct wps_credential;
     13 
     14 #ifdef CONFIG_CTRL_IFACE_DBUS
     15 
     16 #define WPAS_DBUS_OBJECT_PATH_MAX 150
     17 
     18 #define WPAS_DBUS_SERVICE	"fi.epitest.hostap.WPASupplicant"
     19 #define WPAS_DBUS_PATH		"/fi/epitest/hostap/WPASupplicant"
     20 #define WPAS_DBUS_INTERFACE	"fi.epitest.hostap.WPASupplicant"
     21 
     22 #define WPAS_DBUS_PATH_INTERFACES	WPAS_DBUS_PATH "/Interfaces"
     23 #define WPAS_DBUS_IFACE_INTERFACE	WPAS_DBUS_INTERFACE ".Interface"
     24 
     25 #define WPAS_DBUS_NETWORKS_PART "Networks"
     26 #define WPAS_DBUS_IFACE_NETWORK	WPAS_DBUS_INTERFACE ".Network"
     27 
     28 #define WPAS_DBUS_BSSIDS_PART	"BSSIDs"
     29 #define WPAS_DBUS_IFACE_BSSID	WPAS_DBUS_INTERFACE ".BSSID"
     30 
     31 
     32 /* Errors */
     33 #define WPAS_ERROR_INVALID_NETWORK \
     34 	WPAS_DBUS_IFACE_INTERFACE ".InvalidNetwork"
     35 #define WPAS_ERROR_INVALID_BSSID \
     36 	WPAS_DBUS_IFACE_INTERFACE ".InvalidBSSID"
     37 
     38 #define WPAS_ERROR_INVALID_OPTS \
     39 	WPAS_DBUS_INTERFACE ".InvalidOptions"
     40 #define WPAS_ERROR_INVALID_IFACE \
     41 	WPAS_DBUS_INTERFACE ".InvalidInterface"
     42 
     43 #define WPAS_ERROR_ADD_ERROR \
     44 	WPAS_DBUS_INTERFACE ".AddError"
     45 #define WPAS_ERROR_EXISTS_ERROR \
     46 	WPAS_DBUS_INTERFACE ".ExistsError"
     47 #define WPAS_ERROR_REMOVE_ERROR \
     48 	WPAS_DBUS_INTERFACE ".RemoveError"
     49 
     50 #define WPAS_ERROR_SCAN_ERROR \
     51 	WPAS_DBUS_IFACE_INTERFACE ".ScanError"
     52 #define WPAS_ERROR_ADD_NETWORK_ERROR \
     53 	WPAS_DBUS_IFACE_INTERFACE ".AddNetworkError"
     54 #define WPAS_ERROR_INTERNAL_ERROR \
     55 	WPAS_DBUS_IFACE_INTERFACE ".InternalError"
     56 #define WPAS_ERROR_REMOVE_NETWORK_ERROR \
     57 	WPAS_DBUS_IFACE_INTERFACE ".RemoveNetworkError"
     58 
     59 #define WPAS_ERROR_WPS_PBC_ERROR \
     60 	WPAS_DBUS_IFACE_INTERFACE ".WpsPbcError"
     61 #define WPAS_ERROR_WPS_PIN_ERROR \
     62 	WPAS_DBUS_IFACE_INTERFACE ".WpsPinError"
     63 #define WPAS_ERROR_WPS_REG_ERROR \
     64 	WPAS_DBUS_IFACE_INTERFACE ".WpsRegError"
     65 
     66 #define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"
     67 
     68 struct wpa_global;
     69 struct wpa_supplicant;
     70 
     71 int wpa_supplicant_dbus_ctrl_iface_init(struct wpas_dbus_priv *iface);
     72 void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
     73 void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s);
     74 void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
     75 					     enum wpa_states new_state,
     76 					     enum wpa_states old_state);
     77 void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
     78 					 const struct wps_credential *cred);
     79 void wpa_supplicant_dbus_notify_certification(struct wpa_supplicant *wpa_s,
     80 					      int depth, const char *subject,
     81 					      const char *cert_hash,
     82 					      const struct wpabuf *cert);
     83 
     84 char * wpas_dbus_decompose_object_path(const char *path, char **network,
     85 				       char **bssid);
     86 
     87 int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
     88 int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);
     89 
     90 
     91 /* Methods internal to the dbus control interface */
     92 struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
     93 	struct wpa_global *global, const char *path);
     94 
     95 #else /* CONFIG_CTRL_IFACE_DBUS */
     96 
     97 static inline void
     98 wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
     99 {
    100 }
    101 
    102 static inline void
    103 wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
    104 {
    105 }
    106 
    107 static inline void
    108 wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
    109 					enum wpa_states new_state,
    110 					enum wpa_states old_state)
    111 {
    112 }
    113 
    114 static inline void
    115 wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
    116 				    const struct wps_credential *cred)
    117 {
    118 }
    119 
    120 static inline void
    121 wpa_supplicant_dbus_notify_certification(struct wpa_supplicant *wpa_s,
    122 					      int depth, const char *subject,
    123 					      const char *cert_hash,
    124 					      const struct wpabuf *cert)
    125 {
    126 }
    127 
    128 static inline int
    129 wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
    130 {
    131 	return 0;
    132 }
    133 
    134 static inline int
    135 wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
    136 {
    137 	return 0;
    138 }
    139 
    140 #endif /* CONFIG_CTRL_IFACE_DBUS */
    141 
    142 #endif /* CTRL_IFACE_DBUS_H */
    143