src/internet-node/ipv4-interface.h
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 11 Mar 2008 13:30:12 -0700
changeset 2592 3ebf97150166
parent 2542 a9b88fdc09d6
child 2595 b504951bcca8
permissions -rw-r--r--
get rid of CreateObjectWith
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 TraceContext;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
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
 * \brief The IPv4 representation of a network interface
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
 *
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
 * 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
    41
 * 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
    42
 * specific information (addresses) about an interface.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
 *
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
 * This class defines two APIs:
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
 *  - 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
    46
 *    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
    47
 *    configuration.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
 *  - 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
    49
 *    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
    50
 *    will be a Loopback interface which loops every
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
 *    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
    52
 *    subclass typically contains the Ipv4 <-> MAC address
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
 *    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
    54
 *    ARP/RARP protocols.
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    55
 *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    56
 * 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
    57
 * 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
    58
 * becoming useable, the user must invoke SetUp on them
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    59
 * 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
    60
 *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    61
 * Subclasses must implement the two methods:
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    62
 *   - Ipv4Interface::SendTo
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
 */
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
    64
class Ipv4Interface  : public Object
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
{
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
public:
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    68
   * \param nd the NetDevice associated to this Ipv4Interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    69
   *           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
    70
   *           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
    71
   */
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
    72
  Ipv4Interface ();
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  virtual ~Ipv4Interface();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    75
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    76
   * \returns the underlying NetDevice. This method can return
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    77
   *          zero if this interface has no associated NetDevice.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    78
   */
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2542
diff changeset
    79
  virtual Ptr<NetDevice> GetDevice (void) const = 0;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    80
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    81
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    82
   * \param a set the ipv4 address of this interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    83
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
  void SetAddress (Ipv4Address a);
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    85
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    86
   * \param mask set the ipv4 netmask of this interface.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    87
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  void SetNetworkMask (Ipv4Mask mask);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    90
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    91
   * \returns the broadcast ipv4 address associated to this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    92
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
  Ipv4Address GetBroadcast (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    94
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    95
   * \returns the ipv4 netmask of this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    96
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
  Ipv4Mask GetNetworkMask (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    98
  /**
1795
820cc1254290 get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1776
diff changeset
    99
   * \param metric configured routing metric (cost) of this interface
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
   */
1795
820cc1254290 get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1776
diff changeset
   101
  void SetMetric (uint16_t metric);
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
   102
  /**
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
   * \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
   104
   */
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
  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
   106
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   107
   * \returns the ipv4 address of this interface
03d3d3d4eacc document Ipv4Interface completely
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
  Ipv4Address GetAddress (void) const;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   110
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
   * 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
   113
   * 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
   114
   * \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
   115
   */
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
  uint16_t GetMtu (void) const;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
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
   * 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
   120
   * NetDevice states, such as found in real implementations
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
   * (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
   122
   */
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   123
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   124
   * \returns true if this interface is enabled, false otherwise.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   125
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
  bool IsUp (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   127
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   128
   * \returns true if this interface is disabled, false otherwise.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   129
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
  bool IsDown (void) const;
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   131
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   132
   * Enable this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   133
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
  void SetUp (void);
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   135
  /**
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   136
   * Disable this interface
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   137
   */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   138
  void SetDown (void);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
  /**
404
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   141
   * \param p packet to send
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   142
   * \param dest next hop address of packet.
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   143
   *
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   144
   * This method will eventually call the private
03d3d3d4eacc document Ipv4Interface completely
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   145
   * 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
   146
   */ 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1341
diff changeset
   147
  void Send(Ptr<Packet> p, Ipv4Address dest);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
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
   149
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
   150
  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
   151
private:
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1341
diff changeset
   152
  virtual void SendTo (Ptr<Packet> p, Ipv4Address dest) = 0;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
  bool m_ifup;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
  Ipv4Address m_address;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
  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
   156
  uint16_t m_metric;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
};
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
}; // namespace ns3
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
#endif