src/internet-node/ipv4-l3-protocol.h
author Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
Thu, 26 Jul 2007 12:26:21 +0100
changeset 983 47c42bd66fb7
parent 752 a4febfb8416f
child 1176 4894ea885c0f
permissions -rw-r--r--
Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol". Support sending IP broadcast (255.255.255.255) packets (bug #36).
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
// Copyright (c) 2006 Georgia Tech Research Corporation
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
// All rights reserved.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
// This program is free software; you can redistribute it and/or modify
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
// it under the terms of the GNU General Public License version 2 as
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
// published by the Free Software Foundation;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
// This program is distributed in the hope that it will be useful,
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    13
// GNU General Public License for more details.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    14
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    15
// You should have received a copy of the GNU General Public License
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    16
// along with this program; if not, write to the Free Software
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    18
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
// Author: George F. Riley<riley@ece.gatech.edu>
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
//
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
752
a4febfb8416f IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 734
diff changeset
    22
#ifndef IPV4_L3_PROTOCOL_H
a4febfb8416f IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 734
diff changeset
    23
#define IPV4_L3_PROTOCOL_H
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
#include <list>
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <stdint.h>
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    27
#include "ns3/callback-trace-source.h"
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    28
#include "ns3/array-trace-resolver.h"
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 513
diff changeset
    29
#include "ns3/ipv4-address.h"
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
    30
#include "ipv4-header.h"
555
4d3b2a77bc92 convert Node * to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
    31
#include "ns3/ptr.h"
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
    32
#include "ns3/ipv4.h"
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    33
#include "l3-protocol.h"
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
    34
