A Discrete-Event Network Simulator
API
 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 
36 {
37  static TypeId tid = TypeId ("ns3::Ipv6Option")
38  .SetParent<Object> ()
39  .AddAttribute ("OptionNumber", "The IPv6 option number.",
40  UintegerValue (0),
41  MakeUintegerAccessor (&Ipv6Option::GetOptionNumber),
42  MakeUintegerChecker<uint8_t> ())
43  ;
44  return tid;
45 }
46 
48 {
50 }
51 
53 {
54  NS_LOG_FUNCTION (this << node);
55  m_node = node;
56 }
57 
58 
60  ;
61 
63 {
64  static TypeId tid = TypeId ("ns3::Ipv6OptionPad1")
66  .AddConstructor<Ipv6OptionPad1> ()
67  ;
68  return tid;
69 }
70 
72 {
74 }
75 
77 {
79 }
80 
82 {
84 
85  return OPT_NUMBER;
86 }
87 
88 uint8_t Ipv6OptionPad1::Process (Ptr<Packet> packet, uint8_t offset, Ipv6Header const& ipv6Header, bool& isDropped)
89 {
90  NS_LOG_FUNCTION (this << packet << offset << ipv6Header << isDropped);
91 
92  Ptr<Packet> p = packet->Copy ();
93  p->RemoveAtStart (offset);
94 
95  Ipv6OptionPad1Header pad1Header;
96  p->RemoveHeader (pad1Header);
97 
98  isDropped = false;
99 
100  return pad1Header.GetSerializedSize ();
101 }
102 
103 
105  ;
106 
108 {
109  static TypeId tid = TypeId ("ns3::Ipv6OptionPadn")
110  .SetParent<Ipv6Option> ()
111  .AddConstructor<Ipv6OptionPadn> ()
112  ;
113  return tid;
114 }
115 
117 {
119 }
120 
122 {
124 }
125 
127 {
129 
130  return OPT_NUMBER;
131 }
132 
133 uint8_t Ipv6OptionPadn::Process (Ptr<Packet> packet, uint8_t offset, Ipv6Header const& ipv6Header, 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 
148 
150  ;
151 
153 {
154  static TypeId tid = TypeId ("ns3::Ipv6OptionJumbogram")
155  .SetParent<Ipv6Option> ()
156  .AddConstructor<Ipv6OptionJumbogram> ()
157  ;
158  return tid;
159 }
160 
162 {
164 }
165 
167 {
169 }
170 
172 {
174 
175  return OPT_NUMBER;
176 }
177 
178 uint8_t Ipv6OptionJumbogram::Process (Ptr<Packet> packet, uint8_t offset, Ipv6Header const& ipv6Header, bool& isDropped)
179 {
180  NS_LOG_FUNCTION (this << packet << offset << ipv6Header << isDropped);
181 
182  Ptr<Packet> p = packet->Copy ();
183  p->RemoveAtStart (offset);
184 
185  Ipv6OptionJumbogramHeader jumbogramHeader;
186  p->RemoveHeader (jumbogramHeader);
187 
188  isDropped = false;
189 
190  return jumbogramHeader.GetSerializedSize ();
191 }
192 
193 
195  ;
196 
198 {
199  static TypeId tid = TypeId ("ns3::Ipv6OptionRouterAlert")
200  .SetParent<Ipv6Option> ()
201  .AddConstructor<Ipv6OptionRouterAlert> ()
202  ;
203  return tid;
204 }
205 
207 {
209 }
210 
212 {
214 }
215 
217 {
219 
220  return OPT_NUMBER;
221 }
222 
223 uint8_t Ipv6OptionRouterAlert::Process (Ptr<Packet> packet, uint8_t offset, Ipv6Header const& ipv6Header, bool& isDropped)
224 {
225  NS_LOG_FUNCTION (this << packet << offset << ipv6Header << isDropped);
226 
227  Ptr<Packet> p = packet->Copy ();
228  p->RemoveAtStart (offset);
229 
230  Ipv6OptionRouterAlertHeader routerAlertHeader;
231  p->RemoveHeader (routerAlertHeader);
232 
233  isDropped = false;
234 
235  return routerAlertHeader.GetSerializedSize ();
236 }
237 
238 } /* namespace ns3 */
239 
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
Ipv6OptionRouterAlert()
Constructor.
Definition: ipv6-option.cc:206
virtual ~Ipv6Option()
Destructor.
Definition: ipv6-option.cc:47
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-option.h:94
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
static TypeId GetTypeId()
Get the type identificator.
Definition: ipv6-option.cc:152
static TypeId GetTypeId()
Get the type identificator.
Definition: ipv6-option.cc:107
Doxygen introspection did not find any typical Config paths.
Ipv6OptionPadn()
Constructor.
Definition: ipv6-option.cc:116
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
static const uint8_t OPT_NUMBER
Router alert option number.
Definition: ipv6-option.h:240
static const uint8_t OPT_NUMBER
Pad1 option number.
Definition: ipv6-option.h:100
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Ipv6OptionJumbogram()
Constructor.
Definition: ipv6-option.cc:161
static TypeId GetTypeId()
Get the type identificator.
Definition: ipv6-option.cc:35
Ipv6OptionPad1()
Constructor.
Definition: ipv6-option.cc:71
~Ipv6OptionPad1()
Destructor.
Definition: ipv6-option.cc:76
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Definition: packet.cc:353
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: ipv6-option.cc:81
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Hold an unsigned integer type.
Definition: uinteger.h:46
virtual uint8_t Process(Ptr< Packet > packet, uint8_t offset, Ipv6Header const &ipv6Header, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
Definition: ipv6-option.cc:178
void SetNode(Ptr< Node > node)
Set the node.
Definition: ipv6-option.cc:52
Doxygen introspection did not find any typical Config paths.
~Ipv6OptionRouterAlert()
Destructor.
Definition: ipv6-option.cc:211
static const uint8_t OPT_NUMBER
PadN option number.
Definition: ipv6-option.h:147
virtual uint8_t Process(Ptr< Packet > packet, uint8_t offset, Ipv6Header const &ipv6Header, bool &isDropped)
Process method.
Definition: ipv6-option.cc:88
Ptr< Packet > Copy(void) const
Definition: packet.cc:122
virtual uint8_t GetOptionNumber() const =0
Get the option number.
static TypeId GetTypeId()
Get the type identificator.
Definition: ipv6-option.cc:197
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-option.h:141
~Ipv6OptionPadn()
Destructor.
Definition: ipv6-option.cc:121
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-option.h:234
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: ipv6-option.cc:126
~Ipv6OptionJumbogram()
Destructor.
Definition: ipv6-option.cc:166
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: ipv6-option.cc:216
virtual uint8_t GetOptionNumber() const
Get the option number.
Definition: ipv6-option.cc:171
static TypeId GetTypeId()
Get the type identificator.
Definition: ipv6-option.cc:62
static const uint8_t OPT_NUMBER
Jumbogram option number.
Definition: ipv6-option.h:194
Ptr< Node > m_node
The node.
Definition: ipv6-option.h:87
Doxygen introspection did not find any typical Config paths.
NS_LOG_COMPONENT_DEFINE("Ipv6Option")
a base class which provides memory management and object aggregation
Definition: object.h:63
virtual uint8_t Process(Ptr< Packet > packet, uint8_t offset, Ipv6Header const &ipv6Header, bool &isDropped)
Process method.
Definition: ipv6-option.cc:223
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-option.h:188
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-option.h:45
a unique identifier for an interface.
Definition: type-id.h:49
virtual uint8_t Process(Ptr< Packet > packet, uint8_t offset, Ipv6Header const &ipv6Header, bool &isDropped)
Process method.
Definition: ipv6-option.cc:133
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
Doxygen introspection did not find any typical Config paths.