2 * FST module - interface definitions
3 * Copyright (c) 2014, Qualcomm Atheros, Inc.
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
14 #include "common/defs.h"
15 #include "fst/fst_ctrl_iface.h"
17 /* FST module hostap integration API */
20 #define LLT_UNIT_US 32 /* See 10.32.2.2 Transitioning between states */
22 #define FST_LLT_MS_TO_VAL(m) (((u32) (m)) * US_IN_MS / LLT_UNIT_US)
23 #define FST_LLT_VAL_TO_MS(v) (((u32) (v)) * LLT_UNIT_US / US_IN_MS)
25 #define FST_MAX_LLT_MS FST_LLT_VAL_TO_MS(-1)
26 #define FST_MAX_PRIO_VALUE ((u8) -1)
27 #define FST_MAX_GROUP_ID_LEN IFNAMSIZ
29 #define FST_DEFAULT_LLT_CFG_VALUE 50
31 struct hostapd_hw_modes;
32 struct ieee80211_mgmt;
36 struct fst_get_peer_ctx;
37 struct fst_ctrl_handle;
43 * get_bssid - Get BSSID of the interface
44 * @ctx: User context %ctx
45 * Returns: BSSID for success, %NULL for failure.
47 * NOTE: For AP it returns the own BSSID, while for STA - the BSSID of
50 const u8 * (*get_bssid)(void *ctx);
53 * get_channel_info - Get current channel info
54 * @ctx: User context %ctx
55 * @hw_mode: OUT, current HW mode
56 * @channel: OUT, current channel
58 void (*get_channel_info)(void *ctx, enum hostapd_hw_mode *hw_mode,
62 * get_hw_modes - Get hardware modes
63 * @ctx: User context %ctx
64 * @modes: OUT, pointer on array of hw modes
66 * Returns: Number of hw modes available.
68 int (*get_hw_modes)(void *ctx, struct hostapd_hw_modes **modes);
71 * set_ies - Set interface's MB IE
72 * @ctx: User context %ctx
73 * @fst_ies: MB IE buffer (owned by FST module)
75 void (*set_ies)(void *ctx, const struct wpabuf *fst_ies);
78 * send_action - Send FST Action frame via the interface
79 * @ctx: User context %ctx
80 * @addr: Address of the destination STA
81 * @data: Action frame buffer
82 * Returns: 0 for success, negative error code for failure.
84 int (*send_action)(void *ctx, const u8 *addr, struct wpabuf *data);
87 * get_mb_ie - Get last MB IE received from STA
88 * @ctx: User context %ctx
89 * @addr: Address of the STA
90 * Returns: MB IE buffer, %NULL if no MB IE received from the STA
92 const struct wpabuf * (*get_mb_ie)(void *ctx, const u8 *addr);
95 * update_mb_ie - Update last MB IE received from STA
96 * @ctx: User context %ctx
97 * @addr: Address of the STA
98 * @buf: Buffer that contains the MB IEs data
99 * @size: Size of data in %buf
101 void (*update_mb_ie)(void *ctx, const u8 *addr,
102 const u8 *buf, size_t size);
105 * get_peer_first - Get MAC address of the 1st connected STA
106 * @ctx: User context %ctx
107 * @get_ctx: Context to be used for %get_peer_next call
108 * @mb_only: %TRUE if only multi-band capable peer should be reported
109 * Returns: Address of the 1st connected STA, %NULL if no STAs connected
111 const u8 * (*get_peer_first)(void *ctx,
112 struct fst_get_peer_ctx **get_ctx,
115 * get_peer_next - Get MAC address of the next connected STA
116 * @ctx: User context %ctx
117 * @get_ctx: Context received from %get_peer_first or previous
118 * %get_peer_next call
119 * @mb_only: %TRUE if only multi-band capable peer should be reported
120 * Returns: Address of the next connected STA, %NULL if no more STAs
123 const u8 * (*get_peer_next)(void *ctx,
124 struct fst_get_peer_ctx **get_ctx,
129 * fst_global_init - Global FST module initiator
130 * Returns: 0 for success, negative error code for failure.
131 * Note: The purpose of this function is to allocate and initiate global
132 * FST module data structures (linked lists, static data etc.)
133 * This function should be called prior to the 1st %fst_attach call.
135 int fst_global_init(void);
138 * fst_global_deinit - Global FST module de-initiator
139 * Note: The purpose of this function is to deallocate and de-initiate global
140 * FST module data structures (linked lists, static data etc.)
142 void fst_global_deinit(void);
145 * struct fst_ctrl - Notification interface for FST module
149 * init - Initialize the notification interface
150 * Returns: 0 for success, negative error code for failure.
155 * deinit - Deinitialize the notification interface
157 void (*deinit)(void);
160 * on_group_created - Notify about FST group creation
161 * Returns: 0 for success, negative error code for failure.
163 int (*on_group_created)(struct fst_group *g);
166 * on_group_deleted - Notify about FST group deletion
168 void (*on_group_deleted)(struct fst_group *g);
171 * on_iface_added - Notify about interface addition
172 * Returns: 0 for success, negative error code for failure.
174 int (*on_iface_added)(struct fst_iface *i);
177 * on_iface_removed - Notify about interface removal
179 void (*on_iface_removed)(struct fst_iface *i);
182 * on_session_added - Notify about FST session addition
183 * Returns: 0 for success, negative error code for failure.
185 int (*on_session_added)(struct fst_session *s);
188 * on_session_removed - Notify about FST session removal
190 void (*on_session_removed)(struct fst_session *s);
193 * on_event - Notify about FST event
194 * @event_type: Event type
195 * @i: Interface object that relates to the event or NULL
196 * @g: Group object that relates to the event or NULL
197 * @extra - Event specific data (see fst_ctrl_iface.h for more info)
199 void (*on_event)(enum fst_event_type event_type, struct fst_iface *i,
200 struct fst_session *s,
201 const union fst_event_extra *extra);
204 struct fst_ctrl_handle * fst_global_add_ctrl(const struct fst_ctrl *ctrl);
205 void fst_global_del_ctrl(struct fst_ctrl_handle *h);
208 * NOTE: These values have to be read from configuration file
210 struct fst_iface_cfg {
211 char group_id[FST_MAX_GROUP_ID_LEN + 1];
217 * fst_attach - Attach interface to an FST group according to configuration read
218 * @ifname: Interface name
219 * @own_addr: Own interface MAC address
220 * @iface_obj: Callbacks to be used by FST module to communicate with
221 * hostapd/wpa_supplicant
222 * @cfg: FST-related interface configuration read from the configuration file
223 * Returns: FST interface object for success, %NULL for failure.
225 struct fst_iface * fst_attach(const char *ifname,
227 const struct fst_wpa_obj *iface_obj,
228 const struct fst_iface_cfg *cfg);
231 * fst_detach - Detach an interface
232 * @iface: FST interface object
234 void fst_detach(struct fst_iface *iface);
236 /* FST module inputs */
238 * fst_rx_action - FST Action frames handler
239 * @iface: FST interface object
240 * @mgmt: Action frame arrived
241 * @len: Action frame length
243 void fst_rx_action(struct fst_iface *iface, const struct ieee80211_mgmt *mgmt,
247 * fst_notify_peer_connected - FST STA connect handler
248 * @iface: FST interface object
249 * @addr: Address of the connected STA
251 void fst_notify_peer_connected(struct fst_iface *iface, const u8 *addr);
254 * fst_notify_peer_disconnected - FST STA disconnect handler
255 * @iface: FST interface object
256 * @addr: Address of the disconnected STA
258 void fst_notify_peer_disconnected(struct fst_iface *iface, const u8 *addr);
260 /* FST module auxiliary routines */
263 * fst_are_ifaces_aggregated - Determines whether 2 interfaces belong to the
265 * @iface1: 1st FST interface object
266 * @iface1: 2nd FST interface object
268 * Returns: %TRUE if the interfaces belong to the same FST group,
271 Boolean fst_are_ifaces_aggregated(struct fst_iface *iface1,
272 struct fst_iface *iface2);
274 #else /* CONFIG_FST */
276 static inline int fst_global_init(void)
281 static inline int fst_global_start(void)
286 static inline void fst_global_stop(void)
290 static inline void fst_global_deinit(void)
294 #endif /* CONFIG_FST */