A Discrete-Event Network Simulator
API
ipv6-extension-header.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2009 Strasbourg University
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: David Gross <gdavid.devel@gmail.com>
18  */
19 
20 #ifndef IPV6_EXTENSION_HEADER_H
21 #define IPV6_EXTENSION_HEADER_H
22 
23 #include "ipv6-option-header.h"
24 
25 #include "ns3/header.h"
26 #include "ns3/ipv6-address.h"
27 
28 #include <list>
29 #include <ostream>
30 #include <vector>
31 
32 namespace ns3
33 {
34 
41 {
42  public:
47  static TypeId GetTypeId();
48 
53  TypeId GetInstanceTypeId() const override;
54 
59 
63  ~Ipv6ExtensionHeader() override;
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  void Print(std::ostream& os) const override;
94 
99  uint32_t GetSerializedSize() const override;
100 
105  void Serialize(Buffer::Iterator start) const override;
106 
112  uint32_t Deserialize(Buffer::Iterator start) override;
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(const Ipv6OptionHeader& option);
183 
189  uint32_t GetOptionsOffset() const;
190 
196 
197  private:
203  uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const;
204 
209 
213  uint32_t m_optionsOffset;
214 };
215 
222 {
223  public:
228  static TypeId GetTypeId();
229 
234  TypeId GetInstanceTypeId() const override;
235 
240 
244  ~Ipv6ExtensionHopByHopHeader() override;
245 
250  void Print(std::ostream& os) const override;
251 
256  uint32_t GetSerializedSize() const override;
257 
262  void Serialize(Buffer::Iterator start) const override;
263 
269  uint32_t Deserialize(Buffer::Iterator start) override;
270 };
271 
278 {
279  public:
284  static TypeId GetTypeId();
285 
290  TypeId GetInstanceTypeId() const override;
291 
296 
301 
306  void Print(std::ostream& os) const override;
307 
312  uint32_t GetSerializedSize() const override;
313 
318  void Serialize(Buffer::Iterator start) const override;
319 
325  uint32_t Deserialize(Buffer::Iterator start) override;
326 };
327 
334 {
335  public:
340  static TypeId GetTypeId();
341 
346  TypeId GetInstanceTypeId() const override;
347 
352 
356  ~Ipv6ExtensionFragmentHeader() override;
357 
362  void SetOffset(uint16_t offset);
363 
368  uint16_t GetOffset() const;
369 
374  void SetMoreFragment(bool moreFragment);
375 
380  bool GetMoreFragment() const;
381 
386  void SetIdentification(uint32_t identification);
387 
392  uint32_t GetIdentification() const;
393 
398  void Print(std::ostream& os) const override;
399 
404  uint32_t GetSerializedSize() const override;
405 
410  void Serialize(Buffer::Iterator start) const override;
411 
417  uint32_t Deserialize(Buffer::Iterator start) override;
418 
419  private:
423  uint16_t m_offset;
424 
429 };
430 
437 {
438  public:
443  static TypeId GetTypeId();
444 
449  TypeId GetInstanceTypeId() const override;
450 
455 
459  ~Ipv6ExtensionRoutingHeader() override;
460 
465  void SetTypeRouting(uint8_t typeRouting);
466 
471  uint8_t GetTypeRouting() const;
472 
477  void SetSegmentsLeft(uint8_t segmentsLeft);
478 
483  uint8_t GetSegmentsLeft() const;
484 
489  void Print(std::ostream& os) const override;
490 
495  uint32_t GetSerializedSize() const override;
496 
501  void Serialize(Buffer::Iterator start) const override;
502 
508  uint32_t Deserialize(Buffer::Iterator start) override;
509 
510  private:
514  uint8_t m_typeRouting;
515 
519  uint8_t m_segmentsLeft;
520 };
521 
528 {
529  public:
534  static TypeId GetTypeId();
535 
540  TypeId GetInstanceTypeId() const override;
541 
546 
551 
556  void SetNumberAddress(uint8_t n);
557 
562  void SetRoutersAddress(std::vector<Ipv6Address> routersAddress);
563 
568  std::vector<Ipv6Address> GetRoutersAddress() const;
569 
575  void SetRouterAddress(uint8_t index, Ipv6Address addr);
576 
582  Ipv6Address GetRouterAddress(uint8_t index) const;
583 
588  void Print(std::ostream& os) const override;
589 
594  uint32_t GetSerializedSize() const override;
595 
600  void Serialize(Buffer::Iterator start) const override;
601 
607  uint32_t Deserialize(Buffer::Iterator start) override;
608 
609  private:
613  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
614 
619 };
620 
627 {
628  public:
633  static TypeId GetTypeId();
634 
639  TypeId GetInstanceTypeId() const override;
640 
645 
649  ~Ipv6ExtensionESPHeader() override;
650 
655  void Print(std::ostream& os) const override;
656 
661  uint32_t GetSerializedSize() const override;
662 
667  void Serialize(Buffer::Iterator start) const override;
668 
674  uint32_t Deserialize(Buffer::Iterator start) override;
675 };
676 
683 {
684  public:
689  static TypeId GetTypeId();
690 
695  TypeId GetInstanceTypeId() const override;
696 
701 
705  ~Ipv6ExtensionAHHeader() override;
706 
711  void Print(std::ostream& os) const override;
712 
717  uint32_t GetSerializedSize() const override;
718 
723  void Serialize(Buffer::Iterator start) const override;
724 
730  uint32_t Deserialize(Buffer::Iterator start) override;
731 };
732 
733 } // namespace ns3
734 
735 #endif /* IPV6_EXTENSION_HEADER_H */
iterator in a Buffer instance
Definition: buffer.h:100
automatically resized byte buffer
Definition: buffer.h:94
Protocol header serialization and deserialization.
Definition: header.h:44
virtual uint32_t Deserialize(Buffer::Iterator start)=0
Deserialize the object from a buffer iterator.
Describes an IPv6 address.
Definition: ipv6-address.h:49
Header of IPv6 Extension AH.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~Ipv6ExtensionAHHeader() override
Destructor.
static TypeId GetTypeId()
Get the type identificator.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Header of IPv6 Extension Destination.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
~Ipv6ExtensionDestinationHeader() override
Destructor.
void Print(std::ostream &os) const override
Print some information about the packet.
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Header of IPv6 Extension ESP.
static TypeId GetTypeId()
Get the type identificator.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~Ipv6ExtensionESPHeader() override
Destructor.
Header of IPv6 Extension Fragment.
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 GetSerializedSize() const override
Get the serialized size of the packet.
uint32_t m_identification
Identifier of the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Print(std::ostream &os) const override
Print some information about the packet.
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".
~Ipv6ExtensionFragmentHeader() override
Destructor.
void SetMoreFragment(bool moreFragment)
Set the status of "More Fragment" bit.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Header for IPv6 Extension.
void Print(std::ostream &os) const override
Print some information about the packet.
uint8_t m_nextHeader
The "next header" field.
uint16_t GetLength() const
Get the length of the extension.
uint32_t GetSerializedSize() const override
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.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~Ipv6ExtensionHeader() override
Destructor.
void SetNextHeader(uint8_t nextHeader)
Set the "Next header" field.
uint8_t GetNextHeader() const
Get the next header.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint8_t m_length
The "length" field.
Header of IPv6 Extension "Hop by Hop".
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~Ipv6ExtensionHopByHopHeader() override
Destructor.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void Print(std::ostream &os) const override
Print some information about the packet.
Header of IPv6 Extension Routing : Type 0 (Loose Routing)
void Print(std::ostream &os) const override
Print some information about the packet.
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.
VectorIpv6Address_t m_routersAddress
The vector of Routers' IPv6 Address.
Ipv6Address GetRouterAddress(uint8_t index) const
Get a Router IPv6 Address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
~Ipv6ExtensionLooseRoutingHeader() override
Destructor.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
void SetRouterAddress(uint8_t index, Ipv6Address addr)
Set a Router IPv6 Address.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetNumberAddress(uint8_t n)
Set the number of routers' address.
Header of IPv6 Extension Routing.
void SetTypeRouting(uint8_t typeRouting)
Set the "Type of Routing" field.
uint8_t m_typeRouting
Type of routing.
uint8_t GetTypeRouting() const
Get the field "Type of Routing".
uint8_t GetSegmentsLeft() const
Get the field "Segments left".
static TypeId GetTypeId()
Get the type identificator.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetSegmentsLeft(uint8_t segmentsLeft)
Set the "Segments left" field.
uint8_t m_segmentsLeft
Number of left segments.
void Print(std::ostream &os) const override
Print some information about the packet.
~Ipv6ExtensionRoutingHeader() override
Destructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t GetSerializedSize() const override
Get the serialized size of the packet.
Header for IPv6 Option.
Option field for an IPv6ExtensionHeader.
uint32_t GetSerializedSize() const
Get the serialized size of the packet.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
void Serialize(Buffer::Iterator start) const
Serialize all added options.
uint32_t GetOptionsOffset() const
Get the offset where the options begin, measured from the start of the extension header.
uint32_t Deserialize(Buffer::Iterator start, uint32_t length)
Deserialize the packet.
Buffer GetOptionBuffer()
Get the buffer.
Buffer m_optionData
Data payload.
OptionField(uint32_t optionsOffset)
Constructor.
uint32_t m_optionsOffset
Offset.
void AddOption(const Ipv6OptionHeader &option)
Serialize the option, prepending pad1 or padn option as necessary.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
represents the alignment requirements of an option header