OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2016 Universita' degli Studi di Napoli Federico II |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 */ |
| 18 |
| 19 #include "ns3/log.h" |
| 20 #include "ipv4-queue-disc-item.h" |
| 21 |
| 22 namespace ns3 { |
| 23 |
| 24 NS_LOG_COMPONENT_DEFINE ("Ipv4QueueDiscItem"); |
| 25 |
| 26 Ipv4QueueDiscItem::Ipv4QueueDiscItem (Ptr<Packet> p, const Address& addr, |
| 27 uint16_t protocol, const Ipv4Header & head
er) |
| 28 : QueueDiscItem (p, addr, protocol), |
| 29 m_header (header), |
| 30 m_headerAdded (false) |
| 31 { |
| 32 } |
| 33 |
| 34 Ipv4QueueDiscItem::~Ipv4QueueDiscItem() |
| 35 { |
| 36 NS_LOG_FUNCTION (this); |
| 37 } |
| 38 |
| 39 uint32_t Ipv4QueueDiscItem::GetPacketSize(void) const |
| 40 { |
| 41 Ptr<Packet> p = GetPacket (); |
| 42 NS_ASSERT (p != 0); |
| 43 uint32_t ret = p->GetSize (); |
| 44 if (!m_headerAdded) |
| 45 { |
| 46 ret += m_header.GetSerializedSize (); |
| 47 } |
| 48 return ret; |
| 49 } |
| 50 |
| 51 const Ipv4Header& |
| 52 Ipv4QueueDiscItem::GetHeader (void) const |
| 53 { |
| 54 return m_header; |
| 55 } |
| 56 |
| 57 void Ipv4QueueDiscItem::AddHeader(void) |
| 58 { |
| 59 NS_LOG_FUNCTION (this); |
| 60 |
| 61 NS_ASSERT_MSG (!m_headerAdded, "The header has been already added to the packe
t"); |
| 62 Ptr<Packet> p = GetPacket (); |
| 63 NS_ASSERT (p != 0); |
| 64 p->AddHeader (m_header); |
| 65 m_headerAdded = true; |
| 66 } |
| 67 |
| 68 void |
| 69 Ipv4QueueDiscItem::Print (std::ostream& os) const |
| 70 { |
| 71 if (!m_headerAdded) |
| 72 { |
| 73 os << m_header << " "; |
| 74 } |
| 75 os << GetPacket () << " " |
| 76 << "Dst addr " << GetAddress () << " " |
| 77 << "proto " << (uint16_t) GetProtocol () << " " |
| 78 << "txq " << (uint8_t) GetTxQueueIndex () |
| 79 ; |
| 80 } |
| 81 |
| 82 } // namespace ns3 |
OLD | NEW |