checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / epan / dissectors / packet-ieee80211.h
1 /* packet-ieee80211.h
2  * Routines for Wireless LAN (IEEE 802.11) dissection
3  *
4  * Copyright 2000, Axis Communications AB
5  * Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * Copied from README.developer
12  *
13  * SPDX-License-Identifier: GPL-2.0-or-later
14  */
15
16 #include "ws_symbol_export.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif /* __cplusplus */
21
22 typedef struct {
23   gboolean association_has_mobility_domain_element;
24   gboolean has_ft_akm_suite;
25   gboolean has_non_ft_akm_suite;
26   proto_node *rsn_first_ft_akm_suite;
27   proto_node *rsn_first_non_ft_akm_suite;
28 } association_sanity_check_t;
29
30 typedef struct ieee80211_tagged_field_data
31 {
32   int ftype;
33   association_sanity_check_t* sanity_check;
34   gboolean isDMG;
35   proto_item* item_tag;
36   proto_item* item_tag_length;
37 } ieee80211_tagged_field_data_t;
38
39
40 int add_tagged_field(packet_info *pinfo, proto_tree *tree,
41                             tvbuff_t *tvb, int offset, int ftype,
42                             const guint8 *valid_element_ids,
43                             guint valid_element_ids_count,
44                             association_sanity_check_t *association_sanity_check);
45
46 int dissect_wifi_dpp_config_proto(packet_info *pinfo, proto_tree *query,
47                                   tvbuff_t *tvb, int offset);
48 #define MAX_SSID_LEN    32
49 #define MAX_PROTECT_LEN 10
50
51 /*
52  * Table of data rates, indexed by MCS index, bandwidth (0 for 20, 1 for 40),
53  * amd guard interval (0 for long, 1 for short).
54  */
55 #define MAX_MCS_INDEX 76
56
57 WS_DLL_PUBLIC const guint16 ieee80211_ht_Dbps[MAX_MCS_INDEX+1];
58 float ieee80211_htrate(int mcs_index, gboolean bandwidth, gboolean short_gi);
59
60 WS_DLL_PUBLIC value_string_ext ieee80211_supported_rates_vals_ext;
61
62 WS_DLL_PUBLIC
63 gboolean is_broadcast_bssid(const address *bssid);
64
65 #ifdef __cplusplus
66 }
67 #endif /* __cplusplus */
68
69 /*
70  * Extract the protocol version from the frame control field
71  */
72 #define FCF_PROT_VERSION(x)  ((x) & 0x3)
73
74 /*
75  * Extract the frame type from the frame control field.
76  */
77 #define FCF_FRAME_TYPE(x)    (((x) & 0xC) >> 2)
78
79 /*
80  * Extract the frame subtype from the frame control field.
81  */
82 #define FCF_FRAME_SUBTYPE(x) (((x) & 0xF0) >> 4)
83
84 /*
85  * Extract the control frame extension from the frame control field.
86  */
87 #define FCF_FRAME_EXTENSION(x) (((x) & 0xF00) >> 8)
88
89 /*
90  * Checks if the frame is control frame extension.
91  */
92 #define IS_FRAME_EXTENSION(x) ((FCF_FRAME_TYPE(x) == 0x1 && FCF_FRAME_SUBTYPE(x) == 0x6) ? 1 : 0)
93
94 /*
95  * Convert the frame type and subtype from the frame control field into
96  * one of the MGT_, CTRL_, or DATA_ values.
97  * Now includes extension subtype in case present.
98  */
99 #define COMPOSE_FRAME_TYPE(x) ((FCF_FRAME_TYPE(x) == 0x1 && FCF_FRAME_SUBTYPE(x) == 0x6) ? (((x & 0x0C)<< 6) + ((x) & 0xF0) + FCF_FRAME_EXTENSION(x)) : (((x & 0x0C)<< 2)+FCF_FRAME_SUBTYPE(x)))  /* Create key to (sub)type */
100
101 /*
102  * The subtype field of a data frame is, in effect, composed of 4 flag
103  * bits - CF-Ack, CF-Poll, Null (means the frame doesn't actually have
104  * any data), and QoS.
105  */
106 #define DATA_FRAME_IS_CF_ACK(x)  ((x) & 0x01)
107 #define DATA_FRAME_IS_CF_POLL(x) ((x) & 0x02)
108 #define DATA_FRAME_IS_NULL(x)    ((x) & 0x04)
109 #define DATA_FRAME_IS_QOS(x)     ((x) & 0x08)
110
111 /*
112  * Extract the flags from the frame control field.
113  * Now includes subset of flags when the subtype is control frame extension.
114  */
115 #define FCF_FLAGS(x)           ((FCF_FRAME_TYPE(x) == 0x1 && FCF_FRAME_SUBTYPE(x) == 0x6) ? (((x) & 0xF000) >> 12) : (((x) & 0xFF00) >> 8))
116
117 /*
118  * Bits from the flags field.
119  */
120 #define FLAG_TO_DS            0x01
121 #define FLAG_FROM_DS          0x02
122 #define FLAG_MORE_FRAGMENTS   0x04
123 #define FLAG_RETRY            0x08
124 #define FLAG_POWER_MGT        0x10
125 #define FLAG_MORE_DATA        0x20
126 #define FLAG_PROTECTED        0x40
127 #define FLAG_ORDER            0x80    /* overloaded for "has HT control" */
128
129 /*
130  * Test bits in the flags field.
131  */
132 /*
133  * XXX - Only HAVE_FRAGMENTS, IS_PROTECTED, and HAS_HT_CONTROL
134  * are in use.  Should the rest be removed?
135  */
136 #define IS_TO_DS(x)            ((x) & FLAG_TO_DS)
137 #define IS_FROM_DS(x)          ((x) & FLAG_FROM_DS)
138 #define HAVE_FRAGMENTS(x)      ((x) & FLAG_MORE_FRAGMENTS)
139 #define IS_RETRY(x)            ((x) & FLAG_RETRY)
140 #define POWER_MGT_STATUS(x)    ((x) & FLAG_POWER_MGT)
141 #define HAS_MORE_DATA(x)       ((x) & FLAG_MORE_DATA)
142 #define IS_PROTECTED(x)        ((x) & FLAG_PROTECTED)
143 #define IS_STRICTLY_ORDERED(x) ((x) & FLAG_ORDER)      /* for non-QoS data frames */
144 #define HAS_HT_CONTROL(x)      ((x) & FLAG_ORDER)      /* for management and QoS data frames */
145
146 /*
147  * Extract subfields from the flags field.
148  */
149 #define FLAGS_DS_STATUS(x)          ((x) & (FLAG_FROM_DS|FLAG_TO_DS))
150
151 /*
152  * Extract an indication of the types of addresses in a data frame from
153  * the frame control field.
154  */
155 #define FCF_ADDR_SELECTOR(x) ((x) & ((FLAG_TO_DS|FLAG_FROM_DS) << 8))
156
157 #define DATA_ADDR_T1         0
158 #define DATA_ADDR_T2         (FLAG_FROM_DS << 8)
159 #define DATA_ADDR_T3         (FLAG_TO_DS << 8)
160 #define DATA_ADDR_T4         ((FLAG_TO_DS|FLAG_FROM_DS) << 8)
161
162 /*
163  * COMPOSE_FRAME_TYPE() values for management frames.
164  */
165 #define MGT_ASSOC_REQ          0x00  /* association request        */
166 #define MGT_ASSOC_RESP         0x01  /* association response       */
167 #define MGT_REASSOC_REQ        0x02  /* reassociation request      */
168 #define MGT_REASSOC_RESP       0x03  /* reassociation response     */
169 #define MGT_PROBE_REQ          0x04  /* Probe request              */
170 #define MGT_PROBE_RESP         0x05  /* Probe response             */
171 #define MGT_MEASUREMENT_PILOT  0x06  /* Measurement Pilot          */
172 #define MGT_BEACON             0x08  /* Beacon frame               */
173 #define MGT_ATIM               0x09  /* ATIM                       */
174 #define MGT_DISASS             0x0A  /* Disassociation             */
175 #define MGT_AUTHENTICATION     0x0B  /* Authentication             */
176 #define MGT_DEAUTHENTICATION   0x0C  /* Deauthentication           */
177 #define MGT_ACTION             0x0D  /* Action                     */
178 #define MGT_ACTION_NO_ACK      0x0E  /* Action No Ack              */
179 #define MGT_ARUBA_WLAN         0x0F  /* Aruba WLAN Specific        */
180
181 /*
182  * COMPOSE_FRAME_TYPE() values for control frames.
183  * 0x160 - 0x16A are for control frame extension where type = 1 and subtype =6.
184  */
185 #define CTRL_TRIGGER           0x12  /* HE Trigger                     */
186 #define CTRL_BEAMFORM_RPT_POLL 0x14  /* Beamforming Report             */
187 #define CTRL_VHT_NDP_ANNC      0x15  /* VHT NDP Announcement           */
188 #define CTRL_POLL              0x162  /* Poll                          */
189 #define CTRL_SPR               0x163  /* Service Period Request        */
190 #define CTRL_GRANT             0x164  /* Grant                         */
191 #define CTRL_DMG_CTS           0x165  /* DMG Clear to Send             */
192 #define CTRL_DMG_DTS           0x166  /* DMG Denial to Send            */
193 #define CTRL_GRANT_ACK         0x167  /* Grant Acknowledgment          */
194 #define CTRL_SSW               0x168  /* Sector Sweep                  */
195 #define CTRL_SSW_FEEDBACK      0x169  /* Sector Sweep Feedback         */
196 #define CTRL_SSW_ACK           0x16A  /* Sector Sweep Acknowledgment   */
197 #define CTRL_CONTROL_WRAPPER   0x17  /* Control Wrapper                */
198 #define CTRL_BLOCK_ACK_REQ     0x18  /* Block ack Request              */
199 #define CTRL_BLOCK_ACK         0x19  /* Block ack                      */
200 #define CTRL_PS_POLL           0x1A  /* power-save poll                */
201 #define CTRL_RTS               0x1B  /* request to send                */
202 #define CTRL_CTS               0x1C  /* clear to send                  */
203 #define CTRL_ACKNOWLEDGEMENT   0x1D  /* acknowledgement                */
204 #define CTRL_CFP_END           0x1E  /* contention-free period end     */
205 #define CTRL_CFP_ENDACK        0x1F  /* contention-free period end/ack */
206
207 /*
208  * COMPOSE_FRAME_TYPE() values for data frames.
209  */
210 #define DATA                        0x20  /* Data                       */
211 #define DATA_CF_ACK                 0x21  /* Data + CF-Ack              */
212 #define DATA_CF_POLL                0x22  /* Data + CF-Poll             */
213 #define DATA_CF_ACK_POLL            0x23  /* Data + CF-Ack + CF-Poll    */
214 #define DATA_NULL_FUNCTION          0x24  /* Null function (no data)    */
215 #define DATA_CF_ACK_NOD             0x25  /* CF-Ack (no data)           */
216 #define DATA_CF_POLL_NOD            0x26  /* CF-Poll (No data)          */
217 #define DATA_CF_ACK_POLL_NOD        0x27  /* CF-Ack + CF-Poll (no data) */
218
219 #define DATA_QOS_DATA               0x28  /* QoS Data                   */
220 #define DATA_QOS_DATA_CF_ACK        0x29  /* QoS Data + CF-Ack        */
221 #define DATA_QOS_DATA_CF_POLL       0x2A  /* QoS Data + CF-Poll      */
222 #define DATA_QOS_DATA_CF_ACK_POLL   0x2B  /* QoS Data + CF-Ack + CF-Poll    */
223 #define DATA_QOS_NULL               0x2C  /* QoS Null        */
224 #define DATA_QOS_CF_POLL_NOD        0x2E  /* QoS CF-Poll (No Data)      */
225 #define DATA_QOS_CF_ACK_POLL_NOD    0x2F  /* QoS CF-Ack + CF-Poll (No Data) */
226
227 /*
228  * COMPOSE_FRAME_TYPE() values for extension frames.
229  */
230 #define EXTENSION_DMG_BEACON         0x30  /* Extension DMG beacon */
231
232 typedef struct _wlan_stats {
233   guint8 channel;
234   guint8 ssid_len;
235   guchar ssid[MAX_SSID_LEN];
236   gchar protection[MAX_PROTECT_LEN];
237   gboolean fc_retry;
238 } wlan_stats_t;
239
240 typedef struct _wlan_hdr {
241   address bssid;
242   address src;
243   address dst;
244   guint16 type;
245   struct _wlan_stats stats;
246 } wlan_hdr_t;
247
248 #define WLANCAP_MAGIC_COOKIE_BASE 0x80211000
249 #define WLANCAP_MAGIC_COOKIE_V1 0x80211001
250 #define WLANCAP_MAGIC_COOKIE_V2 0x80211002
251
252 /* UAT entry structure. */
253 typedef struct {
254   guint8    key;
255   gchar    *string;
256 } uat_wep_key_record_t;
257
258 #define ADV_PROTO_ID_ANQP      0
259 #define ANV_PROTO_ID_MIH_IS    1
260 #define ADV_PROTO_ID_MIH_CESCD 2
261 #define ADV_PROTO_ID_EAS       3
262 #define ADV_PROTO_ID_VS        221
263
264 typedef struct anqp_info_dissector_data {
265   gboolean request;
266   int idx;
267 } anqp_info_dissector_data_t;
268
269 /* WFA vendor specific subtypes */
270 #define WFA_SUBTYPE_SUBSCRIPTION_REMEDIATION   0
271 #define WFA_SUBTYPE_DEAUTHENTICATION_IMMINENT  1
272 #define WFA_SUBTYPE_P2P                        9
273 #define WFA_SUBTYPE_WIFI_DISPLAY               10
274 #define WFA_SUBTYPE_HS20_INDICATION            16
275 #define WFA_SUBTYPE_HS20_ANQP                  17
276 #define WFA_SUBTYPE_OSEN                       18
277 #define WFA_SUBTYPE_DPP                        26
278 #define WFA_SUBTYPE_IEEE1905_MULTI_AP          27 /* ox1B */
279
280 /*
281  * Editor modelines
282  *
283  * Local Variables:
284  * c-basic-offset: 2
285  * tab-width: 8
286  * indent-tabs-mode: nil
287  * End:
288  *
289  * ex: set shiftwidth=2 tabstop=8 expandtab:
290  * :indentSize=2:tabSize=8:noTabs=true:
291  */