A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-option.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: David Gross <gdavid.devel@gmail.com>
7 */
8
9#include "ipv6-option.h"
10
11#include "ipv6-option-header.h"
12
13#include "ns3/assert.h"
14#include "ns3/log.h"
15#include "ns3/uinteger.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("Ipv6Option");
21
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::Ipv6Option")
29 .SetGroupName("Internet")
30 .AddAttribute("OptionNumber",
31 "The IPv6 option number.",
35 return tid;
36}
37
42
43void
45{
46 NS_LOG_FUNCTION(this << node);
47 m_node = node;
48}
49
51
54{
55 static TypeId tid = TypeId("ns3::Ipv6OptionPad1")
57 .SetGroupName("Internet")
58 .AddConstructor<Ipv6OptionPad1>();
59 return tid;
60}
61
66
71
72uint8_t
74{
75 NS_LOG_FUNCTION(this);
76
77 return OPT_NUMBER;
78}
79
80uint8_t
82 uint8_t offset,
83 const Ipv6Header& ipv6Header,
84 bool& isDropped)
85{
86 NS_LOG_FUNCTION(this << packet << offset << ipv6Header << isDropped);
87
88 Ptr<Packet> p = packet->Copy();
89 p->RemoveAtStart(offset);
90
91 Ipv6OptionPad1Header pad1Header;
92 p->RemoveHeader(pad1Header);
93
94 isDropped = false;
95
96 return pad1Header.GetSerializedSize();
97}
98
100
101TypeId
103{
104 static TypeId tid = TypeId("ns3::Ipv6OptionPadn")
106 .SetGroupName("Internet")
107 .AddConstructor<Ipv6OptionPadn>();
108 return tid;
109}
110
115
120
121uint8_t
123{
124 NS_LOG_FUNCTION(this);
125
126 return OPT_NUMBER;
127}
128
129uint8_t
131 uint8_t offset,
132 const Ipv6Header& ipv6Header,
133 bool& isDropped)
134{
135 NS_LOG_FUNCTION(this << packet << offset << ipv6Header << isDropped);
136
137 Ptr<Packet> p = packet->Copy();
138 p->RemoveAtStart(offset);
139
140 Ipv6OptionPadnHeader padnHeader;
141 p->RemoveHeader(padnHeader);
142
143 isDropped = false;
144
145 return padnHeader.GetSerializedSize();
146}
147
149
150TypeId
152{
153 static TypeId tid = TypeId("ns3::Ipv6OptionJumbogram")
155 .SetGroupName("Internet")
156 .AddConstructor<Ipv6OptionJumbogram>();
157 return tid;
158}
159
164
169
170uint8_t
172{
173 NS_LOG_FUNCTION(this);
174
175 return OPT_NUMBER;
176}
177
178uint8_t
180 uint8_t offset,
181 const Ipv6Header& ipv6Header,
182 bool& isDropped)
183{
184 NS_LOG_FUNCTION(this << packet << offset << ipv6Header << isDropped);
185
186 Ptr<Packet> p = packet->Copy();
187 p->RemoveAtStart(offset);
188
189 Ipv6OptionJumbogramHeader jumbogramHeader;
190 p->RemoveHeader(jumbogramHeader);
191
192 isDropped = false;
193
194 return jumbogramHeader.GetSerializedSize();
195}
196
198
199TypeId
201{
202 static TypeId tid = TypeId("ns3::Ipv6OptionRouterAlert")
204 .SetGroupName("Internet")
205 .AddConstructor<Ipv6OptionRouterAlert>();
206 return tid;
207}
208
213
218
219uint8_t
221{
222 NS_LOG_FUNCTION(this);
223
224 return OPT_NUMBER;
225}
226
227uint8_t
229 uint8_t offset,
230 const Ipv6Header& ipv6Header,
231 bool& isDropped)
232{
233 NS_LOG_FUNCTION(this << packet << offset << ipv6Header << isDropped);
234
235 Ptr<Packet> p = packet->Copy();
236 p->RemoveAtStart(offset);
237
238 Ipv6OptionRouterAlertHeader routerAlertHeader;
239 p->RemoveHeader(routerAlertHeader);
240
241 isDropped = false;
242
243 return routerAlertHeader.GetSerializedSize();
244}
245
246} /* namespace ns3 */
Packet header for IPv6.
Definition ipv6-header.h:24
IPv6 Option base.
Definition ipv6-option.h:36
static TypeId GetTypeId()
Get the type identificator.
~Ipv6Option() override
Destructor.
virtual uint8_t GetOptionNumber() const =0
Get the option number.
Ptr< Node > m_node
The node.
Definition ipv6-option.h:80
void SetNode(Ptr< Node > node)
Set the node.
Header of IPv6 Option Jumbogram.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
IPv6 Option Jumbogram.
uint8_t GetOptionNumber() const override
Get the option number.
~Ipv6OptionJumbogram() override
Destructor.
static TypeId GetTypeId()
Get the type identificator.
uint8_t Process(Ptr< Packet > packet, uint8_t offset, const Ipv6Header &ipv6Header, bool &isDropped) override
Process method Called from Ipv6L3Protocol::Receive.
static const uint8_t OPT_NUMBER
Jumbogram option number.
Ipv6OptionJumbogram()
Constructor.
Header of IPv6 Option Pad1.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
IPv6 Option Pad1.
Definition ipv6-option.h:89
static TypeId GetTypeId()
Get the type identificator.
static const uint8_t OPT_NUMBER
Pad1 option number.
Definition ipv6-option.h:94
uint8_t GetOptionNumber() const override
Get the option number.
Ipv6OptionPad1()
Constructor.
~Ipv6OptionPad1() override
Destructor.
uint8_t Process(Ptr< Packet > packet, uint8_t offset, const Ipv6Header &ipv6Header, bool &isDropped) override
Process method.
Header of IPv6 Option Padn.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
IPv6 Option Padn.
~Ipv6OptionPadn() override
Destructor.
static const uint8_t OPT_NUMBER
PadN option number.
uint8_t GetOptionNumber() const override
Get the option number.
uint8_t Process(Ptr< Packet > packet, uint8_t offset, const Ipv6Header &ipv6Header, bool &isDropped) override
Process method.
Ipv6OptionPadn()
Constructor.
static TypeId GetTypeId()
Get the type identificator.
Header of IPv6 Option Router Alert.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
IPv6 Option Router Alert.
static const uint8_t OPT_NUMBER
Router alert option number.
uint8_t Process(Ptr< Packet > packet, uint8_t offset, const Ipv6Header &ipv6Header, bool &isDropped) override
Process method.
~Ipv6OptionRouterAlert() override
Destructor.
uint8_t GetOptionNumber() const override
Get the option number.
static TypeId GetTypeId()
Get the type identificator.
Ipv6OptionRouterAlert()
Constructor.
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35