From 2096c006aa33f1b49f601f8142fee6615fe2e7f0 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 5 Nov 2015 14:55:34 -0800 Subject: Get rid of ws80211_frequency_to_channel(). Use ieee80211_mhz_to_chan() instead. Change-Id: I1d9a3b9c3a5ad2b1a5bd3f8d10b7f8b1bbcba51d Reviewed-on: https://code.wireshark.org/review/11586 Reviewed-by: Guy Harris --- caputils/ws80211_utils.c | 16 ---------------- caputils/ws80211_utils.h | 7 ------- ui/gtk/main_80211_toolbar.c | 6 ++++-- ui/qt/wireless_frame.cpp | 3 ++- wsutil/frequency-utils.h | 8 ++++++++ 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/caputils/ws80211_utils.c b/caputils/ws80211_utils.c index 590edc47d9..2db292bf9d 100644 --- a/caputils/ws80211_utils.c +++ b/caputils/ws80211_utils.c @@ -1188,22 +1188,6 @@ void ws80211_free_interfaces(GArray *interfaces) g_array_free(interfaces, TRUE); } -int ws80211_frequency_to_channel(int freq) -{ - if (freq == 2484) - return 14; - - if (freq < 2484) - return (freq - 2407) / 5; - - /* 4.9 GHz. https://en.wikipedia.org/wiki/List_of_WLAN_channels, fetched - * 2015-06-15 */ - if (freq < 5000) - return freq / 5 - 800; - - return freq / 5 - 1000; -} - /* * Editor modelines - http://www.wireshark.org/tools/modelines.html * diff --git a/caputils/ws80211_utils.h b/caputils/ws80211_utils.h index 4086f50431..da4ed42065 100644 --- a/caputils/ws80211_utils.h +++ b/caputils/ws80211_utils.h @@ -87,13 +87,6 @@ int ws80211_get_iface_info(const char *name, struct ws80211_iface_info *iface_in */ void ws80211_free_interfaces(GArray *interfaces); -/** Convert a frequency to a channel number - * - * @param freq Frequency in MHz. - * @return The 802.11 channel number matching the provided frequency. - */ -int ws80211_frequency_to_channel(int freq); - /** Set the frequency and channel width for an interface. * * @param name The interface name. diff --git a/ui/gtk/main_80211_toolbar.c b/ui/gtk/main_80211_toolbar.c index 48ead08fa8..d1b58ea768 100644 --- a/ui/gtk/main_80211_toolbar.c +++ b/ui/gtk/main_80211_toolbar.c @@ -43,6 +43,8 @@ #include #include +#include + static GtkWidget *tb80211_tb, *tb80211_iface_list_box, *tb80211_freq_list_box, *tb80211_chan_type_box, *tb80211_info_label; static GArray *tb80211_interfaces; @@ -123,7 +125,7 @@ void tb80211_update_freq(void) for (i = 0; i < tb80211_freq_cnt; i++) { int freq; freq = g_array_index(tb80211_current_iface->frequencies, int, i); - str = g_strdup_printf("%d MHz (%d)", freq, ws80211_frequency_to_channel(freq)); + str = g_strdup_printf("%d MHz (%d)", freq, ieee80211_mhz_to_chan(freq)); gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(tb80211_freq_list_box), str); g_free(str); @@ -216,7 +218,7 @@ tb80211_set_channel(void) } } else { - info = g_strdup_printf("%s Switched to %d MHz (%d)", tb80211_current_iface->ifname, new_freq, ws80211_frequency_to_channel(new_freq)); + info = g_strdup_printf("%s Switched to %d MHz (%d)", tb80211_current_iface->ifname, new_freq, ieee80211_mhz_to_chan(new_freq)); tb80211_current_freq = new_freq; tb80211_current_type = new_type; } diff --git a/ui/qt/wireless_frame.cpp b/ui/qt/wireless_frame.cpp index 6140e7417a..4ba38f363e 100644 --- a/ui/qt/wireless_frame.cpp +++ b/ui/qt/wireless_frame.cpp @@ -33,6 +33,7 @@ #include #include +#include #include @@ -208,7 +209,7 @@ void WirelessFrame::getInterfaceInfo() guint32 frequency = g_array_index(iface->frequencies, guint32, i); double ghz = frequency / 1000.0; QString chan_str = QString("%1 " UTF8_MIDDLE_DOT " %2%3") - .arg(ws80211_frequency_to_channel(frequency)) + .arg(ieee80211_mhz_to_chan(frequency)) .arg(ghz, 0, 'f', 3) .arg(units); ui->channelComboBox->addItem(chan_str, frequency); diff --git a/wsutil/frequency-utils.h b/wsutil/frequency-utils.h index 10603e06d7..9370a60c82 100644 --- a/wsutil/frequency-utils.h +++ b/wsutil/frequency-utils.h @@ -25,6 +25,10 @@ #include "ws_symbol_export.h" +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + /** @file * Frequency and channel conversion utilities. */ @@ -60,6 +64,10 @@ ieee80211_mhz_to_str(guint freq); /* Should this be "(freq < 4920)", or something else? */ #define FREQ_IS_BG(freq) (freq <= 2484) +#ifdef __cplusplus +} +#endif /* __cplusplus */ + #endif /* __FREQUENCY_UTILS_H__ */ /* -- cgit v1.2.1