source: ReferenceDesigns/w3_802.11/c/wlan_mac_common_framework/include/wlan_mac_802_11_defs.h

Last change on this file was 6319, checked in by chunter, 3 years ago

1.8.0 release wlan-mac-se

File size: 5.7 KB
Line 
1/** @file wlan_mac_802_11_defs.h
2 *  @brief Common 802.11 Definitions
3 *
4 *  This contains definitions of 802.11 packets that are required by both
5 *  the upper and lower level CPUs.
6 *
7 *  @copyright Copyright 2013-2019, Mango Communications. All rights reserved.
8 *          Distributed under the Mango Communications Reference Design License
9 *              See LICENSE.txt included in the design archive or
10 *              at http://mangocomm.com/802.11/license
11 *
12 *  This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11)
13 */
14
15#ifndef WLAN_MAC_802_11_H
16#define WLAN_MAC_802_11_H
17
18#include "xil_types.h"
19#include "wlan_common_types.h"
20
21//-----------------------------------------------
22// 802.11 structure defines
23//
24typedef struct mac_header_80211{
25    u8  frame_control_1;
26    u8  frame_control_2;
27    u16 duration_id;
28    u8  address_1[MAC_ADDR_LEN];
29    u8  address_2[MAC_ADDR_LEN];
30    u8  address_3[MAC_ADDR_LEN];
31    u16 sequence_control;
32    //u8  address_4[MAC_ADDR_LEN];
33} __attribute__((__packed__)) mac_header_80211;
34ASSERT_TYPE_SIZE(mac_header_80211, 24);
35
36typedef struct mac_header_80211_ACK{
37    u8  frame_control_1;
38    u8  frame_control_2;
39    u16 duration_id;
40    u8  address_ra[MAC_ADDR_LEN];
41} __attribute__((__packed__))  mac_header_80211_ACK;
42ASSERT_TYPE_SIZE(mac_header_80211_ACK, 10);
43
44typedef struct mac_header_80211_CTS{
45    u8  frame_control_1;
46    u8  frame_control_2;
47    u16 duration_id;
48    u8  address_ra[MAC_ADDR_LEN];
49} __attribute__((__packed__)) mac_header_80211_CTS;
50ASSERT_TYPE_SIZE(mac_header_80211_CTS, 10);
51
52typedef struct mac_header_80211_RTS{
53    u8  frame_control_1;
54    u8  frame_control_2;
55    u16 duration_id;
56    u8  address_ra[MAC_ADDR_LEN];
57    u8  address_ta[MAC_ADDR_LEN];
58} __attribute__((__packed__)) mac_header_80211_RTS;
59ASSERT_TYPE_SIZE(mac_header_80211_RTS, 16);
60
61//IEEE 802.11-2012 section 8.2.4:
62//frame_control_1 bits[7:0]:
63// 7:4: Subtype
64// 3:2: Type
65// 1:0: Protocol Version
66
67#define MAC_FRAME_CTRL1_MASK_TYPE       0x0C
68#define MAC_FRAME_CTRL1_MASK_SUBTYPE    0xF0
69
70//Frame types (Table 8-1)
71#define MAC_FRAME_CTRL1_TYPE_MGMT       0x00
72#define MAC_FRAME_CTRL1_TYPE_CTRL       0x04
73#define MAC_FRAME_CTRL1_TYPE_DATA       0x08
74#define MAC_FRAME_CTRL1_TYPE_RSVD       0x0C
75
76#define WLAN_IS_CTRL_FRAME(f) ((((mac_header_80211*)f)->frame_control_1) & MAC_FRAME_CTRL1_TYPE_CTRL)
77
78//Frame sub-types (Table 8-1)
79//Management (MAC_FRAME_CTRL1_TYPE_MGMT) sub-types
80#define MAC_FRAME_CTRL1_SUBTYPE_ASSOC_REQ       (MAC_FRAME_CTRL1_TYPE_MGMT | 0x00)
81#define MAC_FRAME_CTRL1_SUBTYPE_ASSOC_RESP      (MAC_FRAME_CTRL1_TYPE_MGMT | 0x10)
82#define MAC_FRAME_CTRL1_SUBTYPE_REASSOC_REQ     (MAC_FRAME_CTRL1_TYPE_MGMT | 0x20)
83#define MAC_FRAME_CTRL1_SUBTYPE_REASSOC_RESP    (MAC_FRAME_CTRL1_TYPE_MGMT | 0x30)
84#define MAC_FRAME_CTRL1_SUBTYPE_PROBE_REQ       (MAC_FRAME_CTRL1_TYPE_MGMT | 0x40)
85#define MAC_FRAME_CTRL1_SUBTYPE_PROBE_RESP      (MAC_FRAME_CTRL1_TYPE_MGMT | 0x50)
86#define MAC_FRAME_CTRL1_SUBTYPE_BEACON          (MAC_FRAME_CTRL1_TYPE_MGMT | 0x80)
87#define MAC_FRAME_CTRL1_SUBTYPE_ATIM            (MAC_FRAME_CTRL1_TYPE_MGMT | 0x90)
88#define MAC_FRAME_CTRL1_SUBTYPE_DISASSOC        (MAC_FRAME_CTRL1_TYPE_MGMT | 0xA0)
89#define MAC_FRAME_CTRL1_SUBTYPE_AUTH            (MAC_FRAME_CTRL1_TYPE_MGMT | 0xB0)
90#define MAC_FRAME_CTRL1_SUBTYPE_DEAUTH          (MAC_FRAME_CTRL1_TYPE_MGMT | 0xC0)
91#define MAC_FRAME_CTRL1_SUBTYPE_ACTION          (MAC_FRAME_CTRL1_TYPE_MGMT | 0xD0)
92
93//Control (MAC_FRAME_CTRL1_TYPE_CTRL) sub-types
94#define MAC_FRAME_CTRL1_SUBTYPE_BLK_ACK_REQ     (MAC_FRAME_CTRL1_TYPE_CTRL | 0x80)
95#define MAC_FRAME_CTRL1_SUBTYPE_BLK_ACK         (MAC_FRAME_CTRL1_TYPE_CTRL | 0x90)
96#define MAC_FRAME_CTRL1_SUBTYPE_PS_POLL         (MAC_FRAME_CTRL1_TYPE_CTRL | 0xA0)
97#define MAC_FRAME_CTRL1_SUBTYPE_RTS             (MAC_FRAME_CTRL1_TYPE_CTRL | 0xB0)
98#define MAC_FRAME_CTRL1_SUBTYPE_CTS             (MAC_FRAME_CTRL1_TYPE_CTRL | 0xC0)
99#define MAC_FRAME_CTRL1_SUBTYPE_ACK             (MAC_FRAME_CTRL1_TYPE_CTRL | 0xD0)
100#define MAC_FRAME_CTRL1_SUBTYPE_CF_END          (MAC_FRAME_CTRL1_TYPE_CTRL | 0xE0)
101#define MAC_FRAME_CTRL1_SUBTYPE_CF_END_CF_ACK   (MAC_FRAME_CTRL1_TYPE_CTRL | 0xF0)
102
103//Data (MAC_FRAME_CTRL1_TYPE_DATA) sub-types
104
105#define MAC_FRAME_CTRL1_SUBTYPE_DATA            (MAC_FRAME_CTRL1_TYPE_DATA | 0x00)
106#define MAC_FRAME_CTRL1_SUBTYPE_QOSDATA         (MAC_FRAME_CTRL1_TYPE_DATA | 0x80)
107#define MAC_FRAME_CTRL1_SUBTYPE_NULLDATA        (MAC_FRAME_CTRL1_TYPE_DATA | 0x40)
108
109//IEEE 802.11-2012 section 8.2.4:
110//frame_control_2 bits[7:0]:
111#define MAC_FRAME_CTRL2_FLAG_ORDER      0x80
112#define MAC_FRAME_CTRL2_FLAG_PROTECTED  0x40
113#define MAC_FRAME_CTRL2_FLAG_MORE_DATA  0x20
114#define MAC_FRAME_CTRL2_FLAG_POWER_MGMT 0x10
115#define MAC_FRAME_CTRL2_FLAG_RETRY      0x08
116#define MAC_FRAME_CTRL2_FLAG_MORE_FLAGS 0x04
117#define MAC_FRAME_CTRL2_FLAG_FROM_DS    0x02
118#define MAC_FRAME_CTRL2_FLAG_TO_DS      0x01
119
120typedef struct beacon_probe_frame{
121    u64 timestamp;
122    u16 beacon_interval;
123    u16 capabilities;
124} __attribute__((__packed__)) beacon_probe_frame;
125ASSERT_TYPE_SIZE(beacon_probe_frame, 12);
126
127typedef struct association_req_frame{
128    u16 capabilities;
129    u16 listen_interval;
130} __attribute__((__packed__)) association_req_frame;
131ASSERT_TYPE_SIZE(association_req_frame, 4);
132
133///////Capabilities
134#define CAPABILITIES_ESS                    0x0001
135#define CAPABILITIES_IBSS                   0x0002
136//#define CAPABILITIES_CFP
137#define CAPABILITIES_PRIVACY                0x0010
138#define CAPABILITIES_SHORT_PREAMBLE         0x0020
139#define CAPABILITIES_PBCC                   0x0040
140#define CAPABILITIES_CHAN_AGILITY           0x0080
141#define CAPABILITIES_SPEC_MGMT              0x0100
142#define CAPABILITIES_SHORT_TIMESLOT         0x0400
143#define CAPABILITIES_APSD                   0x0800
144#define CAPABILITIES_DSSS_OFDM              0x2000
145#define CAPABILITIES_DELAYED_BLOCK_ACK      0x4000
146#define CAPABILITIES_IMMEDIATE_BLOCK_ACK    0x8000
147
148
149#define RATE_BASIC 0x80
150
151typedef struct qos_control{
152    u16 control;
153} __attribute__((__packed__)) qos_control;
154ASSERT_TYPE_SIZE(qos_control, 2);
155
156#endif /* WLAN_MAC_802_11_H */
Note: See TracBrowser for help on using the repository browser.