FST: Add the Fast Session Transfer (FST) module
[mech_eap.git] / src / fst / fst_group.h
1 /*
2  * FST module - FST group object definitions
3  * Copyright (c) 2014, Qualcomm Atheros, Inc.
4  *
5  * This software may be distributed under the terms of the BSD license.
6  * See README for more details.
7  */
8
9 #ifndef FST_GROUP_H
10 #define FST_GROUP_H
11
12 struct fst_group {
13         char group_id[IFNAMSIZ + 1];
14         struct dl_list ifaces;
15         u32 dialog_token;
16         u32 fsts_id;
17         struct dl_list global_groups_lentry;
18 };
19
20 struct session_transition_ie;
21
22 #define foreach_fst_group_iface(g, i) \
23         dl_list_for_each((i), &(g)->ifaces, struct fst_iface, group_lentry)
24
25 struct fst_group * fst_group_create(const char *group_id);
26 void fst_group_attach_iface(struct fst_group *g, struct fst_iface *i);
27 void fst_group_detach_iface(struct fst_group *g, struct fst_iface *i);
28 void fst_group_delete(struct fst_group *g);
29
30 void fst_group_update_ie(struct fst_group *g, Boolean cleaning_up);
31
32 static inline Boolean fst_group_has_ifaces(struct fst_group *g)
33 {
34         return !dl_list_empty(&g->ifaces);
35 }
36
37 static inline struct fst_iface * fst_group_first_iface(struct fst_group *g)
38 {
39         if (dl_list_empty(&g->ifaces))
40                 return NULL;
41         return dl_list_first(&g->ifaces, struct fst_iface, group_lentry);
42 }
43
44 static inline const char * fst_group_get_id(struct fst_group *g)
45 {
46         return g->group_id;
47 }
48
49 Boolean fst_group_delete_if_empty(struct fst_group *group);
50 struct fst_iface * fst_group_get_iface_by_name(struct fst_group *g,
51                                                const char *ifname);
52 struct fst_iface *
53 fst_group_find_new_iface_by_stie(struct fst_group *g,
54                                  struct fst_iface *iface,
55                                  const u8 *peer_addr,
56                                  const struct session_transition_ie *stie,
57                                  u8 *iface_peer_addr);
58 struct fst_iface *
59 fst_group_get_new_iface_by_stie_and_mbie(
60         struct fst_group *g, const u8 *mb_ies_buff, size_t mb_ies_size,
61         const struct session_transition_ie *stie, u8 *iface_peer_addr);
62 u8  fst_group_assign_dialog_token(struct fst_group *g);
63 u32 fst_group_assign_fsts_id(struct fst_group *g);
64
65 extern struct dl_list fst_global_groups_list;
66
67 #define foreach_fst_group(g) \
68         dl_list_for_each((g), &fst_global_groups_list, \
69                          struct fst_group, global_groups_lentry)
70
71 static inline struct fst_group * fst_first_group(void)
72 {
73         if (dl_list_empty(&fst_global_groups_list))
74                 return NULL;
75         return dl_list_first(&fst_global_groups_list, struct fst_group,
76                 global_groups_lentry);
77 }
78
79 #endif /* FST_GROUP_H */