#include "ipv4-static-routing.h"
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
namespace ns3 {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
class Packet;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
class NetDevice;
551
12ed30c77cab revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 548
diff changeset
    40
class Ipv4Interface;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
class Ipv4Address;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
class Ipv4Header;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
class Ipv4Route;
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 639
diff changeset
    44
class Node;
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    45
class TraceResolver;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    46
class TraceContext;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    49
class Ipv4L3Protocol : public L3Protocol 
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    50
{
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
public:
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    52
  static const uint16_t PROT_NUMBER;
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 242
diff changeset
    53
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    54
  enum TraceType {
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    55
    TX,
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    56
    RX,
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    57
    DROP,
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    58
    INTERFACES,
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    59
  };
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    60
  typedef ArrayTraceResolver<Ipv4Interface>::Index InterfaceIndex;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    61
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    62
  Ipv4L3Protocol(Ptr<Node> node);
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    63
  virtual ~Ipv4L3Protocol ();
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
406
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    65
  /**
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    66
   * \param context the trace context to use to construct the
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    67
   *        TraceResolver to return
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    68
   * \returns a TraceResolver which can resolve all traces
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    69
   *          performed in this object. The caller must
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    70
   *          delete the returned object.
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    71
   */
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    72
  virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
    73
406
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    74
  /**
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    75
   * \param ttl default ttl to use
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    76
   *
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    77
   * When we need to send an ipv4 packet, we use this default
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    78
   * ttl value.
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    79
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
  void SetDefaultTtl (uint8_t ttl);
406
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    81
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    82
  /**
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    83
   * \param device the device to match
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    84
   * \returns the matching interface, zero if not found.
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    85
   *
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    86
   * Try to find an Ipv4Interface whose NetDevice is equal to
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    87
   * the input NetDevice.
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    88
   */
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
    89
  Ipv4Interface *FindInterfaceForDevice (Ptr<const NetDevice> device);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
  /**
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
   * Lower layer calls this method after calling L3Demux::Lookup
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
   * The ARP subclass needs to know from which NetDevice this
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
   * packet is coming to:
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
   *    - implement a per-NetDevice ARP cache
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
   *    - send back arp replies on the right device
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
   */
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
    98
  virtual void Receive(Packet& p, Ptr<NetDevice> device);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
406
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   100
  /**
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   101
   * \param packet packet to send
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   102
   * \param source source address of packet
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   103
   * \param destination address of packet
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   104
   * \param protocol number of packet
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   105
   *
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   106
   * Higher-level layers call this method to send a packet
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   107
   * down the stack to the MAC and PHY layers.
c3f72daa6430 doxygen for Ipv4 class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   108
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   109
  void Send (Packet const &packet, Ipv4Address source, 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
	     Ipv4Address destination, uint8_t protocol);
237
6562b2679455 make Send method public
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 236
diff changeset
   111
639
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   112
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   113
    
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   114
  void AddHostRouteTo (Ipv4Address dest, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   115
                       Ipv4Address nextHop, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   116
                       uint32_t interface);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   117
  void AddHostRouteTo (Ipv4Address dest, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   118
                       uint32_t interface);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   119
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   120
  void AddNetworkRouteTo (Ipv4Address network, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   121
                          Ipv4Mask networkMask, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   122
                          Ipv4Address nextHop, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   123
                          uint32_t interface);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   124
  void AddNetworkRouteTo (Ipv4Address network, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   125
                          Ipv4Mask networkMask, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   126
                          uint32_t interface);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   127
  void SetDefaultRoute (Ipv4Address nextHop, 
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   128
                        uint32_t interface);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   129
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   130
  void Lookup (Ipv4Header const &ipHeader,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   131
               Packet packet,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   132
               Ipv4RoutingProtocol::RouteReplyCallback routeReply);
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   133
639
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   134
  uint32_t GetNRoutes (void);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   135
  Ipv4Route *GetRoute (uint32_t i);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   136
  void RemoveRoute (uint32_t i);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   137
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   138
  uint32_t AddInterface (Ptr<NetDevice> device);
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   139
  Ipv4Interface * GetInterface (uint32_t i) const;
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   140
  uint32_t GetNInterfaces (void) const;
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   141
4e3a1dc4b1e4 cleanup old dox and reorg header
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 633
diff changeset
   142
  
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   143
  void SetAddress (uint32_t i, Ipv4Address address);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   144
  void SetNetworkMask (uint32_t i, Ipv4Mask mask);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   145
  Ipv4Mask GetNetworkMask (uint32_t t) const;
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   146
  Ipv4Address GetAddress (uint32_t i) const;
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   147
  uint16_t GetMtu (uint32_t i) const;
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   148
  bool IsUp (uint32_t i) const;
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   149
  void SetUp (uint32_t i);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   150
  void SetDown (uint32_t i);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   151
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   152
  void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   153
                           int priority);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   154
513
b7c7ea629de9 make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 504
diff changeset
   155
protected:
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   156
513
b7c7ea629de9 make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 504
diff changeset
   157
  virtual void DoDispose (void);
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   158
513
b7c7ea629de9 make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 504
diff changeset
   159
private:
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   160
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   161
  void SendRealOut (bool found,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   162
                    Ipv4Route const &route,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   163
                    Packet packet,
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   164
                    Ipv4Header const &ipHeader);
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
   165
  bool Forwarding (Packet const &packet, Ipv4Header &ipHeader, Ptr<NetDevice> device);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
  void ForwardUp (Packet p, Ipv4Header const&ip);
551
12ed30c77cab revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 548
diff changeset
   167
  uint32_t AddIpv4Interface (Ipv4Interface *interface);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   168
  void SetupLoopback (void);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 415
diff changeset
   169
  TraceResolver *InterfacesCreateTraceResolver (TraceContext const &context) const;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
551
12ed30c77cab revert Ipv4Interface * -> Ptr<Ipv4Interface>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 548
diff changeset
   171
  typedef std::list<Ipv4Interface*> Ipv4InterfaceList;
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   172
  typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
  Ipv4InterfaceList m_interfaces;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
  uint32_t m_nInterfaces;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
  uint8_t m_defaultTtl;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   177
  uint16_t m_identification;
728
95c426b1cb60 rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 639
diff changeset
   178
  Ptr<Node> m_node;
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 406
diff changeset
   179
  CallbackTraceSource<Packet const &, uint32_t> m_txTrace;
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 406
diff changeset
   180
  CallbackTraceSource<Packet const &, uint32_t> m_rxTrace;
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
   181
  CallbackTraceSource<Packet const &> m_dropTrace;
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   182
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   183
  Ipv4RoutingProtocolList m_routingProtocols;
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   184
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   185
  Ptr<Ipv4StaticRouting> m_staticRouting;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   186
};
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   187
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   188
} // Namespace ns3
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   189
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 752
diff changeset
   190
#endif /* IPV4_L3_PROTOCOL_H */