1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Move PDU utils into their own file

This commit is contained in:
Matias Fontanini
2017-04-30 13:29:33 -07:00
parent 1c2c5d7dd4
commit 39e9f0542d
6 changed files with 90 additions and 107 deletions

View File

@@ -30,30 +30,14 @@
#ifndef TINS_UTILS_H
#define TINS_UTILS_H
#include "macros.h"
#include <string>
#include <stdint.h>
#include "ip_address.h"
#include "ipv6_address.h"
#include "pdu.h"
#include "detail/type_traits.h"
#include "utils/checksum_utils.h"
#include "utils/frequency_utils.h"
#include "utils/routing_utils.h"
#include "utils/resolve_utils.h"
// Fix for Windows interface define on combaseapi.h
#undef interface
#include "utils/pdu_utils.h"
namespace Tins {
class NetworkInterface;
class PacketSender;
class PDU;
class IPv6Address;
template <size_t n>
class HWAddress;
/**
* \brief Network utils namespace.
*
@@ -63,45 +47,6 @@ class HWAddress;
*/
namespace Utils {
/**
* \brief Converts a PDUType to a string.
* \param pduType The PDUType to be converted.
* \return A string representation, for example "DOT11_QOS_DATA".
*/
TINS_API std::string to_string(PDU::PDUType pduType);
template <typename T>
struct is_pdu {
template <typename U>
static char test(typename U::PDUType*);
template <typename U>
static long test(...);
static const bool value = sizeof(test<T>(0)) == 1;
};
/**
* Returns the argument.
*/
inline PDU& dereference_until_pdu(PDU& pdu) {
return pdu;
}
/**
* \brief Dereferences the parameter until a PDU is found.
*
* This function dereferences the parameter until a PDU object
* is found. When it's found, it is returned.
*
* \param value The parameter to be dereferenced.
*/
template<typename T>
inline typename Internals::enable_if<!is_pdu<T>::value, PDU&>::type
dereference_until_pdu(T& value) {
return dereference_until_pdu(*value);
}
} // Utils
} // Tins