root/trunk/ieee80211.h

Revision 129, 8.4 kB (checked in by jwright, 22 months ago)

added rtx capabilities to lorcon_forge, trivial changes to tx.c and ieee80211.h

Line 
1/*
2    This file is part of lorcon
3
4    lorcon is free software; you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 2 of the License, or
7    (at your option) any later version.
8
9    lorcon is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with lorcon; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18    Copyright (c) 2005 dragorn and Joshua Wright
19*/
20
21#ifndef __IEEE80211_H__
22#define __IEEE80211_H__
23
24#ifdef HAVE_CONFIG_H
25#include "config.h"
26#endif
27
28#ifdef HAVE_STDINT_H
29#include <stdint.h>
30#endif
31#ifdef HAVE_INTTYPES_H
32#include <inttypes.h>
33#endif
34
35/* Packet types and reason codes copied from various
36   sources (ieee docs and significant copying from the
37   hostapd common defines) */
38
39#define BIT(x) (1 << (x))
40
41#define WLAN_FC_TYPE_MGMT 0
42#define WLAN_FC_TYPE_CTRL 1
43#define WLAN_FC_TYPE_DATA 2
44
45#define WLAN_FC_SUBTYPE_ASSOCREQ    0
46#define WLAN_FC_SUBTYPE_ASSOCRESP   1
47#define WLAN_FC_SUBTYPE_REASSOCREQ  2
48#define WLAN_FC_SUBTYPE_REASSOCRESP 3
49#define WLAN_FC_SUBTYPE_PROBEREQ    4
50#define WLAN_FC_SUBTYPE_PROBERESP   5
51#define WLAN_FC_SUBTYPE_BEACON      8
52#define WLAN_FC_SUBTYPE_ATIM        9
53#define WLAN_FC_SUBTYPE_DISASSOC    10
54#define WLAN_FC_SUBTYPE_AUTH        11
55#define WLAN_FC_SUBTYPE_DEAUTH      12
56
57#define WLAN_FC_SUBTYPE_PSPOLL      10
58#define WLAN_FC_SUBTYPE_RTS         11
59#define WLAN_FC_SUBTYPE_CTS         12
60#define WLAN_FC_SUBTYPE_ACK         13
61#define WLAN_FC_SUBTYPE_CFEND       14
62#define WLAN_FC_SUBTYPE_CFENDACK    15
63
64#define WLAN_FC_SUBTYPE_DATA            0
65#define WLAN_FC_SUBTYPE_DATACFACK       1
66#define WLAN_FC_SUBTYPE_DATACFPOLL      2
67#define WLAN_FC_SUBTYPE_DATACFACKPOLL   3
68#define WLAN_FC_SUBTYPE_DATANULL        4
69#define WLAN_FC_SUBTYPE_CFACK           5
70#define WLAN_FC_SUBTYPE_CFACKPOLL       6
71#define WLAN_FC_SUBTYPE_CFACKPOLLNODATA 7
72#define WLAN_FC_SUBTYPE_QOSDATA         8
73/* 9 - 11 reserved as of 11/7/2005 - JWRIGHT */
74#define WLAN_FC_SUBTYPE_QOSNULL         12
75
76/* Framecontrol bits */
77#define WLAN_FC_PVER                (BIT(1) | BIT(0))
78#define WLAN_FC_TODS                BIT(8)
79#define WLAN_FC_FROMDS              BIT(9)
80#define WLAN_FC_MOREFRAG            BIT(10)
81#define WLAN_FC_RETRY               BIT(11)
82#define WLAN_FC_PWRMGT              BIT(12)
83#define WLAN_FC_MOREDATA            BIT(13)
84#define WLAN_FC_ISWEP               BIT(14)
85#define WLAN_FC_ORDER               BIT(15)
86
87/* Auth stuff */
88#define WLAN_AUTH_OPEN              0
89#define WLAN_AUTH_SHARED_KEY        1
90#define WLAN_AUTH_CHALLENGE_LEN     128
91
92/* 802.11 capabilities */
93#define WLAN_CAPABILITY_ESS         BIT(0)
94#define WLAN_CAPABILITY_IBSS        BIT(1)
95#define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
96#define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
97#define WLAN_CAPABILITY_PRIVACY     BIT(4)
98
99/* Reason codes */
100#define WLAN_REASON_UNSPECIFIED                     1
101#define WLAN_REASON_PREV_AUTH_NOT_VALID             2
102#define WLAN_REASON_DEAUTH_LEAVING                  3
103#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY      4
104#define WLAN_REASON_DISASSOC_AP_BUSY                5
105#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA   6
106#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA  7
107#define WLAN_REASON_DISASSOC_STA_HAS_LEFT           8
108#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH      9
109
110/* Status codes */
111#define WLAN_STATUS_SUCCESS                     0
112#define WLAN_STATUS_UNSPECIFIED_FAILURE         1
113#define WLAN_STATUS_CAPS_UNSUPPORTED            10
114#define WLAN_STATUS_REASSOC_NO_ASSOC            11
115#define WLAN_STATUS_ASSOC_DENIED_UNSPEC         12
116#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG      13
117#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION    14
118#define WLAN_STATUS_CHALLENGE_FAIL              15
119#define WLAN_STATUS_AUTH_TIMEOUT                16
120#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
121#define WLAN_STATUS_ASSOC_DENIED_RATES          18
122
123#define WLAN_STATUS_ASSOC_DENIED_NOSHORT        19
124#define WLAN_STATUS_ASSOC_DENIED_NOPBCC         20
125#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY      21
126
127#define WLAN_STATUS_INVALID_IE                  40
128#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID      41
129#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID   42
130#define WLAN_STATUS_AKMP_NOT_VALID              43
131#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION  44
132#define WLAN_STATUS_INVALID_RSN_IE_CAPAB        45
133#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY  46
134
135/* Tagged parameters */
136#define WLAN_TAGPARM_SSID           0
137#define WLAN_TAGPARM_SUPPRATES      1
138#define WLAN_TAGPARM_FH_PARAMS      2
139#define WLAN_TAGPARM_DS_PARAMS      3
140#define WLAN_TAGPARM_CF_PARAMS      4
141#define WLAN_TAGPARM_TIM            5
142#define WLAN_TAGPARM_IBSS_PARAMS    6
143#define WLAN_TAGPARM_CHALLENGE      16
144#define WLAN_TAGPARM_GENERIC        221
145
146/* 802.11 management frames */
147#define IEEE80211_HDRLEN_A3 (sizeof(struct ieee80211_hdr))
148#define IEEE80211_HDRLEN_A4 (sizeof(struct ieee80211_hdr) + 6)
149
150struct ieee80211_hdr {
151        union {
152                struct {
153                        uint8_t version:2;
154                        uint8_t type:2;
155                        uint8_t subtype:4;
156                        uint8_t to_ds:1;
157                        uint8_t from_ds:1;
158                        uint8_t more_frag:1;
159                        uint8_t retry:1;
160                        uint8_t pwrmgmt:1;
161                        uint8_t more_data:1;
162                        uint8_t wep:1;
163                        uint8_t order:1;
164                } __attribute__ ((packed)) fc;
165
166                uint16_t fchdr;
167        } u1;
168
169        uint16_t duration;
170        uint8_t addr1[6];
171        uint8_t addr2[6];
172        uint8_t addr3[6];
173
174        union {
175                struct {
176                        uint16_t fragment:4;
177                        uint16_t sequence:12;
178                } __attribute__ ((packed)) seq;
179
180                uint16_t seqhdr;
181        } u2;
182        /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
183         */
184
185        /* followed by wmmhdr is type = 2 and subtype = QoS data (8) or QoS
186           NULL (12)
187         */
188
189} __attribute__ ((packed));
190
191struct ieee80211_mgmt {
192        union {
193                struct {
194                        uint16_t auth_alg;
195                        uint16_t auth_transaction;
196                        uint16_t status_code;
197                        /* possibly followed by Challenge text */
198                        uint8_t variable[0];
199                } __attribute__ ((packed)) auth;
200                struct {
201                        uint16_t reason_code;
202                } __attribute__ ((packed)) deauth;
203                struct {
204                        uint16_t capab_info;
205                        uint16_t listen_interval;
206                        /* followed by SSID and Supported rates */
207                        uint8_t variable[0];
208                } __attribute__ ((packed)) assoc_req;
209                struct {
210                        uint16_t capab_info;
211                        uint16_t status_code;
212                        uint16_t aid;
213                        /* followed by Supported rates */
214                        uint8_t variable[0];
215                } __attribute__ ((packed)) assoc_resp, reassoc_resp;
216                struct {
217                        uint16_t capab_info;
218                        uint16_t listen_interval;
219                        uint8_t current_ap[6];
220                        /* followed by SSID and Supported rates */
221                        uint8_t variable[0];
222                } __attribute__ ((packed)) reassoc_req;
223                struct {
224                        uint16_t reason_code;
225                } __attribute__ ((packed)) disassoc;
226                struct {
227                        uint8_t variable[0];
228                } __attribute__ ((packed)) probe_req;
229                struct {
230                        uint8_t timestamp[8];
231                        uint16_t beacon_int;
232                        uint16_t capab_info;
233                        /* followed by some of SSID, Supported rates,
234                         * FH Params, DS Params, CF Params, IBSS Params, TIM */
235                        uint8_t variable[0];
236                } __attribute__ ((packed)) beacon;
237        } u;
238} __attribute__ ((packed));
239
240/* IEEE 802.11 fixed parameters */
241struct ieee80211_beacon_fixparm {
242        uint8_t timestamp[8];
243        uint16_t beaconinterval;
244        uint16_t capability;
245} __attribute__ ((packed));
246
247struct ieee80211_qos {
248        uint8_t priority:3;
249        uint8_t reserved3:1;
250        uint8_t eosp:1;
251        uint8_t ackpol:2;
252        uint8_t reserved1:1;
253        uint8_t reserved2;
254} __attribute__ ((packed));
255
256struct ieee80211_wep {
257        uint8_t iv[3];
258
259        union {
260                uint8_t indexhdr;
261
262                struct {
263                        uint8_t reserved1:6;
264                        uint8_t keyid:2;
265                } __attribute__ ((packed)) index;
266        } u1;
267} __attribute__ ((packed));
268
269struct ieee80211_tkip {
270        union {
271                struct {
272                        uint8_t tsc1;
273                        uint8_t wepseed;
274                        uint8_t tsc0;
275                        uint8_t reserved1:5;
276                        uint8_t extiv:1;
277                        uint8_t keyid:2;
278                } __attribute__ ((packed)) iv;
279
280                uint8_t ivhdr;
281        } u1;
282
283        union {
284                struct {
285                        uint8_t tsc2;
286                        uint8_t tsc3;
287                        uint8_t tsc4;
288                        uint8_t tsc5;
289                } extiv;
290
291                uint8_t extivhdr[4];
292        } u2;
293
294} __attribute__ ((packed));
295
296struct ieee80211_ccmp {
297        union {
298                struct {
299                        uint8_t pn0;
300                        uint8_t pn1;
301                        uint8_t reserved1;
302                        uint8_t reserved2:5;
303                        uint8_t extiv:1;
304                        uint8_t keyid:2;
305                } __attribute__ ((packed)) iv;
306
307                uint8_t ivhdr;
308        } u1;
309
310        union {
311                struct {
312                        uint8_t pn2;
313                        uint8_t pn3;
314                        uint8_t pn4;
315                        uint8_t pn5;
316                } extiv;
317
318                uint8_t extivhdr[4];
319        } u2;
320
321} __attribute__ ((packed));
322#endif
Note: See TracBrowser for help on using the browser.