tether.h 6.0 KB

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