hostapd: expose beacon reports through ubus
[openwrt/staging/wigyori.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 ieee802_11_elems *elems;
22 int ssi_signal; /* dBm */
23 const u8 *addr;
24 };
25
26 struct hostapd_iface;
27 struct hostapd_data;
28 struct hapd_interfaces;
29 struct rrm_measurement_beacon_report;
30
31 #ifdef UBUS_SUPPORT
32
33 #include <libubox/avl.h>
34 #include <libubus.h>
35
36 struct hostapd_ubus_bss {
37 struct ubus_object obj;
38 struct avl_tree banned;
39 int notify_response;
40 };
41
42 void hostapd_ubus_add_iface(struct hostapd_iface *iface);
43 void hostapd_ubus_free_iface(struct hostapd_iface *iface);
44 void hostapd_ubus_add_bss(struct hostapd_data *hapd);
45 void hostapd_ubus_free_bss(struct hostapd_data *hapd);
46
47 int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
48 void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
49 void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
50 const u8 *addr, u8 token, u8 rep_mode,
51 struct rrm_measurement_beacon_report *rep,
52 size_t len);
53
54 void hostapd_ubus_add(struct hapd_interfaces *interfaces);
55 void hostapd_ubus_free(struct hapd_interfaces *interfaces);
56
57 #else
58
59 struct hostapd_ubus_bss {};
60
61 static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
62 {
63 }
64
65 static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
66 {
67 }
68
69 static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
70 {
71 }
72
73 static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
74 {
75 }
76
77 static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
78 {
79 return 0;
80 }
81
82 static inline void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac)
83 {
84 }
85
86 static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
87 const u8 *addr, u8 token,
88 u8 rep_mode,
89 struct rrm_measurement_beacon_report *rep,
90 size_t len)
91 {
92 }
93
94 static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
95 {
96 }
97
98 static inline void hostapd_ubus_free(struct hapd_interfaces *interfaces)
99 {
100 }
101 #endif
102
103 #endif