A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv6-extension-header.h
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 
200  uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;
201 
206 
210  uint32_t m_optionsOffset;
211 };
212 
218 {
219 public:
224  static TypeId GetTypeId ();
225 
230  virtual TypeId GetInstanceTypeId () const;
231 
236 
240  virtual ~Ipv6ExtensionHopByHopHeader ();
241 
247  virtual void Print (std::ostream &os) const;
248 
253  virtual uint32_t GetSerializedSize () const;
254 
259  virtual void Serialize (Buffer::Iterator start) const;
260 
266  virtual uint32_t Deserialize (Buffer::Iterator start);
267 };
268 
274 {
275 public:
280  static TypeId GetTypeId ();
281 
286  virtual TypeId GetInstanceTypeId () const;
287 
292 
297 
303  virtual void Print (std::ostream &os) const;
304 
309  virtual uint32_t GetSerializedSize () const;
310 
315  virtual void Serialize (Buffer::Iterator start) const;
316 
322  virtual uint32_t Deserialize (Buffer::Iterator start);
323 };
324 
330 {
331 public:
336  static TypeId GetTypeId ();
337 
342  virtual TypeId GetInstanceTypeId () const;
343 
348 
352  virtual ~Ipv6ExtensionFragmentHeader ();
353 
358  void SetOffset (uint16_t offset);
359 
364  uint16_t GetOffset () const;
365 
370  void SetMoreFragment (bool moreFragment);
371 
376  bool GetMoreFragment () const;
377 
382  void SetIdentification (uint32_t identification);
383 
388  uint32_t GetIdentification () const;
389 
395  virtual void Print (std::ostream &os) const;
396 
401  virtual uint32_t GetSerializedSize () const;
402 
407  virtual void Serialize (Buffer::Iterator start) const;
408 
414  virtual uint32_t Deserialize (Buffer::Iterator start);
415 
416 private:
420  uint16_t m_offset;
421 
426 };
427 
433 {
434 public:
439  static TypeId GetTypeId ();
440 
445  virtual TypeId GetInstanceTypeId () const;
446 
451 
455  virtual ~Ipv6ExtensionRoutingHeader ();
456 
461  void SetTypeRouting (uint8_t typeRouting);
462 
467  uint8_t GetTypeRouting () const;
468 
473  void SetSegmentsLeft (uint8_t segmentsLeft);
474 
479  uint8_t GetSegmentsLeft () const;
480 
486  virtual void Print (std::ostream &os) const;
487 
492  virtual uint32_t GetSerializedSize () const;
493 
498  virtual void Serialize (Buffer::Iterator start) const;
499 
505  virtual uint32_t Deserialize (Buffer::Iterator start);
506 
507 private:
511  uint8_t m_typeRouting;
512 
516  uint8_t m_segmentsLeft;
517 };
518 
524 {
525 public:
530  static TypeId GetTypeId ();
531 
536  virtual TypeId GetInstanceTypeId () const;
537 
542 
547 
552  void SetNumberAddress (uint8_t n);
553 
558  void SetRoutersAddress (std::vector<Ipv6Address> routersAddress);
559 
564  std::vector<Ipv6Address> GetRoutersAddress () const;
565 
571  void SetRouterAddress (uint8_t index, Ipv6Address addr);
572 
578  Ipv6Address GetRouterAddress (uint8_t index) const;
579 
585  virtual void Print (std::ostream &os) const;
586 
591  virtual uint32_t GetSerializedSize () const;
592 
597  virtual void Serialize (Buffer::Iterator start) const;
598 
604  virtual uint32_t Deserialize (Buffer::Iterator start);
605 
606 private:
610  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
611 
616 };
617 
623 {
624 public:
629  static TypeId GetTypeId ();
630 
635  virtual TypeId GetInstanceTypeId () const;
636 
641 
645  virtual ~Ipv6ExtensionESPHeader ();
646 
652  virtual void Print (std::ostream &os) const;
653 
658  virtual uint32_t GetSerializedSize () const;
659 
664  virtual void Serialize (Buffer::Iterator start) const;
665 
671  virtual uint32_t Deserialize (Buffer::Iterator start);
672 };
673 
679 {
680 public:
685  static TypeId GetTypeId ();
686 
691  virtual TypeId GetInstanceTypeId () const;
692 
697 
701  virtual ~Ipv6ExtensionAHHeader ();
702 
708  virtual void Print (std::ostream &os) const;
709 
714  virtual uint32_t GetSerializedSize () const;
715 
720  virtual void Serialize (Buffer::Iterator start) const;
721 
727  virtual uint32_t Deserialize (Buffer::Iterator start);
728 };
729 
730 } // namespace ns3
731 
732 #endif /* IPV6_EXTENSION_HEADER_H */
733 
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.
Header of IPv6 Extension ESP.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Header for IPv6 Option.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
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.
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
Header of IPv6 Extension "Hop by Hop".
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.
Header of IPv6 Extension Routing : Type 0 (Loose Routing)
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.
Header of IPv6 Extension AH.
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:44
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".
Header of IPv6 Extension Destination.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Buffer GetOptionBuffer()
Get the buffer.
Header for IPv6 Extension.
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.
Header of IPv6 Extension Fragment.
void SetLength(uint16_t length)
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:44
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.