b0f7c44ab5f49a576bc004a4aa4dffa8d94ad848
[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 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 void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
47 void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
48
49 int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
50 void hostapd_ubus_handle_link_measurement(struct hostapd_data *hapd, const u8 *data, size_t len);
51 void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
52 void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
53 const u8 *addr, u8 token, u8 rep_mode,
54 struct rrm_measurement_beacon_report *rep,
55 size_t len);
56 void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
57 int chan_width, int cf1, int cf2);
58
59 void hostapd_ubus_notify_bss_transition_response(
60 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
61 u8 bss_termination_delay, const u8 *target_bssid,
62 const u8 *candidate_list, u16 candidate_list_len);
63 void hostapd_ubus_add(struct hapd_interfaces *interfaces);
64 void hostapd_ubus_free(struct hapd_interfaces *interfaces);
65 int hostapd_ubus_notify_bss_transition_query(
66 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
67 const u8 *candidate_list, u16 candidate_list_len);
68 void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
69 const char *auth_alg);
70
71 #else
72
73 struct hostapd_ubus_bss {};
74
75 static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
76 {
77 }
78
79 static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
80 {
81 }
82
83 static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
84 {
85 }
86
87 static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
88 {
89 }
90
91 static inline void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
92 {
93 }
94
95 static inline void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
96 {
97 }
98
99 static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
100 {
101 return 0;
102 }
103
104 static inline void hostapd_ubus_handle_link_measurement(struct hostapd_data *hapd, const u8 *data, size_t len)
105 {
106 }
107
108 static inline void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac)
109 {
110 }
111
112 static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
113 const u8 *addr, u8 token,
114 u8 rep_mode,
115 struct rrm_measurement_beacon_report *rep,
116 size_t len)
117 {
118 }
119 static inline void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
120 int chan_width, int cf1, int cf2)
121 {
122 }
123
124 static inline void hostapd_ubus_notify_bss_transition_response(
125 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
126 u8 bss_termination_delay, const u8 *target_bssid,
127 const u8 *candidate_list, u16 candidate_list_len)
128 {
129 }
130
131 static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
132 {
133 }
134
135 static inline void hostapd_ubus_free(struct hapd_interfaces *interfaces)
136 {
137 }
138
139 static inline int hostapd_ubus_notify_bss_transition_query(
140 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
141 const u8 *candidate_list, u16 candidate_list_len)
142 {
143 return 0;
144 }
145
146 static inline void
147 hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
148 const char *auth_alg)
149 {
150 }
151
152 #endif
153
154 #endif