A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
39 class Ipv6ExtensionHeader : public Header
40 {
41 public:
46  static TypeId GetTypeId ();
47 
52  virtual TypeId GetInstanceTypeId () const;
53 
58 
62  virtual ~Ipv6ExtensionHeader ();
63 
68  void SetNextHeader (uint8_t nextHeader);
69 
74  uint8_t GetNextHeader () const;
75 
80  void SetLength (uint16_t length);
81 
86  uint16_t GetLength () const;
87 
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 private:
118  uint8_t m_nextHeader;
119 
123  uint8_t m_length;
124 
129 };
130 
142 {
143 public:
148  OptionField (uint32_t optionsOffset);
149 
153  ~OptionField ();
154 
159  uint32_t GetSerializedSize () const;
160 
165  void Serialize (Buffer::Iterator start) const;
166 
173  uint32_t Deserialize (Buffer::Iterator start, uint32_t length);
174 
179  void AddOption (Ipv6OptionHeader const& option);
180 
186  uint32_t GetOptionsOffset ();
187 
193 
194 private:
195 
201  uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;
202 
207 
211  uint32_t m_optionsOffset;
212 };
213 
219 {
220 public:
225  static TypeId GetTypeId ();
226 
231  virtual TypeId GetInstanceTypeId () const;
232 
237 
241  virtual ~Ipv6ExtensionHopByHopHeader ();
242 
248  virtual void Print (std::ostream &os) const;
249 
254  virtual uint32_t GetSerializedSize () const;
255 
260  virtual void Serialize (Buffer::Iterator start) const;
261 
267  virtual uint32_t Deserialize (Buffer::Iterator start);
268 };
269 
275 {
276 public:
281  static TypeId GetTypeId ();
282 
287  virtual TypeId GetInstanceTypeId () const;
288 
293 
298 
304  virtual void Print (std::ostream &os) const;
305 
310  virtual uint32_t GetSerializedSize () const;
311 
316  virtual void Serialize (Buffer::Iterator start) const;
317 
323  virtual uint32_t Deserialize (Buffer::Iterator start);
324 };
325 
331 {
332 public:
337  static TypeId GetTypeId ();
338 
343  virtual TypeId GetInstanceTypeId () const;
344 
349 
353  virtual ~Ipv6ExtensionFragmentHeader ();
354 
359  void SetOffset (uint16_t offset);
360 
365  uint16_t GetOffset () const;
366 
371  void SetMoreFragment (bool moreFragment);
372 
377  bool GetMoreFragment () const;
378 
383  void SetIdentification (uint32_t identification);
384 
389  uint32_t GetIdentification () const;
390 
396  virtual void Print (std::ostream &os) const;
397 
402  virtual uint32_t GetSerializedSize () const;
403 
408  virtual void Serialize (Buffer::Iterator start) const;
409 
415  virtual uint32_t Deserialize (Buffer::Iterator start);
416 
417 private:
421  uint16_t m_offset;
422 
427 };
428 
434 {
435 public:
440  static TypeId GetTypeId ();
441 
446  virtual TypeId GetInstanceTypeId () const;
447 
452 
456  virtual ~Ipv6ExtensionRoutingHeader ();
457 
462  void SetTypeRouting (uint8_t typeRouting);
463 
468  uint8_t GetTypeRouting () const;
469 
474  void SetSegmentsLeft (uint8_t segmentsLeft);
475 
480  uint8_t GetSegmentsLeft () const;
481 
487  virtual void Print (std::ostream &os) const;
488 
493  virtual uint32_t GetSerializedSize () const;
494 
499  virtual void Serialize (Buffer::Iterator start) const;
500 
506  virtual uint32_t Deserialize (Buffer::Iterator start);
507 
508 private:
512  uint8_t m_typeRouting;
513 
517  uint8_t m_segmentsLeft;
518 };
519 
525 {
526 public:
531  static TypeId GetTypeId ();
532 
537  virtual TypeId GetInstanceTypeId () const;
538 
543 
548 
553  void SetNumberAddress (uint8_t n);
554 
559  void SetRoutersAddress (std::vector<Ipv6Address> routersAddress);
560 
565  std::vector<Ipv6Address> GetRoutersAddress () const;
566 
572  void SetRouterAddress (uint8_t index, Ipv6Address addr);
573 
579  Ipv6Address GetRouterAddress (uint8_t index) const;
580 
586  virtual void Print (std::ostream &os) const;
587 
592  virtual uint32_t GetSerializedSize () const;
593 
598  virtual void Serialize (Buffer::Iterator start) const;
599 
605  virtual uint32_t Deserialize (Buffer::Iterator start);
606 
607 private:
611  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
612 
617 };
618 
624 {
625 public:
630  static TypeId GetTypeId ();
631 
636  virtual TypeId GetInstanceTypeId () const;
637 
642 
646  virtual ~Ipv6ExtensionESPHeader ();
647 
653  virtual void Print (std::ostream &os) const;
654 
659  virtual uint32_t GetSerializedSize () const;
660 
665  virtual void Serialize (Buffer::Iterator start) const;
666 
672  virtual uint32_t Deserialize (Buffer::Iterator start);
673 };
674 
680 {
681 public:
686  static TypeId GetTypeId ();
687 
692  virtual TypeId GetInstanceTypeId () const;
693 
698 
702  virtual ~Ipv6ExtensionAHHeader ();
703 
709  virtual void Print (std::ostream &os) const;
710 
715  virtual uint32_t GetSerializedSize () const;
716 
721  virtual void Serialize (Buffer::Iterator start) const;
722 
728  virtual uint32_t Deserialize (Buffer::Iterator start);
729 };
730 
731 } // namespace ns3
732 
733 #endif /* IPV6_EXTENSION_HEADER_H */
734 
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Protocol header serialization and deserialization.
Definition: header.h:42
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint8_t m_length
The "length" field.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Doxygen introspection did not find any typical Config paths.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Doxygen introspection did not find any typical Config paths.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
Doxygen introspection did not find any typical Config paths.
void SetTypeRouting(uint8_t typeRouting)
Set the "Type of Routing" field.
uint16_t m_offset
Offset of the fragment and More Fragment bit.
automatically resized byte buffer
Definition: buffer.h:92
virtual ~Ipv6ExtensionRoutingHeader()
Destructor.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
Buffer m_optionData
Data payload.
OptionField(uint32_t optionsOffset)
Constructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetOffset(uint16_t offset)
Set the "Offset" field.
static TypeId GetTypeId()
Get the type identificator.
static TypeId GetTypeId()
Get the type identificator.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
represents the alignment requirements of an option header
Doxygen introspection did not find any typical Config paths.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
iterator in a Buffer instance
Definition: buffer.h:98
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual ~Ipv6ExtensionDestinationHeader()
Destructor.
uint8_t m_nextHeader
The "next header" field.
std::vector< Ipv6Address > VectorIpv6Address_t
A vector of IPv6 Address.
Doxygen introspection did not find any typical Config paths.
Option field for an IPv6ExtensionHeader Enables adding options to an IPv6ExtensionHeader.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
Doxygen introspection did not find any typical Config paths.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual ~Ipv6ExtensionESPHeader()
Destructor.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
VectorIpv6Address_t m_routersAddress
The vector of Routers' IPv6 Address.
void SetMoreFragment(bool moreFragment)
Set the status of "More Fragment" bit.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetIdentification(uint32_t identification)
Set the "Identification" field.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
uint32_t m_optionsOffset
Offset.
virtual ~Ipv6ExtensionFragmentHeader()
Destructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
void SetNextHeader(uint8_t nextHeader)
Set the "Next header" field.
virtual ~Ipv6ExtensionAHHeader()
Destructor.
Buffer m_data
The data of the extension.
uint32_t GetOptionsOffset()
Get the offset where the options begin, measured from the start of the extension header.
virtual ~Ipv6ExtensionHeader()
Destructor.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Ipv6Address GetRouterAddress(uint8_t index) const
Get a Router IPv6 Address.
uint8_t GetTypeRouting() const
Get the field "Type of Routing".
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
bool GetMoreFragment() const
Get the status of "More Fragment" bit.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint32_t m_identification
Identifier of the packet.
uint8_t GetSegmentsLeft() const
Get the field "Segments left".
uint8_t GetNextHeader() const
Get the next header.
Describes an IPv6 address.
Definition: ipv6-address.h:46
void SetRoutersAddress(std::vector< Ipv6Address > routersAddress)
Set the vector of routers' address.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
void AddOption(Ipv6OptionHeader const &option)
Serialize the option, prepending pad1 or padn option as necessary.
uint32_t GetIdentification() const
Get the field "Identification".
Doxygen introspection did not find any typical Config paths.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Buffer GetOptionBuffer()
Get the buffer.
Doxygen introspection did not find any typical Config paths.
std::vector< Ipv6Address > GetRoutersAddress() const
Get the vector of routers' address.
uint8_t m_typeRouting
Type of routing.
virtual uint32_t GetSerializedSize() const
Get the serialized size of the packet.
Doxygen introspection did not find any typical Config paths.
void SetLength(uint16_t length)
brief Set the length of the extension.
virtual ~Ipv6ExtensionHopByHopHeader()
Destructor.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
static TypeId GetTypeId()
Get the type identificator.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
uint8_t m_segmentsLeft
Number of left segments.
void Serialize(Buffer::Iterator start) const
Serialize all added options.
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
uint16_t GetOffset() const
Get the field "Offset".
uint16_t GetLength() const
Get the length of the extension.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
void SetRouterAddress(uint8_t index, Ipv6Address addr)
Set a Router IPv6 Address.
virtual void Serialize(Buffer::Iterator start) const
Serialize the packet.
void SetNumberAddress(uint8_t n)
Set the number of routers' address.
a unique identifier for an interface.
Definition: type-id.h:49
virtual uint32_t Deserialize(Buffer::Iterator start)
Deserialize the packet.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
virtual ~Ipv6ExtensionLooseRoutingHeader()
Destructor.
virtual void Print(std::ostream &os) const
Print some informations about the packet.
static TypeId GetTypeId()
Get the type identificator.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the "Segments left" field.