hostapd: add additional ubus notifications
[openwrt/staging/xback.git] / package / network / services / hostapd / src / src / ap / ubus.h
1 /*
2 * hostapd / ubus support
3 * Copyright (c) 2013, Felix Fietkau <nbd@nbd.name>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8 #ifndef __HOSTAPD_UBUS_H
9 #define __HOSTAPD_UBUS_H
10
11 enum hostapd_ubus_event_type {
12 HOSTAPD_UBUS_PROBE_REQ,
13 HOSTAPD_UBUS_AUTH_REQ,
14 HOSTAPD_UBUS_ASSOC_REQ,
15 HOSTAPD_UBUS_TYPE_MAX
16 };
17
18 struct hostapd_ubus_request {
19 enum hostapd_ubus_event_type type;
20 const struct ieee80211_mgmt *mgmt_frame;
21 const struct hostapd_frame_info *frame_info;
22 const u8 *addr;
23 };
24
25 struct hostapd_iface;
26 struct hostapd_data;
27
28 #ifdef UBUS_SUPPORT
29
30 #include <libubox/avl.h>
31 #include <libubus.h>
32
33 struct hostapd_ubus_iface {
34 struct ubus_object obj;
35 };
36
37 struct hostapd_ubus_bss {
38 struct ubus_object obj;
39 struct avl_tree banned;
40 int notify_response;
41 };
42
43 void hostapd_ubus_add_iface(struct hostapd_iface *iface);
44 void hostapd_ubus_free_iface(struct hostapd_iface *iface);
45 void hostapd_ubus_add_bss(struct hostapd_data *hapd);
46 void hostapd_ubus_free_bss(struct hostapd_data *hapd);
47
48 int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
49 void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
50
51 #else
52
53 struct hostapd_ubus_iface {};
54
55 struct hostapd_ubus_bss {};
56
57 static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
58 {
59 }
60
61 static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
62 {
63 }
64
65 static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
66 {
67 }
68
69 static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
70 {
71 }
72
73 static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
74 {
75 return 0;
76 }
77
78 static inline void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac)
79 {
80 }
81 #endif
82
83 #endif