NetBurner 3.5.0
PDF Version
 
ieee802.h
Go to the documentation of this file.
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
9#ifndef _IEEE802_H_
10#define _IEEE802_H_
11#include <nettypes.h>
12
13/*
14 ******************************************************************************
15 *
16 * All structures are in network order (big-endian)
17 *
18 ******************************************************************************
19 */
20
21/*
22 ******************************************************************************
23 *
24 * Constant definitions
25 *
26 ******************************************************************************
27 */
28/* Destination service access point */
29#define IEEE802_DSAP_SNAP_PACKET_UNNUMBERED (0xAA)
30
31/* Source service access point */
32#define IEEE802_SSAP_SNAP_PACKET_UNNUMBERED (0xAA)
33
34/* Source service access point */
35#define IEEE802_CONTROL_SNAP_PACKET_UNNUMBERED (0x03)
36
37/*
38 OUI
39 IEEE802_OUI_ETHERNET_TYPE 00-00-00
40 IEEE801_OUI_DEC 00-00-F8
41
42 Notes:
43 Only OUI byte 3 changes so far
44
45 */
46#define IEEE802_OUI_ETHERNET_TYPE (0x00)
47#define IEEE801_OUI_DEC (0xF8)
48
49/* OUI length */
50#define IEEE802_P80211_OUI_LEN (3)
51
52/*
53 IEEE 802.11 Control Frame
54 Type
55 IEEE80211_TYPE_MANAGEMENT - Management
56 IEEE80211_TYPE_CONTROL - Control
57 IEEE80211_TYPE_DATA - Data
58
59 Subtype
60 IEEE80211_SUBTYPE_DATA - Data
61 IEEE80211_SUBTYPE_NULL - No data
62 IEEE80211_SUBTYPE_QOS - QOS
63
64 */
65#define IEEE80211_TYPE_MANAGEMENT (0x0)
66#define IEEE80211_TYPE_CONTROL (0x1)
67#define IEEE80211_TYPE_DATA (0x2)
68
69#define IEEE80211_SUBTYPE_DATA (0x0)
70#define IEEE80211_SUBTYPE_NULL (0x4)
71#define IEEE80211_SUBTYPE_QOS (0x8)
72
73/*
74 ******************************************************************************
75 *
76 * Structures
77 *
78 ******************************************************************************
79 */
80/*
81 IEEE 802.3 Standard Frame Media Access Control (MAC) Header
82 destination - Destination MAC-48
83 source - Source MAC-48 address
84 typeOrLength - Type or length
85
86*/
87typedef struct _Ieee802_3_Header
88{
89 MACADDRESS_48 destination;
90 MACADDRESS_48 source;
91 beuint16_t typeOrLength;
92
93} __attribute__((packed)) Ieee802_3_Header;
94
95/*
96 IEEE 802.2 Logical Link Control (LLC) +
97 Subnetwork Access Protocol (SNAP) header
98
99 dsap - Destination service access point
100 ssap - Source service access point
101 control - Control
102 oui - Organizationally Unique Identfier
103
104
105*/
106typedef struct _Ieee802_2_SnapHeader
107{
108 /* LLC for SNAP Header 0xAA 0xAA 0x03 */
109 uint8_t dsap;
110 uint8_t ssap;
111 uint8_t control;
112
113 /* Organizational Unique Identifier */
114 uint8_t oui[IEEE802_P80211_OUI_LEN];
115
116 /* Typically EtherType IPV4 (0x0800) */
117 beuint16_t protocolType;
118
119} __attribute__((packed)) Ieee802_2_SnapHeader;
120
121/*
122 ******************************************************************************
123 * IEEE 802.11
124 ******************************************************************************
125 */
126/*
127 IEEE 802.11 Packet Header Frame Control Field
128 order - 1 frames strictly ordered
129 wep - 1 yes, 0 no
130 more - More data for destination
131 power - 1 power save, 0 no after transmit
132 retry - Retransmission of previous fragment
133 fragmented - 1 more fragment frames to follow, 0 last frame
134 fromDs - Incoming from distribution system
135 toDs - Forward to distribution system
136 subType - Subtype
137 type - Type
138 version - Currently 0
139
140 */
141typedef struct _FrameControl
142{
143 uint16_t order : 1;
144 uint16_t wep : 1;
145 uint16_t more : 1;
146 uint16_t power : 1;
147 uint16_t retry : 1;
148 uint16_t fragmented : 1;
149 uint16_t fromDs : 1;
150 uint16_t toDs : 1;
151 uint16_t subType : 4;
152 uint16_t type : 2;
153 uint16_t version : 2;
154
155} __attribute__((packed)) FrameControl;
156
157/*
158 IEEE 802.11 Packet Header Format
159 frameControl - Frame control
160 durationId - Data frame duration, control id of transmitter
161 address[1|2|3|4} - MAC-48 address based on control frame from/to DS
162 sequence - sequence control
163
164 Notes:
165 Precedes data followed by 4 byte frame sequence check defined in P802.11
166 Addresses
167 -------------------------------------------------------------------
168 | To DS | From DS | Address 1 | Address 2 | Address 3 | Address 4 |
169 -------------------------------------------------------------------
170 | 0 | 0 | DA | SA | BSSID | N/A |
171 | 0 | 1 | DA | BSSID | SA | N/A |
172 | 1 | 0 | BSSID | SA | DA | N/A |
173 | 1 | 1 | RA | TA | DA | SA |
174
175 ONLY defined for 3 addresses, the 4 address header is used AP to AP
176
177 */
178typedef struct _Ieee802_11_Header
179{
180 FrameControl frameControl;
181 beuint16_t durationId;
182 MACADDRESS_48 address1;
183 MACADDRESS_48 address2;
184 MACADDRESS_48 address3;
185 beuint16_t sequence;
186
187} __attribute__((packed)) Ieee802_11_Header;
188
189#endif /* _IEEE802_H_ */
NetBurner IPADDR4 Class. See the IPADDR4 Class page for complete documentation.