src/internet-node/ipv4-interface.h
author Tom Henderson <tomh@tomh.org>
Sat, 06 Oct 2007 21:21:07 -0700
changeset 1776 0d5be0c3d229
parent 1341 f685d4bf320f
child 1795 820cc1254290
permissions -rw-r--r--
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
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) 2005,2006,2007 INRIA
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
 * Authors: 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
 *  Mathieu Lacage <mathieu.lacage@sophia.inria.fr>,
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
 *  Tom Henderson <tomh@tomh.org>
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
 */
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
#ifndef IPV4_INTERFACE_H
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
#define IPV4_INTERFACE_H
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    26
#include <list>
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 474
diff changeset
    27
#include "ns3/ipv4-address.h"
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
    28
#include "ns3/ptr.h"
1341
f685d4bf320f use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1333
diff changeset
    29
#include "ns3/object.h"
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    30
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    31
namespace ns3 {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
class NetDevice;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
class Packet;
345
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 236
diff changeset
    35
class TraceResolver;
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 236
diff changeset
    36
class TraceContext;
236
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
/**
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
 * \brief The IPv4 representation of a network interface
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
 *
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
 * This class roughly corresponds to the struct in_device
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
 * of Linux; the main purpose is to provide address-family
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
 * specific information (addresses) about an interface.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
 *
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
 * This class defines two APIs:
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
 *  - the public API which is expected to be used by both 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
 *    the IPv4 layer and the user during forwarding and 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
 *    configuration.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
 *  - the private API which is expected to be implemented
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
 *    by subclasses of this base class. One such subclass 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
 *    will be a Loopback interface which loops every
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
 *    packet sent back to the ipv4 layer. Another such 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
 *    subclass typically contains the Ipv4 <-> MAC address
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
 *    translation logic which will use most of the time the
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
 *    ARP/RARP protocols.
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    56
 *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    57
 * By default, Ipv4 interface are created in the "down" state
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    58
 * with ip address 192.168.0.1 and a matching mask. Before
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    59
 * becoming useable, the user must invoke SetUp on them
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    60
 * once the final Ipv4 address and mask has been set.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    61
 *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    62
 * Subclasses must implement the two methods:
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    63
 *   - Ipv4Interface::SendTo
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
 */
1341
f685d4bf320f use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1333
diff changeset
    65
class Ipv4Interface  : public Object
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
{
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
public:
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    69
   * \param nd the NetDevice associated to this Ipv4Interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    70
   *           This value can be zero in which case the MTU
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    71
   *           of this interface will be 2^(16-1).
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
   */
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
    73
  Ipv4Interface (Ptr<NetDevice> nd);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
  virtual ~Ipv4Interface();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    76
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    77
   * \returns the underlying NetDevice. This method can return
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    78
   *          zero if this interface has no associated NetDevice.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    79
   */
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
    80
  Ptr<NetDevice> GetDevice (void) const;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    82
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    83
   * \param a set the ipv4 address of this interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    84
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
  void SetAddress (Ipv4Address a);
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    86
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    87
   * \param mask set the ipv4 netmask of this interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    88
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
  void SetNetworkMask (Ipv4Mask mask);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    91
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    92
   * \returns the broadcast ipv4 address associated to this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    93
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
  Ipv4Address GetBroadcast (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    95
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    96
   * \returns the ipv4 netmask of this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    97
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
  Ipv4Mask GetNetworkMask (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    99
  /**
1776
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   100
   * \param configured routing metric (cost) of this interface
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   101
   */
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   102
  void SetMetric (uint16_t);
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   103
  /**
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   104
   * \returns configured routing metric (cost) of this interface
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   105
   */
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   106
  uint16_t GetMetric (void) const;
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   107
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   108
   * \returns the ipv4 address of this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   109
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
  Ipv4Address GetAddress (void) const;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   112
  /**
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   113
   * This function a pass-through to NetDevice GetMtu, modulo
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   114
   * the  LLC/SNAP header i.e., ipv4MTU = NetDeviceMtu - LLCSNAPSIZE
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   115
   * \returns the Maximum Transmission Unit associated to this interface.
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
   */
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
  uint16_t GetMtu (void) const;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
  /**
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
   * These are IP interface states and may be distinct from 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
   * NetDevice states, such as found in real implementations
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
   * (where the device may be down but IP interface state is still up).
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
   */
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   124
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   125
   * \returns true if this interface is enabled, false otherwise.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   126
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  bool IsUp (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   128
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   129
   * \returns true if this interface is disabled, false otherwise.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   130
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
  bool IsDown (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   132
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   133
   * Enable this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   134
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
  void SetUp (void);
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   136
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   137
   * Disable this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   138
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
  void SetDown (void);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   142
   * \param p packet to send
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   143
   * \param dest next hop address of packet.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   144
   *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   145
   * This method will eventually call the private
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   146
   * SendTo method which must be implemented by subclasses.
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
   */ 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
  void Send(Packet p, Ipv4Address dest);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
1341
f685d4bf320f use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1333
diff changeset
   150
protected:
f685d4bf320f use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1333
diff changeset
   151
  virtual void DoDispose (void);
f685d4bf320f use the Object::GetTraceResolver tracing support rather than the old adhoc tracing code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1333
diff changeset
   152
private:
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
  virtual void SendTo (Packet p, Ipv4Address dest) = 0;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
   154
  Ptr<NetDevice> m_netdevice;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
  bool m_ifup;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
  Ipv4Address m_address;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
  Ipv4Mask m_netmask;
1776
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1341
diff changeset
   158
  uint16_t m_metric;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
};
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
}; // namespace ns3
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
#endif