A Discrete-Event Network Simulator
API
byte-tag-list.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 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 #ifndef BYTE_TAG_LIST_H
21 #define BYTE_TAG_LIST_H
22 
23 #define __STDC_LIMIT_MACROS
24 #include <stdint.h>
25 #include "ns3/type-id.h"
26 #include "tag-buffer.h"
27 
28 namespace ns3 {
29 
30 struct ByteTagListData;
31 
64 {
65 public:
72  class Iterator
73  {
74 public:
81  struct Item
82  {
84  uint32_t size;
85  int32_t start;
86  int32_t end;
88 
91  Item (TagBuffer buf);
92 private:
94  friend class ByteTagList;
96  friend class ByteTagList::Iterator;
97  };
98 
104  bool HasNext (void) const;
105 
111  struct ByteTagList::Iterator::Item Next (void);
112 
118  uint32_t GetOffsetStart (void) const;
119 private:
121  friend class ByteTagList;
122 
131  Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd, int32_t adjustment);
132 
136  void PrepareForNext (void);
137  uint8_t *m_current;
138  uint8_t *m_end;
139  int32_t m_offsetStart;
140  int32_t m_offsetEnd;
141  int32_t m_adjustment;
142  uint32_t m_nextTid;
143  uint32_t m_nextSize;
144  int32_t m_nextStart;
145  int32_t m_nextEnd;
146  };
147 
148  ByteTagList ();
149 
157  ByteTagList (const ByteTagList &o);
158 
169  ~ByteTagList ();
170 
181  TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
182 
188  void Add (const ByteTagList &o);
189 
194  void RemoveAll (void);
195 
207  ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
208 
214  inline void Adjust (int32_t adjustment);
215 
223  void AddAtEnd (int32_t appendOffset);
231  void AddAtStart (int32_t prependOffset);
237  uint32_t GetSerializedSize (void) const;
246  uint32_t Serialize (uint32_t* buffer, uint32_t maxSize) const;
255  uint32_t Deserialize (const uint32_t* buffer, uint32_t size);
256 
257 private:
263  ByteTagList::Iterator BeginAll (void) const;
264 
270  struct ByteTagListData *Allocate (uint32_t size);
271 
276  void Deallocate (struct ByteTagListData *data);
277 
278  int32_t m_minStart;
279  int32_t m_maxEnd;
280  int32_t m_adjustment;
281  uint32_t m_used;
283 };
284 
285 void
286 ByteTagList::Adjust (int32_t adjustment)
287 {
288  m_adjustment += adjustment;
289 }
290 
291 } // namespace ns3
292 
293 #endif /* BYTE_TAG_LIST_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::ByteTagList::AddAtEnd
void AddAtEnd(int32_t appendOffset)
Make sure that all offsets are smaller than appendOffset which represents the location where new byte...
Definition: byte-tag-list.cc:278
ns3::ByteTagList::m_adjustment
int32_t m_adjustment
adjustment to byte tag offsets
Definition: byte-tag-list.h:280
ns3::ByteTagList::ByteTagList
ByteTagList()
Definition: byte-tag-list.cc:141
ns3::ByteTagList::m_data
struct ByteTagListData * m_data
the ByteTagListData structure
Definition: byte-tag-list.h:282
ns3::ByteTagList::~ByteTagList
~ByteTagList()
Definition: byte-tag-list.cc:183
ns3::ByteTagList::Iterator::Item::size
uint32_t size
size of tag data
Definition: byte-tag-list.h:84
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::ByteTagList::Iterator::Next
struct ByteTagList::Iterator::Item Next(void)
Returns the next Item from the ByteTagList.
Definition: byte-tag-list.cc:88
ns3::ByteTagList::Serialize
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Serialize the tag list into a byte buffer.
Definition: byte-tag-list.cc:457
ns3::ByteTagList::GetSerializedSize
uint32_t GetSerializedSize(void) const
Returns number of bytes required for packet serialization.
Definition: byte-tag-list.cc:428
ns3::ByteTagList::Iterator::Item::buf
TagBuffer buf
the data for the tag as generated by Tag::Serialize
Definition: byte-tag-list.h:87
ns3::ByteTagList::Iterator::Iterator
Iterator(uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd, int32_t adjustment)
Constructor.
Definition: byte-tag-list.cc:122
ns3::ByteTagList::Iterator::Item::Item
Item(TagBuffer buf)
Constructs an item with the given TagBuffer.
Definition: byte-tag-list.cc:75
ns3::ByteTagList::m_used
uint32_t m_used
the number of used bytes in the buffer
Definition: byte-tag-list.h:281
ns3::ByteTagList::Begin
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
Definition: byte-tag-list.cc:264
ns3::ByteTagList::Adjust
void Adjust(int32_t adjustment)
Adjust the offsets stored internally by the adjustment delta.
Definition: byte-tag-list.h:286
ns3::ByteTagList::Iterator::Item::start
int32_t start
offset to the start of the tag from the virtual byte buffer
Definition: byte-tag-list.h:85
ns3::ByteTagList::Iterator::m_offsetStart
int32_t m_offsetStart
Offset to the start of the tag from the virtual byte buffer.
Definition: byte-tag-list.h:139
ns3::ByteTagList::Iterator::m_end
uint8_t * m_end
End tag.
Definition: byte-tag-list.h:138
ns3::ByteTagList::Iterator::Item::end
int32_t end
offset to the end of the tag from the virtual byte buffer
Definition: byte-tag-list.h:86
ns3::ByteTagList::RemoveAll
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
Definition: byte-tag-list.cc:243
tag-buffer.h
ns3::ByteTagList::Iterator::Item::tid
TypeId tid
type of the tag
Definition: byte-tag-list.h:83
ns3::ByteTagList::Deserialize
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Deserialize tag list from the provided buffer.
Definition: byte-tag-list.cc:550
ns3::ByteTagList::AddAtStart
void AddAtStart(int32_t prependOffset)
Make sure that all offsets are bigger than prependOffset which represents the location where new byte...
Definition: byte-tag-list.cc:310
ns3::ByteTagList::m_maxEnd
int32_t m_maxEnd
maximal end offset
Definition: byte-tag-list.h:279
visualizer.core.start
def start()
Definition: core.py:1855
ns3::ByteTagList::Iterator::HasNext
bool HasNext(void) const
Used to determine if the iterator is at the end of the byteTagList.
Definition: byte-tag-list.cc:82
ns3::ByteTagListData
Internal representation of the byte tags stored in a packet.
Definition: byte-tag-list.cc:41
ns3::ByteTagList::Iterator::Item
An item specifies an individual tag within a byte buffer.
Definition: byte-tag-list.h:82
ns3::ByteTagList::Iterator::m_adjustment
int32_t m_adjustment
Adjustment to byte tag offsets.
Definition: byte-tag-list.h:141
data
uint8_t data[writeSize]
Definition: socket-bound-tcp-static-routing.cc:53
ns3::ByteTagList::Iterator::m_nextEnd
int32_t m_nextEnd
End of the next tag.
Definition: byte-tag-list.h:145
ns3::ByteTagList::operator=
ByteTagList & operator=(const ByteTagList &o)
Assignment operator, deallocates current data and assigns value of passed in ByteTagList.
Definition: byte-tag-list.cc:164
ns3::ByteTagList
keep track of the byte tags stored in a packet.
Definition: byte-tag-list.h:64
ns3::ByteTagList::Iterator::GetOffsetStart
uint32_t GetOffsetStart(void) const
Returns the offset from the start of the virtual byte buffer to the ByteTagList.
Definition: byte-tag-list.cc:134
ns3::ByteTagList::Iterator::m_offsetEnd
int32_t m_offsetEnd
Offset to the end of the tag from the virtual byte buffer.
Definition: byte-tag-list.h:140
ns3::ByteTagList::Iterator::PrepareForNext
void PrepareForNext(void)
Prepare the iterator for the next tag.
Definition: byte-tag-list.cc:102
ns3::ByteTagList::Iterator::m_current
uint8_t * m_current
Current tag.
Definition: byte-tag-list.h:137
ns3::ByteTagList::BeginAll
ByteTagList::Iterator BeginAll(void) const
Returns an iterator pointing to the very first tag in this list.
Definition: byte-tag-list.cc:255
ns3::ByteTagList::Iterator::m_nextSize
uint32_t m_nextSize
Size of the next tag.
Definition: byte-tag-list.h:143
ns3::ByteTagList::Add
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
Definition: byte-tag-list.cc:192
ns3::ByteTagList::Iterator::m_nextTid
uint32_t m_nextTid
TypeId of the next tag.
Definition: byte-tag-list.h:142
ns3::ByteTagList::Iterator
An iterator for iterating through a byte tag list.
Definition: byte-tag-list.h:73
ns3::TagBuffer
read and write tag data
Definition: tag-buffer.h:52
ns3::ByteTagList::Allocate
struct ByteTagListData * Allocate(uint32_t size)
Allocate the memory for the ByteTagListData.
Definition: byte-tag-list.cc:345
ns3::ByteTagList::Iterator::m_nextStart
int32_t m_nextStart
Start of the next tag.
Definition: byte-tag-list.h:144
ns3::ByteTagList::m_minStart
int32_t m_minStart
minimal start offset
Definition: byte-tag-list.h:278
ns3::ByteTagList::Deallocate
void Deallocate(struct ByteTagListData *data)
Deallocates a ByteTagListData.
Definition: byte-tag-list.cc:371