3 * Copyright 2012, Pontus Fuchs <pontus.fuchs@gmail.com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #ifndef __WS80211_UTILS_H__
13 #define __WS80211_UTILS_H__
15 #include <wireshark.h>
19 #endif /* __cplusplus */
21 enum ws80211_channel_type
{
24 WS80211_CHAN_HT40MINUS
,
25 WS80211_CHAN_HT40PLUS
,
27 WS80211_CHAN_VHT80P80
,
31 #define CHAN_NO_HT "NOHT"
32 #define CHAN_HT20 "HT20"
33 #define CHAN_HT40MINUS "HT40-"
34 #define CHAN_HT40PLUS "HT40+"
35 #define CHAN_VHT80 "VHT80"
36 #define CHAN_VHT80P80 "VHT80+80"
37 #define CHAN_VHT160 "VHT160"
39 enum ws80211_fcs_validation
{
45 struct ws80211_interface
50 GArray
*frequencies
; /* Array of uint32_t? */
51 int channel_types
; /* Union for all bands */
55 struct ws80211_iface_info
{
57 enum ws80211_channel_type current_chan_type
;
58 int current_center_freq1
;
59 int current_center_freq2
;
60 enum ws80211_fcs_validation current_fcs_validation
;
63 /** Initialize the 802.11 environment.
64 * On Linux this initializes an nl80211_state struct.
66 * @return WS80211_INIT_OK on success, WS80211_INIT_NOT_SUPPORTED if the
67 * 802.11 environment isn't supported, or the negative of an errno value
70 #define WS80211_INIT_OK 0
71 #define WS80211_INIT_NOT_SUPPORTED 1
73 int ws80211_init(void);
75 /** Build a list of 802.11 interfaces.
77 * @return A GArray of pointers to struct ws80211_interface on success, NULL on failure.
79 /* XXX Should we make this an array of structs instead of an array of struct pointers?
80 * It'd save a bit of mallocing and freeing. */
81 GArray
* ws80211_find_interfaces(void);
83 int ws80211_get_iface_info(const char *name
, struct ws80211_iface_info
*iface_info
);
85 /** Free an interface list.
87 * @param interfaces A list of interfaces created with ws80211_find_interfaces().
89 void ws80211_free_interfaces(GArray
*interfaces
);
91 /** Set the frequency and channel width for an interface.
93 * @param name The interface name.
94 * @param freq The frequency in MHz.
95 * @param chan_type The HT channel type (no, 20Mhz, 40Mhz...).
96 * @param center_freq The center frequency in MHz (if 80MHz, 80+80MHz or 160MHz).
97 * @param center_freq2 The 2nd center frequency in MHz (if 80+80MHz).
98 * @return Zero on success, nonzero on failure.
100 int ws80211_set_freq(const char *name
, uint32_t freq
, int chan_type
, uint32_t _U_ center_freq
, uint32_t _U_ center_freq2
);
102 int ws80211_str_to_chan_type(const char *s
);
103 const char *ws80211_chan_type_to_str(int type
);
105 /** Check to see if we have FCS filtering.
107 * @return true if FCS filtering is supported on this platform.
109 bool ws80211_has_fcs_filter(void);
111 /** Set the FCS validation behavior for an interface.
113 * @param name The interface name.
114 * @param fcs_validation The desired validation behavior.
115 * @return Zero on success, nonzero on failure.
117 int ws80211_set_fcs_validation(const char *name
, enum ws80211_fcs_validation fcs_validation
);
120 /** Get the path to a helper application.
121 * Return the path to a separate 802.11 helper application, e.g.
122 * the GNOME Network Manager.
124 * @return The path to the helper on success, NULL on failure.
126 const char *ws80211_get_helper_path(void);
130 #endif /* __cplusplus */
132 #endif /* __WS80211_UTILS_H__ */