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
ipv6-option.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007-2009 Strasbourg University
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: David Gross <gdavid.devel@gmail.com>
19
*/
20
21
#include "ns3/log.h"
22
#include "ns3/assert.h"
23
#include "ns3/uinteger.h"
24
#include "
ipv6-option.h
"
25
#include "
ipv6-option-header.h
"
26
27
NS_LOG_COMPONENT_DEFINE
(
"Ipv6Option"
);
28
29
namespace
ns3
30
{
31
32
NS_OBJECT_ENSURE_REGISTERED
(Ipv6Option);
33
34
TypeId
Ipv6Option::GetTypeId
()
35
{
36
static
TypeId
tid =
TypeId
(
"ns3::Ipv6Option"
)
37
.
SetParent
<
Object
> ()
38
.AddAttribute (
"OptionNumber"
,
"The IPv6 option number."
,
39
UintegerValue
(0),
40
MakeUintegerAccessor (&
Ipv6Option::GetOptionNumber
),
41
MakeUintegerChecker<uint8_t> ())
42
;
43
return
tid;
44
}
45
46
Ipv6Option::~Ipv6Option
()
47
{
48
NS_LOG_FUNCTION_NOARGS
();
49
}
50
51
void
Ipv6Option::SetNode
(
Ptr<Node>
node)
52
{
53
NS_LOG_FUNCTION
(
this
<< node);
54
m_node
= node;
55
}
56
57
58
NS_OBJECT_ENSURE_REGISTERED
(
Ipv6OptionPad1
);
59
60
TypeId
Ipv6OptionPad1::GetTypeId
()
61
{
62
static
TypeId
tid =
TypeId
(
"ns3::Ipv6OptionPad1"
)
63
.
SetParent
<
Ipv6Option
> ()
64
.AddConstructor<Ipv6OptionPad1> ()
65
;
66
return
tid;
67
}
68
69
Ipv6OptionPad1::Ipv6OptionPad1
()
70
{
71
NS_LOG_FUNCTION_NOARGS
();
72
}
73
74
Ipv6OptionPad1::~Ipv6OptionPad1
()
75
{
76
NS_LOG_FUNCTION_NOARGS
();
77
}
78
79
uint8_t
Ipv6OptionPad1::GetOptionNumber
()
const
80
{
81
NS_LOG_FUNCTION_NOARGS
();
82
83
return
OPT_NUMBER
;
84
}
85
86
uint8_t
Ipv6OptionPad1::Process
(
Ptr<Packet>
packet, uint8_t offset,
Ipv6Header
const
& ipv6Header,
bool
& isDropped)
87
{
88
NS_LOG_FUNCTION
(
this
<< packet << offset << ipv6Header << isDropped);
89
90
Ptr<Packet>
p = packet->
Copy
();
91
p->
RemoveAtStart
(offset);
92
93
Ipv6OptionPad1Header
pad1Header;
94
p->
RemoveHeader
(pad1Header);
95
96
isDropped =
false
;
97
98
return
pad1Header.
GetSerializedSize
();
99
}
100
101
102
NS_OBJECT_ENSURE_REGISTERED
(
Ipv6OptionPadn
);
103
104
TypeId
Ipv6OptionPadn::GetTypeId
()
105
{
106
static
TypeId
tid =
TypeId
(
"ns3::Ipv6OptionPadn"
)
107
.
SetParent
<
Ipv6Option
> ()
108
.AddConstructor<Ipv6OptionPadn> ()
109
;
110
return
tid;
111
}
112
113
Ipv6OptionPadn::Ipv6OptionPadn
()
114
{
115
NS_LOG_FUNCTION_NOARGS
();
116
}
117
118
Ipv6OptionPadn::~Ipv6OptionPadn
()
119
{
120
NS_LOG_FUNCTION_NOARGS
();
121
}
122
123
uint8_t
Ipv6OptionPadn::GetOptionNumber
()
const
124
{
125
NS_LOG_FUNCTION_NOARGS
();
126
127
return
OPT_NUMBER
;
128
}
129
130
uint8_t
Ipv6OptionPadn::Process
(
Ptr<Packet>
packet, uint8_t offset,
Ipv6Header
const
& ipv6Header,
bool
& isDropped)
131
{
132
NS_LOG_FUNCTION
(
this
<< packet << offset << ipv6Header << isDropped);
133
134
Ptr<Packet>
p = packet->
Copy
();
135
p->
RemoveAtStart
(offset);
136
137
Ipv6OptionPadnHeader
padnHeader;
138
p->
RemoveHeader
(padnHeader);
139
140
isDropped =
false
;
141
142
return
padnHeader.
GetSerializedSize
();
143
}
144
145
146
NS_OBJECT_ENSURE_REGISTERED
(
Ipv6OptionJumbogram
);
147
148
TypeId
Ipv6OptionJumbogram::GetTypeId
()
149
{
150
static
TypeId
tid =
TypeId
(
"ns3::Ipv6OptionJumbogram"
)
151
.
SetParent
<
Ipv6Option
> ()
152
.AddConstructor<Ipv6OptionJumbogram> ()
153
;
154
return
tid;
155
}
156
157
Ipv6OptionJumbogram::Ipv6OptionJumbogram
()
158
{
159
NS_LOG_FUNCTION_NOARGS
();
160
}
161
162
Ipv6OptionJumbogram::~Ipv6OptionJumbogram
()
163
{
164
NS_LOG_FUNCTION_NOARGS
();
165
}
166
167
uint8_t
Ipv6OptionJumbogram::GetOptionNumber
()
const
168
{
169
NS_LOG_FUNCTION_NOARGS
();
170
171
return
OPT_NUMBER
;
172
}
173
174
uint8_t
Ipv6OptionJumbogram::Process
(
Ptr<Packet>
packet, uint8_t offset,
Ipv6Header
const
& ipv6Header,
bool
& isDropped)
175
{
176
NS_LOG_FUNCTION
(
this
<< packet << offset << ipv6Header << isDropped);
177
178
Ptr<Packet>
p = packet->
Copy
();
179
p->
RemoveAtStart
(offset);
180
181
Ipv6OptionJumbogramHeader
jumbogramHeader;
182
p->
RemoveHeader
(jumbogramHeader);
183
184
isDropped =
false
;
185
186
return
jumbogramHeader.
GetSerializedSize
();
187
}
188
189
190
NS_OBJECT_ENSURE_REGISTERED
(
Ipv6OptionRouterAlert
);
191
192
TypeId
Ipv6OptionRouterAlert::GetTypeId
()
193
{
194
static
TypeId
tid =
TypeId
(
"ns3::Ipv6OptionRouterAlert"
)
195
.
SetParent
<
Ipv6Option
> ()
196
.AddConstructor<Ipv6OptionRouterAlert> ()
197
;
198
return
tid;
199
}
200
201
Ipv6OptionRouterAlert::Ipv6OptionRouterAlert
()
202
{
203
NS_LOG_FUNCTION_NOARGS
();
204
}
205
206
Ipv6OptionRouterAlert::~Ipv6OptionRouterAlert
()
207
{
208
NS_LOG_FUNCTION_NOARGS
();
209
}
210
211
uint8_t
Ipv6OptionRouterAlert::GetOptionNumber
()
const
212
{
213
NS_LOG_FUNCTION_NOARGS
();
214
215
return
OPT_NUMBER
;
216
}
217
218
uint8_t
Ipv6OptionRouterAlert::Process
(
Ptr<Packet>
packet, uint8_t offset,
Ipv6Header
const
& ipv6Header,
bool
& isDropped)
219
{
220
NS_LOG_FUNCTION
(
this
<< packet << offset << ipv6Header << isDropped);
221
222
Ptr<Packet>
p = packet->
Copy
();
223
p->
RemoveAtStart
(offset);
224
225
Ipv6OptionRouterAlertHeader
routerAlertHeader;
226
p->
RemoveHeader
(routerAlertHeader);
227
228
isDropped =
false
;
229
230
return
routerAlertHeader.
GetSerializedSize
();
231
}
232
233
}
/* namespace ns3 */
234
src
internet
model
ipv6-option.cc
Generated on Tue Nov 13 2012 10:32:15 for ns-3 by
1.8.1.2