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 protected:
118  uint8_t m_length;
119 
120 private:
124  uint8_t m_nextHeader;
125 
130 };
131 
143 {
144 public:
149  OptionField (uint32_t optionsOffset);
150 
154  ~OptionField ();
155 
160  uint32_t GetSerializedSize () const;
161 
166  void Serialize (Buffer::Iterator start) const;
167 
174  uint32_t Deserialize (Buffer::Iterator start, uint32_t length);
175 
180  void AddOption (Ipv6OptionHeader const& option);
181 
187  uint32_t GetOptionsOffset ();
188 
194 
195 private:
196 
202  uint32_t CalculatePad (Ipv6OptionHeader::Alignment alignment) const;
203 
208 
212  uint32_t m_optionsOffset;
213 };
214 
220 {
221 public:
226  static TypeId GetTypeId ();
227 
232  virtual TypeId GetInstanceTypeId () const;
233 
238 
242  virtual ~Ipv6ExtensionHopByHopHeader ();
243 
249  virtual void Print (std::ostream &os) const;
250 
255  virtual uint32_t GetSerializedSize () const;
256 
261  virtual void Serialize (Buffer::Iterator start) const;
262 
268  virtual uint32_t Deserialize (Buffer::Iterator start);
269 };
270 
276 {
277 public:
282  static TypeId GetTypeId ();
283 
288  virtual TypeId GetInstanceTypeId () const;
289 
294 
299 
305  virtual void Print (std::ostream &os) const;
306 
311  virtual uint32_t GetSerializedSize () const;
312 
317  virtual void Serialize (Buffer::Iterator start) const;
318 
324  virtual uint32_t Deserialize (Buffer::Iterator start);
325 };
326 
332 {
333 public:
338  static TypeId GetTypeId ();
339 
344  virtual TypeId GetInstanceTypeId () const;
345 
350 
354  virtual ~Ipv6ExtensionFragmentHeader ();
355 
360  void SetOffset (uint16_t offset);
361 
366  uint16_t GetOffset () const;
367 
372  void SetMoreFragment (bool moreFragment);
373 
378  bool GetMoreFragment () const;
379 
384  void SetIdentification (uint32_t identification);
385 
390  uint32_t GetIdentification () const;
391 
397  virtual void Print (std::ostream &os) const;
398 
403  virtual uint32_t GetSerializedSize () const;
404 
409  virtual void Serialize (Buffer::Iterator start) const;
410 
416  virtual uint32_t Deserialize (Buffer::Iterator start);
417 
418 private:
422  uint16_t m_offset;
423 
428 };
429 
435 {
436 public:
441  static TypeId GetTypeId ();
442 
447  virtual TypeId GetInstanceTypeId () const;
448 
453 
457  virtual ~Ipv6ExtensionRoutingHeader ();
458 
463  void SetTypeRouting (uint8_t typeRouting);
464 
469  uint8_t GetTypeRouting () const;
470 
475  void SetSegmentsLeft (uint8_t segmentsLeft);
476 
481  uint8_t GetSegmentsLeft () const;
482 
488  virtual void Print (std::ostream &os) const;
489 
494  virtual uint32_t GetSerializedSize () const;
495 
500  virtual void Serialize (Buffer::Iterator start) const;
501 
507  virtual uint32_t Deserialize (Buffer::Iterator start);
508 
509 private:
513  uint8_t m_typeRouting;
514 
518  uint8_t m_segmentsLeft;
519 };
520 
526 {
527 public:
532  static TypeId GetTypeId ();
533 
538  virtual TypeId GetInstanceTypeId () const;
539 
544 
549 
554  void SetNumberAddress (uint8_t n);
555 
560  void SetRoutersAddress (std::vector<Ipv6Address> routersAddress);
561 
566  std::vector<Ipv6Address> GetRoutersAddress () const;
567 
573  void SetRouterAddress (uint8_t index, Ipv6Address addr);
574 
580  Ipv6Address GetRouterAddress (uint8_t index) const;
581 
587  virtual void Print (std::ostream &os) const;
588 
593  virtual uint32_t GetSerializedSize () const;
594 
599  virtual void Serialize (Buffer::Iterator start) const;
600 
606  virtual uint32_t Deserialize (Buffer::Iterator start);
607 
608 private:
612  typedef std::vector<Ipv6Address> VectorIpv6Address_t;
613 
618 };
619 
625 {
626 public:
631  static TypeId GetTypeId ();
632 
637  virtual TypeId GetInstanceTypeId () const;
638 
643 
647  virtual ~Ipv6ExtensionESPHeader ();
648 
654  virtual void Print (std::ostream &os) const;
655 
660  virtual uint32_t GetSerializedSize () const;
661 
666  virtual void Serialize (Buffer::Iterator start) const;
667 
673  virtual uint32_t Deserialize (Buffer::Iterator start);
674 };
675 
681 {
682 public:
687  static TypeId GetTypeId ();
688 
693  virtual TypeId GetInstanceTypeId () const;
694 
699 
703  virtual ~Ipv6ExtensionAHHeader ();
704 
710  virtual void Print (std::ostream &os) const;
711 
716  virtual uint32_t GetSerializedSize () const;
717 
722  virtual void Serialize (Buffer::Iterator start) const;
723 
729  virtual uint32_t Deserialize (Buffer::Iterator start);
730 };
731 
732 } // namespace ns3
733 
734 #endif /* IPV6_EXTENSION_HEADER_H */
735 
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.
Introspection did not find any typical Config paths.
virtual TypeId GetInstanceTypeId() const
Get the instance type ID.
Introspection did not find any typical Config paths.
uint32_t CalculatePad(Ipv6OptionHeader::Alignment alignment) const
Calculate padding.
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
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.
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.
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:48
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".
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.
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.
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:58
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.