TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags
[wireshark-sm.git] / wsutil / 802_11-utils.h
blob5c496da208014c906467c1de097cf5ab77b4485d
1 /* 802_11-utils.h
2 * 802.11 utility definitions
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 2007 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #ifndef __802_11_UTILS_H__
12 #define __802_11_UTILS_H__
14 #include <wireshark.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif /* __cplusplus */
20 /** @file
21 * 802.11 utilities.
24 /**
25 * Given a center frequency in MHz, return a channel number.
26 * @param freq Frequency in MHz.
27 * @return The equivalent channel or -1 if no match is found.
29 WS_DLL_PUBLIC
30 int
31 ieee80211_mhz_to_chan(unsigned freq);
33 /**
34 * Given an 802.11 channel number and a band type, return a center frequency.
35 * @param chan Channel number
36 * @param is_bg true if the channel is a b/g channel, false otherwise.
37 * @return The equivalent frequency or 0 if no match is found.
39 WS_DLL_PUBLIC
40 unsigned
41 ieee80211_chan_to_mhz(int chan, bool is_bg);
43 /**
44 * Given an 802.11 channel center frequency in MHz, return a string
45 * representation.
46 * @param freq Frequench in MHz.
47 * @return A string showing the frequency, channel number, and type.
48 * The string must be freed with g_free() after use.
50 WS_DLL_PUBLIC
51 char*
52 ieee80211_mhz_to_str(unsigned freq);
55 * Get Frequency given a Channel number and band.
57 WS_DLL_PUBLIC
58 unsigned
59 ieee80211_chan_band_to_mhz(int chan, bool is_bg, bool is_6ghz);
61 /* Should this be "(freq < 4920)", or something else? */
62 #define FREQ_IS_BG(freq) ((freq) <= 2484)
63 #define CHAN_IS_BG(chan) ((chan) <= 14)
65 #define FREQ_IS_6G(freq) (5950 <= (freq) && (freq) <= 7125)
68 * Test whether a data rate is an {HR}/DSSS (legacy DSSS/11b) data rate
69 * and whether it's an OFDM (11a/11g OFDM mode) data rate.
71 * rate is in units of 500 Kb/s.
73 * The 22 and 33 Mb/s rates for DSSS use Packet Binary Convolutional
74 * Coding (PBCC). That was provided by Texas Instruments as 11b+,
75 * and was in section 19.6 "ERP-PBCC operation specifications" of
76 * IEEE Std 802.11g-2003, and sections 18.4.6.6 "DSSS/PBCC data modulation
77 * and modulation rate (optional)" and 19.6 "ERP-PBCC operation
78 * specifications" of IEEE Std 802.11-2007, and sections 17.4.6.7 "DSSS/PBCC
79 * data modulation and modulation rate (optional)" and 19.6 "ERP-PBCC
80 * operation specifications" of IEEE Std 802.11-2012, marked as optional
81 * in both cases, but is not present in IEEE Std 802.11-2016.
83 * (Note: not to be confused with "peanut butter and chocolate chips":
85 * https://www.bigoven.com/recipe/peanut-butter-chocolate-chip-cookies-pbcc-cookies/186266
87 * :-))
89 #define RATE_IS_DSSS(rate) \
90 ((rate) == 2 /* 1 Mb/s */ || \
91 (rate) == 4 /* 2 Mb/s */ || \
92 (rate) == 11 /* 5.5 Mb/s */ || \
93 (rate) == 22 /* 11 Mb/s */ || \
94 (rate) == 44 /* 22 Mb/s */ || \
95 (rate) == 66 /* 33 Mb/s */)
97 #define RATE_IS_OFDM(rate) \
98 ((rate) == 12 /* 6 Mb/s */ || \
99 (rate) == 18 /* 9 Mb/s */ || \
100 (rate) == 24 /* 12 Mb/s */ || \
101 (rate) == 36 /* 18 Mb/s */ || \
102 (rate) == 48 /* 24 Mb/s */ || \
103 (rate) == 72 /* 36 Mb/s */ || \
104 (rate) == 96 /* 48 Mb/s */ || \
105 (rate) == 108 /* 54 Mb/s */)
107 #ifdef __cplusplus
109 #endif /* __cplusplus */
111 #endif /* __802_11_UTILS_H__ */
114 * Editor modelines
116 * Local Variables:
117 * c-basic-offset: 4
118 * tab-width: 8
119 * indent-tabs-mode: nil
120 * End:
122 * vi: set shiftwidth=4 tabstop=8 expandtab:
123 * :indentSize=4:tabSize=8:noTabs=true: