8c208832e525871fdb20977c1121dd5064985f4c
[dragonfly.git] / contrib / hostapd-0.5.8 / 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 #define WME_OUI_TYPE 2
30 #define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0
31 #define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1
32 #define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2
33 #define WME_VERSION 1
34
35 #define WME_ACTION_CATEGORY 17
36 #define WME_ACTION_CODE_SETUP_REQUEST 0
37 #define WME_ACTION_CODE_SETUP_RESPONSE 1
38 #define WME_ACTION_CODE_TEARDOWN 2
39
40 #define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0
41 #define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1
42 #define WME_SETUP_RESPONSE_STATUS_REFUSED 3
43
44 #define WME_TSPEC_DIRECTION_UPLINK 0
45 #define WME_TSPEC_DIRECTION_DOWNLINK 1
46 #define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3
47
48 extern inline u16 tsinfo(int tag1d, int contention_based, int direction)
49 {
50         return (tag1d << 11) | (contention_based << 7) | (direction << 5) |
51           (tag1d << 1);
52 }
53
54
55 struct wme_information_element {
56         /* required fields for WME version 1 */
57         u8 oui[3];
58         u8 oui_type;
59         u8 oui_subtype;
60         u8 version;
61         u8 acInfo;
62
63 } __attribute__ ((packed));
64
65 struct wme_ac_parameter {
66 #if __BYTE_ORDER == __LITTLE_ENDIAN
67         /* byte 1 */
68         u8      aifsn:4,
69                 acm:1,
70                 aci:2,
71                 reserved:1;
72
73         /* byte 2 */
74         u8      eCWmin:4,
75                 eCWmax:4;
76 #elif __BYTE_ORDER == __BIG_ENDIAN
77         /* byte 1 */
78         u8      reserved:1,
79                 aci:2,
80                 acm:1,
81                 aifsn:4;
82
83         /* byte 2 */
84         u8      eCWmax:4,
85                 eCWmin:4;
86 #else
87 #error  "Please fix <endian.h>"
88 #endif
89
90         /* bytes 3 & 4 */
91         u16 txopLimit;
92 } __attribute__ ((packed));
93
94 struct wme_parameter_element {
95         /* required fields for WME version 1 */
96         u8 oui[3];
97         u8 oui_type;
98         u8 oui_subtype;
99         u8 version;
100         u8 acInfo;
101         u8 reserved;
102         struct wme_ac_parameter ac[4];
103
104 } __attribute__ ((packed));
105
106 struct wme_tspec_info_element {
107         u8 eid;
108         u8 length;
109         u8 oui[3];
110         u8 oui_type;
111         u8 oui_subtype;
112         u8 version;
113         u16 ts_info;
114         u16 nominal_msdu_size;
115         u16 maximum_msdu_size;
116         u32 minimum_service_interval;
117         u32 maximum_service_interval;
118         u32 inactivity_interval;
119         u32 start_time;
120         u32 minimum_data_rate;
121         u32 mean_data_rate;
122         u32 maximum_burst_size;
123         u32 minimum_phy_rate;
124         u32 peak_data_rate;
125         u32 delay_bound;
126         u16 surplus_bandwidth_allowance;
127         u16 medium_time;
128 } __attribute__ ((packed));
129
130
131 /* Access Categories */
132 enum {
133         WME_AC_BK = 1,
134         WME_AC_BE = 0,
135         WME_AC_VI = 2,
136         WME_AC_VO = 3
137 };
138
139
140 u8 * hostapd_eid_wme(struct hostapd_data *hapd, u8 *eid);
141 int hostapd_eid_wme_valid(struct hostapd_data *hapd, u8 *eid, size_t len);
142 int hostapd_wme_sta_config(struct hostapd_data *hapd, struct sta_info *sta);
143 void hostapd_wme_action(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
144                         size_t len);
145
146 #endif /* WME_H */