A Discrete-Event Network Simulator
API
ipv6-extension-header.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008-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 #ifndef IPV6_EXTENSION_HEADER_H
22 #define IPV6_EXTENSION_HEADER_H
23 
24 #include <vector>
25 #include <list>
26 #include <ostream>
27 
28 #include "ns3/header.h"
29 #include "ns3/ipv6-address.h"
30 #include "ipv6-option-header.h"
31 
32 namespace ns3
33 {
34 
40 class Ipv6ExtensionHeader : public Header
41 {
42 public:
47  static TypeId GetTypeId ();
48 
53  virtual TypeId GetInstanceTypeId () const;
54 
59 
63  virtual ~Ipv6ExtensionHeader ();
64 
69  void SetNextHeader (uint8_t nextHeader);
70 
75  uint8_t GetNextHeader () const;
76 
81  void SetLength (uint16_t length);
82 
87  uint16_t GetLength () const;
88 
93  virtual void Print (std::ostream &os) const;
94 
99  virtual uint32_t GetSerializedSize () const;
100 
105  virtual void Serialize (Buffer::Iterator start) const;
106 
112  virtual uint32_t Deserialize (Buffer::Iterator start);
113 
114 protected:
118  uint8_t m_length;
119 
120 private:
124  uint8_t m_nextHeader;
125 
130 };
131 
145 {
146 public:
151  OptionField (uint32_t optionsOffset);
152 
156  ~OptionField ();
157 
162  uint32_t GetSerializedSize () const;
163 
168  void Serialize (Buffer::Iterator start) const;
169 
176  uint32_t Deserialize (Buffer::Iterator start, uint32_t length);
177 
182  void AddOption (Ipv6OptionHeader const& option);
183 
189  uint32_t GetOptionsOffset ();
190 
196 
197 private:
198 
204  uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;
205 
210 
214  uint32_t m_optionsOffset;
215 };
216 
223 {
224 public:
229  static TypeId GetTypeId ();
230 
235  virtual TypeId GetInstanceTypeId () const;
236 
241 
245  virtual ~Ipv6ExtensionHopByHopHeader ();
246 
251  virtual void Print (std::ostream &os) const;
252 
257  virtual uint32_t GetSerializedSize () const;
258 
263  virtual void Serialize (Buffer::Iterator start) const;
264 
270  virtual uint32_t Deserialize (Buffer::Iterator start);
271 };
272 
279 {
280 public:
285  static TypeId GetTypeId ();
286 
291  virtual TypeId GetInstanceTypeId () const;
292 
297 
302 
307  virtual void Print (std::ostream &os) const;
308 
313  virtual uint32_t GetSerializedSize () const;
314 
319  virtual void Serialize (Buffer::Iterator start) const;
320 
326  virtual uint32_t Deserialize (Buffer::Iterator start);
327 };
328 
335 {
336 public:
341  static TypeId GetTypeId ();
342 
347  virtual TypeId GetInstanceTypeId () const;
348 
353 
357  virtual ~Ipv6ExtensionFragmentHeader ();
358 
363  void SetOffset (uint16_t offset);
364 
369  uint16_t GetOffset () const;
370 
375  void SetMoreFragment (bool moreFragment);
376 
381  bool GetMoreFragment () const;
382 
387  void SetIdentification (uint32_t identification);
388 
393  uint32_t GetIdentification () const;
394 
399  virtual void Print (std::ostream &os) const;
400 
405  virtual uint32_t GetSerializedSize () const;
406 
411  virtual void Serialize (Buffer::Iterator start) const;
412 
418  virtual uint32_t Deserialize (Buffer::Iterator start);
419 
420 private:
424  uint16_t m_offset;
425 
430 };
431 
438 {
439 public:
444  static TypeId GetTypeId ();
445 
450  virtual TypeId GetInstanceTypeId () const;
451 
456 
460  virtual ~Ipv6ExtensionRoutingHeader ();
461 
466  void SetTypeRouting (uint8_t typeRouting);
467 
472  uint8_t GetTypeRouting () const;
473 
478  void SetSegmentsLeft (uint8_t segmentsLeft);
479 
484  uint8_t GetSegmentsLeft () const;
485 
490  virtual void Print (std::ostream &os) const;
491 
496  virtual uint32_t GetSerializedSize () const;
497 
502  virtual void Serialize (Buffer::Iterator start) const;
503 
509  virtual uint32_t Deserialize (Buffer::Iterator start);
510 
511 private:
515  uint8_t m_typeRouting;
516 
520  uint8_t m_segmentsLeft;
521 };
522 
529 {
530 public:
535  static TypeId GetTypeId ();
536 
541  virtual TypeId GetInstanceTypeId () const;
542 
547 
552 
557  void SetNumberAddress (uint8_t n);
558 
563  void SetRoutersAddress (std::vector<Ipv6Address> routersAddress);
564 
569  std::vector<Ipv6Address> GetRoutersAddress () const;
570 
576  void SetRouterAddress (uint8_t index, Ipv6Address addr);
577 
583  Ipv6Address GetRouterAddress (uint8_t index) const;
584 
589  virtual void Print (std::ostream &os) const;
590 
595  virtual uint32_t GetSerializedSize () const;
596 
601  virtual void Serialize (Buffer::Iterator start) const;
602 
608  virtual uint32_t Deserialize (Buffer::Iterator start);
609 
610 private:
614  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
615 
620 };
621 
628 {
629 public:
634  static TypeId GetTypeId ();
635 
640  virtual TypeId GetInstanceTypeId () const;
641 
646 
650  virtual ~Ipv6ExtensionESPHeader ();
651 
656  virtual void Print (std::ostream &os) const;
657 
662  virtual uint32_t GetSerializedSize () const;
663 
668  virtual void Serialize (Buffer::Iterator start) const;
669 
675  virtual uint32_t Deserialize (Buffer::Iterator start);
676 };
677 
684 {
685 public:
690  static TypeId GetTypeId ();
691 
696  virtual TypeId GetInstanceTypeId () const;
697 
702 
706  virtual ~Ipv6ExtensionAHHeader ();
707 
712  virtual void Print (std::ostream &os) const;
713 
718  virtual uint32_t GetSerializedSize () const;
719 
724  virtual void Serialize (Buffer::Iterator start) const;
725 
731  virtual uint32_t Deserialize (Buffer::Iterator start);
732 };
733 
734 } // namespace ns3
735 
736 #endif /* IPV6_EXTENSION_HEADER_H */
737 
iterator in a Buffer instance
Definition: buffer.h:99
automatically resized byte buffer
Definition: buffer.h:93
Protocol header serialization and deserialization.
Definition: header.h:43
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Describes an IPv6 address.
Definition: ipv6-address.h:50
Header of IPv6 Extension AH.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~Ipv6ExtensionAHHeader()
Destructor.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type identificator.
Header of IPv6 Extension Destination.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~Ipv6ExtensionDestinationHeader()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Header of IPv6 Extension ESP.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~Ipv6ExtensionESPHeader()
Destructor.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Print(std::ostream &os) const
Print some information about the packet.
Header of IPv6 Extension Fragment.
virtual void Print(std::ostream &os) const
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
void SetIdentification(uint32_t identification)
Set the "Identification" field.
void SetOffset(uint16_t offset)
Set the "Offset" field.
uint32_t m_identification
Identifier of the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~Ipv6ExtensionFragmentHeader()
Destructor.
uint16_t m_offset
Offset of the fragment and More Fragment bit.
uint16_t GetOffset() const
Get the field "Offset".
bool GetMoreFragment() const
Get the status of "More Fragment" bit.
uint32_t GetIdentification() const
Get the field "Identification".
void SetMoreFragment(bool moreFragment)
Set the status of "More Fragment" bit.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Header for IPv6 Extension.
uint8_t m_nextHeader
The "next header" field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint16_t GetLength() const
Get the length of the extension.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type identificator.
void SetLength(uint16_t length)
brief Set the length of the extension.
Buffer m_data
The data of the extension.
void SetNextHeader(uint8_t nextHeader)
Set the "Next header" field.
virtual ~Ipv6ExtensionHeader()
Destructor.
virtual void Print(std::ostream &os) const
Print some information about the packet.
uint8_t GetNextHeader() const
Get the next header.
uint8_t m_length
The "length" field.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Header of IPv6 Extension "Hop by Hop".
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual ~Ipv6ExtensionHopByHopHeader()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Header of IPv6 Extension Routing : Type 0 (Loose Routing)
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
std::vector< Ipv6Address > GetRoutersAddress() const
Get the vector of routers' address.
void SetRoutersAddress(std::vector< Ipv6Address > routersAddress)
Set the vector of routers' address.
std::vector< Ipv6Address > VectorIpv6Address_t
A vector of IPv6 Address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
VectorIpv6Address_t m_routersAddress
The vector of Routers' IPv6 Address.
Ipv6Address GetRouterAddress(uint8_t index) const
Get a Router IPv6 Address.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetRouterAddress(uint8_t index, Ipv6Address addr)
Set a Router IPv6 Address.
virtual void Print(std::ostream &os) const
Print some information about the packet.
void SetNumberAddress(uint8_t n)
Set the number of routers' address.
Header of IPv6 Extension Routing.
virtual ~Ipv6ExtensionRoutingHeader()
Destructor.
void SetTypeRouting(uint8_t typeRouting)
Set the "Type of Routing" field.
uint8_t m_typeRouting
Type of routing.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint8_t GetTypeRouting() const
Get the field "Type of Routing".
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint8_t GetSegmentsLeft() const
Get the field "Segments left".
static TypeId GetTypeId()
Get the type identificator.
virtual void Print(std::ostream &os) const
Print some information about the packet.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the "Segments left" field.
uint8_t m_segmentsLeft
Number of left segments.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Header for IPv6 Option.
Option field for an IPv6ExtensionHeader.
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
void AddOption(Ipv6OptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
void Serialize(Buffer::Iterator start) const
Serialize all added options.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Buffer GetOptionBuffer()
Get the buffer.
uint32_t GetOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header.
Buffer m_optionData
Data payload.
OptionField(uint32_t optionsOffset)
Constructor.
uint32_t m_optionsOffset
Offset.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
def start()
Definition: core.py:1853
represents the alignment requirements of an option header