A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
byte-tag-list.h
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 #include <stdint.h>
24 #include "ns3/type-id.h"
25 #include "tag-buffer.h"
26 
27 namespace ns3 {
28 
29 struct ByteTagListData;
30 
69 {
70 public:
71 
72  class Iterator
73  {
74 public:
75  struct Item
76  {
77  TypeId tid;
78  uint32_t size;
79  int32_t start;
80  int32_t end;
81  TagBuffer buf;
82  Item (TagBuffer buf);
83 private:
84  friend class ByteTagList;
85  friend class ByteTagList::Iterator;
86  };
87  bool HasNext (void) const;
88  struct ByteTagList::Iterator::Item Next (void);
89  uint32_t GetOffsetStart (void) const;
90 private:
91  friend class ByteTagList;
92  Iterator (uint8_t *start, uint8_t *end, int32_t offsetStart, int32_t offsetEnd);
93  void PrepareForNext (void);
94  uint8_t *m_current;
95  uint8_t *m_end;
96  int32_t m_offsetStart;
97  int32_t m_offsetEnd;
98  uint32_t m_nextTid;
99  uint32_t m_nextSize;
100  int32_t m_nextStart;
101  int32_t m_nextEnd;
102  };
103 
104  ByteTagList ();
105  ByteTagList (const ByteTagList &o);
106  ByteTagList &operator = (const ByteTagList &o);
107  ~ByteTagList ();
108 
119  TagBuffer Add (TypeId tid, uint32_t bufferSize, int32_t start, int32_t end);
120 
126  void Add (const ByteTagList &o);
127 
128  void RemoveAll (void);
129 
141  ByteTagList::Iterator Begin (int32_t offsetStart, int32_t offsetEnd) const;
142 
148  void AddAtEnd (int32_t adjustment, int32_t appendOffset);
154  void AddAtStart (int32_t adjustment, int32_t prependOffset);
155 
156 private:
157  bool IsDirtyAtEnd (int32_t appendOffset);
158  bool IsDirtyAtStart (int32_t prependOffset);
159  ByteTagList::Iterator BeginAll (void) const;
160 
161  struct ByteTagListData *Allocate (uint32_t size);
162  void Deallocate (struct ByteTagListData *data);
163 
164  uint16_t m_used;
165  struct ByteTagListData *m_data;
166 };
167 
168 } // namespace ns3
169 
170 #endif /* BYTE_TAG_LIST_H */
keep track of the tags stored in a packet.
Definition: byte-tag-list.h:68
TagBuffer Add(TypeId tid, uint32_t bufferSize, int32_t start, int32_t end)
void AddAtEnd(int32_t adjustment, int32_t appendOffset)
ByteTagList::Iterator Begin(int32_t offsetStart, int32_t offsetEnd) const
read and write tag data
Definition: tag-buffer.h:51
a unique identifier for an interface.
Definition: type-id.h:44
void AddAtStart(int32_t adjustment, int32_t prependOffset)