tether.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/if_ether.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 U_MULTI_ADDR_LEN 8 // multicast address length
  39. #ifdef __BIG_ENDIAN
  40. #define TYPE_MGMT_PROBE_RSP 0x5000
  41. //
  42. // wFrameCtl field in the S802_11Header
  43. //
  44. // NOTE....
  45. // in network byte order, high byte is going first
  46. #define FC_TODS 0x0001
  47. #define FC_FROMDS 0x0002
  48. #define FC_MOREFRAG 0x0004
  49. #define FC_RETRY 0x0008
  50. #define FC_POWERMGT 0x0010
  51. #define FC_MOREDATA 0x0020
  52. #define FC_WEP 0x0040
  53. #define TYPE_802_11_ATIM 0x9000
  54. #define TYPE_802_11_DATA 0x0800
  55. #define TYPE_802_11_CTL 0x0400
  56. #define TYPE_802_11_MGMT 0x0000
  57. #define TYPE_802_11_MASK 0x0C00
  58. #define TYPE_SUBTYPE_MASK 0xFC00
  59. #define TYPE_802_11_NODATA 0x4000
  60. #define TYPE_DATE_NULL 0x4800
  61. #define TYPE_CTL_PSPOLL 0xa400
  62. #define TYPE_CTL_RTS 0xb400
  63. #define TYPE_CTL_CTS 0xc400
  64. #define TYPE_CTL_ACK 0xd400
  65. //#define WEP_IV_MASK 0xFFFFFF00
  66. #else //if LITTLE_ENDIAN
  67. //
  68. // wType field in the SEthernetHeader
  69. //
  70. // NOTE....
  71. // in network byte order, high byte is going first
  72. #define TYPE_MGMT_PROBE_RSP 0x0050
  73. //
  74. // wFrameCtl field in the S802_11Header
  75. //
  76. // NOTE....
  77. // in network byte order, high byte is going first
  78. #define FC_TODS 0x0100
  79. #define FC_FROMDS 0x0200
  80. #define FC_MOREFRAG 0x0400
  81. #define FC_RETRY 0x0800
  82. #define FC_POWERMGT 0x1000
  83. #define FC_MOREDATA 0x2000
  84. #define FC_WEP 0x4000
  85. #define TYPE_802_11_ATIM 0x0090
  86. #define TYPE_802_11_DATA 0x0008
  87. #define TYPE_802_11_CTL 0x0004
  88. #define TYPE_802_11_MGMT 0x0000
  89. #define TYPE_802_11_MASK 0x000C
  90. #define TYPE_SUBTYPE_MASK 0x00FC
  91. #define TYPE_802_11_NODATA 0x0040
  92. #define TYPE_DATE_NULL 0x0048
  93. #define TYPE_CTL_PSPOLL 0x00a4
  94. #define TYPE_CTL_RTS 0x00b4
  95. #define TYPE_CTL_CTS 0x00c4
  96. #define TYPE_CTL_ACK 0x00d4
  97. //#define WEP_IV_MASK 0x00FFFFFF
  98. #endif //#ifdef __BIG_ENDIAN
  99. #define WEP_IV_MASK 0x00FFFFFF
  100. /*--------------------- Export Types ------------------------------*/
  101. //
  102. // Ethernet packet
  103. //
  104. typedef struct tagSEthernetHeader {
  105. BYTE abyDstAddr[ETH_ALEN];
  106. BYTE abySrcAddr[ETH_ALEN];
  107. WORD wType;
  108. } __attribute__ ((__packed__))
  109. SEthernetHeader, *PSEthernetHeader;
  110. //
  111. // 802_3 packet
  112. //
  113. typedef struct tagS802_3Header {
  114. BYTE abyDstAddr[ETH_ALEN];
  115. BYTE abySrcAddr[ETH_ALEN];
  116. WORD wLen;
  117. } __attribute__ ((__packed__))
  118. S802_3Header, *PS802_3Header;
  119. //
  120. // 802_11 packet
  121. //
  122. typedef struct tagS802_11Header {
  123. WORD wFrameCtl;
  124. WORD wDurationID;
  125. BYTE abyAddr1[ETH_ALEN];
  126. BYTE abyAddr2[ETH_ALEN];
  127. BYTE abyAddr3[ETH_ALEN];
  128. WORD wSeqCtl;
  129. BYTE abyAddr4[ETH_ALEN];
  130. } __attribute__ ((__packed__))
  131. S802_11Header, *PS802_11Header;
  132. /*--------------------- Export Macros ------------------------------*/
  133. /*--------------------- Export Classes ----------------------------*/
  134. /*--------------------- Export Variables --------------------------*/
  135. /*--------------------- Export Functions --------------------------*/
  136. BYTE ETHbyGetHashIndexByCrc32(PBYTE pbyMultiAddr);
  137. //BYTE ETHbyGetHashIndexByCrc(PBYTE pbyMultiAddr);
  138. BOOL ETHbIsBufferCrc32Ok(PBYTE pbyBuffer, unsigned int cbFrameLength);
  139. #endif /* __TETHER_H__ */