fixed gcc warnings and some pointer issues thanks to hunz
[my-code/hdw-sniff.git] / ieee80211.h
1 #ifndef IEEE80211_H
2 #define IEEE80211_H
3
4 typedef unsigned int u32;
5 typedef unsigned short u16;
6 typedef unsigned char u8;
7
8 #include <endian.h>
9 #if __BYTE_ORDER == __LITTLE_ENDIAN
10 #define le_to_host16(n) (n)
11 #define host_to_le32(n) (n)
12 #else
13 #include <byteswap.h>
14 #define le_to_host16(n) bswap_16(n)
15 #define host_to_le32(n) bswap_32(n)
16 #endif
17
18 struct linux_wlan_ng_val {
19         u32 did;
20         u16 status, len;
21         u32 data;
22 } __attribute__ ((packed));
23
24 struct linux_wlan_ng_prism_hdr {
25         u32 msgcode, msglen;
26         char devname[16];
27         struct linux_wlan_ng_val hosttime, mactime, channel, rssi, sq, signal,
28                 noise, rate, istx, frmlen;
29 } __attribute__ ((packed));
30
31 #define BIT(x) (1 << (x))
32
33 #define WLAN_FC_PVER (BIT(1) | BIT(0))
34 #define WLAN_FC_TODS BIT(8)
35 #define WLAN_FC_FROMDS BIT(9)
36 #define WLAN_FC_MOREFRAG BIT(10)
37 #define WLAN_FC_RETRY BIT(11)
38 #define WLAN_FC_PWRMGT BIT(12)
39 #define WLAN_FC_MOREDATA BIT(13)
40 #define WLAN_FC_ISWEP BIT(14)
41 #define WLAN_FC_ORDER BIT(15)
42
43 #define WLAN_FC_GET_TYPE(fc) (((fc) & (BIT(3) | BIT(2))) >> 2)
44 #define WLAN_FC_GET_STYPE(fc) \
45         (((fc) & (BIT(7) | BIT(6) | BIT(5) | BIT(4))) >> 4)
46
47 #define WLAN_GET_SEQ_FRAG(seq) ((seq) & (BIT(3) | BIT(2) | BIT(1) | BIT(0)))
48 #define WLAN_GET_SEQ_SEQ(seq) \
49         (((seq) & (~(BIT(3) | BIT(2) | BIT(1) | BIT(0)))) >> 4)
50
51 #define WLAN_FC_TYPE_MGMT 0
52 #define WLAN_FC_TYPE_CTRL 1
53 #define WLAN_FC_TYPE_DATA 2
54
55 /* management */
56 #define WLAN_FC_STYPE_ASSOC_REQ 0
57 #define WLAN_FC_STYPE_ASSOC_RESP 1
58 #define WLAN_FC_STYPE_REASSOC_REQ 2
59 #define WLAN_FC_STYPE_REASSOC_RESP 3
60 #define WLAN_FC_STYPE_PROBE_REQ 4
61 #define WLAN_FC_STYPE_PROBE_RESP 5
62 #define WLAN_FC_STYPE_BEACON 8
63 #define WLAN_FC_STYPE_ATIM 9
64 #define WLAN_FC_STYPE_DISASSOC 10
65 #define WLAN_FC_STYPE_AUTH 11
66 #define WLAN_FC_STYPE_DEAUTH 12
67
68 /* control */
69 #define WLAN_FC_STYPE_PSPOLL 10
70 #define WLAN_FC_STYPE_RTS 11
71 #define WLAN_FC_STYPE_CTS 12
72 #define WLAN_FC_STYPE_ACK 13
73 #define WLAN_FC_STYPE_CFEND 14
74 #define WLAN_FC_STYPE_CFENDACK 15
75
76 /* data */
77 #define WLAN_FC_STYPE_DATA 0
78 #define WLAN_FC_STYPE_DATA_CFACK 1
79 #define WLAN_FC_STYPE_DATA_CFPOLL 2
80 #define WLAN_FC_STYPE_DATA_CFACKPOLL 3
81 #define WLAN_FC_STYPE_NULLFUNC 4
82 #define WLAN_FC_STYPE_CFACK 5
83 #define WLAN_FC_STYPE_CFPOLL 6
84 #define WLAN_FC_STYPE_CFACKPOLL 7
85
86 /* Authentication algorithms */
87 #define WLAN_AUTH_OPEN 0
88 #define WLAN_AUTH_SHARED_KEY 1
89
90 #define WLAN_AUTH_CHALLENGE_LEN 128
91
92 #define WLAN_CAPABILITY_ESS BIT(0)
93 #define WLAN_CAPABILITY_IBSS BIT(1)
94 #define WLAN_CAPABILITY_CF_POLLABLE BIT(2)
95 #define WLAN_CAPABILITY_CF_POLL_REQUEST BIT(3)
96 #define WLAN_CAPABILITY_PRIVACY BIT(4)
97
98 /* Status codes */
99 #define WLAN_STATUS_SUCCESS 0
100 #define WLAN_STATUS_UNSPECIFIED_FAILURE 1
101 #define WLAN_STATUS_CAPS_UNSUPPORTED 10
102 #define WLAN_STATUS_REASSOC_NO_ASSOC 11
103 #define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
104 #define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
105 #define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
106 #define WLAN_STATUS_CHALLENGE_FAIL 15
107 #define WLAN_STATUS_AUTH_TIMEOUT 16
108 #define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
109 #define WLAN_STATUS_ASSOC_DENIED_RATES 18
110 /* 802.11b */
111 #define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
112 #define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
113 #define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
114
115 /* Reason codes */
116 #define WLAN_REASON_UNSPECIFIED 1
117 #define WLAN_REASON_PREV_AUTH_NOT_VALID 2
118 #define WLAN_REASON_DEAUTH_LEAVING 3
119 #define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
120 #define WLAN_REASON_DISASSOC_AP_BUSY 5
121 #define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
122 #define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
123 #define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
124 #define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
125
126
127 /* Information Element IDs */
128 #define WLAN_EID_SSID 0
129 #define WLAN_EID_SUPP_RATES 1
130 #define WLAN_EID_FH_PARAMS 2
131 #define WLAN_EID_DS_PARAMS 3
132 #define WLAN_EID_CF_PARAMS 4
133 #define WLAN_EID_TIM 5
134 #define WLAN_EID_IBSS_PARAMS 6
135 #define WLAN_EID_CHALLENGE 16
136
137
138 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
139 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
140
141 #endif