aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/ctrl_iface_dbus.h
blob: 059a37372eddd5bfefc042e4cd451ec364784876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * WPA Supplicant / dbus-based control interface
 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * Alternatively, this software may be distributed under the terms of BSD
 * license.
 *
 * See README and COPYING for more details.
 */

#ifndef CTRL_IFACE_DBUS_H
#define CTRL_IFACE_DBUS_H

struct wps_credential;

#ifdef CONFIG_CTRL_IFACE_DBUS

#ifndef SIGPOLL
#ifdef SIGIO
/*
 * If we do not have SIGPOLL, try to use SIGIO instead. This is needed for
 * FreeBSD.
 */
#define SIGPOLL SIGIO
#endif
#endif

#include <dbus/dbus.h>

#define WPAS_DBUS_OBJECT_PATH_MAX 150

#define WPAS_DBUS_SERVICE	"fi.epitest.hostap.WPASupplicant"
#define WPAS_DBUS_PATH		"/fi/epitest/hostap/WPASupplicant"
#define WPAS_DBUS_INTERFACE	"fi.epitest.hostap.WPASupplicant"

#define WPAS_DBUS_PATH_INTERFACES	WPAS_DBUS_PATH "/Interfaces"
#define WPAS_DBUS_IFACE_INTERFACE	WPAS_DBUS_INTERFACE ".Interface"

#define WPAS_DBUS_NETWORKS_PART "Networks"
#define WPAS_DBUS_IFACE_NETWORK	WPAS_DBUS_INTERFACE ".Network"

#define WPAS_DBUS_BSSIDS_PART	"BSSIDs"
#define WPAS_DBUS_IFACE_BSSID	WPAS_DBUS_INTERFACE ".BSSID"


/* Errors */
#define WPAS_ERROR_INVALID_NETWORK \
	WPAS_DBUS_IFACE_INTERFACE ".InvalidNetwork"
#define WPAS_ERROR_INVALID_BSSID \
	WPAS_DBUS_IFACE_INTERFACE ".InvalidBSSID"

#define WPAS_ERROR_INVALID_OPTS \
	WPAS_DBUS_INTERFACE ".InvalidOptions"
#define WPAS_ERROR_INVALID_IFACE \
	WPAS_DBUS_INTERFACE ".InvalidInterface"

#define WPAS_ERROR_ADD_ERROR \
	WPAS_DBUS_INTERFACE ".AddError"
#define WPAS_ERROR_EXISTS_ERROR \
	WPAS_DBUS_INTERFACE ".ExistsError"
#define WPAS_ERROR_REMOVE_ERROR \
	WPAS_DBUS_INTERFACE ".RemoveError"

#define WPAS_ERROR_SCAN_ERROR \
	WPAS_DBUS_IFACE_INTERFACE ".ScanError"
#define WPAS_ERROR_ADD_NETWORK_ERROR \
	WPAS_DBUS_IFACE_INTERFACE ".AddNetworkError"
#define WPAS_ERROR_INTERNAL_ERROR \
	WPAS_DBUS_IFACE_INTERFACE ".InternalError"
#define WPAS_ERROR_REMOVE_NETWORK_ERROR \
	WPAS_DBUS_IFACE_INTERFACE ".RemoveNetworkError"

#define WPAS_DBUS_BSSID_FORMAT "%02x%02x%02x%02x%02x%02x"

struct wpa_global;
struct wpa_supplicant;

struct ctrl_iface_dbus_priv *
wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global);
void wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface);
void wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s);
void wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s);
void wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
					     wpa_states new_state,
					     wpa_states old_state);
void wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
					 const struct wps_credential *cred);

char * wpas_dbus_decompose_object_path(const char *path, char **network,
                                       char **bssid);

int wpas_dbus_register_iface(struct wpa_supplicant *wpa_s);
int wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s);


/* Methods internal to the dbus control interface */
u32 wpa_supplicant_dbus_next_objid(struct ctrl_iface_dbus_priv *iface);

int wpa_supplicant_set_dbus_path(struct wpa_supplicant *wpa_s,
				 const char *path);
const char *wpa_supplicant_get_dbus_path(struct wpa_supplicant *wpa_s);
struct wpa_supplicant * wpa_supplicant_get_iface_by_dbus_path(
	struct wpa_global *global, const char *path);

DBusMessage * wpas_dbus_new_invalid_iface_error(DBusMessage *message);
DBusMessage * wpas_dbus_new_invalid_network_error(DBusMessage *message);

#else /* CONFIG_CTRL_IFACE_DBUS */

static inline struct ctrl_iface_dbus_priv *
wpa_supplicant_dbus_ctrl_iface_init(struct wpa_global *global)
{
	return (struct ctrl_iface_dbus_priv *) 1;
}

static inline void
wpa_supplicant_dbus_ctrl_iface_deinit(struct ctrl_iface_dbus_priv *iface)
{
}

static inline void
wpa_supplicant_dbus_notify_scan_results(struct wpa_supplicant *wpa_s)
{
}

static inline void
wpa_supplicant_dbus_notify_scanning(struct wpa_supplicant *wpa_s)
{
}

static inline void
wpa_supplicant_dbus_notify_state_change(struct wpa_supplicant *wpa_s,
					wpa_states new_state,
					wpa_states old_state)
{
}

static inline void
wpa_supplicant_dbus_notify_wps_cred(struct wpa_supplicant *wpa_s,
				    const struct wps_credential *cred)
{
}

static inline int
wpas_dbus_register_iface(struct wpa_supplicant *wpa_s)
{
	return 0;
}

static inline int
wpas_dbus_unregister_iface(struct wpa_supplicant *wpa_s)
{
	return 0;
}

#endif /* CONFIG_CTRL_IFACE_DBUS */

#endif /* CTRL_IFACE_DBUS_H */