src/internet-node/ipv4-interface.cc
author Craig Dowell <craigdo@ee.washington.edu>
Mon, 29 Oct 2007 12:48:01 -0700
changeset 1867 16deaedc0380
parent 1776 0d5be0c3d229
parent 1866 e7dbcc4df546
child 1870 67b3d2dea3d5
permissions -rw-r--r--
merge in packet.bundle
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
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
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
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ipv4-interface.h"
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 474
diff changeset
    23
#include "ns3/ipv4-address.h"
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 474
diff changeset
    24
#include "ns3/net-device.h"
1333
c0d66de933e9 convert TraceResolver * to Ptr<TraceResolver>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1325
diff changeset
    25
#include "ns3/trace-resolver.h"
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    26
#include "ns3/log.h"
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
    27
#include "ns3/packet.h"
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    28
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    29
NS_LOG_COMPONENT_DEFINE ("Ipv4Interface");
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
  /**
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
   * By default, Ipv4 interface are created in the "down" state
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
   * with ip address 192.168.0.1 and a matching mask. Before
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
   * becoming useable, the user must invoke SetUp on them
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    37
   * once the final Ipv4 address and mask has been set.
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    38
   */
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    39
Ipv4Interface::Ipv4Interface (Ptr<NetDevice> nd) 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
  : m_netdevice (nd), 
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: 1504
diff changeset
    41
    m_ifup(false),
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: 1504
diff changeset
    42
    m_metric(1)
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    43
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    44
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    45
  NS_LOG_PARAM ("(" << &nd << ")");
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    46
}
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
Ipv4Interface::~Ipv4Interface ()
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    49
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    50
  NS_LOG_FUNCTION;
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    51
}
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
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
    53
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
    54
Ipv4Interface::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
    55
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    56
  NS_LOG_FUNCTION;
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
    57
  m_netdevice = 0;
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
    58
  Object::DoDispose ();
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
    59
}
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
    60
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    61
Ptr<NetDevice>
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 524
diff changeset
    62
Ipv4Interface::GetDevice (void) const
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    64
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  return m_netdevice;
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
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
void 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
Ipv4Interface::SetAddress (Ipv4Address a)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    71
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    72
  NS_LOG_PARAM ("(" << a << ")");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
  m_address = a;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
}
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    75
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    76
void 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
Ipv4Interface::SetNetworkMask (Ipv4Mask mask)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    78
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    79
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    80
  NS_LOG_PARAM ("(" << mask << ")");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
  m_netmask = mask;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    82
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
Ipv4Address
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
Ipv4Interface::GetBroadcast (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    87
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  uint32_t mask = m_netmask.GetHostOrder ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
  uint32_t address = m_address.GetHostOrder ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  Ipv4Address broadcast = Ipv4Address (address | (~mask));
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
  return broadcast;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
}
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
    93
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
Ipv4Mask 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
Ipv4Interface::GetNetworkMask (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    97
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
  return m_netmask;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
}
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   100
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: 1504
diff changeset
   101
void
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: 1504
diff changeset
   102
Ipv4Interface::SetMetric (uint16_t metric)
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: 1504
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: 1504
diff changeset
   104
  NS_LOG_FUNCTION;
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: 1504
diff changeset
   105
  NS_LOG_PARAM ("(" << metric << ")");
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: 1504
diff changeset
   106
  m_metric = metric;
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: 1504
diff changeset
   107
}
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: 1504
diff changeset
   108
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: 1504
diff changeset
   109
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: 1504
diff changeset
   110
Ipv4Interface::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: 1504
diff changeset
   111
{
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: 1504
diff changeset
   112
  NS_LOG_FUNCTION;
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: 1504
diff changeset
   113
  return m_metric;
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: 1504
diff changeset
   114
}
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: 1504
diff changeset
   115
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
Ipv4Address 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
Ipv4Interface::GetAddress (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   119
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   120
  return m_address;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   122
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
uint16_t 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
Ipv4Interface::GetMtu (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   126
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
  if (m_netdevice == 0)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   128
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   129
      uint32_t mtu = (1<<16) - 1;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   130
      return mtu;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   132
  return m_netdevice->GetMtu ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   133
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   134
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   135
/**
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   136
 * These are IP interface states and may be distinct from 
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   137
 * NetDevice states, such as found in real implementations
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   138
 * (where the device may be down but IP interface state is still up).
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 568
diff changeset
   139
 */
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
bool 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   141
Ipv4Interface::IsUp (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   142
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   143
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
  return m_ifup;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   145
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   147
bool 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
Ipv4Interface::IsDown (void) const
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   150
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
  return !m_ifup;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   152
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   153
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   154
void 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
Ipv4Interface::SetUp (void)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   156
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   157
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   158
  m_ifup = true;
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
void 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   162
Ipv4Interface::SetDown (void)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   163
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   164
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
  m_ifup = false;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   166
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   168
// public wrapper on private virtual function
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
void 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1504
diff changeset
   170
Ipv4Interface::Send(Ptr<Packet> p, Ipv4Address dest)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   171
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   172
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   173
  if (IsUp()) {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   174
    NS_LOG_LOGIC ("SendTo");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
    SendTo(p, dest);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   176
  }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   177
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   178
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   179
}; // namespace ns3
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   180