Forest Bond | 5449c68 | 2009-04-25 10:30:44 -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 | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 29 | #ifndef __TETHER_H__ |
| 30 | #define __TETHER_H__ |
| 31 | |
Charles Clément | 670ea81 | 2010-05-19 11:30:51 -0700 | [diff] [blame] | 32 | #include <linux/etherdevice.h> |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 33 | #include "ttype.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 34 | |
| 35 | /*--------------------- Export Definitions -------------------------*/ |
| 36 | // |
| 37 | // constants |
| 38 | // |
Charles Clément | 078b078 | 2010-05-14 19:37:32 -0700 | [diff] [blame] | 39 | #define U_ETHER_ADDR_STR_LEN (ETH_ALEN * 2 + 1) |
Joe Perches | 947f9a0 | 2013-03-18 10:45:04 -0700 | [diff] [blame] | 40 | // Ethernet address string length |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 41 | |
Charles Clément | f4a68b9 | 2010-05-18 11:30:20 -0700 | [diff] [blame] | 42 | #define MAX_LOOKAHEAD_SIZE ETH_FRAME_LEN |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 43 | |
| 44 | #define U_MULTI_ADDR_LEN 8 // multicast address length |
| 45 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 46 | #ifdef __BIG_ENDIAN |
| 47 | |
| 48 | #define TYPE_PKT_IP 0x0800 // |
| 49 | #define TYPE_PKT_ARP 0x0806 // |
| 50 | #define TYPE_PKT_RARP 0x8035 // |
| 51 | #define TYPE_PKT_IPX 0x8137 // |
| 52 | #define TYPE_PKT_802_1x 0x888e |
| 53 | #define TYPE_PKT_PreAuth 0x88C7 |
| 54 | |
| 55 | #define TYPE_PKT_PING_M_REQ 0x8011 // master reguest |
| 56 | #define TYPE_PKT_PING_S_GNT 0x8022 // slave grant |
| 57 | #define TYPE_PKT_PING_M 0x8077 // pingpong master packet |
| 58 | #define TYPE_PKT_PING_S 0x8088 // pingpong slave packet |
| 59 | #define TYPE_PKT_WOL_M_REQ 0x8033 // WOL waker request |
| 60 | #define TYPE_PKT_WOL_S_GNT 0x8044 // WOL sleeper grant |
| 61 | #define TYPE_MGMT_PROBE_RSP 0x5000 |
| 62 | #define TYPE_PKT_VNT_DIAG 0x8011 // Diag Pkt |
| 63 | #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt |
| 64 | // |
| 65 | // wFrameCtl field in the S802_11Header |
| 66 | // |
| 67 | // NOTE.... |
| 68 | // in network byte order, high byte is going first |
| 69 | #define FC_TODS 0x0001 |
| 70 | #define FC_FROMDS 0x0002 |
| 71 | #define FC_MOREFRAG 0x0004 |
| 72 | #define FC_RETRY 0x0008 |
| 73 | #define FC_POWERMGT 0x0010 |
| 74 | #define FC_MOREDATA 0x0020 |
| 75 | #define FC_WEP 0x0040 |
| 76 | #define TYPE_802_11_ATIM 0x9000 |
| 77 | |
| 78 | #define TYPE_802_11_DATA 0x0800 |
| 79 | #define TYPE_802_11_CTL 0x0400 |
| 80 | #define TYPE_802_11_MGMT 0x0000 |
| 81 | #define TYPE_802_11_MASK 0x0C00 |
| 82 | #define TYPE_SUBTYPE_MASK 0xFC00 |
| 83 | #define TYPE_802_11_NODATA 0x4000 |
| 84 | #define TYPE_DATE_NULL 0x4800 |
| 85 | |
| 86 | #define TYPE_CTL_PSPOLL 0xa400 |
| 87 | #define TYPE_CTL_RTS 0xb400 |
| 88 | #define TYPE_CTL_CTS 0xc400 |
| 89 | #define TYPE_CTL_ACK 0xd400 |
| 90 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 91 | #else //if LITTLE_ENDIAN |
| 92 | // |
| 93 | // wType field in the SEthernetHeader |
| 94 | // |
| 95 | // NOTE.... |
| 96 | // in network byte order, high byte is going first |
| 97 | #define TYPE_PKT_IP 0x0008 // |
| 98 | #define TYPE_PKT_ARP 0x0608 // |
| 99 | #define TYPE_PKT_RARP 0x3580 // |
| 100 | #define TYPE_PKT_IPX 0x3781 // |
| 101 | |
| 102 | #define TYPE_PKT_802_1x 0x8e88 |
| 103 | #define TYPE_PKT_PreAuth 0xC788 |
| 104 | |
| 105 | #define TYPE_PKT_PING_M_REQ 0x1180 // master reguest |
| 106 | #define TYPE_PKT_PING_S_GNT 0x2280 // slave grant |
| 107 | #define TYPE_PKT_PING_M 0x7780 // pingpong master packet |
| 108 | #define TYPE_PKT_PING_S 0x8880 // pingpong slave packet |
| 109 | #define TYPE_PKT_WOL_M_REQ 0x3380 // WOL waker request |
| 110 | #define TYPE_PKT_WOL_S_GNT 0x4480 // WOL sleeper grant |
| 111 | #define TYPE_MGMT_PROBE_RSP 0x0050 |
| 112 | #define TYPE_PKT_VNT_DIAG 0x1180 // Diag Pkt |
| 113 | #define TYPE_PKT_VNT_PER 0x8888 // Diag PER Pkt |
| 114 | // |
| 115 | // wFrameCtl field in the S802_11Header |
| 116 | // |
| 117 | // NOTE.... |
| 118 | // in network byte order, high byte is going first |
| 119 | #define FC_TODS 0x0100 |
| 120 | #define FC_FROMDS 0x0200 |
| 121 | #define FC_MOREFRAG 0x0400 |
| 122 | #define FC_RETRY 0x0800 |
| 123 | #define FC_POWERMGT 0x1000 |
| 124 | #define FC_MOREDATA 0x2000 |
| 125 | #define FC_WEP 0x4000 |
| 126 | #define TYPE_802_11_ATIM 0x0090 |
| 127 | |
| 128 | #define TYPE_802_11_DATA 0x0008 |
| 129 | #define TYPE_802_11_CTL 0x0004 |
| 130 | #define TYPE_802_11_MGMT 0x0000 |
| 131 | #define TYPE_802_11_MASK 0x000C |
| 132 | #define TYPE_SUBTYPE_MASK 0x00FC |
| 133 | #define TYPE_802_11_NODATA 0x0040 |
| 134 | #define TYPE_DATE_NULL 0x0048 |
| 135 | |
| 136 | #define TYPE_CTL_PSPOLL 0x00a4 |
| 137 | #define TYPE_CTL_RTS 0x00b4 |
| 138 | #define TYPE_CTL_CTS 0x00c4 |
| 139 | #define TYPE_CTL_ACK 0x00d4 |
| 140 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 141 | #endif //#ifdef __BIG_ENDIAN |
| 142 | |
| 143 | #define WEP_IV_MASK 0x00FFFFFF |
| 144 | |
| 145 | /*--------------------- Export Types ------------------------------*/ |
| 146 | // |
| 147 | // Ethernet packet |
| 148 | // |
| 149 | typedef struct tagSEthernetHeader { |
Joe Perches | 947f9a0 | 2013-03-18 10:45:04 -0700 | [diff] [blame] | 150 | unsigned char abyDstAddr[ETH_ALEN]; |
| 151 | unsigned char abySrcAddr[ETH_ALEN]; |
| 152 | unsigned short wType; |
| 153 | } __attribute__ ((__packed__)) |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 154 | SEthernetHeader, *PSEthernetHeader; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 155 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 156 | // |
| 157 | // 802_3 packet |
| 158 | // |
| 159 | typedef struct tagS802_3Header { |
Joe Perches | 947f9a0 | 2013-03-18 10:45:04 -0700 | [diff] [blame] | 160 | unsigned char abyDstAddr[ETH_ALEN]; |
| 161 | unsigned char abySrcAddr[ETH_ALEN]; |
| 162 | unsigned short wLen; |
| 163 | } __attribute__ ((__packed__)) |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 164 | S802_3Header, *PS802_3Header; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 165 | |
| 166 | // |
| 167 | // 802_11 packet |
| 168 | // |
| 169 | typedef struct tagS802_11Header { |
Joe Perches | 947f9a0 | 2013-03-18 10:45:04 -0700 | [diff] [blame] | 170 | unsigned short wFrameCtl; |
| 171 | unsigned short wDurationID; |
| 172 | unsigned char abyAddr1[ETH_ALEN]; |
| 173 | unsigned char abyAddr2[ETH_ALEN]; |
| 174 | unsigned char abyAddr3[ETH_ALEN]; |
| 175 | unsigned short wSeqCtl; |
| 176 | unsigned char abyAddr4[ETH_ALEN]; |
| 177 | } __attribute__ ((__packed__)) |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 178 | S802_11Header, *PS802_11Header; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 179 | |
| 180 | /*--------------------- Export Macros ------------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 181 | |
| 182 | /*--------------------- Export Classes ----------------------------*/ |
| 183 | |
| 184 | /*--------------------- Export Variables --------------------------*/ |
| 185 | |
| 186 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 187 | |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 188 | unsigned char ETHbyGetHashIndexByCrc32(unsigned char *pbyMultiAddr); |
| 189 | //unsigned char ETHbyGetHashIndexByCrc(unsigned char *pbyMultiAddr); |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 190 | bool ETHbIsBufferCrc32Ok(unsigned char *pbyBuffer, unsigned int cbFrameLength); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 191 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 192 | #endif // __TETHER_H__ |