A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv6-extension.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-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_H
22 #define IPV6_EXTENSION_H
23 
24 #include <map>
25 #include <list>
26 
27 #include "ns3/object.h"
28 #include "ns3/node.h"
29 #include "ns3/ptr.h"
30 #include "ipv6-interface.h"
31 #include "ns3/ipv6-header.h"
32 #include "ns3/buffer.h"
33 #include "ns3/packet.h"
34 #include "ns3/random-variable-stream.h"
35 #include "ns3/ipv6-address.h"
36 #include "ns3/traced-callback.h"
37 
38 
39 namespace ns3 {
40 
47 class Ipv6Extension : public Object
48 {
49 public:
54  static TypeId GetTypeId ();
55 
59  Ipv6Extension ();
60 
64  virtual ~Ipv6Extension ();
65 
70  void SetNode (Ptr<Node> node);
71 
76  Ptr<Node> GetNode () const;
77 
82  virtual uint8_t GetExtensionNumber () const = 0;
83 
96  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped) = 0;
97 
111  virtual uint8_t ProcessOptions (Ptr<Packet>& packet, uint8_t offset, uint8_t length, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
112 
121  int64_t AssignStreams (int64_t stream);
122 
123 protected:
128 
133 
134 private:
139 };
140 
146 {
147 public:
151  static const uint8_t EXT_NUMBER = 0;
152 
157  static TypeId GetTypeId ();
158 
163 
168 
173  virtual uint8_t GetExtensionNumber () const;
174 
186  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
187 };
188 
194 {
195 public:
199  static const uint8_t EXT_NUMBER = 60;
200 
205  static TypeId GetTypeId ();
206 
211 
216 
221  virtual uint8_t GetExtensionNumber () const;
222 
234  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
235 };
236 
242 {
243 public:
247  static const uint8_t EXT_NUMBER = 44;
248 
253  static TypeId GetTypeId ();
254 
259 
264 
269  virtual uint8_t GetExtensionNumber () const;
270 
282  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
283 
290  void GetFragments (Ptr<Packet> packet, uint32_t fragmentSize, std::list<Ptr<Packet> >& listFragments);
291 
292 protected:
296  virtual void DoDispose ();
297 
298 private:
303  class Fragments : public SimpleRefCount<Fragments>
304  {
305 public:
309  Fragments ();
310 
314  ~Fragments ();
315 
322  void AddFragment (Ptr<Packet> fragment, uint16_t fragmentOffset, bool moreFragment);
323 
328  void SetUnfragmentablePart (Ptr<Packet> unfragmentablePart);
329 
334  bool IsEntire () const;
335 
340  Ptr<Packet> GetPacket () const;
341 
346  Ptr<Packet> GetPartialPacket () const;
347 
351  void SetTimeoutEventId (EventId event);
352 
356  void CancelTimeout ();
357 
358 private:
363 
367  std::list<std::pair<Ptr<Packet>, uint16_t> > m_packetFragments;
368 
373 
378  };
379 
386  void HandleFragmentsTimeout (std::pair<Ipv6Address, uint32_t> key, Ipv6Header & ipHeader);
387 
392  Ptr<Packet> GetPartialPacket () const;
393 
397  void SetTimeoutEventId (EventId event);
398 
402  void CancelTimeout ();
403 
404  typedef std::map<std::pair<Ipv6Address, uint32_t>, Ptr<Fragments> > MapFragments_t;
405 
409  MapFragments_t m_fragments;
410 };
411 
419 {
420 public:
424  static const uint8_t EXT_NUMBER = 43;
425 
430  static TypeId GetTypeId ();
431 
436 
441 
446  virtual uint8_t GetExtensionNumber () const;
447 
452  virtual uint8_t GetTypeRouting () const;
453 
466  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
467 };
468 
474 {
475 public:
480  static TypeId GetTypeId ();
481 
486 
490  virtual ~Ipv6ExtensionRoutingDemux ();
491 
496  void SetNode (Ptr<Node> node);
497 
502  void Insert (Ptr<Ipv6ExtensionRouting> extensionRouting);
503 
509  Ptr<Ipv6ExtensionRouting> GetExtensionRouting (uint8_t typeRouting);
510 
515  void Remove (Ptr<Ipv6ExtensionRouting> extensionRouting);
516 
517 protected:
521  virtual void DoDispose ();
522 
523 private:
524  typedef std::list<Ptr<Ipv6ExtensionRouting> > Ipv6ExtensionRoutingList_t;
525 
529  Ipv6ExtensionRoutingList_t m_extensionsRouting;
530 
535 };
536 
542 {
543 public:
547  static const uint8_t TYPE_ROUTING = 0;
548 
553  static TypeId GetTypeId ();
554 
559 
564 
569  virtual uint8_t GetTypeRouting () const;
570 
584  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
585 };
586 
592 {
593 public:
597  static const uint8_t EXT_NUMBER = 50;
598 
603  static TypeId GetTypeId ();
604 
608  Ipv6ExtensionESP ();
609 
614 
619  virtual uint8_t GetExtensionNumber () const;
620 
633  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
634 };
635 
641 {
642 public:
646  static const uint8_t EXT_NUMBER = 51;
647 
652  static TypeId GetTypeId ();
653 
657  Ipv6ExtensionAH ();
658 
662  ~Ipv6ExtensionAH ();
663 
668  virtual uint8_t GetExtensionNumber () const;
669 
682  virtual uint8_t Process (Ptr<Packet>& packet, uint8_t offset, Ipv6Header const& ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool& isDropped);
683 };
684 
685 } /* namespace ns3 */
686 
687 #endif /* IPV6_EXTENSION_H */
688 
void GetFragments(Ptr< Packet > packet, uint32_t fragmentSize, std::list< Ptr< Packet > > &listFragments)
Fragment a packet.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
Ptr< UniformRandomVariable > m_uvar
Provides uniform random variables.
IPv6 Extension base If you want to implement a new IPv6 extension, all you have to do is implement a ...
int64_t AssignStreams(int64_t stream)
Ipv6ExtensionLooseRouting()
Constructor.
Packet header for IPv6.
Definition: ipv6-header.h:33
virtual void DoDispose()
Dispose this object.
TracedCallback< Ptr< const Packet > > m_dropTrace
Drop trace callback.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
void Insert(Ptr< Ipv6ExtensionRouting > extensionRouting)
Insert a new IPv6 Routing Extension.
static const uint8_t EXT_NUMBER
Fragmentation extension number.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
void SetTimeoutEventId(EventId event)
Set the Timeout EventId.
void SetNode(Ptr< Node > node)
Set the node.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
virtual void DoDispose()
Dispose this object.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static TypeId GetTypeId()
Get the type identificator.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
static const uint8_t TYPE_ROUTING
Routing type.
static TypeId GetTypeId()
Get the type identificator.
virtual ~Ipv6ExtensionRoutingDemux()
Destructor.
Ipv6ExtensionRoutingDemux()
Constructor.
IPv6 Extension Destination.
Ipv6ExtensionFragment()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
IPv6 Extension Routing If you want to implement a new IPv6 routing extension, all you have to do is i...
void CancelTimeout()
Cancel the timeout event.
static TypeId GetTypeId()
Get the type identificator.
~Ipv6ExtensionHopByHop()
Destructor.
void SetTimeoutEventId(EventId event)
Set the Timeout EventId.
Ipv6ExtensionHopByHop()
Constructor.
void HandleFragmentsTimeout(std::pair< Ipv6Address, uint32_t > key, Ipv6Header &ipHeader)
Process the timeout for packet fragments.
Ptr< Packet > GetPacket() const
Get the entire packet.
Ptr< Packet > m_unfragmentable
The unfragmentable part.
IPv6 Extension ESP (Encapsulating Security Payload)
bool m_moreFragment
If other fragments will be sent.
~Ipv6ExtensionFragment()
Destructor.
void CancelTimeout()
Cancel the timeout event.
~Ipv6ExtensionRouting()
Destructor.
Ptr< Node > m_node
The node.
static TypeId GetTypeId()
Get the type identificator.
Ipv6ExtensionDestination()
Constructor.
IPv6 Extension Routing Demux.
void SetUnfragmentablePart(Ptr< Packet > unfragmentablePart)
Set the unfragmentable part of the packet.
bool IsEntire() const
If all fragments have been added.
IPv6 Extension "Hop By Hop".
Ptr< Node > GetNode() const
Get the node.
void Remove(Ptr< Ipv6ExtensionRouting > extensionRouting)
Remove a routing extension from this demux.
void AddFragment(Ptr< Packet > fragment, uint16_t fragmentOffset, bool moreFragment)
Add a fragment.
void SetNode(Ptr< Node > node)
Set the node.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
virtual uint8_t ProcessOptions(Ptr< Packet > &packet, uint8_t offset, uint8_t length, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process options Called by implementing classes to process the options.
static TypeId GetTypeId()
Get the type identificator.
MapFragments_t m_fragments
The hash of fragmented packets.
static TypeId GetTypeId()
The interface ID.
static TypeId GetTypeId()
Get the type identificator.
Ptr< Ipv6ExtensionRouting > GetExtensionRouting(uint8_t typeRouting)
Get the routing extension corresponding to typeRouting.
~Ipv6ExtensionESP()
Destructor.
Ipv6ExtensionAH()
Constructor.
static TypeId GetTypeId()
Get the type identificator.
IPv6 Extension Loose Routing.
virtual uint8_t GetExtensionNumber() const =0
Get the extension number.
static const uint8_t EXT_NUMBER
Hop-by-hop extension number.
Ipv6Extension()
Constructor.
IPv6 Extension Fragment.
EventId m_timeoutEventId
Timeout handler event.
Describes an IPv6 address.
Definition: ipv6-address.h:44
virtual uint8_t GetTypeRouting() const
Get the type of routing.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method.
an identifier for simulation events.
Definition: event-id.h:46
Ipv6ExtensionRouting()
Constructor.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
virtual uint8_t GetExtensionNumber() const
Get the extension number.
virtual uint8_t GetTypeRouting() const
Get the type of routing.
static const uint8_t EXT_NUMBER
ESP extension number.
Ipv6ExtensionRoutingList_t m_extensionsRouting
List of IPv6 Routing Extensions supported.
std::list< std::pair< Ptr< Packet >, uint16_t > > m_packetFragments
The current fragments.
Ipv6ExtensionESP()
Constructor.
a base class which provides memory management and object aggregation
Definition: object.h:63
static const uint8_t EXT_NUMBER
Destination extension number.
Ptr< Node > m_node
The node.
static const uint8_t EXT_NUMBER
Routing extension number.
A template-based reference counting class.
a unique identifier for an interface.
Definition: type-id.h:44
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
static TypeId GetTypeId()
Get the type identificator.
static const uint8_t EXT_NUMBER
AH extension number.
~Ipv6ExtensionAH()
Destructor.
Ptr< Packet > GetPartialPacket() const
Get the packet parts so far received.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method Called from Ipv6L3Protocol::Receive.
virtual ~Ipv6Extension()
Destructor.
IPv6 Extension AH (Authentication Header)
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)
Process method.
virtual uint8_t Process(Ptr< Packet > &packet, uint8_t offset, Ipv6Header const &ipv6Header, Ipv6Address dst, uint8_t *nextHeader, bool &isDropped)=0
Process method Called from Ipv6L3Protocol::Receive.