mirror of
https://github.com/mfontanini/libtins
synced 2026-01-27 20:24:26 +01:00
Remove useless includes
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user