33 #include <tins/cxxstd.h> 35 #include <tins/timestamp.h> 42 template<
typename WrappedType,
typename TimestampType>
67 template<
typename PDUType,
typename TimestampType>
70 typedef PDUType pdu_type;
71 typedef TimestampType timestamp_type;
94 const pdu_type
pdu()
const {
108 friend class BaseSniffer;
109 friend class SnifferIterator;
112 : pdu_(pdu), ts_(ts) {}
116 void*
operator new (
size_t size);
117 void operator delete (
void* p);
153 : pdu_(apdu->clone()), ts_(tstamp) { }
161 : pdu_(apdu.clone()), ts_(tstamp) { }
172 : pdu_(apdu), ts_(tstamp) { }
183 : pdu_(rhs.clone()), ts_(
Timestamp::current_time()) { }
236 PDU* tmp = std::move(pdu_);
237 pdu_ = std::move(rhs.pdu_);
238 rhs.pdu_ = std::move(tmp);
239 ts_ = rhs.timestamp();
289 PDU* some_pdu = pdu_;
299 operator bool()
const {
300 return pdu_ ?
true :
false;
321 #endif // TINS_PACKET_H PDU * release_pdu()
Releases ownership of the stored PDU*.
Definition: packet.h:288
~Packet()
Packet destructor.
Definition: packet.h:250
Packet & operator=(Packet &&rhs) TINS_NOEXCEPT
Definition: packet.h:234
Packet & operator/=(const PDU &rhs)
Concatenation operator.
Definition: packet.h:311
PDU * pdu()
Returns the stored PDU*.
Definition: packet.h:266
Packet(Packet &&rhs) TINS_NOEXCEPT
Definition: packet.h:227
const PDU * pdu() const
Returns the stored PDU*.
Definition: packet.h:275
Packet & operator=(const Packet &rhs)
Copy assignment operator.
Definition: packet.h:214
const Timestamp & timestamp() const
Returns the packet timestamp.
Definition: packet.h:104
const Timestamp & timestamp() const
Definition: packet.h:257
Packet(PDU *apdu, const Timestamp &tstamp, own_pdu)
Constructs a Packet from a PDU* and a Timestamp.
Definition: packet.h:171
Packet(const PDU &rhs)
Constructs a Packet from a const PDU&.
Definition: packet.h:182
Packet(const RefPacket &pck)
Constructs a Packet from a RefPacket.
Definition: packet.h:191
Packet()
Default constructs a Packet.
Definition: packet.h:144
pdu_type pdu()
Returns the wrapped_type.
Definition: packet.h:87
The Tins namespace.
Definition: address_range.h:38
Packet(const Packet &rhs)
Copy constructor.
Definition: packet.h:205
Represents a packet timestamp.
Definition: timestamp.h:47
PacketWrapper< PDU *, Timestamp > PtrPacket
Thin wrapper over a PDU pointer and a Timestamp.
Definition: packet.h:54
Packet(const PDU *apdu, const Timestamp &tstamp)
Constructs a Packet from a PDU* and a Timestamp.
Definition: packet.h:152
virtual PDU * clone() const =0
Clones this packet.
const pdu_type pdu() const
Returns the PDU const reference.
Definition: packet.h:94
Packet(const PDU &apdu, const Timestamp &tstamp)
Constructs a Packet from a PDU& and a Timestamp.
Definition: packet.h:160
Base class for protocol data units.
Definition: pdu.h:107
PacketWrapper< PDU &, const Timestamp & > RefPacket
Thin wrapper over a PDU and Timestamp reference.
Definition: packet.h:43
Packet(const PtrPacket &pck)
Constructs a Packet from a PtrPacket object.
Definition: packet.h:197
Represents a sniffed packet.
Definition: packet.h:43