A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tag-buffer.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 TAG_BUFFER_H
21
#define TAG_BUFFER_H
22
23
#include <stdint.h>
24
25
#define TAG_BUFFER_USE_INLINE 1
26
27
#ifdef TAG_BUFFER_USE_INLINE
28
#define TAG_BUFFER_INLINE inline
29
#else
30
#define TAG_BUFFER_INLINE
31
#endif
32
33
namespace
ns3 {
34
51
class
TagBuffer
52
{
53
public
:
54
TagBuffer
(uint8_t *
start
, uint8_t *end);
55
void
TrimAtEnd
(uint32_t trim);
56
void
CopyFrom
(
TagBuffer
o);
57
63
TAG_BUFFER_INLINE
void
WriteU8
(uint8_t v);
69
TAG_BUFFER_INLINE
void
WriteU16
(uint16_t v);
75
TAG_BUFFER_INLINE
void
WriteU32
(uint32_t v);
81
void
WriteU64
(uint64_t v);
88
void
WriteDouble
(
double
v);
96
void
Write
(
const
uint8_t *buffer, uint32_t size);
103
TAG_BUFFER_INLINE
uint8_t
ReadU8
(
void
);
110
TAG_BUFFER_INLINE
uint16_t
ReadU16
(
void
);
117
TAG_BUFFER_INLINE
uint32_t
ReadU32
(
void
);
124
uint64_t
ReadU64
(
void
);
131
double
ReadDouble
(
void
);
140
void
Read
(uint8_t *buffer, uint32_t size);
141
private
:
142
143
uint8_t *
m_current
;
144
uint8_t *
m_end
;
145
};
146
147
}
// namespace ns3
148
149
#ifdef TAG_BUFFER_USE_INLINE
150
151
#include "ns3/assert.h"
152
153
namespace
ns3 {
154
155
void
156
TagBuffer::WriteU8
(uint8_t v)
157
{
158
NS_ASSERT
(
m_current
+ 1 <=
m_end
);
159
*
m_current
= v;
160
m_current
++;
161
}
162
163
void
164
TagBuffer::WriteU16
(uint16_t
data
)
165
{
166
WriteU8
((data >> 0) & 0xff);
167
WriteU8
((data >> 8) & 0xff);
168
}
169
void
170
TagBuffer::WriteU32
(uint32_t
data
)
171
{
172
WriteU8
((data >> 0) & 0xff);
173
WriteU8
((data >> 8) & 0xff);
174
WriteU8
((data >> 16) & 0xff);
175
WriteU8
((data >> 24) & 0xff);
176
}
177
178
uint8_t
179
TagBuffer::ReadU8
(
void
)
180
{
181
NS_ASSERT
(
m_current
+ 1 <=
m_end
);
182
uint8_t v;
183
v = *
m_current
;
184
m_current
++;
185
return
v;
186
}
187
188
uint16_t
189
TagBuffer::ReadU16
(
void
)
190
{
191
uint8_t byte0 =
ReadU8
();
192
uint8_t byte1 =
ReadU8
();
193
uint16_t
data
= byte1;
194
data <<= 8;
195
data |= byte0;
196
return
data
;
197
}
198
uint32_t
199
TagBuffer::ReadU32
(
void
)
200
{
201
uint8_t byte0 =
ReadU8
();
202
uint8_t byte1 =
ReadU8
();
203
uint8_t byte2 =
ReadU8
();
204
uint8_t byte3 =
ReadU8
();
205
uint32_t
data
= byte3;
206
data <<= 8;
207
data |= byte2;
208
data <<= 8;
209
data |= byte1;
210
data <<= 8;
211
data |= byte0;
212
return
data
;
213
}
214
215
}
// namespace ns3
216
217
#endif
/* TAG_BUFFER_USE_INLINE */
218
219
#endif
/* TAG_BUFFER_H */
ns3::TagBuffer::Write
void Write(const uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:125
ns3::TagBuffer::WriteU64
void WriteU64(uint64_t v)
Definition:
tag-buffer.cc:102
ns3::TagBuffer::WriteDouble
void WriteDouble(double v)
Definition:
tag-buffer.cc:115
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::TagBuffer::TrimAtEnd
void TrimAtEnd(uint32_t trim)
Definition:
tag-buffer.cc:192
ns3::TagBuffer::m_current
uint8_t * m_current
Definition:
tag-buffer.h:143
ns3::TagBuffer::ReadU32
TAG_BUFFER_INLINE uint32_t ReadU32(void)
Definition:
tag-buffer.h:199
visualizer.core.start
def start
Definition:
core.py:1482
ns3::TagBuffer::ReadU8
TAG_BUFFER_INLINE uint8_t ReadU8(void)
Definition:
tag-buffer.h:179
ns3::TagBuffer::ReadDouble
double ReadDouble(void)
Definition:
tag-buffer.cc:164
ns3::TagBuffer::m_end
uint8_t * m_end
Definition:
tag-buffer.h:144
data
uint8_t data[writeSize]
Definition:
socket-bound-tcp-static-routing.cc:53
ns3::TagBuffer::WriteU32
TAG_BUFFER_INLINE void WriteU32(uint32_t v)
Definition:
tag-buffer.h:170
ns3::TagBuffer::WriteU16
TAG_BUFFER_INLINE void WriteU16(uint16_t v)
Definition:
tag-buffer.h:164
TAG_BUFFER_INLINE
#define TAG_BUFFER_INLINE
Definition:
tag-buffer.h:28
ns3::TagBuffer::ReadU64
uint64_t ReadU64(void)
Definition:
tag-buffer.cc:134
ns3::TagBuffer::WriteU8
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Definition:
tag-buffer.h:156
ns3::TagBuffer
read and write tag data
Definition:
tag-buffer.h:51
ns3::TagBuffer::TagBuffer
TagBuffer(uint8_t *start, uint8_t *end)
Definition:
tag-buffer.cc:184
ns3::TagBuffer::Read
void Read(uint8_t *buffer, uint32_t size)
Definition:
tag-buffer.cc:176
ns3::TagBuffer::ReadU16
TAG_BUFFER_INLINE uint16_t ReadU16(void)
Definition:
tag-buffer.h:189
ns3::TagBuffer::CopyFrom
void CopyFrom(TagBuffer o)
Definition:
tag-buffer.cc:200
src
network
model
tag-buffer.h
Generated on Sat Apr 19 2014 14:07:05 for ns-3 by
1.8.6