uclient: update to Git HEAD (2024-04-19)
[openwrt/openwrt.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 #include "sta_info.h"
12
13 enum hostapd_ubus_event_type {
14 HOSTAPD_UBUS_PROBE_REQ,
15 HOSTAPD_UBUS_AUTH_REQ,
16 HOSTAPD_UBUS_ASSOC_REQ,
17 HOSTAPD_UBUS_TYPE_MAX
18 };
19
20 struct hostapd_ubus_request {
21 enum hostapd_ubus_event_type type;
22 const struct ieee80211_mgmt *mgmt_frame;
23 const struct ieee802_11_elems *elems;
24 int ssi_signal; /* dBm */
25 const u8 *addr;
26 };
27
28 struct hostapd_iface;
29 struct hostapd_data;
30 struct hapd_interfaces;
31 struct rrm_measurement_beacon_report;
32 struct sta_info;
33
34 #ifdef UBUS_SUPPORT
35
36 #include <libubox/avl.h>
37 #include <libubus.h>
38
39 struct hostapd_ubus_bss {
40 struct ubus_object obj;
41 struct avl_tree banned;
42 int notify_response;
43 };
44
45 void hostapd_ubus_add_iface(struct hostapd_iface *iface);
46 void hostapd_ubus_free_iface(struct hostapd_iface *iface);
47 void hostapd_ubus_add_bss(struct hostapd_data *hapd);
48 void hostapd_ubus_free_bss(struct hostapd_data *hapd);
49 void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
50 void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
51
52 int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req);
53 void hostapd_ubus_handle_link_measurement(struct hostapd_data *hapd, const u8 *data, size_t len);
54 void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac);
55 void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
56 const u8 *addr, u8 token, u8 rep_mode,
57 struct rrm_measurement_beacon_report *rep,
58 size_t len);
59 void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
60 int chan_width, int cf1, int cf2);
61
62 void hostapd_ubus_notify_bss_transition_response(
63 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
64 u8 bss_termination_delay, const u8 *target_bssid,
65 const u8 *candidate_list, u16 candidate_list_len);
66 void hostapd_ubus_add(struct hapd_interfaces *interfaces);
67 void hostapd_ubus_free(struct hapd_interfaces *interfaces);
68 int hostapd_ubus_notify_bss_transition_query(
69 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
70 const u8 *candidate_list, u16 candidate_list_len);
71 void hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
72 const char *auth_alg);
73
74 #else
75
76 struct hostapd_ubus_bss {};
77
78 static inline void hostapd_ubus_add_iface(struct hostapd_iface *iface)
79 {
80 }
81
82 static inline void hostapd_ubus_free_iface(struct hostapd_iface *iface)
83 {
84 }
85
86 static inline void hostapd_ubus_add_bss(struct hostapd_data *hapd)
87 {
88 }
89
90 static inline void hostapd_ubus_free_bss(struct hostapd_data *hapd)
91 {
92 }
93
94 static inline void hostapd_ubus_add_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
95 {
96 }
97
98 static inline void hostapd_ubus_remove_vlan(struct hostapd_data *hapd, struct hostapd_vlan *vlan)
99 {
100 }
101
102 static inline int hostapd_ubus_handle_event(struct hostapd_data *hapd, struct hostapd_ubus_request *req)
103 {
104 return 0;
105 }
106
107 static inline void hostapd_ubus_handle_link_measurement(struct hostapd_data *hapd, const u8 *data, size_t len)
108 {
109 }
110
111 static inline void hostapd_ubus_notify(struct hostapd_data *hapd, const char *type, const u8 *mac)
112 {
113 }
114
115 static inline void hostapd_ubus_notify_beacon_report(struct hostapd_data *hapd,
116 const u8 *addr, u8 token,
117 u8 rep_mode,
118 struct rrm_measurement_beacon_report *rep,
119 size_t len)
120 {
121 }
122 static inline void hostapd_ubus_notify_radar_detected(struct hostapd_iface *iface, int frequency,
123 int chan_width, int cf1, int cf2)
124 {
125 }
126
127 static inline void hostapd_ubus_notify_bss_transition_response(
128 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 status_code,
129 u8 bss_termination_delay, const u8 *target_bssid,
130 const u8 *candidate_list, u16 candidate_list_len)
131 {
132 }
133
134 static inline void hostapd_ubus_add(struct hapd_interfaces *interfaces)
135 {
136 }
137
138 static inline void hostapd_ubus_free(struct hapd_interfaces *interfaces)
139 {
140 }
141
142 static inline int hostapd_ubus_notify_bss_transition_query(
143 struct hostapd_data *hapd, const u8 *addr, u8 dialog_token, u8 reason,
144 const u8 *candidate_list, u16 candidate_list_len)
145 {
146 return 0;
147 }
148
149 static inline void
150 hostapd_ubus_notify_authorized(struct hostapd_data *hapd, struct sta_info *sta,
151 const char *auth_alg)
152 {
153 }
154
155 #endif
156
157 #endif