diff --git a/include/tins/internals.h b/include/tins/internals.h index 38c75ca..f2d30f2 100644 --- a/include/tins/internals.h +++ b/include/tins/internals.h @@ -52,57 +52,6 @@ class ICMPExtensionsStructure; namespace Internals { -template -class byte_array { -public: - typedef uint8_t* iterator; - typedef const uint8_t* const_iterator; - - byte_array() { - std::fill(begin(), end(), 0); - } - - template - byte_array(InputIterator start, InputIterator last) { - std::copy(start, last, data); - } - - template - byte_array(InputIterator start) { - std::copy(start, n, data); - } - - uint8_t& operator[](size_t i) { - return data[i]; - } - - uint8_t operator[](size_t i) const{ - return data[i]; - } - - iterator begin() { - return data; - } - - iterator end() { - return data + n; - } - - const_iterator begin() const { - return data; - } - - const_iterator end() const { - return data + n; - } - - size_t size() const { - return n; - } -private: - uint8_t data[n]; -}; - void skip_line(std::istream& input); bool from_hex(const std::string& str, uint32_t& result); bool from_hex(const std::string& str, std::string& result); diff --git a/src/crypto.cpp b/src/crypto.cpp index 9ffd2c1..4bf3071 100644 --- a/src/crypto.cpp +++ b/src/crypto.cpp @@ -38,8 +38,8 @@ #endif // TINS_HAVE_WPA2_DECRYPTION #include "dot11/dot11_data.h" #include "dot11/dot11_beacon.h" -#include "internals.h" #include "exceptions.h" +#include "detail/type_traits.h" using std::string; using std::make_pair; @@ -52,6 +52,51 @@ using std::fill; using std::runtime_error; namespace Tins { +namespace Internals { + +template +class byte_array { +public: + typedef uint8_t* iterator; + typedef const uint8_t* const_iterator; + + byte_array() { + std::memset(data, 0, size()); + } + + uint8_t& operator[](size_t i) { + return data[i]; + } + + uint8_t operator[](size_t i) const{ + return data[i]; + } + + iterator begin() { + return data; + } + + iterator end() { + return data + n; + } + + const_iterator begin() const { + return data; + } + + const_iterator end() const { + return data + n; + } + + size_t size() const { + return n; + } +private: + uint8_t data[n]; +}; + +} // Internals + namespace Crypto { WEPDecrypter::WEPDecrypter()