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