Bug Summary

File:/tmp/asd-nat/home/nat/Work/ns-3-dev-git/build/../src/network/model/packet.cc
Location:line 682, column 7
Description:Value stored to 'size' is never read

Annotated Source Code

1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2005,2006 INRIA
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 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20#include "packet.h"
21#include "ns3/assert.h"
22#include "ns3/log.h"
23#include "ns3/simulator.h"
24#include <string>
25#include <cstdarg>
26
27namespace ns3 {
28
29NS_LOG_COMPONENT_DEFINE ("Packet")static ns3::LogComponent g_log = ns3::LogComponent ("Packet",
"../src/network/model/packet.cc")
;
30
31uint32_t Packet::m_globalUid = 0;
32
33TypeId
34ByteTagIterator::Item::GetTypeId (void) const
35{
36 return m_tid;
37}
38uint32_t
39ByteTagIterator::Item::GetStart (void) const
40{
41 return m_start;
42}
43uint32_t
44ByteTagIterator::Item::GetEnd (void) const
45{
46 return m_end;
47}
48void
49ByteTagIterator::Item::GetTag (Tag &tag) const
50{
51 if (tag.GetInstanceTypeId () != GetTypeId ())
52 {
53 NS_FATAL_ERROR ("The tag you provided is not of the right type.")do { std::cerr << "msg=\"" << "The tag you provided is not of the right type."
<< "\", "; do { std::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 53 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } while (false)
;
54 }
55 tag.Deserialize (m_buffer);
56}
57ByteTagIterator::Item::Item (TypeId tid, uint32_t start, uint32_t end, TagBuffer buffer)
58 : m_tid (tid),
59 m_start (start),
60 m_end (end),
61 m_buffer (buffer)
62{
63}
64bool
65ByteTagIterator::HasNext (void) const
66{
67 return m_current.HasNext ();
68}
69ByteTagIterator::Item
70ByteTagIterator::Next (void)
71{
72 ByteTagList::Iterator::Item i = m_current.Next ();
73 return ByteTagIterator::Item (i.tid,
74 i.start-m_current.GetOffsetStart (),
75 i.end-m_current.GetOffsetStart (),
76 i.buf);
77}
78ByteTagIterator::ByteTagIterator (ByteTagList::Iterator i)
79 : m_current (i)
80{
81}
82
83
84PacketTagIterator::PacketTagIterator (const struct PacketTagList::TagData *head)
85 : m_current (head)
86{
87}
88bool
89PacketTagIterator::HasNext (void) const
90{
91 return m_current != 0;
92}
93PacketTagIterator::Item
94PacketTagIterator::Next (void)
95{
96 NS_ASSERT (HasNext ())do { if (!(HasNext ())) { std::cerr << "assert failed. cond=\""
<< "HasNext ()" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 96 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
97 const struct PacketTagList::TagData *prev = m_current;
98 m_current = m_current->next;
99 return PacketTagIterator::Item (prev);
100}
101
102PacketTagIterator::Item::Item (const struct PacketTagList::TagData *data)
103 : m_data (data)
104{
105}
106TypeId
107PacketTagIterator::Item::GetTypeId (void) const
108{
109 return m_data->tid;
110}
111void
112PacketTagIterator::Item::GetTag (Tag &tag) const
113{
114 NS_ASSERT (tag.GetInstanceTypeId () == m_data->tid)do { if (!(tag.GetInstanceTypeId () == m_data->tid)) { std
::cerr << "assert failed. cond=\"" << "tag.GetInstanceTypeId () == m_data->tid"
<< "\", "; do { std::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 114 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
115 tag.Deserialize (TagBuffer ((uint8_t*)m_data->data,
116 (uint8_t*)m_data->data + m_data->size));
117}
118
119
120Ptr<Packet>
121Packet::Copy (void) const
122{
123 // we need to invoke the copy constructor directly
124 // rather than calling Create because the copy constructor
125 // is private.
126 return Ptr<Packet> (new Packet (*this), false);
127}
128
129Packet::Packet ()
130 : m_buffer (),
131 m_byteTagList (),
132 m_packetTagList (),
133 /* The upper 32 bits of the packet id in
134 * metadata is for the system id. For non-
135 * distributed simulations, this is simply
136 * zero. The lower 32 bits are for the
137 * global UID
138 */
139 m_metadata (static_cast<uint64_t> (Simulator::GetSystemId ()) << 32 | m_globalUid, 0),
140 m_nixVector (0)
141{
142 m_globalUid++;
143}
144
145Packet::Packet (const Packet &o)
146 : m_buffer (o.m_buffer),
147 m_byteTagList (o.m_byteTagList),
148 m_packetTagList (o.m_packetTagList),
149 m_metadata (o.m_metadata)
150{
151 o.m_nixVector ? m_nixVector = o.m_nixVector->Copy ()
152 : m_nixVector = 0;
153}
154
155Packet &
156Packet::operator = (const Packet &o)
157{
158 if (this == &o)
159 {
160 return *this;
161 }
162 m_buffer = o.m_buffer;
163 m_byteTagList = o.m_byteTagList;
164 m_packetTagList = o.m_packetTagList;
165 m_metadata = o.m_metadata;
166 o.m_nixVector ? m_nixVector = o.m_nixVector->Copy ()
167 : m_nixVector = 0;
168 return *this;
169}
170
171Packet::Packet (uint32_t size)
172 : m_buffer (size),
173 m_byteTagList (),
174 m_packetTagList (),
175 /* The upper 32 bits of the packet id in
176 * metadata is for the system id. For non-
177 * distributed simulations, this is simply
178 * zero. The lower 32 bits are for the
179 * global UID
180 */
181 m_metadata (static_cast<uint64_t> (Simulator::GetSystemId ()) << 32 | m_globalUid, size),
182 m_nixVector (0)
183{
184 m_globalUid++;
185}
186Packet::Packet (uint8_t const *buffer, uint32_t size, bool magic)
187 : m_buffer (0, false),
188 m_byteTagList (),
189 m_packetTagList (),
190 m_metadata (0,0),
191 m_nixVector (0)
192{
193 NS_ASSERT (magic)do { if (!(magic)) { std::cerr << "assert failed. cond=\""
<< "magic" << "\", "; do { std::cerr << "file="
<< "../src/network/model/packet.cc" << ", line="
<< 193 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
194 Deserialize (buffer, size);
195}
196
197Packet::Packet (uint8_t const*buffer, uint32_t size)
198 : m_buffer (),
199 m_byteTagList (),
200 m_packetTagList (),
201 /* The upper 32 bits of the packet id in
202 * metadata is for the system id. For non-
203 * distributed simulations, this is simply
204 * zero. The lower 32 bits are for the
205 * global UID
206 */
207 m_metadata (static_cast<uint64_t> (Simulator::GetSystemId ()) << 32 | m_globalUid, size),
208 m_nixVector (0)
209{
210 m_globalUid++;
211 m_buffer.AddAtStart (size);
212 Buffer::Iterator i = m_buffer.Begin ();
213 i.Write (buffer, size);
214}
215
216Packet::Packet (const Buffer &buffer, const ByteTagList &byteTagList,
217 const PacketTagList &packetTagList, const PacketMetadata &metadata)
218 : m_buffer (buffer),
219 m_byteTagList (byteTagList),
220 m_packetTagList (packetTagList),
221 m_metadata (metadata),
222 m_nixVector (0)
223{
224}
225
226Ptr<Packet>
227Packet::CreateFragment (uint32_t start, uint32_t length) const
228{
229 NS_LOG_FUNCTION (this << start << length)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << start << length; std::clog << ")" <<
std::endl; } } while (false)
;
230 Buffer buffer = m_buffer.CreateFragment (start, length);
231 ByteTagList byteTagList = m_byteTagList;
232 byteTagList.Adjust (-start);
233 NS_ASSERT (m_buffer.GetSize () >= start + length)do { if (!(m_buffer.GetSize () >= start + length)) { std::
cerr << "assert failed. cond=\"" << "m_buffer.GetSize () >= start + length"
<< "\", "; do { std::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 233 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
234 uint32_t end = m_buffer.GetSize () - (start + length);
235 PacketMetadata metadata = m_metadata.CreateFragment (start, end);
236 // again, call the constructor directly rather than
237 // through Create because it is private.
238 Ptr<Packet> ret = Ptr<Packet> (new Packet (buffer, byteTagList, m_packetTagList, metadata), false);
239 ret->SetNixVector (GetNixVector ());
240 return ret;
241}
242
243void
244Packet::SetNixVector (Ptr<NixVector> nixVector)
245{
246 m_nixVector = nixVector;
247}
248
249Ptr<NixVector>
250Packet::GetNixVector (void) const
251{
252 return m_nixVector;
253}
254
255void
256Packet::AddHeader (const Header &header)
257{
258 uint32_t size = header.GetSerializedSize ();
259 NS_LOG_FUNCTION (this << header.GetInstanceTypeId ().GetName () << size)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << header.GetInstanceTypeId ().GetName () <<
size; std::clog << ")" << std::endl; } } while (
false)
;
260 m_buffer.AddAtStart (size);
261 m_byteTagList.Adjust (size);
262 m_byteTagList.AddAtStart (size);
263 header.Serialize (m_buffer.Begin ());
264 m_metadata.AddHeader (header, size);
265}
266uint32_t
267Packet::RemoveHeader (Header &header)
268{
269 uint32_t deserialized = header.Deserialize (m_buffer.Begin ());
270 NS_LOG_FUNCTION (this << header.GetInstanceTypeId ().GetName () << deserialized)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << header.GetInstanceTypeId ().GetName () <<
deserialized; std::clog << ")" << std::endl; } }
while (false)
;
271 m_buffer.RemoveAtStart (deserialized);
272 m_byteTagList.Adjust (-deserialized);
273 m_metadata.RemoveHeader (header, deserialized);
274 return deserialized;
275}
276uint32_t
277Packet::PeekHeader (Header &header) const
278{
279 uint32_t deserialized = header.Deserialize (m_buffer.Begin ());
280 NS_LOG_FUNCTION (this << header.GetInstanceTypeId ().GetName () << deserialized)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << header.GetInstanceTypeId ().GetName () <<
deserialized; std::clog << ")" << std::endl; } }
while (false)
;
281 return deserialized;
282}
283void
284Packet::AddTrailer (const Trailer &trailer)
285{
286 uint32_t size = trailer.GetSerializedSize ();
287 NS_LOG_FUNCTION (this << trailer.GetInstanceTypeId ().GetName () << size)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << trailer.GetInstanceTypeId ().GetName () <<
size; std::clog << ")" << std::endl; } } while (
false)
;
288 m_byteTagList.AddAtEnd (GetSize ());
289 m_buffer.AddAtEnd (size);
290 Buffer::Iterator end = m_buffer.End ();
291 trailer.Serialize (end);
292 m_metadata.AddTrailer (trailer, size);
293}
294uint32_t
295Packet::RemoveTrailer (Trailer &trailer)
296{
297 uint32_t deserialized = trailer.Deserialize (m_buffer.End ());
298 NS_LOG_FUNCTION (this << trailer.GetInstanceTypeId ().GetName () << deserialized)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << trailer.GetInstanceTypeId ().GetName () <<
deserialized; std::clog << ")" << std::endl; } }
while (false)
;
299 m_buffer.RemoveAtEnd (deserialized);
300 m_metadata.RemoveTrailer (trailer, deserialized);
301 return deserialized;
302}
303uint32_t
304Packet::PeekTrailer (Trailer &trailer)
305{
306 uint32_t deserialized = trailer.Deserialize (m_buffer.End ());
307 NS_LOG_FUNCTION (this << trailer.GetInstanceTypeId ().GetName () << deserialized)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << trailer.GetInstanceTypeId ().GetName () <<
deserialized; std::clog << ")" << std::endl; } }
while (false)
;
308 return deserialized;
309}
310
311void
312Packet::AddAtEnd (Ptr<const Packet> packet)
313{
314 NS_LOG_FUNCTION (this << packet << packet->GetSize ())do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << packet << packet->GetSize (); std::clog
<< ")" << std::endl; } } while (false)
;
315 m_byteTagList.AddAtEnd (GetSize ());
316 ByteTagList copy = packet->m_byteTagList;
317 copy.AddAtStart (0);
318 copy.Adjust (GetSize ());
319 m_byteTagList.Add (copy);
320 m_buffer.AddAtEnd (packet->m_buffer);
321 m_metadata.AddAtEnd (packet->m_metadata);
322}
323void
324Packet::AddPaddingAtEnd (uint32_t size)
325{
326 NS_LOG_FUNCTION (this << size)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << size; std::clog << ")" << std::endl
; } } while (false)
;
327 m_byteTagList.AddAtEnd (GetSize ());
328 m_buffer.AddAtEnd (size);
329 m_metadata.AddPaddingAtEnd (size);
330}
331void
332Packet::RemoveAtEnd (uint32_t size)
333{
334 NS_LOG_FUNCTION (this << size)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << size; std::clog << ")" << std::endl
; } } while (false)
;
335 m_buffer.RemoveAtEnd (size);
336 m_metadata.RemoveAtEnd (size);
337}
338void
339Packet::RemoveAtStart (uint32_t size)
340{
341 NS_LOG_FUNCTION (this << size)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << size; std::clog << ")" << std::endl
; } } while (false)
;
342 m_buffer.RemoveAtStart (size);
343 m_byteTagList.Adjust (-size);
344 m_metadata.RemoveAtStart (size);
345}
346
347void
348Packet::RemoveAllByteTags (void)
349{
350 NS_LOG_FUNCTION (this)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this; std::clog << ")" << std::endl; } } while (
false)
;
351 m_byteTagList.RemoveAll ();
352}
353
354uint32_t
355Packet::CopyData (uint8_t *buffer, uint32_t size) const
356{
357 return m_buffer.CopyData (buffer, size);
358}
359
360void
361Packet::CopyData (std::ostream *os, uint32_t size) const
362{
363 return m_buffer.CopyData (os, size);
364}
365
366uint64_t
367Packet::GetUid (void) const
368{
369 return m_metadata.GetUid ();
370}
371
372void
373Packet::PrintByteTags (std::ostream &os) const
374{
375 ByteTagIterator i = GetByteTagIterator ();
376 while (i.HasNext ())
377 {
378 ByteTagIterator::Item item = i.Next ();
379 os << item.GetTypeId ().GetName () << " [" << item.GetStart () << "-" << item.GetEnd () << "]";
380 Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
381 if (constructor.IsNull ())
382 {
383 if (i.HasNext ())
384 {
385 os << " ";
386 }
387 continue;
388 }
389 Tag *tag = dynamic_cast<Tag *> (constructor ());
390 NS_ASSERT (tag != 0)do { if (!(tag != 0)) { std::cerr << "assert failed. cond=\""
<< "tag != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 390 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
391 os << " ";
392 item.GetTag (*tag);
393 tag->Print (os);
394 if (i.HasNext ())
395 {
396 os << " ";
397 }
398 delete tag;
399 }
400}
401
402std::string
403Packet::ToString() const
404{
405 std::ostringstream oss;
406 Print (oss);
407 return oss.str();
408}
409
410void
411Packet::Print (std::ostream &os) const
412{
413 PacketMetadata::ItemIterator i = m_metadata.BeginItem (m_buffer);
414 while (i.HasNext ())
415 {
416 PacketMetadata::Item item = i.Next ();
417 if (item.isFragment)
418 {
419 switch (item.type) {
420 case PacketMetadata::Item::PAYLOAD:
421 os << "Payload";
422 break;
423 case PacketMetadata::Item::HEADER:
424 case PacketMetadata::Item::TRAILER:
425 os << item.tid.GetName ();
426 break;
427 }
428 os << " Fragment [" << item.currentTrimedFromStart<<":"
429 << (item.currentTrimedFromStart + item.currentSize) << "]";
430 }
431 else
432 {
433 switch (item.type) {
434 case PacketMetadata::Item::PAYLOAD:
435 os << "Payload (size=" << item.currentSize << ")";
436 break;
437 case PacketMetadata::Item::HEADER:
438 case PacketMetadata::Item::TRAILER:
439 os << item.tid.GetName () << " (";
440 {
441 NS_ASSERT (item.tid.HasConstructor ())do { if (!(item.tid.HasConstructor ())) { std::cerr << "assert failed. cond=\""
<< "item.tid.HasConstructor ()" << "\", "; do { std
::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 441 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
442 Callback<ObjectBase *> constructor = item.tid.GetConstructor ();
443 NS_ASSERT (!constructor.IsNull ())do { if (!(!constructor.IsNull ())) { std::cerr << "assert failed. cond=\""
<< "!constructor.IsNull ()" << "\", "; do { std::
cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 443 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
444 ObjectBase *instance = constructor ();
445 NS_ASSERT (instance != 0)do { if (!(instance != 0)) { std::cerr << "assert failed. cond=\""
<< "instance != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 445 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
446 Chunk *chunk = dynamic_cast<Chunk *> (instance);
447 NS_ASSERT (chunk != 0)do { if (!(chunk != 0)) { std::cerr << "assert failed. cond=\""
<< "chunk != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 447 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
448 chunk->Deserialize (item.current);
449 chunk->Print (os);
450 delete chunk;
451 }
452 os << ")";
453 break;
454 }
455 }
456 if (i.HasNext ())
457 {
458 os << " ";
459 }
460 }
461#if 0
462 // The code below will work only if headers and trailers
463 // define the right attributes which is not the case for
464 // now. So, as a temporary measure, we use the
465 // headers' and trailers' Print method as shown above.
466 PacketMetadata::ItemIterator i = m_metadata.BeginItem (m_buffer);
467 while (i.HasNext ())
468 {
469 PacketMetadata::Item item = i.Next ();
470 if (item.isFragment)
471 {
472 switch (item.type) {
473 case PacketMetadata::Item::PAYLOAD:
474 os << "Payload";
475 break;
476 case PacketMetadata::Item::HEADER:
477 case PacketMetadata::Item::TRAILER:
478 os << item.tid.GetName ();
479 break;
480 }
481 os << " Fragment [" << item.currentTrimedFromStart<<":"
482 << (item.currentTrimedFromStart + item.currentSize) << "]";
483 }
484 else
485 {
486 switch (item.type) {
487 case PacketMetadata::Item::PAYLOAD:
488 os << "Payload (size=" << item.currentSize << ")";
489 break;
490 case PacketMetadata::Item::HEADER:
491 case PacketMetadata::Item::TRAILER:
492 os << item.tid.GetName () << "(";
493 {
494 NS_ASSERT (item.tid.HasConstructor ())do { if (!(item.tid.HasConstructor ())) { std::cerr << "assert failed. cond=\""
<< "item.tid.HasConstructor ()" << "\", "; do { std
::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 494 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
495 Callback<ObjectBase *> constructor = item.tid.GetConstructor ();
496 NS_ASSERT (constructor.IsNull ())do { if (!(constructor.IsNull ())) { std::cerr << "assert failed. cond=\""
<< "constructor.IsNull ()" << "\", "; do { std::
cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 496 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
497 ObjectBase *instance = constructor ();
498 NS_ASSERT (instance != 0)do { if (!(instance != 0)) { std::cerr << "assert failed. cond=\""
<< "instance != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 498 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
499 Chunk *chunk = dynamic_cast<Chunk *> (instance);
500 NS_ASSERT (chunk != 0)do { if (!(chunk != 0)) { std::cerr << "assert failed. cond=\""
<< "chunk != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 500 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
501 chunk->Deserialize (item.current);
502 for (uint32_t j = 0; j < item.tid.GetAttributeN (); j++)
503 {
504 std::string attrName = item.tid.GetAttributeName (j);
505 std::string value;
506 bool ok = chunk->GetAttribute (attrName, value);
507 NS_ASSERT (ok)do { if (!(ok)) { std::cerr << "assert failed. cond=\""
<< "ok" << "\", "; do { std::cerr << "file="
<< "../src/network/model/packet.cc" << ", line="
<< 507 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
508 os << attrName << "=" << value;
509 if ((j + 1) < item.tid.GetAttributeN ())
510 {
511 os << ",";
512 }
513 }
514 }
515 os << ")";
516 break;
517 }
518 }
519 if (i.HasNext ())
520 {
521 os << " ";
522 }
523 }
524#endif
525}
526
527PacketMetadata::ItemIterator
528Packet::BeginItem (void) const
529{
530 return m_metadata.BeginItem (m_buffer);
531}
532
533void
534Packet::EnablePrinting (void)
535{
536 NS_LOG_FUNCTION_NOARGS ()do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "()" << std::endl; } } while (false
)
;
537 PacketMetadata::Enable ();
538}
539
540void
541Packet::EnableChecking (void)
542{
543 NS_LOG_FUNCTION_NOARGS ()do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "()" << std::endl; } } while (false
)
;
544 PacketMetadata::EnableChecking ();
545}
546
547uint32_t Packet::GetSerializedSize (void) const
548{
549 uint32_t size = 0;
550
551 if (m_nixVector)
552 {
553 // increment total size by the size of the nix-vector
554 // ensuring 4-byte boundary
555 size += ((m_nixVector->GetSerializedSize () + 3) & (~3));
556
557 // add 4-bytes for entry of total length of nix-vector
558 size += 4;
559 }
560 else
561 {
562 // if no nix-vector, still have to add 4-bytes
563 // to account for the entry of total size for
564 // nix-vector in the buffer
565 size += 4;
566 }
567
568 //Tag size
569 /// \todo Serialze Tags size
570 //size += m_tags.GetSerializedSize ();
571
572 // increment total size by size of meta-data
573 // ensuring 4-byte boundary
574 size += ((m_metadata.GetSerializedSize () + 3) & (~3));
575
576 // add 4-bytes for entry of total length of meta-data
577 size += 4;
578
579 // increment total size by size of buffer
580 // ensuring 4-byte boundary
581 size += ((m_buffer.GetSerializedSize () + 3) & (~3));
582
583 // add 4-bytes for entry of total length of buffer
584 size += 4;
585
586 return size;
587}
588
589uint32_t
590Packet::Serialize (uint8_t* buffer, uint32_t maxSize) const
591{
592 uint32_t* p = reinterpret_cast<uint32_t *> (buffer);
593 uint32_t size = 0;
594
595 // if nix-vector exists, serialize it
596 if (m_nixVector)
597 {
598 uint32_t nixSize = m_nixVector->GetSerializedSize ();
599 if (size + nixSize <= maxSize)
600 {
601 // put the total length of nix-vector in the
602 // buffer. this includes 4-bytes for total
603 // length itself
604 *p++ = nixSize + 4;
605 size += nixSize;
606
607 // serialize the nix-vector
608 uint32_t serialized =
609 m_nixVector->Serialize (p, nixSize);
610 if (serialized)
611 {
612 // increment p by nixSize bytes
613 // ensuring 4-byte boundary
614 p += ((nixSize+3) & (~3)) / 4;
615 }
616 else
617 {
618 return 0;
619 }
620 }
621 else
622 {
623 return 0;
624 }
625 }
626 else
627 {
628 // no nix vector, set zero length,
629 // ie 4-bytes, since it must include
630 // length for itself
631 if (size + 4 <= maxSize)
632 {
633 size += 4;
634 *p++ = 4;
635 }
636 else
637 {
638 return 0;
639 }
640 }
641
642 // Serialize Tags
643 /// \todo Serialize Tags
644
645 // Serialize Metadata
646 uint32_t metaSize = m_metadata.GetSerializedSize ();
647 if (size + metaSize <= maxSize)
648 {
649 // put the total length of metadata in the
650 // buffer. this includes 4-bytes for total
651 // length itself
652 *p++ = metaSize + 4;
653 size += metaSize;
654
655 // serialize the metadata
656 uint32_t serialized =
657 m_metadata.Serialize (reinterpret_cast<uint8_t *> (p), metaSize);
658 if (serialized)
659 {
660 // increment p by metaSize bytes
661 // ensuring 4-byte boundary
662 p += ((metaSize+3) & (~3)) / 4;
663 }
664 else
665 {
666 return 0;
667 }
668 }
669 else
670 {
671 return 0;
672 }
673
674 // Serialize the packet contents
675 uint32_t bufSize = m_buffer.GetSerializedSize ();
676 if (size + bufSize <= maxSize)
677 {
678 // put the total length of the buffer in the
679 // buffer. this includes 4-bytes for total
680 // length itself
681 *p++ = bufSize + 4;
682 size += bufSize;
Value stored to 'size' is never read
683
684 // serialize the buffer
685 uint32_t serialized =
686 m_buffer.Serialize (reinterpret_cast<uint8_t *> (p), bufSize);
687 if (serialized)
688 {
689 // increment p by bufSize bytes
690 // ensuring 4-byte boundary
691 p += ((bufSize+3) & (~3)) / 4;
692 }
693 else
694 {
695 return 0;
696 }
697 }
698 else
699 {
700 return 0;
701 }
702
703 // Serialized successfully
704 return 1;
705}
706
707uint32_t
708Packet::Deserialize (const uint8_t* buffer, uint32_t size)
709{
710 NS_LOG_FUNCTION (this)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this; std::clog << ")" << std::endl; } } while (
false)
;
711
712 const uint32_t* p = reinterpret_cast<const uint32_t *> (buffer);
713
714 // read nix-vector
715 NS_ASSERT (!m_nixVector)do { if (!(!m_nixVector)) { std::cerr << "assert failed. cond=\""
<< "!m_nixVector" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 715 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
716 uint32_t nixSize = *p++;
717
718 // if size less than nixSize, the buffer
719 // will be overrun, assert
720 NS_ASSERT (size >= nixSize)do { if (!(size >= nixSize)) { std::cerr << "assert failed. cond=\""
<< "size >= nixSize" << "\", "; do { std::cerr
<< "file=" << "../src/network/model/packet.cc" <<
", line=" << 720 << std::endl; ::ns3::FatalImpl::
FlushStreams (); if (true) std::terminate (); } while (false)
; } } while (false)
;
721
722 size -= nixSize;
723
724 if (nixSize > 4)
725 {
726 Ptr<NixVector> nix = Create<NixVector> ();
727 uint32_t nixDeserialized = nix->Deserialize (p, nixSize);
728 if (!nixDeserialized)
729 {
730 // nix-vector not deserialized
731 // completely
732 return 0;
733 }
734 m_nixVector = nix;
735 // increment p by nixSize ensuring
736 // 4-byte boundary
737 p += ((((nixSize - 4) + 3) & (~3)) / 4);
738 }
739
740 // read tags
741 /// \todo Deserialize Tags
742 //uint32_t tagsDeserialized = m_tags.Deserialize (buffer.Begin ());
743 //buffer.RemoveAtStart (tagsDeserialized);
744
745 // read metadata
746 uint32_t metaSize = *p++;
747
748 // if size less than metaSize, the buffer
749 // will be overrun, assert
750 NS_ASSERT (size >= metaSize)do { if (!(size >= metaSize)) { std::cerr << "assert failed. cond=\""
<< "size >= metaSize" << "\", "; do { std::cerr
<< "file=" << "../src/network/model/packet.cc" <<
", line=" << 750 << std::endl; ::ns3::FatalImpl::
FlushStreams (); if (true) std::terminate (); } while (false)
; } } while (false)
;
751
752 size -= metaSize;
753
754 uint32_t metadataDeserialized =
755 m_metadata.Deserialize (reinterpret_cast<const uint8_t *> (p), metaSize);
756 if (!metadataDeserialized)
757 {
758 // meta-data not deserialized
759 // completely
760 return 0;
761 }
762 // increment p by metaSize ensuring
763 // 4-byte boundary
764 p += ((((metaSize - 4) + 3) & (~3)) / 4);
765
766 // read buffer contents
767 uint32_t bufSize = *p++;
768
769 // if size less than bufSize, the buffer
770 // will be overrun, assert
771 NS_ASSERT (size >= bufSize)do { if (!(size >= bufSize)) { std::cerr << "assert failed. cond=\""
<< "size >= bufSize" << "\", "; do { std::cerr
<< "file=" << "../src/network/model/packet.cc" <<
", line=" << 771 << std::endl; ::ns3::FatalImpl::
FlushStreams (); if (true) std::terminate (); } while (false)
; } } while (false)
;
772
773 size -= bufSize;
774
775 uint32_t bufferDeserialized =
776 m_buffer.Deserialize (reinterpret_cast<const uint8_t *> (p), bufSize);
777 if (!bufferDeserialized)
778 {
779 // buffer not deserialized
780 // completely
781 return 0;
782 }
783
784 // return zero if did not deserialize the
785 // number of expected bytes
786 return (size == 0);
787}
788
789void
790Packet::AddByteTag (const Tag &tag) const
791{
792 NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ())do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << tag.GetInstanceTypeId ().GetName () << tag
.GetSerializedSize (); std::clog << ")" << std::endl
; } } while (false)
;
793 ByteTagList *list = const_cast<ByteTagList *> (&m_byteTagList);
794 TagBuffer buffer = list->Add (tag.GetInstanceTypeId (), tag.GetSerializedSize (),
795 0,
796 GetSize ());
797 tag.Serialize (buffer);
798}
799ByteTagIterator
800Packet::GetByteTagIterator (void) const
801{
802 return ByteTagIterator (m_byteTagList.Begin (0, GetSize ()));
803}
804
805bool
806Packet::FindFirstMatchingByteTag (Tag &tag) const
807{
808 TypeId tid = tag.GetInstanceTypeId ();
809 ByteTagIterator i = GetByteTagIterator ();
810 while (i.HasNext ())
811 {
812 ByteTagIterator::Item item = i.Next ();
813 if (tid == item.GetTypeId ())
814 {
815 item.GetTag (tag);
816 return true;
817 }
818 }
819 return false;
820}
821
822void
823Packet::AddPacketTag (const Tag &tag) const
824{
825 NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ())do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << tag.GetInstanceTypeId ().GetName () << tag
.GetSerializedSize (); std::clog << ")" << std::endl
; } } while (false)
;
826 m_packetTagList.Add (tag);
827}
828
829bool
830Packet::RemovePacketTag (Tag &tag)
831{
832 NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ())do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << tag.GetInstanceTypeId ().GetName () << tag
.GetSerializedSize (); std::clog << ")" << std::endl
; } } while (false)
;
833 bool found = m_packetTagList.Remove (tag);
834 return found;
835}
836bool
837Packet::ReplacePacketTag (Tag &tag)
838{
839 NS_LOG_FUNCTION (this << tag.GetInstanceTypeId ().GetName () << tag.GetSerializedSize ())do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this << tag.GetInstanceTypeId ().GetName () << tag
.GetSerializedSize (); std::clog << ")" << std::endl
; } } while (false)
;
840 bool found = m_packetTagList.Replace (tag);
841 return found;
842}
843
844bool
845Packet::PeekPacketTag (Tag &tag) const
846{
847 bool found = m_packetTagList.Peek (tag);
848 return found;
849}
850void
851Packet::RemoveAllPacketTags (void)
852{
853 NS_LOG_FUNCTION (this)do { if (g_log.IsEnabled (ns3::LOG_FUNCTION)) { if (g_log.IsEnabled
(ns3::LOG_PREFIX_TIME)) { ns3::LogTimePrinter printer = ns3::
LogGetTimePrinter (); if (printer != 0) { (*printer)(std::clog
); std::clog << " "; } }; if (g_log.IsEnabled (ns3::LOG_PREFIX_NODE
)) { ns3::LogNodePrinter printer = ns3::LogGetNodePrinter ();
if (printer != 0) { (*printer)(std::clog); std::clog <<
" "; } }; ; std::clog << g_log.Name () << ":" <<
__FUNCTION__ << "("; ns3::ParameterLogger (std::clog) <<
this; std::clog << ")" << std::endl; } } while (
false)
;
854 m_packetTagList.RemoveAll ();
855}
856
857void
858Packet::PrintPacketTags (std::ostream &os) const
859{
860 PacketTagIterator i = GetPacketTagIterator ();
861 while (i.HasNext ())
862 {
863 PacketTagIterator::Item item = i.Next ();
864 NS_ASSERT (item.GetTypeId ().HasConstructor ())do { if (!(item.GetTypeId ().HasConstructor ())) { std::cerr <<
"assert failed. cond=\"" << "item.GetTypeId ().HasConstructor ()"
<< "\", "; do { std::cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 864 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
865 Callback<ObjectBase *> constructor = item.GetTypeId ().GetConstructor ();
866 NS_ASSERT (!constructor.IsNull ())do { if (!(!constructor.IsNull ())) { std::cerr << "assert failed. cond=\""
<< "!constructor.IsNull ()" << "\", "; do { std::
cerr << "file=" << "../src/network/model/packet.cc"
<< ", line=" << 866 << std::endl; ::ns3::FatalImpl
::FlushStreams (); if (true) std::terminate (); } while (false
); } } while (false)
;
867 ObjectBase *instance = constructor ();
868 Tag *tag = dynamic_cast<Tag *> (instance);
869 NS_ASSERT (tag != 0)do { if (!(tag != 0)) { std::cerr << "assert failed. cond=\""
<< "tag != 0" << "\", "; do { std::cerr <<
"file=" << "../src/network/model/packet.cc" << ", line="
<< 869 << std::endl; ::ns3::FatalImpl::FlushStreams
(); if (true) std::terminate (); } while (false); } } while (
false)
;
870 item.GetTag (*tag);
871 tag->Print (os);
872 delete tag;
873 if (i.HasNext ())
874 {
875 os << " ";
876 }
877 }
878}
879
880PacketTagIterator
881Packet::GetPacketTagIterator (void) const
882{
883 return PacketTagIterator (m_packetTagList.Head ());
884}
885
886std::ostream& operator<< (std::ostream& os, const Packet &packet)
887{
888 packet.Print (os);
889 return os;
890}
891
892} // namespace ns3