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
28namespace ns3 {
29
30struct ByteTagListData;
31
64{
65public:
73 {
74public:
81 struct Item
82 {
88
92private:
94 friend class ByteTagList;
97 };
98
104 bool HasNext (void) const;
105
111 struct ByteTagList::Iterator::Item Next (void);
112
118 uint32_t GetOffsetStart (void) const;
119private:
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;
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
257private:
263 ByteTagList::Iterator BeginAll (void) const;
264
270 struct ByteTagListData *Allocate (uint32_t size);
271
276 void Deallocate (struct ByteTagListData *data);
277
283};
284
285void
287{
288 m_adjustment += adjustment;
289}
290
291} // namespace ns3
292
293#endif /* BYTE_TAG_LIST_H */
An iterator for iterating through a byte tag list.
Definition: byte-tag-list.h:73
uint8_t * m_current
Current tag.
int32_t m_adjustment
Adjustment to byte tag offsets.
int32_t m_offsetEnd
Offset to the end of the tag from the virtual byte buffer.
uint32_t GetOffsetStart(void) const
Returns the offset from the start of the virtual byte buffer to the ByteTagList.
bool HasNext(void) const
Used to determine if the iterator is at the end of the byteTagList.
int32_t m_nextEnd
End of the next tag.
int32_t m_nextStart
Start of the next tag.
int32_t m_offsetStart
Offset to the start of the tag from the virtual byte buffer.
uint32_t m_nextSize
Size of the next tag.
Iterator(uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd, int32_t adjustment)
Constructor.
uint32_t m_nextTid
TypeId of the next tag.
struct ByteTagList::Iterator::Item Next(void)
Returns the next Item from the ByteTagList.
uint8_t * m_end
End tag.
void PrepareForNext(void)
Prepare the iterator for the next tag.
keep track of the byte tags stored in a packet.
Definition: byte-tag-list.h:64
uint32_t Deserialize(const uint32_t *buffer, uint32_t size)
Deserialize tag list from the provided buffer.
void AddAtEnd(int32_t appendOffset)
Make sure that all offsets are smaller than appendOffset which represents the location where new byte...
ByteTagList & operator=(const ByteTagList &o)
Assignment operator, deallocates current data and assigns value of passed in ByteTagList.
void Adjust(int32_t adjustment)
Adjust the offsets stored internally by the adjustment delta.
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
int32_t m_minStart
minimal start offset
uint32_t m_used
the number of used bytes in the buffer
struct ByteTagListData * Allocate(uint32_t size)
Allocate the memory for the ByteTagListData.
struct ByteTagListData * m_data
the ByteTagListData structure
void RemoveAll(void)
Removes all of the tags from the ByteTagList.
ByteTagList::Iterator BeginAll(void) const
Returns an iterator pointing to the very first tag in this list.
uint32_t GetSerializedSize(void) const
Returns number of bytes required for packet serialization.
int32_t m_adjustment
adjustment to byte tag offsets
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
uint32_t Serialize(uint32_t *buffer, uint32_t maxSize) const
Serialize the tag list into a byte buffer.
void AddAtStart(int32_t prependOffset)
Make sure that all offsets are bigger than prependOffset which represents the location where new byte...
int32_t m_maxEnd
maximal end offset
void Deallocate(struct ByteTagListData *data)
Deallocates a ByteTagListData.
read and write tag data
Definition: tag-buffer.h:52
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1852
uint8_t data[writeSize]
An item specifies an individual tag within a byte buffer.
Definition: byte-tag-list.h:82
TypeId tid
type of the tag
Definition: byte-tag-list.h:83
TagBuffer buf
the data for the tag as generated by Tag::Serialize
Definition: byte-tag-list.h:87
uint32_t size
size of tag data
Definition: byte-tag-list.h:84
int32_t end
offset to the end of the tag from the virtual byte buffer
Definition: byte-tag-list.h:86
Item(TagBuffer buf)
Constructs an item with the given TagBuffer.
int32_t start
offset to the start of the tag from the virtual byte buffer
Definition: byte-tag-list.h:85
Internal representation of the byte tags stored in a packet.