MCPcopy Create free account
hub / github.com/attermann/microReticulum / Packet

Method Packet

src/microReticulum/Packet.cpp:40–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38// ============================================================================
39
40Packet::Packet(const Destination& destination, const Bytes& data) :
41 _object(new Object(destination, {Type::NONE}))
42{
43 if (_object->_destination) {
44 // Defaults are applied via Object's in-class member initializers
45 // (HEADER_1, DATA, CONTEXT_NONE, BROADCAST, FLAG_UNSET).
46 _object->_data = data;
47 if (_object->_data.size() > MDU) {
48 _object->_truncated = true;
49 _object->_data.resize(MDU);
50 }
51 _object->_flags = get_packed_flags();
52 _object->_create_receipt = true;
53 }
54 else {
55 // Fallback: empty destination means treat data as a raw inbound
56 // buffer. Preserved from the legacy constructor's behaviour for
57 // out-of-tree callers that may rely on this path.
58 _object->_raw = data;
59 _object->_packed = true;
60 _object->_fromPacked = true;
61 _object->_create_receipt = false;
62 }
63 MEMF("Packet object created, this: %p, data: %p", (void*)this, (void*)_object.get());
64}
65
66Packet::Packet(const Link& link, const Bytes& data) :
67 // CBA Must use a destination that targets the Link itself instead of the

Callers 1

mainFunction · 0.45

Calls 13

packet_typeMethod · 0.95
resizeMethod · 0.80
getMethod · 0.80
hashMethod · 0.80
context_flagMethod · 0.80
create_receiptMethod · 0.80
header_typeMethod · 0.80
transport_typeMethod · 0.80
contextMethod · 0.80
attached_interfaceMethod · 0.80
DestinationClass · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected