WMM cleanup (WME -> WMM rename, comments, etc.)
[wpasupplicant] / hostapd / wme.h
1 /*
2  * hostapd / WMM (Wi-Fi Multimedia)
3  * Copyright 2002-2003, Instant802 Networks, Inc.
4  * Copyright 2005-2006, Devicescape Software, Inc.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * Alternatively, this software may be distributed under the terms of BSD
11  * license.
12  *
13  * See README and COPYING for more details.
14  */
15
16 #ifndef WME_H
17 #define WME_H
18
19 #ifdef __linux__
20 #include <endian.h>
21 #endif /* __linux__ */
22
23 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
24 #include <sys/types.h>
25 #include <sys/endian.h>
26 #endif /* defined(__FreeBSD__) || defined(__NetBSD__) ||
27         * defined(__DragonFly__) */
28
29
30 /*
31  * WMM Information Element (used in (Re)Association Request frames; may also be
32  * used in Beacon frames)
33  */
34 struct wmm_information_element {
35         /* Element ID: 221 (0xdd); Length: 7 */
36         /* required fields for WMM version 1 */
37         u8 oui[3]; /* 00:50:f2 */
38         u8 oui_type; /* 2 */
39         u8 oui_subtype; /* 0 */
40         u8 version; /* 1 for WMM version 1.0 */
41         u8 qos_info; /* AP/STA specific QoS info */
42
43 } __attribute__ ((packed));
44
45 struct wmm_ac_parameter {
46 #if __BYTE_ORDER == __LITTLE_ENDIAN
47         /* byte 1: ACI/AIFSN */
48         u8      aifsn:4,
49                 acm:1,
50                 aci:2,
51                 reserved:1;
52
53         /* byte 2: ECWmin/ECWmax (CW = 2^ECW - 1) */
54         u8      e_cw_min:4,
55                 e_cw_max:4;
56 #elif __BYTE_ORDER == __BIG_ENDIAN
57         /* byte 1: ACI/AIFSN */
58         u8      reserved:1,
59                 aci:2,
60                 acm:1,
61                 aifsn:4;
62
63         /* byte 2: ECWmin/ECWmax */
64         u8      e_cw_max:4,
65                 e_cw_min:4;
66 #else
67 #error  "Please fix <endian.h>"
68 #endif
69
70         /* bytes 3 & 4 */
71         le16 txop_limit;
72 } __attribute__ ((packed));
73
74 /*
75  * WMM Parameter Element (used in Beacon, Probe Response, and (Re)Association
76  * Response frmaes)
77  */
78 struct wmm_parameter_element {
79         /* Element ID: 221 (0xdd); Length: 24 */
80         /* required fields for WMM version 1 */
81         u8 oui[3]; /* 00:50:f2 */
82         u8 oui_type; /* 2 */
83         u8 oui_subtype; /* 1 */
84         u8 version; /* 1 for WMM version 1.0 */
85         u8 qos_info; /* AP/STA specif QoS info */
86         u8 reserved; /* 0 */
87         struct wmm_ac_parameter ac[4]; /* AC_BE, AC_BK, AC_VI, AC_VO */
88
89 } __attribute__ ((packed));
90
91 /* WMM TSPEC Element */
92 struct wmm_tspec_element {
93         u8 eid; /* 221 = 0xdd */
94         u8 length; /* 6 + 55 = 61 */
95         u8 oui[3]; /* 00:50:f2 */
96         u8 oui_type; /* 2 */
97         u8 oui_subtype; /* 2 */
98         u8 version; /* 1 */
99         /* WMM TSPEC body (55 octets): */
100         u8 ts_info[3];
101         le16 nominal_msdu_size;
102         le16 maximum_msdu_size;
103         le32 minimum_service_interval;
104         le32 maximum_service_interval;
105         le32 inactivity_interval;
106         le32 suspension_interval;
107         le32 service_start_time;
108         le32 minimum_data_rate;
109         le32 mean_data_rate;
110         le32 peak_data_rate;
111         le32 maximum_burst_size;
112         le32 delay_bound;
113         le32 minimum_phy_rate;
114         le16 surplus_bandwidth_allowance;
115         le16 medium_time;
116 } __attribute__ ((packed));
117
118
119 /* Access Categories / ACI to AC coding */
120 enum {
121         WMM_AC_BE = 0 /* Best Effort */,
122         WMM_AC_BK = 1 /* Background */,
123         WMM_AC_VI = 2 /* Video */,
124         WMM_AC_VO = 3 /* Voice */
125 };
126
127 struct ieee80211_mgmt;
128
129 u8 * hostapd_eid_wmm(struct hostapd_data *hapd, u8 *eid);
130 int hostapd_eid_wmm_valid(struct hostapd_data *hapd, u8 *eid, size_t len);
131 #ifdef NEED_MLME
132 int hostapd_wmm_sta_config(struct hostapd_data *hapd, struct sta_info *sta);
133 #else /* NEED_MLME */
134 static inline int hostapd_wmm_sta_config(struct hostapd_data *hapd,
135                                          struct sta_info *sta)
136 {
137         return 0;
138 }
139 #endif /* NEED_MLME */
140 void hostapd_wmm_action(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
141                         size_t len);
142
143 #endif /* WME_H */