1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-26 12:01:34 +01:00

Add OutputMemoryStream and port most classes to use it

This commit is contained in:
Matias Fontanini
2015-12-26 06:30:00 -08:00
parent 9750f46c6d
commit 02e2b278de
34 changed files with 438 additions and 418 deletions

View File

@@ -35,6 +35,7 @@
#include "memory_helpers.h"
using Tins::Memory::InputMemoryStream;
using Tins::Memory::OutputMemoryStream;
namespace Tins {
@@ -81,12 +82,14 @@ uint32_t SLL::header_size() const {
}
void SLL::write_serialization(uint8_t *buffer, uint32_t total_sz, const PDU *) {
if(inner_pdu()) {
OutputMemoryStream stream(buffer, total_sz);
if (inner_pdu()) {
Constants::Ethernet::e flag = Internals::pdu_flag_to_ether_type(
inner_pdu()->pdu_type()
);
protocol(static_cast<uint16_t>(flag));
}
std::memcpy(buffer, &_header, sizeof(_header));
}
stream.write(_header);
}
} // Tins