xref: /freebsd/contrib/wpa/src/fst/fst_group.h (revision c1d255d3ffdbe447de3ab875bf4e7d7accc5bfc5)
1325151a3SRui Paulo /*
2325151a3SRui Paulo  * FST module - FST group object definitions
3325151a3SRui Paulo  * Copyright (c) 2014, Qualcomm Atheros, Inc.
4325151a3SRui Paulo  *
5325151a3SRui Paulo  * This software may be distributed under the terms of the BSD license.
6325151a3SRui Paulo  * See README for more details.
7325151a3SRui Paulo  */
8325151a3SRui Paulo 
9325151a3SRui Paulo #ifndef FST_GROUP_H
10325151a3SRui Paulo #define FST_GROUP_H
11325151a3SRui Paulo 
12325151a3SRui Paulo struct fst_group {
13325151a3SRui Paulo 	char group_id[IFNAMSIZ + 1];
14325151a3SRui Paulo 	struct dl_list ifaces;
15325151a3SRui Paulo 	u8 dialog_token;
16325151a3SRui Paulo 	u32 fsts_id;
17325151a3SRui Paulo 	struct dl_list global_groups_lentry;
18325151a3SRui Paulo };
19325151a3SRui Paulo 
20325151a3SRui Paulo struct session_transition_ie;
21325151a3SRui Paulo 
22325151a3SRui Paulo #define foreach_fst_group_iface(g, i) \
23325151a3SRui Paulo 	dl_list_for_each((i), &(g)->ifaces, struct fst_iface, group_lentry)
24325151a3SRui Paulo 
25325151a3SRui Paulo struct fst_group * fst_group_create(const char *group_id);
26325151a3SRui Paulo void fst_group_attach_iface(struct fst_group *g, struct fst_iface *i);
27325151a3SRui Paulo void fst_group_detach_iface(struct fst_group *g, struct fst_iface *i);
28325151a3SRui Paulo void fst_group_delete(struct fst_group *g);
29325151a3SRui Paulo 
30325151a3SRui Paulo void fst_group_update_ie(struct fst_group *g);
31325151a3SRui Paulo 
fst_group_has_ifaces(struct fst_group * g)32*c1d255d3SCy Schubert static inline bool fst_group_has_ifaces(struct fst_group *g)
33325151a3SRui Paulo {
34325151a3SRui Paulo 	return !dl_list_empty(&g->ifaces);
35325151a3SRui Paulo }
36325151a3SRui Paulo 
fst_group_first_iface(struct fst_group * g)37325151a3SRui Paulo static inline struct fst_iface * fst_group_first_iface(struct fst_group *g)
38325151a3SRui Paulo {
39325151a3SRui Paulo 	return dl_list_first(&g->ifaces, struct fst_iface, group_lentry);
40325151a3SRui Paulo }
41325151a3SRui Paulo 
fst_group_get_id(struct fst_group * g)42325151a3SRui Paulo static inline const char * fst_group_get_id(struct fst_group *g)
43325151a3SRui Paulo {
44325151a3SRui Paulo 	return g->group_id;
45325151a3SRui Paulo }
46325151a3SRui Paulo 
47*c1d255d3SCy Schubert bool fst_group_delete_if_empty(struct fst_group *group);
48325151a3SRui Paulo struct fst_iface * fst_group_get_iface_by_name(struct fst_group *g,
49325151a3SRui Paulo 					       const char *ifname);
50325151a3SRui Paulo struct fst_iface *
51780fb4a2SCy Schubert fst_group_get_peer_other_connection(struct fst_iface *iface,
52780fb4a2SCy Schubert 				    const u8 *peer_addr, u8 band_id,
53780fb4a2SCy Schubert 				    u8 *other_peer_addr);
54325151a3SRui Paulo u8  fst_group_assign_dialog_token(struct fst_group *g);
55325151a3SRui Paulo u32 fst_group_assign_fsts_id(struct fst_group *g);
56325151a3SRui Paulo 
57325151a3SRui Paulo extern struct dl_list fst_global_groups_list;
58325151a3SRui Paulo 
59325151a3SRui Paulo #define foreach_fst_group(g) \
60325151a3SRui Paulo 	dl_list_for_each((g), &fst_global_groups_list, \
61325151a3SRui Paulo 			 struct fst_group, global_groups_lentry)
62325151a3SRui Paulo 
fst_first_group(void)63325151a3SRui Paulo static inline struct fst_group * fst_first_group(void)
64325151a3SRui Paulo {
65325151a3SRui Paulo 	return dl_list_first(&fst_global_groups_list, struct fst_group,
66325151a3SRui Paulo 			     global_groups_lentry);
67325151a3SRui Paulo }
68325151a3SRui Paulo 
69325151a3SRui Paulo #endif /* FST_GROUP_H */
70