Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 1 | /* |
| 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: tether.h |
| 20 | * |
| 21 | * Purpose: |
| 22 | * |
| 23 | * Author: Tevin Chen |
| 24 | * |
| 25 | * Date: Jan. 28, 1997 |
| 26 | * |
| 27 | */ |
| 28 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 29 | #ifndef __TETHER_H__ |
| 30 | #define __TETHER_H__ |
| 31 | |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 32 | #include <linux/if_ether.h> |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 33 | #include "ttype.h" |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 34 | |
| 35 | /*--------------------- Export Definitions -------------------------*/ |
| 36 | // |
| 37 | // constants |
| 38 | // |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 39 | #define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1) |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 40 | // Ethernet address string length |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 41 | #define U_MULTI_ADDR_LEN 8 // multicast address length |
| 42 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 43 | #ifdef __BIG_ENDIAN |
| 44 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 45 | #define TYPE_MGMT_PROBE_RSP 0x5000 |
Andres More | 203e461 | 2010-08-04 19:12:34 -0300 | [diff] [blame] | 46 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 47 | // |
| 48 | // wFrameCtl field in the S802_11Header |
| 49 | // |
| 50 | // NOTE.... |
| 51 | // in network byte order, high byte is going first |
| 52 | #define FC_TODS 0x0001 |
| 53 | #define FC_FROMDS 0x0002 |
| 54 | #define FC_MOREFRAG 0x0004 |
| 55 | #define FC_RETRY 0x0008 |
| 56 | #define FC_POWERMGT 0x0010 |
| 57 | #define FC_MOREDATA 0x0020 |
| 58 | #define FC_WEP 0x0040 |
| 59 | #define TYPE_802_11_ATIM 0x9000 |
| 60 | |
| 61 | #define TYPE_802_11_DATA 0x0800 |
| 62 | #define TYPE_802_11_CTL 0x0400 |
| 63 | #define TYPE_802_11_MGMT 0x0000 |
| 64 | #define TYPE_802_11_MASK 0x0C00 |
| 65 | #define TYPE_SUBTYPE_MASK 0xFC00 |
| 66 | #define TYPE_802_11_NODATA 0x4000 |
| 67 | #define TYPE_DATE_NULL 0x4800 |
| 68 | |
| 69 | #define TYPE_CTL_PSPOLL 0xa400 |
| 70 | #define TYPE_CTL_RTS 0xb400 |
| 71 | #define TYPE_CTL_CTS 0xc400 |
| 72 | #define TYPE_CTL_ACK 0xd400 |
| 73 | |
| 74 | |
| 75 | //#define WEP_IV_MASK 0xFFFFFF00 |
| 76 | |
| 77 | #else //if LITTLE_ENDIAN |
| 78 | // |
| 79 | // wType field in the SEthernetHeader |
| 80 | // |
| 81 | // NOTE.... |
| 82 | // in network byte order, high byte is going first |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 83 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 84 | #define TYPE_MGMT_PROBE_RSP 0x0050 |
Andres More | 203e461 | 2010-08-04 19:12:34 -0300 | [diff] [blame] | 85 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 86 | // |
| 87 | // wFrameCtl field in the S802_11Header |
| 88 | // |
| 89 | // NOTE.... |
| 90 | // in network byte order, high byte is going first |
| 91 | #define FC_TODS 0x0100 |
| 92 | #define FC_FROMDS 0x0200 |
| 93 | #define FC_MOREFRAG 0x0400 |
| 94 | #define FC_RETRY 0x0800 |
| 95 | #define FC_POWERMGT 0x1000 |
| 96 | #define FC_MOREDATA 0x2000 |
| 97 | #define FC_WEP 0x4000 |
| 98 | #define TYPE_802_11_ATIM 0x0090 |
| 99 | |
| 100 | #define TYPE_802_11_DATA 0x0008 |
| 101 | #define TYPE_802_11_CTL 0x0004 |
| 102 | #define TYPE_802_11_MGMT 0x0000 |
| 103 | #define TYPE_802_11_MASK 0x000C |
| 104 | #define TYPE_SUBTYPE_MASK 0x00FC |
| 105 | #define TYPE_802_11_NODATA 0x0040 |
| 106 | #define TYPE_DATE_NULL 0x0048 |
| 107 | |
| 108 | #define TYPE_CTL_PSPOLL 0x00a4 |
| 109 | #define TYPE_CTL_RTS 0x00b4 |
| 110 | #define TYPE_CTL_CTS 0x00c4 |
| 111 | #define TYPE_CTL_ACK 0x00d4 |
| 112 | |
| 113 | |
| 114 | //#define WEP_IV_MASK 0x00FFFFFF |
| 115 | |
| 116 | #endif //#ifdef __BIG_ENDIAN |
| 117 | |
| 118 | #define WEP_IV_MASK 0x00FFFFFF |
| 119 | |
| 120 | /*--------------------- Export Types ------------------------------*/ |
| 121 | // |
| 122 | // Ethernet packet |
| 123 | // |
| 124 | typedef struct tagSEthernetHeader { |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 125 | BYTE abyDstAddr[ETH_ALEN]; |
| 126 | BYTE abySrcAddr[ETH_ALEN]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 127 | WORD wType; |
Andres More | d9d1ccb | 2010-05-26 20:00:36 -0300 | [diff] [blame] | 128 | } __attribute__ ((__packed__)) |
Jim Lieb | 193a823 | 2009-08-12 14:54:06 -0700 | [diff] [blame] | 129 | SEthernetHeader, *PSEthernetHeader; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 130 | |
| 131 | |
| 132 | // |
| 133 | // 802_3 packet |
| 134 | // |
| 135 | typedef struct tagS802_3Header { |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 136 | BYTE abyDstAddr[ETH_ALEN]; |
| 137 | BYTE abySrcAddr[ETH_ALEN]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 138 | WORD wLen; |
Andres More | d9d1ccb | 2010-05-26 20:00:36 -0300 | [diff] [blame] | 139 | } __attribute__ ((__packed__)) |
Jim Lieb | 193a823 | 2009-08-12 14:54:06 -0700 | [diff] [blame] | 140 | S802_3Header, *PS802_3Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 141 | |
| 142 | // |
| 143 | // 802_11 packet |
| 144 | // |
| 145 | typedef struct tagS802_11Header { |
| 146 | WORD wFrameCtl; |
| 147 | WORD wDurationID; |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 148 | BYTE abyAddr1[ETH_ALEN]; |
| 149 | BYTE abyAddr2[ETH_ALEN]; |
| 150 | BYTE abyAddr3[ETH_ALEN]; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 151 | WORD wSeqCtl; |
Andres More | 9a0e756 | 2010-04-13 21:54:48 -0300 | [diff] [blame] | 152 | BYTE abyAddr4[ETH_ALEN]; |
Andres More | d9d1ccb | 2010-05-26 20:00:36 -0300 | [diff] [blame] | 153 | } __attribute__ ((__packed__)) |
Jim Lieb | 193a823 | 2009-08-12 14:54:06 -0700 | [diff] [blame] | 154 | S802_11Header, *PS802_11Header; |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 155 | |
| 156 | /*--------------------- Export Macros ------------------------------*/ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 157 | |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 158 | /*--------------------- Export Classes ----------------------------*/ |
| 159 | |
| 160 | /*--------------------- Export Variables --------------------------*/ |
| 161 | |
| 162 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 163 | |
| 164 | BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr); |
| 165 | //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr); |
Andres More | cc856e6 | 2010-05-17 21:34:01 -0300 | [diff] [blame] | 166 | BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength); |
Forest Bond | 92b9679 | 2009-06-13 07:38:31 -0400 | [diff] [blame] | 167 | |
Andres More | e7b07d1 | 2010-05-01 19:12:26 -0300 | [diff] [blame] | 168 | #endif /* __TETHER_H__ */ |