blob: 1ffb2734cfae080dde03b3148ed1d24bd5884ea5 [file] [log] [blame]
Forest Bond5449c682009-04-25 10:30:44 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * File: wctl.h
20 *
21 * Purpose:
22 *
23 * Author: Jerry Chen
24 *
25 * Date: Jun. 27, 2002
26 *
27 */
28
Forest Bond5449c682009-04-25 10:30:44 -040029#ifndef __WCTL_H__
30#define __WCTL_H__
31
Forest Bond5449c682009-04-25 10:30:44 -040032#include "ttype.h"
Forest Bond5449c682009-04-25 10:30:44 -040033#include "tether.h"
Forest Bond5449c682009-04-25 10:30:44 -040034#include "device.h"
Forest Bond5449c682009-04-25 10:30:44 -040035
36/*--------------------- Export Definitions -------------------------*/
37
Joe Perchese2b8c6d2013-03-18 10:45:10 -070038#define IS_TYPE_DATA(pMACHeader) \
39 ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_DATA)
Forest Bond5449c682009-04-25 10:30:44 -040040
Joe Perchese2b8c6d2013-03-18 10:45:10 -070041#define IS_TYPE_MGMT(pMACHeader) \
42 ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_MGMT)
Forest Bond5449c682009-04-25 10:30:44 -040043
Joe Perchese2b8c6d2013-03-18 10:45:10 -070044#define IS_TYPE_CONTROL(pMACHeader) \
45 ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_802_11_MASK) == TYPE_802_11_CTL)
Forest Bond5449c682009-04-25 10:30:44 -040046
Joe Perchese2b8c6d2013-03-18 10:45:10 -070047#define IS_FC_MOREDATA(pMACHeader) \
48 ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREDATA) == FC_MOREDATA)
Forest Bond5449c682009-04-25 10:30:44 -040049
Joe Perchese2b8c6d2013-03-18 10:45:10 -070050#define IS_FC_POWERMGT(pMACHeader) \
51 ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_POWERMGT) == FC_POWERMGT)
Forest Bond5449c682009-04-25 10:30:44 -040052
Joe Perchese2b8c6d2013-03-18 10:45:10 -070053#define IS_FC_RETRY(pMACHeader) \
54 ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_RETRY) == FC_RETRY)
Forest Bond5449c682009-04-25 10:30:44 -040055
Joe Perchese2b8c6d2013-03-18 10:45:10 -070056#define IS_FC_WEP(pMACHeader) \
57 ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_WEP) == FC_WEP)
Forest Bond5449c682009-04-25 10:30:44 -040058
59#ifdef __BIG_ENDIAN
60
Joe Perchese2b8c6d2013-03-18 10:45:10 -070061#define IS_FRAGMENT_PKT(pMACHeader) \
62 (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
63 ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) != 0))
Forest Bond5449c682009-04-25 10:30:44 -040064
Joe Perchese2b8c6d2013-03-18 10:45:10 -070065#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
66 ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x0F00) == 0)
Forest Bond5449c682009-04-25 10:30:44 -040067
68#else
69
Joe Perchese2b8c6d2013-03-18 10:45:10 -070070#define IS_FRAGMENT_PKT(pMACHeader) \
71 (((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) != 0) | \
72 ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) != 0))
Forest Bond5449c682009-04-25 10:30:44 -040073
Joe Perchese2b8c6d2013-03-18 10:45:10 -070074#define IS_FIRST_FRAGMENT_PKT(pMACHeader) \
75 ((((PS802_11Header) pMACHeader)->wSeqCtl & 0x000F) == 0)
Forest Bond5449c682009-04-25 10:30:44 -040076
77#endif//#ifdef __BIG_ENDIAN
78
Joe Perchese2b8c6d2013-03-18 10:45:10 -070079#define IS_LAST_FRAGMENT_PKT(pMACHeader) \
80 ((((PS802_11Header) pMACHeader)->wFrameCtl & FC_MOREFRAG) == 0)
Forest Bond5449c682009-04-25 10:30:44 -040081
Joe Perchese2b8c6d2013-03-18 10:45:10 -070082#define IS_CTL_PSPOLL(pMACHeader) \
83 ((((PS802_11Header) pMACHeader)->wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_CTL_PSPOLL)
Forest Bond5449c682009-04-25 10:30:44 -040084
Joe Perchesbda2a442013-03-18 20:55:40 -070085#define ADD_ONE_WITH_WRAP_AROUND(uVar, uModulo) \
86do { \
87 if ((uVar) >= ((uModulo) - 1)) \
88 (uVar) = 0; \
89 else \
90 (uVar)++; \
91} while (0)
Forest Bond5449c682009-04-25 10:30:44 -040092
Forest Bond5449c682009-04-25 10:30:44 -040093/*--------------------- Export Classes ----------------------------*/
94
95/*--------------------- Export Variables --------------------------*/
96
97/*--------------------- Export Functions --------------------------*/
Forest Bond5449c682009-04-25 10:30:44 -040098
Charles Clément7b6a0012010-08-01 17:15:50 +020099bool WCTLbIsDuplicate(PSCache pCache, PS802_11Header pMACHeader);
100bool WCTLbHandleFragment(PSDevice pDevice, PS802_11Header pMACHeader,
Joe Perchese2b8c6d2013-03-18 10:45:10 -0700101 unsigned int cbFrameLength, bool bWEP, bool bExtIV);
Charles Clémentb6e95cd2010-06-02 09:52:01 -0700102unsigned int WCTLuSearchDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
103unsigned int WCTLuInsertDFCB(PSDevice pDevice, PS802_11Header pMACHeader);
Forest Bond5449c682009-04-25 10:30:44 -0400104
Forest Bond5449c682009-04-25 10:30:44 -0400105#endif // __WCTL_H__