15449c685a4b39534f18869a93896370224463715Forest Bond/*
25449c685a4b39534f18869a93896370224463715Forest Bond * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
35449c685a4b39534f18869a93896370224463715Forest Bond * All rights reserved.
45449c685a4b39534f18869a93896370224463715Forest Bond *
55449c685a4b39534f18869a93896370224463715Forest Bond * This program is free software; you can redistribute it and/or modify
65449c685a4b39534f18869a93896370224463715Forest Bond * it under the terms of the GNU General Public License as published by
75449c685a4b39534f18869a93896370224463715Forest Bond * the Free Software Foundation; either version 2 of the License, or
85449c685a4b39534f18869a93896370224463715Forest Bond * (at your option) any later version.
95449c685a4b39534f18869a93896370224463715Forest Bond *
105449c685a4b39534f18869a93896370224463715Forest Bond * This program is distributed in the hope that it will be useful,
115449c685a4b39534f18869a93896370224463715Forest Bond * but WITHOUT ANY WARRANTY; without even the implied warranty of
125449c685a4b39534f18869a93896370224463715Forest Bond * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
135449c685a4b39534f18869a93896370224463715Forest Bond * GNU General Public License for more details.
145449c685a4b39534f18869a93896370224463715Forest Bond *
155449c685a4b39534f18869a93896370224463715Forest Bond * You should have received a copy of the GNU General Public License along
165449c685a4b39534f18869a93896370224463715Forest Bond * with this program; if not, write to the Free Software Foundation, Inc.,
175449c685a4b39534f18869a93896370224463715Forest Bond * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
185449c685a4b39534f18869a93896370224463715Forest Bond *
19612822f5dd1638de442cf50eb9da54632fba0e66Jim Lieb *
205449c685a4b39534f18869a93896370224463715Forest Bond * File: 80211hdr.h
215449c685a4b39534f18869a93896370224463715Forest Bond *
22612822f5dd1638de442cf50eb9da54632fba0e66Jim Lieb * Purpose: 802.11 MAC headers related pre-defines and macros.
23612822f5dd1638de442cf50eb9da54632fba0e66Jim Lieb *
245449c685a4b39534f18869a93896370224463715Forest Bond *
255449c685a4b39534f18869a93896370224463715Forest Bond * Author: Lyndon Chen
265449c685a4b39534f18869a93896370224463715Forest Bond *
275449c685a4b39534f18869a93896370224463715Forest Bond * Date: Apr 8, 2002
285449c685a4b39534f18869a93896370224463715Forest Bond *
295449c685a4b39534f18869a93896370224463715Forest Bond */
305449c685a4b39534f18869a93896370224463715Forest Bond
315449c685a4b39534f18869a93896370224463715Forest Bond#ifndef __80211HDR_H__
325449c685a4b39534f18869a93896370224463715Forest Bond#define __80211HDR_H__
335449c685a4b39534f18869a93896370224463715Forest Bond
345449c685a4b39534f18869a93896370224463715Forest Bond#include "ttype.h"
355449c685a4b39534f18869a93896370224463715Forest Bond
360b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* bit type */
375449c685a4b39534f18869a93896370224463715Forest Bond#define BIT0	0x00000001
385449c685a4b39534f18869a93896370224463715Forest Bond#define BIT1	0x00000002
395449c685a4b39534f18869a93896370224463715Forest Bond#define BIT2	0x00000004
405449c685a4b39534f18869a93896370224463715Forest Bond#define BIT3	0x00000008
415449c685a4b39534f18869a93896370224463715Forest Bond#define BIT4	0x00000010
425449c685a4b39534f18869a93896370224463715Forest Bond#define BIT5	0x00000020
435449c685a4b39534f18869a93896370224463715Forest Bond#define BIT6	0x00000040
445449c685a4b39534f18869a93896370224463715Forest Bond#define BIT7	0x00000080
455449c685a4b39534f18869a93896370224463715Forest Bond#define BIT8	0x00000100
465449c685a4b39534f18869a93896370224463715Forest Bond#define BIT9	0x00000200
475449c685a4b39534f18869a93896370224463715Forest Bond#define BIT10	0x00000400
485449c685a4b39534f18869a93896370224463715Forest Bond#define BIT11	0x00000800
495449c685a4b39534f18869a93896370224463715Forest Bond#define BIT12	0x00001000
505449c685a4b39534f18869a93896370224463715Forest Bond#define BIT13	0x00002000
515449c685a4b39534f18869a93896370224463715Forest Bond#define BIT14	0x00004000
525449c685a4b39534f18869a93896370224463715Forest Bond#define BIT15	0x00008000
535449c685a4b39534f18869a93896370224463715Forest Bond#define BIT16	0x00010000
545449c685a4b39534f18869a93896370224463715Forest Bond#define BIT17	0x00020000
555449c685a4b39534f18869a93896370224463715Forest Bond#define BIT18	0x00040000
565449c685a4b39534f18869a93896370224463715Forest Bond#define BIT19	0x00080000
575449c685a4b39534f18869a93896370224463715Forest Bond#define BIT20	0x00100000
585449c685a4b39534f18869a93896370224463715Forest Bond#define BIT21	0x00200000
595449c685a4b39534f18869a93896370224463715Forest Bond#define BIT22	0x00400000
605449c685a4b39534f18869a93896370224463715Forest Bond#define BIT23	0x00800000
615449c685a4b39534f18869a93896370224463715Forest Bond#define BIT24	0x01000000
625449c685a4b39534f18869a93896370224463715Forest Bond#define BIT25	0x02000000
635449c685a4b39534f18869a93896370224463715Forest Bond#define BIT26	0x04000000
645449c685a4b39534f18869a93896370224463715Forest Bond#define BIT27	0x08000000
655449c685a4b39534f18869a93896370224463715Forest Bond#define BIT28	0x10000000
665449c685a4b39534f18869a93896370224463715Forest Bond#define BIT29	0x20000000
675449c685a4b39534f18869a93896370224463715Forest Bond#define BIT30	0x40000000
685449c685a4b39534f18869a93896370224463715Forest Bond#define BIT31	0x80000000
695449c685a4b39534f18869a93896370224463715Forest Bond
70bd83515a9024460e1743bd82d665af8206d34e7eTülin İzer/* 802.11 frame related, defined as 802.11 spec */
715449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_ADDR_LEN               6
725449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_CRC_LEN                4
735449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_CRC32_LEN              4
745449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FCS_LEN                4
755449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_BSSID_LEN              6
765449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_BSS_TS_LEN             8
775449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_HDR_ADDR2_LEN          16
785449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_HDR_ADDR3_LEN          24
795449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_HDR_ADDR4_LEN          30
805449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_IEHDR_LEN              2
815449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SSID_MAXLEN            32
825449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_RATES_MAXLEN           16
835449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_RATES_MAXLEN_11B       4
845449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_RSN_MAXLEN             32
855449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_DATA_MAXLEN            2312
864309635f692192ddcc540964189d92cad0ade249Rajbinder Brar#define WLAN_A3FR_MAXLEN            (WLAN_HDR_ADDR3_LEN + WLAN_DATA_MAXLEN + \
874309635f692192ddcc540964189d92cad0ade249Rajbinder Brar				     WLAN_CRC_LEN)
885449c685a4b39534f18869a93896370224463715Forest Bond
895449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_BEACON_FR_MAXLEN       WLAN_A3FR_MAXLEN
905449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_ATIM_FR_MAXLEN         (WLAN_HDR_ADDR3_LEN + 0)
915449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_NULLDATA_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 0)
925449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_DISASSOC_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 2)
935449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_ASSOCREQ_FR_MAXLEN     WLAN_A3FR_MAXLEN
945449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_ASSOCRESP_FR_MAXLEN    WLAN_A3FR_MAXLEN
955449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_REASSOCREQ_FR_MAXLEN   WLAN_A3FR_MAXLEN
965449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_REASSOCRESP_FR_MAXLEN  WLAN_A3FR_MAXLEN
975449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_PROBEREQ_FR_MAXLEN     WLAN_A3FR_MAXLEN
985449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_PROBERESP_FR_MAXLEN    WLAN_A3FR_MAXLEN
995449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_AUTHEN_FR_MAXLEN       WLAN_A3FR_MAXLEN
1005449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_DEAUTHEN_FR_MAXLEN     (WLAN_HDR_ADDR3_LEN + 2)
1015449c685a4b39534f18869a93896370224463715Forest Bond
1025449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP_NKEYS              4
1035449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP40_KEYLEN           5
1045449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP104_KEYLEN          13
1055449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP232_KEYLEN          29
1065449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEPMAX_KEYLEN          32
1075449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_CHALLENGE_IE_MAXLEN    255
1085449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_CHALLENGE_IE_LEN       130
1095449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_CHALLENGE_LEN          128
1105449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP_IV_LEN             4
1115449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_WEP_ICV_LEN            4
1125449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FRAGS_MAX              16
1135449c685a4b39534f18869a93896370224463715Forest Bond
1140b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Frame Type */
1155449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_TYPE_MGR 0x00
1165449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_TYPE_CTL  0x01
1175449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_TYPE_DATA 0x02
1185449c685a4b39534f18869a93896370224463715Forest Bond
1195449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FTYPE_MGMT 0x00
1205449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FTYPE_CTL  0x01
1215449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FTYPE_DATA 0x02
1225449c685a4b39534f18869a93896370224463715Forest Bond
1230b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Frame Subtypes */
1245449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_ASSOCREQ        0x00
1255449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_ASSOCRESP       0x01
1265449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_REASSOCREQ      0x02
1275449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_REASSOCRESP     0x03
1285449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_PROBEREQ        0x04
1295449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_PROBERESP       0x05
1305449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_BEACON          0x08
1315449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_ATIM            0x09
1325449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DISASSOC        0x0a
1335449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_AUTHEN          0x0b
1345449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DEAUTHEN        0x0c
1355449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_ACTION          0x0d
1365449c685a4b39534f18869a93896370224463715Forest Bond
1370b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Control */
1385449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_PSPOLL          0x0a
1395449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_RTS             0x0b
1405449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CTS             0x0c
1415449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_ACK             0x0d
1425449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CFEND           0x0e
1435449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CFENDCFACK      0x0f
1445449c685a4b39534f18869a93896370224463715Forest Bond
1450b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Data */
1465449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DATAONLY        0x00
1475449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DATA_CFACK      0x01
1485449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DATA_CFPOLL     0x02
1495449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_DATA_CFACK_CFPOLL   0x03
1505449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_NULL            0x04
1515449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CFACK           0x05
1525449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CFPOLL          0x06
1535449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_FSTYPE_CFACK_CFPOLL    0x07
1545449c685a4b39534f18869a93896370224463715Forest Bond
1555449c685a4b39534f18869a93896370224463715Forest Bond#ifdef __BIG_ENDIAN
1565449c685a4b39534f18869a93896370224463715Forest Bond
1570b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* GET & SET Frame Control bit */
1584d609018495e8f79abcb941f8e315c8c603c909dMartin Hofmann#define WLAN_GET_FC_PRVER(n)    (((unsigned short)(n) >> 8) & (BIT0 | BIT1))
1592986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FTYPE(n)    ((((unsigned short)(n) >> 8) & (BIT2 | BIT3)) >> 2)
1602986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FSTYPE(n)   ((((unsigned short)(n) >> 8) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
1612986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_TODS(n)     ((((unsigned short)(n) << 8) & (BIT8)) >> 8)
1622986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FROMDS(n)   ((((unsigned short)(n) << 8) & (BIT9)) >> 9)
1632986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n) << 8) & (BIT10)) >> 10)
1642986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_RETRY(n)    ((((unsigned short)(n) << 8) & (BIT11)) >> 11)
1652986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_PWRMGT(n)   ((((unsigned short)(n) << 8) & (BIT12)) >> 12)
1662986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n) << 8) & (BIT13)) >> 13)
1672986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_ISWEP(n)    ((((unsigned short)(n) << 8) & (BIT14)) >> 14)
1682986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_ORDER(n)    ((((unsigned short)(n) << 8) & (BIT15)) >> 15)
1695449c685a4b39534f18869a93896370224463715Forest Bond
1700b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Sequence Field bit */
1712986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n) >> 8) & (BIT0|BIT1|BIT2|BIT3))
1722986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n) >> 8) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
1735449c685a4b39534f18869a93896370224463715Forest Bond
1740b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Capability Field bit */
1755449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_ESS(n)           (((n) >> 8) & BIT0)
1765449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_IBSS(n)          ((((n) >> 8) & BIT1) >> 1)
1775449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_CFPOLLABLE(n)    ((((n) >> 8) & BIT2) >> 2)
1785449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_CFPOLLREQ(n)     ((((n) >> 8) & BIT3) >> 3)
1795449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_PRIVACY(n)       ((((n) >> 8) & BIT4) >> 4)
1805449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) ((((n) >> 8) & BIT5) >> 5)
1815449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_PBCC(n)          ((((n) >> 8) & BIT6) >> 6)
1825449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_AGILITY(n)       ((((n) >> 8) & BIT7) >> 7)
1835449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n)   ((((n))      & BIT8) >> 10)
1845449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) ((((n))      & BIT10) >> 10)
1855449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_DSSSOFDM(n)      ((((n))      & BIT13) >> 13)
1865449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_GRPACK(n)        ((((n))      & BIT14) >> 14)
1875449c685a4b39534f18869a93896370224463715Forest Bond
1885449c685a4b39534f18869a93896370224463715Forest Bond#else
1895449c685a4b39534f18869a93896370224463715Forest Bond
1900b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* GET & SET Frame Control bit */
1912986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_PRVER(n)    (((unsigned short)(n)) & (BIT0 | BIT1))
1922986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FTYPE(n)    ((((unsigned short)(n)) & (BIT2 | BIT3)) >> 2)
1932986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FSTYPE(n)   ((((unsigned short)(n)) & (BIT4|BIT5|BIT6|BIT7)) >> 4)
1942986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_TODS(n)     ((((unsigned short)(n)) & (BIT8)) >> 8)
1952986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_FROMDS(n)   ((((unsigned short)(n)) & (BIT9)) >> 9)
1962986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_MOREFRAG(n) ((((unsigned short)(n)) & (BIT10)) >> 10)
1972986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_RETRY(n)    ((((unsigned short)(n)) & (BIT11)) >> 11)
1982986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_PWRMGT(n)   ((((unsigned short)(n)) & (BIT12)) >> 12)
1992986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_MOREDATA(n) ((((unsigned short)(n)) & (BIT13)) >> 13)
2002986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_ISWEP(n)    ((((unsigned short)(n)) & (BIT14)) >> 14)
2012986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_FC_ORDER(n)    ((((unsigned short)(n)) & (BIT15)) >> 15)
2025449c685a4b39534f18869a93896370224463715Forest Bond
2030b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Sequence Field bit */
2042986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_SEQ_FRGNUM(n) (((unsigned short)(n)) & (BIT0|BIT1|BIT2|BIT3))
2052986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_GET_SEQ_SEQNUM(n) ((((unsigned short)(n)) & (~(BIT0|BIT1|BIT2|BIT3))) >> 4)
2065449c685a4b39534f18869a93896370224463715Forest Bond
2070b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Capability Field bit */
2085449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_ESS(n)           ((n) & BIT0)
2095449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_IBSS(n)          (((n) & BIT1) >> 1)
2105449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_CFPOLLABLE(n)    (((n) & BIT2) >> 2)
2115449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_CFPOLLREQ(n)     (((n) & BIT3) >> 3)
2125449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_PRIVACY(n)       (((n) & BIT4) >> 4)
2135449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SHORTPREAMBLE(n) (((n) & BIT5) >> 5)
2145449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_PBCC(n)          (((n) & BIT6) >> 6)
2155449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_AGILITY(n)       (((n) & BIT7) >> 7)
2165449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SPECTRUMMNG(n)   (((n) & BIT8) >> 10)
2175449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_SHORTSLOTTIME(n) (((n) & BIT10) >> 10)
2185449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_DSSSOFDM(n)      (((n) & BIT13) >> 13)
2195449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_CAP_INFO_GRPACK(n)        (((n) & BIT14) >> 14)
2205449c685a4b39534f18869a93896370224463715Forest Bond
2210b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini#endif /*#ifdef __BIG_ENDIAN */
2225449c685a4b39534f18869a93896370224463715Forest Bond
2235449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_ESS(n)           (n)
2245449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_IBSS(n)          ((n) << 1)
2255449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_CFPOLLABLE(n)    ((n) << 2)
2265449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_CFPOLLREQ(n)     ((n) << 3)
2275449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_PRIVACY(n)       ((n) << 4)
2285449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_SHORTPREAMBLE(n) ((n) << 5)
2295449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_SPECTRUMMNG(n)   ((n) << 8)
2305449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_PBCC(n)          ((n) << 6)
2315449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_AGILITY(n)       ((n) << 7)
2325449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_SHORTSLOTTIME(n) ((n) << 10)
2335449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_DSSSOFDM(n)      ((n) << 13)
2345449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_CAP_INFO_GRPACK(n)        ((n) << 14)
2355449c685a4b39534f18869a93896370224463715Forest Bond
2362986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_PRVER(n)    ((unsigned short)(n))
2372986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_FTYPE(n)    (((unsigned short)(n)) << 2)
2382986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_FSTYPE(n)   (((unsigned short)(n)) << 4)
2392986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_TODS(n)     (((unsigned short)(n)) << 8)
2402986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_FROMDS(n)   (((unsigned short)(n)) << 9)
2412986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_MOREFRAG(n) (((unsigned short)(n)) << 10)
2422986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_RETRY(n)    (((unsigned short)(n)) << 11)
2432986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_PWRMGT(n)   (((unsigned short)(n)) << 12)
2442986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_MOREDATA(n) (((unsigned short)(n)) << 13)
2452986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_ISWEP(n)    (((unsigned short)(n)) << 14)
2462986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_FC_ORDER(n)    (((unsigned short)(n)) << 15)
2475449c685a4b39534f18869a93896370224463715Forest Bond
2482986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_SEQ_FRGNUM(n) ((unsigned short)(n))
2492986db5fd31e312206d3ebfa4786aac04bdbe486Charles Clément#define WLAN_SET_SEQ_SEQNUM(n) (((unsigned short)(n)) << 4)
2505449c685a4b39534f18869a93896370224463715Forest Bond
2510b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* ERP Field bit */
2525449c685a4b39534f18869a93896370224463715Forest Bond
2535449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_ERP_NONERP_PRESENT(n)     ((n) & BIT0)
2545449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_ERP_USE_PROTECTION(n)     (((n) & BIT1) >> 1)
2555449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_GET_ERP_BARKER_MODE(n)        (((n) & BIT2) >> 2)
2565449c685a4b39534f18869a93896370224463715Forest Bond
2575449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_ERP_NONERP_PRESENT(n)     (n)
2585449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_ERP_USE_PROTECTION(n)     ((n) << 1)
2595449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_SET_ERP_BARKER_MODE(n)        ((n) << 2)
2605449c685a4b39534f18869a93896370224463715Forest Bond
2610b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* Support & Basic Rates field */
2625449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_MGMT_IS_BASICRATE(b)    ((b) & BIT7)
2635449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_MGMT_GET_RATE(b)        ((b) & ~BIT7)
2645449c685a4b39534f18869a93896370224463715Forest Bond
2650b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* TIM field */
2665449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_MGMT_IS_MULTICAST_TIM(b)   ((b) & BIT0)
2675449c685a4b39534f18869a93896370224463715Forest Bond#define WLAN_MGMT_GET_TIM_OFFSET(b)     (((b) & ~BIT0) >> 1)
2685449c685a4b39534f18869a93896370224463715Forest Bond
2690b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* 3-Addr & 4-Addr */
2702989e96f17f2dcbd73aee37856899c2885df0686Charles Clément#define WLAN_HDR_A3_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR3_LEN)
2712989e96f17f2dcbd73aee37856899c2885df0686Charles Clément#define WLAN_HDR_A4_DATA_PTR(p) (((unsigned char *)(p)) + WLAN_HDR_ADDR4_LEN)
2725449c685a4b39534f18869a93896370224463715Forest Bond
2730b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* IEEE ADDR */
2745449c685a4b39534f18869a93896370224463715Forest Bond#define IEEE_ADDR_UNIVERSAL         0x02
2755449c685a4b39534f18869a93896370224463715Forest Bond#define IEEE_ADDR_GROUP             0x01
2765449c685a4b39534f18869a93896370224463715Forest Bond
2775449c685a4b39534f18869a93896370224463715Forest Bondtypedef struct {
278d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr[6];
2795449c685a4b39534f18869a93896370224463715Forest Bond} IEEE_ADDR, *PIEEE_ADDR;
2805449c685a4b39534f18869a93896370224463715Forest Bond
2810b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini/* 802.11 Header Format */
2825449c685a4b39534f18869a93896370224463715Forest Bond
2835449c685a4b39534f18869a93896370224463715Forest Bondtypedef struct tagWLAN_80211HDR_A2 {
284d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wFrameCtl;
285d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wDurationID;
286d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr1[WLAN_ADDR_LEN];
287d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr2[WLAN_ADDR_LEN];
2880b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini} __attribute__ ((__packed__))
2895449c685a4b39534f18869a93896370224463715Forest BondWLAN_80211HDR_A2, *PWLAN_80211HDR_A2;
2905449c685a4b39534f18869a93896370224463715Forest Bond
2915449c685a4b39534f18869a93896370224463715Forest Bondtypedef struct tagWLAN_80211HDR_A3 {
292d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wFrameCtl;
293d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wDurationID;
294d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr1[WLAN_ADDR_LEN];
295d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr2[WLAN_ADDR_LEN];
296d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr3[WLAN_ADDR_LEN];
297d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wSeqCtl;
298d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches} __attribute__ ((__packed__))
2995449c685a4b39534f18869a93896370224463715Forest BondWLAN_80211HDR_A3, *PWLAN_80211HDR_A3;
3005449c685a4b39534f18869a93896370224463715Forest Bond
3015449c685a4b39534f18869a93896370224463715Forest Bondtypedef struct tagWLAN_80211HDR_A4 {
302d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wFrameCtl;
303d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wDurationID;
304d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr1[WLAN_ADDR_LEN];
305d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr2[WLAN_ADDR_LEN];
306d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr3[WLAN_ADDR_LEN];
307d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned short wSeqCtl;
308d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	unsigned char abyAddr4[WLAN_ADDR_LEN];
3090b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini} __attribute__ ((__packed__))
3105449c685a4b39534f18869a93896370224463715Forest BondWLAN_80211HDR_A4, *PWLAN_80211HDR_A4;
3115449c685a4b39534f18869a93896370224463715Forest Bond
3125449c685a4b39534f18869a93896370224463715Forest Bondtypedef union tagUWLAN_80211HDR {
313d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	WLAN_80211HDR_A2        sA2;
314d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	WLAN_80211HDR_A3        sA3;
315d74e97699ad43ca5674eff20ba281ce5fd1bdae9Joe Perches	WLAN_80211HDR_A4        sA4;
3165449c685a4b39534f18869a93896370224463715Forest Bond} UWLAN_80211HDR, *PUWLAN_80211HDR;
3175449c685a4b39534f18869a93896370224463715Forest Bond
3180b25a610c1f4e1f9632421e10a0f4c6497ea7debAndrea Gelmini#endif /* __80211HDR_H__ */
319