diff --git a/src/internet/model/ipv4-queue-disc-item.cc b/src/internet/model/ipv4-queue-disc-item.cc index 5cc21428e..672c338ea 100644 --- a/src/internet/model/ipv4-queue-disc-item.cc +++ b/src/internet/model/ipv4-queue-disc-item.cc @@ -79,4 +79,20 @@ Ipv4QueueDiscItem::Print (std::ostream& os) const ; } +bool +Ipv4QueueDiscItem::GetUint8Value (QueueItem::Uint8Values field, uint8_t& value) const +{ + bool ret = false; + + switch (field) + { + case IP_DSFIELD: + value = m_header.GetTos (); + ret = true; + break; + } + + return ret; +} + } // namespace ns3 diff --git a/src/internet/model/ipv4-queue-disc-item.h b/src/internet/model/ipv4-queue-disc-item.h index 8e4dfb105..a780083db 100644 --- a/src/internet/model/ipv4-queue-disc-item.h +++ b/src/internet/model/ipv4-queue-disc-item.h @@ -70,6 +70,15 @@ public: */ virtual void Print (std::ostream &os) const; + /* + * The values for the fields of the Ipv4 header are taken from m_header and + * thus might differ from those present in the packet in case the header is + * modified after being added to the packet. However, this function is likely + * to be called before the header is added to the packet (i.e., before the + * packet is dequeued from the queue disc) + */ + virtual bool GetUint8Value (Uint8Values field, uint8_t &value) const; + private: /** * \brief Default constructor diff --git a/src/internet/model/ipv6-queue-disc-item.cc b/src/internet/model/ipv6-queue-disc-item.cc index 2f8648f93..3f888a590 100644 --- a/src/internet/model/ipv6-queue-disc-item.cc +++ b/src/internet/model/ipv6-queue-disc-item.cc @@ -79,4 +79,20 @@ Ipv6QueueDiscItem::Print (std::ostream& os) const ; } +bool +Ipv6QueueDiscItem::GetUint8Value (QueueItem::Uint8Values field, uint8_t& value) const +{ + bool ret = false; + + switch (field) + { + case IP_DSFIELD: + value = m_header.GetTrafficClass (); + ret = true; + break; + } + + return ret; +} + } // namespace ns3 diff --git a/src/internet/model/ipv6-queue-disc-item.h b/src/internet/model/ipv6-queue-disc-item.h index ccc9cfc58..79211c724 100644 --- a/src/internet/model/ipv6-queue-disc-item.h +++ b/src/internet/model/ipv6-queue-disc-item.h @@ -70,6 +70,15 @@ public: */ virtual void Print (std::ostream &os) const; + /* + * The values for the fields of the Ipv6 header are taken from m_header and + * thus might differ from those present in the packet in case the header is + * modified after being added to the packet. However, this function is likely + * to be called before the header is added to the packet (i.e., before the + * packet is dequeued from the queue disc) + */ + virtual bool GetUint8Value (Uint8Values field, uint8_t &value) const; + private: /** * \brief Default constructor diff --git a/src/network/model/net-device.cc b/src/network/model/net-device.cc index e3e16f7d5..f69261018 100644 --- a/src/network/model/net-device.cc +++ b/src/network/model/net-device.cc @@ -53,6 +53,12 @@ QueueItem::GetPacketSize (void) const return m_packet->GetSize (); } +bool +QueueItem::GetUint8Value (QueueItem::Uint8Values field, uint8_t& value) const +{ + return false; +} + void QueueItem::Print (std::ostream& os) const { diff --git a/src/network/model/net-device.h b/src/network/model/net-device.h index ce76ceaad..5708af7a5 100644 --- a/src/network/model/net-device.h +++ b/src/network/model/net-device.h @@ -78,6 +78,24 @@ public: */ virtual uint32_t GetPacketSize (void) const; + /** + * \enum Uint8Values + * \brief 1-byte fields of the packet whose value can be retrieved, if present + */ + enum Uint8Values + { + IP_DSFIELD + }; + + /** + * \brief Retrieve the value of a given field from the packet, if present + * \param field the field whose value has to be retrieved + * \param value the output parameter to store the retrieved value + * + * \return true if the requested field is present in the packet, false otherwise. + */ + virtual bool GetUint8Value (Uint8Values field, uint8_t &value) const; + /** * \brief Print the item contents. * \param os output stream in which the data should be printed.