1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-30 13:34:27 +01:00

Added concat operator to Packet and an overload that takes a PDU*.

This commit is contained in:
Matias Fontanini
2012-12-05 17:04:39 -03:00
parent 765285c6ee
commit 75b32c75bc
6 changed files with 95 additions and 11 deletions

View File

@@ -130,8 +130,19 @@ public:
*
* The PDU* is cloned using PDU::clone.
*/
Packet(PDU *apdu, const Timestamp &tstamp)
: pdu_(apdu->clone()), ts(tstamp) {}
Packet(const PDU *apdu, const Timestamp &tstamp)
: pdu_(apdu->clone()), ts(tstamp) { }
/**
* \brief Constructs a Packet from a const PDU&.
*
* The timestamp will be set to the current time.
*
* This calls PDU::clone on the PDU parameter.
*
*/
Packet(const PDU &rhs)
: pdu_(rhs.clone()), ts(Timestamp::current_time()) { }
/**
* \brief Constructs a Packet from a RefPacket.
@@ -248,6 +259,19 @@ public:
operator bool() const {
return bool(pdu_);
}
/**
*
* \brief Concatenation operator.
*
* Adds the PDU at the end of the PDU stack.
*
* \param rhs The PDU to be appended.
*/
Packet &operator/=(const PDU &rhs) {
pdu_ /= rhs;
return *this;
}
private:
PDU *pdu_;
Timestamp ts;