1e5b75505Sopenharmony_ci/*
2e5b75505Sopenharmony_ci * FST module - FST interface object definitions
3e5b75505Sopenharmony_ci * Copyright (c) 2014, Qualcomm Atheros, Inc.
4e5b75505Sopenharmony_ci *
5e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license.
6e5b75505Sopenharmony_ci * See README for more details.
7e5b75505Sopenharmony_ci */
8e5b75505Sopenharmony_ci
9e5b75505Sopenharmony_ci
10e5b75505Sopenharmony_ci#ifndef FST_IFACE_H
11e5b75505Sopenharmony_ci#define FST_IFACE_H
12e5b75505Sopenharmony_ci
13e5b75505Sopenharmony_ci#include "utils/includes.h"
14e5b75505Sopenharmony_ci#include "utils/common.h"
15e5b75505Sopenharmony_ci#include "list.h"
16e5b75505Sopenharmony_ci#include "fst.h"
17e5b75505Sopenharmony_ci
18e5b75505Sopenharmony_cistruct fst_iface {
19e5b75505Sopenharmony_ci	struct fst_group *group;
20e5b75505Sopenharmony_ci	struct fst_wpa_obj iface_obj;
21e5b75505Sopenharmony_ci	u8 own_addr[ETH_ALEN];
22e5b75505Sopenharmony_ci	struct wpabuf *mb_ie;
23e5b75505Sopenharmony_ci	char ifname[IFNAMSIZ + 1];
24e5b75505Sopenharmony_ci	struct fst_iface_cfg cfg;
25e5b75505Sopenharmony_ci	struct dl_list group_lentry;
26e5b75505Sopenharmony_ci};
27e5b75505Sopenharmony_ci
28e5b75505Sopenharmony_cistruct fst_iface * fst_iface_create(struct fst_group *g, const char *ifname,
29e5b75505Sopenharmony_ci				    const u8 *own_addr,
30e5b75505Sopenharmony_ci				    const struct fst_wpa_obj *iface_obj,
31e5b75505Sopenharmony_ci				    const struct fst_iface_cfg *cfg);
32e5b75505Sopenharmony_civoid fst_iface_delete(struct fst_iface *i);
33e5b75505Sopenharmony_ci
34e5b75505Sopenharmony_cistatic inline struct fst_group * fst_iface_get_group(struct fst_iface *i)
35e5b75505Sopenharmony_ci{
36e5b75505Sopenharmony_ci	return i->group;
37e5b75505Sopenharmony_ci}
38e5b75505Sopenharmony_ci
39e5b75505Sopenharmony_cistatic inline const char * fst_iface_get_name(struct fst_iface *i)
40e5b75505Sopenharmony_ci{
41e5b75505Sopenharmony_ci	return i->ifname;
42e5b75505Sopenharmony_ci}
43e5b75505Sopenharmony_ci
44e5b75505Sopenharmony_cistatic inline const u8 * fst_iface_get_addr(struct fst_iface *i)
45e5b75505Sopenharmony_ci{
46e5b75505Sopenharmony_ci	return i->own_addr;
47e5b75505Sopenharmony_ci}
48e5b75505Sopenharmony_ci
49e5b75505Sopenharmony_cistatic inline const char * fst_iface_get_group_id(struct fst_iface *i)
50e5b75505Sopenharmony_ci{
51e5b75505Sopenharmony_ci	return i->cfg.group_id;
52e5b75505Sopenharmony_ci}
53e5b75505Sopenharmony_ci
54e5b75505Sopenharmony_cistatic inline u8 fst_iface_get_priority(struct fst_iface *i)
55e5b75505Sopenharmony_ci{
56e5b75505Sopenharmony_ci	return i->cfg.priority;
57e5b75505Sopenharmony_ci}
58e5b75505Sopenharmony_ci
59e5b75505Sopenharmony_cistatic inline u32 fst_iface_get_llt(struct fst_iface *i)
60e5b75505Sopenharmony_ci{
61e5b75505Sopenharmony_ci	return i->cfg.llt;
62e5b75505Sopenharmony_ci}
63e5b75505Sopenharmony_ci
64e5b75505Sopenharmony_cistatic inline const struct wpabuf * fst_iface_get_mbie(struct fst_iface *i)
65e5b75505Sopenharmony_ci{
66e5b75505Sopenharmony_ci	return i->mb_ie;
67e5b75505Sopenharmony_ci}
68e5b75505Sopenharmony_ci
69e5b75505Sopenharmony_cistatic inline const u8 * fst_iface_get_bssid(struct fst_iface *i)
70e5b75505Sopenharmony_ci{
71e5b75505Sopenharmony_ci	return i->iface_obj.get_bssid(i->iface_obj.ctx);
72e5b75505Sopenharmony_ci}
73e5b75505Sopenharmony_ci
74e5b75505Sopenharmony_cistatic inline void fst_iface_get_channel_info(struct fst_iface *i,
75e5b75505Sopenharmony_ci					      enum hostapd_hw_mode *hw_mode,
76e5b75505Sopenharmony_ci					      u8 *channel)
77e5b75505Sopenharmony_ci{
78e5b75505Sopenharmony_ci	i->iface_obj.get_channel_info(i->iface_obj.ctx, hw_mode, channel);
79e5b75505Sopenharmony_ci}
80e5b75505Sopenharmony_ci
81e5b75505Sopenharmony_cistatic inline int fst_iface_get_hw_modes(struct fst_iface *i,
82e5b75505Sopenharmony_ci					 struct hostapd_hw_modes **modes)
83e5b75505Sopenharmony_ci{
84e5b75505Sopenharmony_ci	return i->iface_obj.get_hw_modes(i->iface_obj.ctx, modes);
85e5b75505Sopenharmony_ci}
86e5b75505Sopenharmony_ci
87e5b75505Sopenharmony_cistatic inline void fst_iface_set_ies(struct fst_iface *i,
88e5b75505Sopenharmony_ci				     const struct wpabuf *fst_ies)
89e5b75505Sopenharmony_ci{
90e5b75505Sopenharmony_ci	i->iface_obj.set_ies(i->iface_obj.ctx, fst_ies);
91e5b75505Sopenharmony_ci}
92e5b75505Sopenharmony_ci
93e5b75505Sopenharmony_cistatic inline int fst_iface_send_action(struct fst_iface *i,
94e5b75505Sopenharmony_ci					const u8 *addr, struct wpabuf *data)
95e5b75505Sopenharmony_ci{
96e5b75505Sopenharmony_ci	return i->iface_obj.send_action(i->iface_obj.ctx, addr, data);
97e5b75505Sopenharmony_ci}
98e5b75505Sopenharmony_ci
99e5b75505Sopenharmony_cistatic inline const struct wpabuf *
100e5b75505Sopenharmony_cifst_iface_get_peer_mb_ie(struct fst_iface *i, const u8 *addr)
101e5b75505Sopenharmony_ci{
102e5b75505Sopenharmony_ci	return i->iface_obj.get_mb_ie(i->iface_obj.ctx, addr);
103e5b75505Sopenharmony_ci}
104e5b75505Sopenharmony_ci
105e5b75505Sopenharmony_cistatic inline void fst_iface_update_mb_ie(struct fst_iface *i,
106e5b75505Sopenharmony_ci					  const u8 *addr,
107e5b75505Sopenharmony_ci					  const u8 *buf, size_t size)
108e5b75505Sopenharmony_ci{
109e5b75505Sopenharmony_ci	i->iface_obj.update_mb_ie(i->iface_obj.ctx, addr, buf, size);
110e5b75505Sopenharmony_ci}
111e5b75505Sopenharmony_ci
112e5b75505Sopenharmony_cistatic inline const u8 * fst_iface_get_peer_first(struct fst_iface *i,
113e5b75505Sopenharmony_ci						  struct fst_get_peer_ctx **ctx,
114e5b75505Sopenharmony_ci						  Boolean mb_only)
115e5b75505Sopenharmony_ci{
116e5b75505Sopenharmony_ci	return i->iface_obj.get_peer_first(i->iface_obj.ctx, ctx, mb_only);
117e5b75505Sopenharmony_ci}
118e5b75505Sopenharmony_ci
119e5b75505Sopenharmony_cistatic inline const u8 * fst_iface_get_peer_next(struct fst_iface *i,
120e5b75505Sopenharmony_ci						 struct fst_get_peer_ctx **ctx,
121e5b75505Sopenharmony_ci						 Boolean mb_only)
122e5b75505Sopenharmony_ci{
123e5b75505Sopenharmony_ci	return i->iface_obj.get_peer_next(i->iface_obj.ctx, ctx, mb_only);
124e5b75505Sopenharmony_ci}
125e5b75505Sopenharmony_ci
126e5b75505Sopenharmony_ciBoolean fst_iface_is_connected(struct fst_iface *iface, const u8 *addr,
127e5b75505Sopenharmony_ci			       Boolean mb_only);
128e5b75505Sopenharmony_civoid fst_iface_attach_mbie(struct fst_iface *i, struct wpabuf *mbie);
129e5b75505Sopenharmony_cienum mb_band_id fst_iface_get_band_id(struct fst_iface *i);
130e5b75505Sopenharmony_ci
131e5b75505Sopenharmony_cistatic inline void * fst_iface_get_wpa_obj_ctx(struct fst_iface *i)
132e5b75505Sopenharmony_ci{
133e5b75505Sopenharmony_ci	return i->iface_obj.ctx;
134e5b75505Sopenharmony_ci}
135e5b75505Sopenharmony_ci
136e5b75505Sopenharmony_ci#endif /* FST_IFACE_H */
137