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 
94  virtual void Print (std::ostream &os) const;
95 
100  virtual uint32_t GetSerializedSize () const;
101 
106  virtual void Serialize (Buffer::Iterator start) const;
107 
113  virtual uint32_t Deserialize (Buffer::Iterator start);
114 
115 protected:
119  uint8_t m_length;
120 
121 private:
125  uint8_t m_nextHeader;
126 
131 };
132 
146 {
147 public:
152  OptionField (uint32_t optionsOffset);
153 
157  ~OptionField ();
158 
163  uint32_t GetSerializedSize () const;
164 
169  void Serialize (Buffer::Iterator start) const;
170 
177  uint32_t Deserialize (Buffer::Iterator start, uint32_t length);
178 
183  void AddOption (Ipv6OptionHeader const& option);
184 
190  uint32_t GetOptionsOffset ();
191 
197 
198 private:
199 
205  uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;
206 
211 
215  uint32_t m_optionsOffset;
216 };
217 
224 {
225 public:
230  static TypeId GetTypeId ();
231 
236  virtual TypeId GetInstanceTypeId () const;
237 
242 
246  virtual ~Ipv6ExtensionHopByHopHeader ();
247 
253  virtual void Print (std::ostream &os) const;
254 
259  virtual uint32_t GetSerializedSize () const;
260 
265  virtual void Serialize (Buffer::Iterator start) const;
266 
272  virtual uint32_t Deserialize (Buffer::Iterator start);
273 };
274 
281 {
282 public:
287  static TypeId GetTypeId ();
288 
293  virtual TypeId GetInstanceTypeId () const;
294 
299 
304 
310  virtual void Print (std::ostream &os) const;
311 
316  virtual uint32_t GetSerializedSize () const;
317 
322  virtual void Serialize (Buffer::Iterator start) const;
323 
329  virtual uint32_t Deserialize (Buffer::Iterator start);
330 };
331 
338 {
339 public:
344  static TypeId GetTypeId ();
345 
350  virtual TypeId GetInstanceTypeId () const;
351 
356 
360  virtual ~Ipv6ExtensionFragmentHeader ();
361 
366  void SetOffset (uint16_t offset);
367 
372  uint16_t GetOffset () const;
373 
378  void SetMoreFragment (bool moreFragment);
379 
384  bool GetMoreFragment () const;
385 
390  void SetIdentification (uint32_t identification);
391 
396  uint32_t GetIdentification () const;
397 
403  virtual void Print (std::ostream &os) const;
404 
409  virtual uint32_t GetSerializedSize () const;
410 
415  virtual void Serialize (Buffer::Iterator start) const;
416 
422  virtual uint32_t Deserialize (Buffer::Iterator start);
423 
424 private:
428  uint16_t m_offset;
429 
434 };
435 
442 {
443 public:
448  static TypeId GetTypeId ();
449 
454  virtual TypeId GetInstanceTypeId () const;
455 
460 
464  virtual ~Ipv6ExtensionRoutingHeader ();
465 
470  void SetTypeRouting (uint8_t typeRouting);
471 
476  uint8_t GetTypeRouting () const;
477 
482  void SetSegmentsLeft (uint8_t segmentsLeft);
483 
488  uint8_t GetSegmentsLeft () const;
489 
495  virtual void Print (std::ostream &os) const;
496 
501  virtual uint32_t GetSerializedSize () const;
502 
507  virtual void Serialize (Buffer::Iterator start) const;
508 
514  virtual uint32_t Deserialize (Buffer::Iterator start);
515 
516 private:
520  uint8_t m_typeRouting;
521 
525  uint8_t m_segmentsLeft;
526 };
527 
534 {
535 public:
540  static TypeId GetTypeId ();
541 
546  virtual TypeId GetInstanceTypeId () const;
547 
552 
557 
562  void SetNumberAddress (uint8_t n);
563 
568  void SetRoutersAddress (std::vector<Ipv6Address> routersAddress);
569 
574  std::vector<Ipv6Address> GetRoutersAddress () const;
575 
581  void SetRouterAddress (uint8_t index, Ipv6Address addr);
582 
588  Ipv6Address GetRouterAddress (uint8_t index) const;
589 
595  virtual void Print (std::ostream &os) const;
596 
601  virtual uint32_t GetSerializedSize () const;
602 
607  virtual void Serialize (Buffer::Iterator start) const;
608 
614  virtual uint32_t Deserialize (Buffer::Iterator start);
615 
616 private:
620  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
621 
626 };
627 
634 {
635 public:
640  static TypeId GetTypeId ();
641 
646  virtual TypeId GetInstanceTypeId () const;
647 
652 
656  virtual ~Ipv6ExtensionESPHeader ();
657 
663  virtual void Print (std::ostream &os) const;
664 
669  virtual uint32_t GetSerializedSize () const;
670 
675  virtual void Serialize (Buffer::Iterator start) const;
676 
682  virtual uint32_t Deserialize (Buffer::Iterator start);
683 };
684 
691 {
692 public:
697  static TypeId GetTypeId ();
698 
703  virtual TypeId GetInstanceTypeId () const;
704 
709 
713  virtual ~Ipv6ExtensionAHHeader ();
714 
720  virtual void Print (std::ostream &os) const;
721 
726  virtual uint32_t GetSerializedSize () const;
727 
732  virtual void Serialize (Buffer::Iterator start) const;
733 
739  virtual uint32_t Deserialize (Buffer::Iterator start);
740 };
741 
742 } // namespace ns3
743 
744 #endif /* IPV6_EXTENSION_HEADER_H */
745 
Protocol header serialization and deserialization.
Definition: header.h:42
uint8_t m_length
The "length" field.
virtual void Print(std::ostream &os) const
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Header of IPv6 Extension ESP.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Buffer GetOptionBuffer()
Get the buffer.
Header for IPv6 Option.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Header of IPv6 Extension Routing.
void SetTypeRouting(uint8_t typeRouting)
Set the "Type of Routing" field.
uint16_t m_offset
Offset of the fragment and More Fragment bit.
Ipv6Address GetRouterAddress(uint8_t index) const
Get a Router IPv6 Address.
automatically resized byte buffer
Definition: buffer.h:92
def start()
Definition: core.py:1844
uint16_t GetOffset() const
Get the field "Offset".
virtual ~Ipv6ExtensionRoutingHeader()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
uint8_t GetNextHeader() const
Get the next header.
uint16_t GetLength() const
Get the length of the extension.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Buffer m_optionData
Data payload.
uint32_t GetIdentification() const
Get the field "Identification".
void SetOffset(uint16_t offset)
Set the "Offset" field.
static TypeId GetTypeId()
Get the type identificator.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
represents the alignment requirements of an option header
Header of IPv6 Extension "Hop by Hop".
iterator in a Buffer instance
Definition: buffer.h:98
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 ~Ipv6ExtensionDestinationHeader()
Destructor.
uint8_t m_nextHeader
The "next header" field.
std::vector< Ipv6Address > VectorIpv6Address_t
A vector of IPv6 Address.
Header of IPv6 Extension Routing : Type 0 (Loose Routing)
Option field for an IPv6ExtensionHeader.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Header of IPv6 Extension AH.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual ~Ipv6ExtensionESPHeader()
Destructor.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual void Print(std::ostream &os) const
Print some information about the packet.
VectorIpv6Address_t m_routersAddress
The vector of Routers&#39; IPv6 Address.
uint8_t GetTypeRouting() const
Get the field "Type of Routing".
void SetMoreFragment(bool moreFragment)
Set the status of "More Fragment" bit.
void SetIdentification(uint32_t identification)
Set the "Identification" field.
std::vector< Ipv6Address > GetRoutersAddress() const
Get the vector of routers&#39; address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint32_t m_optionsOffset
Offset.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~Ipv6ExtensionFragmentHeader()
Destructor.
void SetNextHeader(uint8_t nextHeader)
Set the "Next header" field.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Serialize(Buffer::Iterator start) const
Serialize all added options.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual ~Ipv6ExtensionAHHeader()
Destructor.
Buffer m_data
The data of the extension.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void AddOption(Ipv6OptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
virtual ~Ipv6ExtensionHeader()
Destructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint32_t m_identification
Identifier of the packet.
Describes an IPv6 address.
Definition: ipv6-address.h:49
void SetRoutersAddress(std::vector< Ipv6Address > routersAddress)
Set the vector of routers&#39; address.
bool GetMoreFragment() const
Get the status of "More Fragment" bit.
Header of IPv6 Extension Destination.
uint32_t GetOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Header for IPv6 Extension.
virtual void Print(std::ostream &os) const
Print some information about the packet.
uint8_t m_typeRouting
Type of routing.
Header of IPv6 Extension Fragment.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
void SetLength(uint16_t length)
brief Set the length of the extension.
OptionField(uint32_t optionsOffset)
Constructor.
virtual ~Ipv6ExtensionHopByHopHeader()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint8_t m_segmentsLeft
Number of left segments.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Print(std::ostream &os) const
Print some information about the packet.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint8_t GetSegmentsLeft() const
Get the field "Segments left".
virtual void Print(std::ostream &os) const
Print some information about the packet.
void SetRouterAddress(uint8_t index, Ipv6Address addr)
Set a Router IPv6 Address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
void SetNumberAddress(uint8_t n)
Set the number of routers&#39; address.
a unique identifier for an interface.
Definition: type-id.h:58
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual ~Ipv6ExtensionLooseRoutingHeader()
Destructor.
virtual void Print(std::ostream &os) const
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the "Segments left" field.