33#include <tins/cxxstd.h>
35#include <tins/timestamp.h>
42template<
typename WrappedType,
typename TimestampType>
67template<
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) {}
114 PacketWrapper(
const PacketWrapper&);
115 PacketWrapper& operator=(
const PacketWrapper&);
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()) { }
227 Packet(
Packet &&rhs) TINS_NOEXCEPT : pdu_(rhs.pdu()), ts_(rhs.timestamp()) {
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;
Base class for protocol data units.
Definition pdu.h:107
virtual PDU * clone() const =0
Clones this packet.
Represents a sniffed packet.
Definition packet.h:68
const pdu_type pdu() const
Returns the PDU const reference.
Definition packet.h:94
const Timestamp & timestamp() const
Returns the packet timestamp.
Definition packet.h:104
pdu_type pdu()
Returns the wrapped_type.
Definition packet.h:87
Packet(const PDU &apdu, const Timestamp &tstamp)
Constructs a Packet from a PDU& and a Timestamp.
Definition packet.h:160
Packet(const PDU &rhs)
Constructs a Packet from a const PDU&.
Definition packet.h:182
Packet & operator=(Packet &&rhs) TINS_NOEXCEPT
Definition packet.h:234
Packet(const RefPacket &pck)
Constructs a Packet from a RefPacket.
Definition packet.h:191
PDU * release_pdu()
Releases ownership of the stored PDU*.
Definition packet.h:288
~Packet()
Packet destructor.
Definition packet.h:250
PDU * pdu()
Returns the stored PDU*.
Definition packet.h:266
Packet(PDU *apdu, const Timestamp &tstamp, own_pdu)
Constructs a Packet from a PDU* and a Timestamp.
Definition packet.h:171
Packet(const Packet &rhs)
Copy constructor.
Definition packet.h:205
Packet(const PDU *apdu, const Timestamp &tstamp)
Constructs a Packet from a PDU* and a Timestamp.
Definition packet.h:152
Packet()
Default constructs a Packet.
Definition packet.h:144
Packet(Packet &&rhs) TINS_NOEXCEPT
Definition packet.h:227
const PDU * pdu() const
Returns the stored PDU*.
Definition packet.h:275
Packet & operator/=(const PDU &rhs)
Concatenation operator.
Definition packet.h:311
Packet & operator=(const Packet &rhs)
Copy assignment operator.
Definition packet.h:214
const Timestamp & timestamp() const
Definition packet.h:257
Packet(const PtrPacket &pck)
Constructs a Packet from a PtrPacket object.
Definition packet.h:197
Represents a packet timestamp.
Definition timestamp.h:47
The Tins namespace.
Definition address_range.h:38
PacketWrapper< PDU *, Timestamp > PtrPacket
Thin wrapper over a PDU pointer and a Timestamp.
Definition packet.h:54
PacketWrapper< PDU &, const Timestamp & > RefPacket
Thin wrapper over a PDU and Timestamp reference.
Definition packet.h:49