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

Remove useless includes

This commit is contained in:
Matias Fontanini
2017-05-13 10:43:29 -07:00
parent c6f4e816aa
commit a5766a19c2
25 changed files with 53 additions and 74 deletions

View File

@@ -919,52 +919,6 @@ private:
options_type options_;
};
namespace Internals {
template<typename InputIterator>
void class_option_data2option(InputIterator start,
InputIterator end,
std::vector<uint8_t>& buffer,
size_t start_index = 0) {
size_t index = start_index;
uint16_t uint16_t_buffer;
while (start != end) {
buffer.resize(buffer.size() + sizeof(uint16_t) + start->size());
uint16_t_buffer = Endian::host_to_be(static_cast<uint16_t>(start->size()));
std::memcpy(&buffer[index], &uint16_t_buffer, sizeof(uint16_t));
index += sizeof(uint16_t);
std::copy(start->begin(), start->end(), buffer.begin() + index);
index += start->size();
start++;
}
}
template<typename OutputType>
OutputType option2class_option_data(const uint8_t* ptr, uint32_t total_sz) {
typedef typename OutputType::value_type value_type;
OutputType output;
size_t index = 0;
while (index + 2 < total_sz) {
uint16_t size;
std::memcpy(&size, ptr + index, sizeof(uint16_t));
size = Endian::be_to_host(size);
index += sizeof(uint16_t);
if (index + size > total_sz) {
throw option_not_found();
}
output.push_back(
value_type(ptr + index, ptr + index + size)
);
index += size;
}
if (index != total_sz) {
throw malformed_option();
}
return output;
}
} // Internals
} // Tins
#endif // TINS_DHCPV6_H

View File

@@ -30,7 +30,6 @@
#ifndef TINS_SNAP_H
#define TINS_SNAP_H
#include <stdint.h>
#include "pdu.h"
#include "macros.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "bootp.h"
#include "exceptions.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "endianness.h"
#include "dhcp.h"

View File

@@ -42,6 +42,55 @@ using Tins::Memory::OutputMemoryStream;
namespace Tins {
namespace Internals {
template<typename InputIterator>
void class_option_data2option(InputIterator start,
InputIterator end,
vector<uint8_t>& buffer,
size_t start_index = 0) {
size_t index = start_index;
uint16_t uint16_t_buffer;
while (start != end) {
buffer.resize(buffer.size() + sizeof(uint16_t) + start->size());
uint16_t_buffer = Endian::host_to_be(static_cast<uint16_t>(start->size()));
memcpy(&buffer[index], &uint16_t_buffer, sizeof(uint16_t));
index += sizeof(uint16_t);
if (!start->empty()) {
memcpy(&*buffer.begin() + index, &*start->begin(), start->size());
}
index += start->size();
start++;
}
}
template<typename OutputType>
OutputType option2class_option_data(const uint8_t* ptr, uint32_t total_sz) {
typedef typename OutputType::value_type value_type;
OutputType output;
size_t index = 0;
while (index + 2 < total_sz) {
uint16_t size;
memcpy(&size, ptr + index, sizeof(uint16_t));
size = Endian::be_to_host(size);
index += sizeof(uint16_t);
if (index + size > total_sz) {
throw option_not_found();
}
output.push_back(
value_type(ptr + index, ptr + index + size)
);
index += size;
}
if (index != total_sz) {
throw malformed_option();
}
return output;
}
} // Internals
PDU::metadata DHCPv6::extract_metadata(const uint8_t* /*buffer*/, uint32_t total_sz) {
if (TINS_UNLIKELY(total_sz < 2)) {
throw malformed_packet();

View File

@@ -28,9 +28,6 @@
*/
#include <utility>
#include <stdexcept>
#include <sstream>
#include <memory>
#include <cstdio>
#include "dns.h"
#include "ip_address.h"
@@ -40,7 +37,6 @@
#include "memory_helpers.h"
using std::string;
using std::copy;
using std::memcpy;
using std::list;
using std::make_pair;
@@ -372,7 +368,7 @@ uint32_t DNS::compose_name(const uint8_t* ptr, char* out_ptr) const {
if (current_out_ptr != out_ptr) {
*current_out_ptr++ = '.';
}
copy(ptr, ptr + size, current_out_ptr);
memcpy(current_out_ptr, ptr, size);
current_out_ptr += size;
ptr += size;
}

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "dot1q.h"
#include "exceptions.h"

View File

@@ -28,7 +28,6 @@
*/
#include <cstring>
#include <stdexcept>
#include "macros.h"
#ifndef _WIN32
#if defined(BSD) || defined(__FreeBSD_kernel__)

View File

@@ -28,7 +28,6 @@
*/
#include <cstring>
#include <stdexcept>
#include "eapol.h"
#include "exceptions.h"
#include "rawpdu.h"

View File

@@ -29,9 +29,9 @@
#include <sstream>
#include <iomanip>
#include <stdexcept>
#include <algorithm>
#include "hw_address.h"
#include "exceptions.h"
using std::string;
using std::ostream;

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#ifndef _WIN32
#include <netinet/in.h>

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#ifndef _WIN32
#include <netdb.h>

View File

@@ -37,7 +37,6 @@
// std::hash
#include <memory>
#endif // TINS_IS_CXX11
#include <stdexcept>
#include <sstream>
#include <iostream>
#include "ip_address.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "llc.h"
#include "stp.h"

View File

@@ -37,7 +37,6 @@
#else
#include <ws2tcpip.h>
#endif
#include <stdexcept>
#include <cstring>
#include "loopback.h"
#include "packet_sender.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <string.h>
#include "offline_packet_filter.h"
#include "pdu.h"

View File

@@ -30,7 +30,6 @@
#ifndef _WIN32
#include <sys/time.h>
#endif
#include <stdexcept>
#include <string.h>
#include "packet_writer.h"
#include "packet.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "exceptions.h"
#include "pktap.h"

View File

@@ -32,7 +32,6 @@
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include <stdexcept>
#include "macros.h"
#ifndef _WIN32
#if defined(BSD) || defined(__FreeBSD_kernel__)

View File

@@ -31,7 +31,6 @@
#ifdef TINS_HAVE_DOT11
#include <cstring>
#include <stdexcept>
#include "exceptions.h"
#include "pdu.h"
#include "pdu_option.h"

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "sll.h"
#include "exceptions.h"

View File

@@ -28,7 +28,6 @@
*/
#include <cstring>
#include <stdexcept>
#ifndef _WIN32
#include <sys/types.h>
#include <net/ethernet.h>

View File

@@ -27,7 +27,6 @@
*
*/
#include <stdexcept>
#include <cstring>
#include "udp.h"
#include "constants.h"

View File

@@ -48,7 +48,7 @@
#include <iphlpapi.h>
#undef interface
#endif
#include <stdexcept>
#include "exceptions.h"
#include "ip_address.h"
#include "ipv6_address.h"
#include "hw_address.h"

View File

@@ -55,7 +55,6 @@
#endif
#include <set>
#include <fstream>
#include <stdexcept>
#include "network_interface.h"
#include "exceptions.h"