blob: b66c179c596e2b09ffbad7f052fc3acdeb0afc83 [file] [log] [blame]
The Android Open Source Project845e0122009-03-03 19:31:34 -08001/*
2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#ifndef CTRL_IFACE_DBUS_H
16#define CTRL_IFACE_DBUS_H
17
18#ifdef CONFIG_CTRL_IFACE_DBUS
19
20#ifndef SIGPOLL
21#ifdef SIGIO
22/*
23 * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
24 * FreeBSD.
25 */
26#define SIGPOLL SIGIO
27#endif
28#endif
29
30#include <dbus/dbus.h>
31
32#define WPAS_DBUS_OBJECT_PATH_MAX 150
33
34#define WPAS_DBUS_SERVICE "fi.epitest.hostap.WPASupplicant"
35#define WPAS_DBUS_PATH "/fi/epitest/hostap/WPASupplicant"
36#define WPAS_DBUS_INTERFACE "fi.epitest.hostap.WPASupplicant"
37
38#define WPAS_DBUS_PATH_INTERFACES WPAS_DBUS_PATH "/Interfaces"
39#define WPAS_DBUS_IFACE_INTERFACE WPAS_DBUS_INTERFACE ".Interface"
40
41#define WPAS_DBUS_NETWORKS_PART "Networks"
42#define WPAS_DBUS_IFACE_NETWORK WPAS_DBUS_INTERFACE ".Network"
43
44#define WPAS_DBUS_BSSIDS_PART "BSSIDs"
45#define WPAS_DBUS_IFACE_BSSID WPAS_DBUS_INTERFACE ".BSSID"
46
47
48/* Errors */
49#define WPAS_ERROR_INVALID_NETWORK \
50 WPAS_DBUS_IFACE_INTERFACE ".InvalidNetwork"
51#define WPAS_ERROR_INVALID_BSSID \
52 WPAS_DBUS_IFACE_INTERFACE ".InvalidBSSID"
53
54#define WPAS_ERROR_INVALID_OPTS \
55 WPAS_DBUS_INTERFACE ".InvalidOptions"
56#define WPAS_ERROR_INVALID_IFACE \
57 WPAS_DBUS_INTERFACE ".InvalidInterface"
58
59#define WPAS_ERROR_ADD_ERROR \
60 WPAS_DBUS_INTERFACE ".AddError"
61#define WPAS_ERROR_EXISTS_ERROR \
62 WPAS_DBUS_INTERFACE ".ExistsError"
63#define WPAS_ERROR_REMOVE_ERROR \
64 WPAS_DBUS_INTERFACE ".RemoveError"
65
66#define WPAS_ERROR_SCAN_ERROR \
67 WPAS_DBUS_IFACE_INTERFACE ".ScanError"
68#define WPAS_ERROR_ADD_NETWORK_ERROR \
69 WPAS_DBUS_IFACE_INTERFACE ".AddNetworkError"
70#define WPAS_ERROR_INTERNAL_ERROR \
71 WPAS_DBUS_IFACE_INTERFACE ".InternalError"
72#define WPAS_ERROR_REMOVE_NETWORK_ERROR \
73 WPAS_DBUS_IFACE_INTERFACE ".RemoveNetworkError"
74
75#define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"
76
77struct wpa_global;
78struct wpa_supplicant;
79
80struct ctrl_iface_dbus_priv *
81wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global);
82void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface);
83void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
84void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
85 wpa_states new_state,
86 wpa_states old_state);
87
88char * wpas_dbus_decompose_object_path(const char *path, char **network,
89 char **bssid);
90
91int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
92int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);
93
94
95/* Methods internal to the dbus control interface */
96u32 wpa_supplicant_dbus_next_objid(struct ctrl_iface_dbus_priv *iface);
97
98int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
99 const char *path);
100const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s);
101struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
102 struct wpa_global *global, const char *path);
103
104DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message);
105DBusMessage * wpas_dbus_new_invalid_network_error(DBusMessage *message);
106
107#else /* CONFIG_CTRL_IFACE_DBUS */
108
109static inline struct ctrl_iface_dbus_priv *
110wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global)
111{
112 return (struct ctrl_iface_dbus_priv *) 1;
113}
114
115static inline void
116wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
117{
118}
119
120static inline void
121wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
122{
123}
124
125static inline void
126wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
127 wpa_states new_state,
128 wpa_states old_state)
129{
130}
131
132static inline int
133wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
134{
135 return 0;
136}
137
138static inline int
139wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
140{
141 return 0;
142}
143
144#endif /* CONFIG_CTRL_IFACE_DBUS */
145
146#endif /* CTRL_IFACE_DBUS_H */