| 38 | // ============================================================================ |
| 39 | |
| 40 | Packet::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 | |
| 66 | Packet::Packet(const Link& link, const Bytes& data) : |
| 67 | // CBA Must use a destination that targets the Link itself instead of the |
no test coverage detected