mirror of
https://github.com/mfontanini/libtins
synced 2026-01-30 05:24:26 +01:00
Move frequency (channel) utils into their own file
This commit is contained in:
@@ -73,6 +73,7 @@ set(SOURCES
|
||||
dot11/dot11_probe.cpp
|
||||
dot11/dot11_control.cpp
|
||||
utils/checksum_utils.cpp
|
||||
utils/frequency_utils.cpp
|
||||
)
|
||||
|
||||
SET(PCAP_DEPENDENT_SOURCES
|
||||
|
||||
@@ -44,11 +44,11 @@
|
||||
#include <net/ethernet.h>
|
||||
#endif
|
||||
#include "dot11/dot11_base.h"
|
||||
#include "utils.h"
|
||||
#include "packet_sender.h"
|
||||
#include "exceptions.h"
|
||||
#include "memory_helpers.h"
|
||||
#include "utils/checksum_utils.h"
|
||||
#include "utils/frequency_utils.h"
|
||||
|
||||
using std::memcpy;
|
||||
|
||||
|
||||
@@ -524,14 +524,6 @@ set<string> network_interfaces() {
|
||||
return output;
|
||||
}
|
||||
#endif // _WIN32
|
||||
|
||||
uint16_t channel_to_mhz(uint16_t channel) {
|
||||
return 2407 + (channel * 5);
|
||||
}
|
||||
|
||||
uint16_t mhz_to_channel(uint16_t mhz) {
|
||||
return (mhz - 2407) / 5;
|
||||
}
|
||||
|
||||
string to_string(PDU::PDUType pduType) {
|
||||
#define ENUM_TEXT(p) case(PDU::p): return #p;
|
||||
|
||||
44
src/utils/frequency_utils.cpp
Normal file
44
src/utils/frequency_utils.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Matias Fontanini
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils/frequency_utils.h"
|
||||
|
||||
namespace Tins {
|
||||
namespace Utils {
|
||||
|
||||
uint16_t channel_to_mhz(uint16_t channel) {
|
||||
return 2407 + (channel * 5);
|
||||
}
|
||||
|
||||
uint16_t mhz_to_channel(uint16_t mhz) {
|
||||
return (mhz - 2407) / 5;
|
||||
}
|
||||
|
||||
} // Utils
|
||||
} // Tins
|
||||
Reference in New Issue
Block a user