source: ReferenceDesigns/w3_802.11/c/wlan_mac_high_framework/include/wlan_mac_packet_types.h

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

1.8.0 release wlan-mac-se

File size: 5.6 KB
RevLine 
[6319]1/** @file wlan_mac_packet_types.h
2 *  @brief Packet Constructors
3 *
4 *  This contains code for constructing a variety of different types of MPDUs.
5 *
6 *  @copyright Copyright 2013-2019, Mango Communications. All rights reserved.
7 *          Distributed under the Mango Communications Reference Design License
8 *              See LICENSE.txt included in the design archive or
9 *              at http://mangocomm.com/802.11/license
10 *
11 *  This file is part of the Mango 802.11 Reference Design (https://mangocomm.com/802.11)
12 */
13
14
15#ifndef WLAN_MAC_PACKET_TYPES_H_
16#define WLAN_MAC_PACKET_TYPES_H_
17
18#include "xil_types.h"
19
20//Forward declarations
21struct mac_header_80211_common;
22struct network_info_t;
23
24typedef struct authentication_frame {
25    u16 auth_algorithm;
26    u16 auth_sequence;
27    u16 status_code;
28} authentication_frame;
29ASSERT_TYPE_SIZE(authentication_frame, 6);
30
31typedef struct deauthentication_frame {
32    u16 reason_code;
33} deauthentication_frame;
34ASSERT_TYPE_SIZE(deauthentication_frame, 2);
35
36typedef struct association_response_frame {
37    u16 capabilities;
38    u16 status_code;
39    u16 association_id;
40} association_response_frame;
41ASSERT_TYPE_SIZE(association_response_frame, 6);
42
43typedef struct association_request_frame {
44    u16 capabilities;
45    u16 listen_interval;
46} association_request_frame;
47ASSERT_TYPE_SIZE(association_request_frame, 4);
48
49typedef struct channel_switch_announcement_frame {
50    u8 category;
51    u8 action;
52
53    // Channel Switch Announcement Element (Section 8.4.2.21)
54    u8 element_id;                 // Set to 37 (Table 8-54 - Section 8.4.2.1)
55    u8 length;                     // Set to 3
56    u8 chan_switch_mode;           // Set to 0 - No restrictions on transmission until a channel switch
57    u8 new_chan_num;
58    u8 chan_switch_count;          // Set to 0 - Switch occurs any time after the frame is transmitted
59
60} channel_switch_announcement_frame;
61ASSERT_TYPE_SIZE(channel_switch_announcement_frame, 7);
62
63typedef struct measurement_common_frame {
64    u8 category;
65    u8 action;
66    u8 dialog_token;
67    u8 element_id;
68    u8 length;
69    u8 measurement_token;
70    u8 request_mode;
71    u8 measurement_type;
72    ///Note, technically measurement action frames can follow this comment with additional fields of unknown length
73    ///But currently, the three types of measurements are all the same so for ease we'll hardcode that structure here
74    u8 channel;
75    u8 start_time[8];
76    u8 duration[2];
77} measurement_common_frame;
78ASSERT_TYPE_SIZE(measurement_common_frame, 19);
79
80//#define MEASUREMENT_REQ_MODE_ENABLE  0x40
81//#define MEASUREMENT_REQ_MODE_REQUEST 0x20
82//#define MEASUREMENT_REQ_MODE_REPORT  0x10
83
84#define MEASUREMENT_REQ_MODE_PARALLEL    0x01
85#define MEASUREMENT_REQ_MODE_ENABLE      0x02
86#define MEASUREMENT_REQ_MODE_REPORTS     0x04
87#define MEASUREMENT_REQ_MODE_AUTONOMOUS  0x08
88
89#define MEASUREMENT_TYPE_BASIC 0
90#define MEASUREMENT_TYPE_CCA 1
91#define MEASUREMENT_TYPE_RPA 2
92
93
94
95
96#define AUTH_ALGO_OPEN_SYSTEM 0x00
97
98#define AUTH_SEQ_REQ 0x01
99#define AUTH_SEQ_RESP 0x02
100
101// Reason Codes as per IEEE 802.11-2012 standard.(table 8.36)
102#define DEAUTH_REASON_STA_IS_LEAVING                       3
103#define DEAUTH_REASON_INACTIVITY                           4
104#define DEAUTH_REASON_NONASSOCIATED_STA                    7
105#define DISASSOC_REASON_STA_IS_LEAVING                     8
106
107// Status Codes: Table 7-23 in 802.11-2007
108#define STATUS_SUCCESS 0
109#define STATUS_AUTH_REJECT_UNSPECIFIED 1
110#define STATUS_AUTH_REJECT_OUTSIDE_SCOPE 12
111#define STATUS_AUTH_REJECT_CHALLENGE_FAILURE 15
112#define STATUS_REJECT_TOO_MANY_ASSOCIATIONS 17
113
114#define wlan_create_beacon_frame(a,b,c,d,e) wlan_create_beacon_probe_resp_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_BEACON,e)
115#define wlan_create_probe_resp_frame(a,b,c,d,e) wlan_create_beacon_probe_resp_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_PROBE_RESP,e)
116
117int wlan_create_beacon_probe_resp_frame(u8* pkt,
118                                        u8* addr1,
119                                        u8* addr2,
120                                        u8* addr3,
121                                        u8 frame_control_1,
122                                        struct network_info_t* network_info);
123
124int wlan_create_probe_req_frame(u8* pkt,
125                                u8* addr1,
126                                u8* addr2,
127                                u8* addr3,
128                                char* ssid);
129
130int wlan_create_auth_frame(u8* pkt,
131                           u8* addr1,
132                           u8* addr2,
133                           u8* addr3,
134                           u16 auth_algorithm,
135                           u16 auth_seq,
136                           u16 status_code);
137
138#define wlan_create_deauth_frame(a,b,c,d,e)   wlan_create_deauth_disassoc_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_DEAUTH,e)
139#define wlan_create_disassoc_frame(a,b,c,d,e) wlan_create_deauth_disassoc_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_DISASSOC,e)
140
141int wlan_create_deauth_disassoc_frame(u8* pkt,
142                                      u8* addr1,
143                                      u8* addr2,
144                                      u8* addr3,
145                                      u8 frame_control_1,
146                                      u16 reason_code);
147
148int wlan_create_association_response_frame(u8* pkt,
149                                           u8* addr1,
150                                           u8* addr2,
151                                           u8* addr3,
152                                           u16 status,
153                                           u16 AID,
154                                           struct network_info_t* network_info);
155
156#define wlan_create_association_req_frame(a,b,c,d,e) wlan_create_reassoc_assoc_req_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_ASSOC_REQ,e)
157#define wlan_create_reassociation_req_frame(a,b,c,d,e) wlan_create_reassoc_assoc_req_frame(a,b,c,d,MAC_FRAME_CTRL1_SUBTYPE_REASSOC_REQ,e)
158
159int wlan_create_reassoc_assoc_req_frame(u8* pkt,
160                                        u8* addr1,
161                                        u8* addr2,
162                                        u8* addr3,
163                                        u8 frame_control_1,
164                                        struct network_info_t* network_info);
165
166int wlan_create_data_frame_header(u8* pkt,
167                                  u8* addr1,
168                                  u8* addr2,
169                                  u8* addr3,
170                                  u8 frame_control_2);
171
172#endif /* WLAN_MAC_PACKET_TYPES_H_ */
Note: See TracBrowser for help on using the repository browser.