Wireshark  4.3.0
The Wireshark network protocol analyzer
802_11-utils.h
Go to the documentation of this file.
1 /* 802_11-utils.h
2  * 802.11 utility definitions
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 2007 Gerald Combs
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef __802_11_UTILS_H__
12 #define __802_11_UTILS_H__
13 
14 #include <wireshark.h>
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
19 
29 WS_DLL_PUBLIC
30 int
31 ieee80211_mhz_to_chan(unsigned freq);
32 
39 WS_DLL_PUBLIC
40 unsigned
41 ieee80211_chan_to_mhz(int chan, bool is_bg);
42 
50 WS_DLL_PUBLIC
51 char*
52 ieee80211_mhz_to_str(unsigned freq);
53 
54 /* Should this be "(freq < 4920)", or something else? */
55 #define FREQ_IS_BG(freq) ((freq) <= 2484)
56 #define CHAN_IS_BG(chan) ((chan) <= 14)
57 
58 #define FREQ_IS_6G(freq) (5950 <= (freq) && (freq) <= 7125)
59 
60 /*
61  * Test whether a data rate is an {HR}/DSSS (legacy DSSS/11b) data rate
62  * and whether it's an OFDM (11a/11g OFDM mode) data rate.
63  *
64  * rate is in units of 500 Kb/s.
65  *
66  * The 22 and 33 Mb/s rates for DSSS use Packet Binary Convolutional
67  * Coding (PBCC). That was provided by Texas Instruments as 11b+,
68  * and was in section 19.6 "ERP-PBCC operation specifications" of
69  * IEEE Std 802.11g-2003, and sections 18.4.6.6 "DSSS/PBCC data modulation
70  * and modulation rate (optional)" and 19.6 "ERP-PBCC operation
71  * specifications" of IEEE Std 802.11-2007, and sections 17.4.6.7 "DSSS/PBCC
72  * data modulation and modulation rate (optional)" and 19.6 "ERP-PBCC
73  * operation specifications" of IEEE Std 802.11-2012, marked as optional
74  * in both cases, but is not present in IEEE Std 802.11-2016.
75  *
76  * (Note: not to be confused with "peanut butter and chocolate chips":
77  *
78  * https://www.bigoven.com/recipe/peanut-butter-chocolate-chip-cookies-pbcc-cookies/186266
79  *
80  * :-))
81  */
82 #define RATE_IS_DSSS(rate) \
83  ((rate) == 2 /* 1 Mb/s */ || \
84  (rate) == 4 /* 2 Mb/s */ || \
85  (rate) == 11 /* 5.5 Mb/s */ || \
86  (rate) == 22 /* 11 Mb/s */ || \
87  (rate) == 44 /* 22 Mb/s */ || \
88  (rate) == 66 /* 33 Mb/s */)
89 
90 #define RATE_IS_OFDM(rate) \
91  ((rate) == 12 /* 6 Mb/s */ || \
92  (rate) == 18 /* 9 Mb/s */ || \
93  (rate) == 24 /* 12 Mb/s */ || \
94  (rate) == 36 /* 18 Mb/s */ || \
95  (rate) == 48 /* 24 Mb/s */ || \
96  (rate) == 72 /* 36 Mb/s */ || \
97  (rate) == 96 /* 48 Mb/s */ || \
98  (rate) == 108 /* 54 Mb/s */)
99 
100 #ifdef __cplusplus
101 }
102 #endif /* __cplusplus */
103 
104 #endif /* __802_11_UTILS_H__ */
105 
106 /*
107  * Editor modelines
108  *
109  * Local Variables:
110  * c-basic-offset: 4
111  * tab-width: 8
112  * indent-tabs-mode: nil
113  * End:
114  *
115  * vi: set shiftwidth=4 tabstop=8 expandtab:
116  * :indentSize=4:tabSize=8:noTabs=true:
117  */
WS_DLL_PUBLIC char * ieee80211_mhz_to_str(unsigned freq)
Definition: 802_11-utils.c:90
WS_DLL_PUBLIC int ieee80211_mhz_to_chan(unsigned freq)
Definition: 802_11-utils.c:51
WS_DLL_PUBLIC unsigned ieee80211_chan_to_mhz(int chan, bool is_bg)
Definition: 802_11-utils.c:74