src/internet-node/ipv4-l3-protocol.cc
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 13 Mar 2008 12:56:49 -0700
changeset 2602 d9262bff6df2
parent 2592 3ebf97150166
child 2711 83addb15f632
permissions -rw-r--r--
add back support for introspected doxygen.
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
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    22
#include "ns3/packet.h"
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    23
#include "ns3/log.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
    24
#include "ns3/callback.h"
524
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 514
diff changeset
    25
#include "ns3/ipv4-address.h"
082ffdd8fbd7 move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 514
diff changeset
    26
#include "ns3/ipv4-route.h"
729
b5e744285e92 rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 728
diff changeset
    27
#include "ns3/node.h"
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
    28
#include "ns3/net-device.h"
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    29
#include "ns3/uinteger.h"
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    30
#include "ns3/trace-source-accessor.h"
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    31
#include "ns3/object-vector.h"
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    32
733
fb1882e7d785 rename ipv4.h to ipv4-l3-protocol.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 729
diff changeset
    33
#include "ipv4-l3-protocol.h"
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
#include "ipv4-l4-protocol.h"
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    35
#include "ipv4-header.h"
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    36
#include "ipv4-interface.h"
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    37
#include "ipv4-loopback-interface.h"
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    38
#include "arp-ipv4-interface.h"
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
#include "ipv4-l4-demux.h"
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    40
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    41
NS_LOG_COMPONENT_DEFINE ("Ipv4L3Protocol");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
namespace ns3 {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    45
const uint16_t Ipv4L3Protocol::PROT_NUMBER = 0x0800;
293
007bc9e735f3 remove Ipv4L3Protocol class.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 287
diff changeset
    46
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
    47
NS_OBJECT_ENSURE_REGISTERED (Ipv4L3Protocol);
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
    48
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
    49
TypeId 
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
    50
Ipv4L3Protocol::GetTypeId (void)
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
    51
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2592
diff changeset
    52
  static TypeId tid = TypeId ("ns3::Ipv4L3Protocol")
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    53
    .SetParent<Object> ()
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    54
    .AddConstructor<Ipv4L3Protocol> ()
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    55
    .AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing packets generated on this node.",
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    56
                   Uinteger (64),
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    57
                   MakeUintegerAccessor (&Ipv4L3Protocol::m_defaultTtl),
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    58
                   MakeUintegerChecker<uint8_t> ())
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    59
    .AddTraceSource ("Tx", "Send ipv4 packet to outgoing interface.",
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    60
                   MakeTraceSourceAccessor (&Ipv4L3Protocol::m_txTrace))
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    61
    .AddTraceSource ("Rx", "Receive ipv4 packet from incoming interface.",
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    62
                     MakeTraceSourceAccessor (&Ipv4L3Protocol::m_rxTrace))
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    63
    .AddTraceSource ("Drop", "Drop ipv4 packet",
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    64
                     MakeTraceSourceAccessor (&Ipv4L3Protocol::m_dropTrace))
2537
c937f3317a1f be consistant in how lists of objects are named.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2503
diff changeset
    65
    .AddAttribute ("InterfaceList", "The set of Ipv4 interfaces associated to this Ipv4 stack.",
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    66
                   ObjectVector (),
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    67
                   MakeObjectVectorAccessor (&Ipv4L3Protocol::m_interfaces),
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    68
                   MakeObjectVectorChecker ())
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    69
    ;
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
    70
  return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
    71
}
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
    72
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    73
Ipv4L3Protocol::Ipv4L3Protocol()
1176
4894ea885c0f implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 983
diff changeset
    74
  : m_nInterfaces (0),
2498
e01570293b98 convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
    75
    m_identification (0)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    76
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    77
  NS_LOG_FUNCTION;
2230
9f13ac3291e0 add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1870
diff changeset
    78
  m_staticRouting = CreateObject<Ipv4StaticRouting> ();
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: 979
diff changeset
    79
  AddRoutingProtocol (m_staticRouting, 0);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
    80
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    81
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    82
Ipv4L3Protocol::~Ipv4L3Protocol ()
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    83
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    84
  NS_LOG_FUNCTION;
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    85
}
496
894c8380d57b use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    86
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    87
void
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    88
Ipv4L3Protocol::SetNode (Ptr<Node> node)
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    89
{
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    90
  m_node = node;
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    91
  SetupLoopback ();
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    92
}
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
    93
496
894c8380d57b use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    94
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
    95
Ipv4L3Protocol::DoDispose (void)
496
894c8380d57b use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    96
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
    97
  NS_LOG_FUNCTION;
496
894c8380d57b use Dispose more extensively
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 487
diff changeset
    98
  m_interfaces.clear ();
555
4d3b2a77bc92 convert Node * to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 551
diff changeset
    99
  m_node = 0;
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: 979
diff changeset
   100
  m_staticRouting->Dispose ();
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: 979
diff changeset
   101
  m_staticRouting = 0;
1176
4894ea885c0f implement the Node::ProtocolHandler support.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 983
diff changeset
   102
  Object::DoDispose ();
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   103
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   104
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   105
void
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   106
Ipv4L3Protocol::SetupLoopback (void)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   107
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   108
  NS_LOG_FUNCTION;
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   109
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
   110
  Ptr<Ipv4LoopbackInterface> interface = CreateObject<Ipv4LoopbackInterface> ();
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
   111
  interface->SetNode (m_node);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   112
  interface->SetAddress (Ipv4Address::GetLoopback ());
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   113
  interface->SetNetworkMask (Ipv4Mask::GetLoopback ());
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   114
  uint32_t index = AddIpv4Interface (interface);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   115
  AddHostRouteTo (Ipv4Address::GetLoopback (), index);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   116
  interface->SetUp ();
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   117
}
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   118
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   119
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   120
Ipv4L3Protocol::SetDefaultTtl (uint8_t ttl)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   121
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   122
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   123
  m_defaultTtl = ttl;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   124
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   125
    
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   126
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   127
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   128
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest, 
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
   129
                      Ipv4Address nextHop, 
47b41507a45a move channel.cc channel.h to node directory; merge ns-3-tracing from mathieu
Tom Henderson <tomh@tomh.org>
parents: 293
diff changeset
   130
                      uint32_t interface)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   131
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   132
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   133
  NS_LOG_PARAMS (this << dest << nextHop << interface);
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: 979
diff changeset
   134
  m_staticRouting->AddHostRouteTo (dest, nextHop, interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   135
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   136
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   137
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   138
Ipv4L3Protocol::AddHostRouteTo (Ipv4Address dest, 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   139
				uint32_t interface)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   140
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   141
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   142
  NS_LOG_PARAMS (this << dest << interface);
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: 979
diff changeset
   143
  m_staticRouting->AddHostRouteTo (dest, interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   144
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   145
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   146
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   147
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network, 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   148
				   Ipv4Mask networkMask, 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   149
				   Ipv4Address nextHop, 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   150
				   uint32_t interface)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   151
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   152
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   153
  NS_LOG_PARAMS (this << network << networkMask << nextHop << interface);
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: 979
diff changeset
   154
  m_staticRouting->AddNetworkRouteTo (network, networkMask, nextHop, interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   155
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   156
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   157
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   158
Ipv4L3Protocol::AddNetworkRouteTo (Ipv4Address network, 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   159
				   Ipv4Mask networkMask, 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   160
				   uint32_t interface)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   161
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   162
  NS_LOG_FUNCTION; 
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   163
  NS_LOG_PARAMS (this << network << networkMask << interface);
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: 979
diff changeset
   164
  m_staticRouting->AddNetworkRouteTo (network, networkMask, interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   165
}
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   166
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   167
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   168
Ipv4L3Protocol::SetDefaultRoute (Ipv4Address nextHop, 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   169
				 uint32_t interface)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   170
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   171
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   172
  NS_LOG_PARAMS (this << nextHop << interface);
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: 979
diff changeset
   173
  m_staticRouting->SetDefaultRoute (nextHop, interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   174
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   175
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: 979
diff changeset
   176
void
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   177
Ipv4L3Protocol::Lookup (
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   178
  Ipv4Header const &ipHeader,
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   179
  Ptr<Packet> packet,
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   180
  Ipv4RoutingProtocol::RouteReplyCallback routeReply)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   181
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   182
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   183
  NS_LOG_PARAMS (this << &ipHeader << packet << &routeReply);
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   184
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   185
  Lookup (Ipv4RoutingProtocol::IF_INDEX_ANY, ipHeader, packet, routeReply);
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   186
}
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: 979
diff changeset
   187
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: 979
diff changeset
   188
void
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   189
Ipv4L3Protocol::Lookup (
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   190
  uint32_t ifIndex,
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   191
  Ipv4Header const &ipHeader,
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   192
  Ptr<Packet> packet,
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   193
  Ipv4RoutingProtocol::RouteReplyCallback routeReply)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   194
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   195
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   196
  NS_LOG_PARAMS (this << ifIndex << &ipHeader << packet << &routeReply);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   197
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   198
  for (Ipv4RoutingProtocolList::const_iterator rprotoIter = 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   199
         m_routingProtocols.begin ();
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   200
       rprotoIter != m_routingProtocols.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   201
       rprotoIter++)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   202
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   203
      NS_LOG_LOGIC ("Requesting route");
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   204
      if ((*rprotoIter).second->RequestRoute (ifIndex, ipHeader, packet, 
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   205
                                              routeReply))
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: 979
diff changeset
   206
        return;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   207
    }
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   208
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   209
  if (ipHeader.GetDestination ().IsMulticast () && 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   210
      ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY)
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   211
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   212
      NS_LOG_LOGIC ("Multicast destination with local source");
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   213
//
1445
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   214
// We have a multicast packet originating from the current node and were not
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   215
// able to send it using the usual RequestRoute process.  Since the usual
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   216
// process includes trying to use a default multicast route, this means that
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   217
// there was no specific route out of the node found, and there was no default
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   218
// multicast route set.
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   219
//
1445
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   220
// The fallback position is to look for a default unicast route and use that
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   221
// to get the packet off the node if we have one.
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   222
//
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   223
      Ipv4Route *route = m_staticRouting->GetDefaultRoute ();
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   224
1445
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   225
      if (route)
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   226
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   227
          NS_LOG_LOGIC ("Local source. Using unicast default route for "
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   228
            "multicast packet");
1445
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   229
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   230
          routeReply (true, *route, packet, ipHeader);
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   231
          return;
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   232
        }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   233
    }
1445
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   234
//
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   235
// No route found
3fba36666488 Don't flood multicasts if no route found
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   236
//
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: 979
diff changeset
   237
  routeReply (false, Ipv4Route (), packet, 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: 979
diff changeset
   238
}
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: 979
diff changeset
   239
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: 979
diff changeset
   240
void
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: 979
diff changeset
   241
Ipv4L3Protocol::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: 979
diff changeset
   242
                                    int priority)
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: 979
diff changeset
   243
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   244
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   245
  NS_LOG_PARAMS (this << &routingProtocol << priority);
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: 979
diff changeset
   246
  m_routingProtocols.push_back
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: 979
diff changeset
   247
    (std::pair<int, Ptr<Ipv4RoutingProtocol> > (-priority, 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: 979
diff changeset
   248
  m_routingProtocols.sort ();
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   249
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   250
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   251
uint32_t 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   252
Ipv4L3Protocol::GetNRoutes (void)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   253
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   254
  NS_LOG_FUNCTION;
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: 979
diff changeset
   255
  return m_staticRouting->GetNRoutes ();
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   256
}
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: 979
diff changeset
   257
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   258
Ipv4Route *
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   259
Ipv4L3Protocol::GetRoute (uint32_t index)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   260
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   261
  NS_LOG_FUNCTION;
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: 979
diff changeset
   262
  return m_staticRouting->GetRoute (index);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   263
}
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: 979
diff changeset
   264
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   265
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   266
Ipv4L3Protocol::RemoveRoute (uint32_t index)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   267
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   268
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   269
  NS_LOG_PARAMS (this << index);
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: 979
diff changeset
   270
  m_staticRouting->RemoveRoute (index);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   271
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   272
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   273
void 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   274
Ipv4L3Protocol::AddMulticastRoute (Ipv4Address origin,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   275
                                   Ipv4Address group,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   276
                                   uint32_t inputInterface,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   277
                                   std::vector<uint32_t> outputInterfaces)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   278
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   279
  NS_LOG_FUNCTION; 
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   280
  NS_LOG_PARAMS (this << origin << group << inputInterface << &outputInterfaces);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   281
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   282
  m_staticRouting->AddMulticastRoute (origin, group, inputInterface,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   283
    outputInterfaces);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   284
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   285
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   286
void 
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1443
diff changeset
   287
Ipv4L3Protocol::SetDefaultMulticastRoute (uint32_t outputInterface)
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   288
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   289
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   290
  NS_LOG_PARAMS (this << outputInterface);
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   291
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1443
diff changeset
   292
  m_staticRouting->SetDefaultMulticastRoute (outputInterface);
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   293
}
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   294
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   295
uint32_t 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   296
Ipv4L3Protocol::GetNMulticastRoutes (void) const
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   297
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   298
  NS_LOG_FUNCTION;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   299
  return m_staticRouting->GetNMulticastRoutes ();
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   300
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   301
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   302
Ipv4MulticastRoute *
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   303
Ipv4L3Protocol::GetMulticastRoute (uint32_t index) const
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   304
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   305
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   306
  NS_LOG_PARAMS (this << index);
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   307
  return m_staticRouting->GetMulticastRoute (index);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   308
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   309
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   310
void 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   311
Ipv4L3Protocol::RemoveMulticastRoute (Ipv4Address origin,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   312
                                       Ipv4Address group,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   313
                                       uint32_t inputInterface)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   314
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   315
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   316
  NS_LOG_PARAMS (this << origin << group << inputInterface);
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   317
  m_staticRouting->RemoveMulticastRoute (origin, group, inputInterface);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   318
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   319
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   320
void 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   321
Ipv4L3Protocol::RemoveMulticastRoute (uint32_t index)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   322
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   323
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   324
  NS_LOG_PARAMS (this << index);
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   325
  m_staticRouting->RemoveMulticastRoute (index);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   326
}
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   327
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   328
uint32_t 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   329
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   330
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   331
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   332
  NS_LOG_PARAMS (this << &device);
2592
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
   333
  Ptr<ArpIpv4Interface> interface = CreateObject<ArpIpv4Interface> ();
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
   334
  interface->SetNode (m_node);
3ebf97150166 get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2537
diff changeset
   335
  interface->SetDevice (device);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   336
  return AddIpv4Interface (interface);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   337
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   338
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   339
uint32_t 
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
   340
Ipv4L3Protocol::AddIpv4Interface (Ptr<Ipv4Interface>interface)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   341
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   342
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   343
  NS_LOG_PARAMS (this << interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   344
  uint32_t index = m_nInterfaces;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   345
  m_interfaces.push_back (interface);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   346
  m_nInterfaces++;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   347
  return index;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   348
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   349
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
   350
Ptr<Ipv4Interface>
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   351
Ipv4L3Protocol::GetInterface (uint32_t index) const
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   352
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   353
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   354
  NS_LOG_PARAMS (this << index);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   355
  uint32_t tmp = 0;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   356
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   357
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   358
      if (index == tmp) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   359
	{
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   360
	  return *i;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   361
	}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   362
      tmp++;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   363
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   364
  return 0;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   365
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   366
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   367
uint32_t 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   368
Ipv4L3Protocol::GetNInterfaces (void) const
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   369
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   370
  NS_LOG_FUNCTION;
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   371
  return m_nInterfaces;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   372
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   373
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   374
uint32_t 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   375
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr) const
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   376
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   377
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   378
  NS_LOG_PARAMS (this << addr);
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   379
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   380
  uint32_t ifIndex = 0;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   381
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   382
       i != m_interfaces.end (); 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   383
       i++, ifIndex++)
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   384
    {
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   385
      if ((*i)->GetAddress () == addr)
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   386
        {
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   387
          return ifIndex;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   388
        }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   389
    }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   390
2326
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2325
diff changeset
   391
  NS_FATAL_ERROR ("Ipv4L3Protocol::FindInterfaceForAddr (): "
eec07777d1a2 Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2325
diff changeset
   392
                  "Interface not found for IP address " << addr);
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   393
  return 0;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   394
}
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   395
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   396
uint32_t 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   397
Ipv4L3Protocol::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   398
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   399
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   400
  NS_LOG_PARAMS (this << addr << mask);
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   401
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   402
  uint32_t ifIndex = 0;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   403
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   404
       i != m_interfaces.end (); 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   405
       i++, ifIndex++)
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   406
    {
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   407
      if ((*i)->GetAddress ().CombineMask (mask) == addr.CombineMask (mask))
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   408
        {
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   409
          return ifIndex;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   410
        }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   411
    }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   412
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   413
  NS_ASSERT_MSG(false, "Ipv4L3Protocol::FindInterfaceForAddr (): "
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   414
    "Interface not found for masked IP address");
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   415
  return 0;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   416
}
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   417
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
   418
Ptr<Ipv4Interface>
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   419
Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   420
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   421
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   422
  NS_LOG_PARAMS (this << &device);
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   423
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); i != m_interfaces.end (); i++)
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   424
    {
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
   425
      if ((*i)->GetDevice () == device)
242
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   426
        {
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   427
          return *i;
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   428
        }
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   429
    }
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   430
  return 0;
a44932709b47 add arp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 241
diff changeset
   431
}  
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   432
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   433
void 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   434
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   435
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   436
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   437
  NS_LOG_PARAMS (this << &device << packet << protocol <<  from);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   438
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   439
  NS_LOG_LOGIC ("Packet from " << from);
1443
580ed7a4dd1e Move MakeMulticastAddress to NetDevice
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   440
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   441
  uint32_t index = 0;
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   442
  Ptr<Ipv4Interface> ipv4Interface;
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   443
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin (); 
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   444
       i != m_interfaces.end (); 
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   445
       i++)
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   446
    {
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   447
      ipv4Interface = *i;
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   448
      if (ipv4Interface->GetDevice () == device)
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   449
        {
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   450
          m_rxTrace (packet, index);
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   451
          break;
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   452
        }
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   453
      index++;
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   454
    }
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   455
  Ipv4Header ipHeader;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   456
  packet->RemoveHeader (ipHeader);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   457
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   458
  if (!ipHeader.IsChecksumOk ()) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   459
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   460
      return;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   461
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   462
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   463
  if (Forwarding (index, packet, ipHeader, device)) 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   464
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   465
      return;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   466
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   467
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   468
  NS_LOG_LOGIC ("Forward up");
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   469
  ForwardUp (packet, ipHeader, ipv4Interface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   470
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   471
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: 979
diff changeset
   472
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   473
void 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   474
Ipv4L3Protocol::Send (Ptr<Packet> packet, 
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   475
            Ipv4Address source, 
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   476
            Ipv4Address destination,
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   477
            uint8_t protocol)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   478
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   479
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   480
  NS_LOG_PARAMS (this << packet << source << destination << protocol);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   481
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   482
  Ipv4Header ipHeader;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   483
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   484
  ipHeader.SetSource (source);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   485
  ipHeader.SetDestination (destination);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   486
  ipHeader.SetProtocol (protocol);
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   487
  ipHeader.SetPayloadSize (packet->GetSize ());
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   488
  ipHeader.SetTtl (m_defaultTtl);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   489
  ipHeader.SetMayFragment ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   490
  ipHeader.SetIdentification (m_identification);
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   491
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   492
  m_identification ++;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   493
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: 979
diff changeset
   494
  if (destination.IsBroadcast ())
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: 979
diff changeset
   495
    {
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: 979
diff changeset
   496
      uint32_t ifaceIndex = 0;
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: 979
diff changeset
   497
      for (Ipv4InterfaceList::iterator ifaceIter = m_interfaces.begin ();
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: 979
diff changeset
   498
           ifaceIter != m_interfaces.end (); ifaceIter++, ifaceIndex++)
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: 979
diff changeset
   499
        {
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
   500
          Ptr<Ipv4Interface> outInterface = *ifaceIter;
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   501
          Ptr<Packet> packetCopy = packet->Copy ();
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   502
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   503
          NS_ASSERT (packetCopy->GetSize () <= outInterface->GetMtu ());
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   504
          packetCopy->AddHeader (ipHeader);
1308
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   505
          m_txTrace (packetCopy, ifaceIndex);
5c5937a4150d backout 9856d1175cbb:642d6798feaa:27dd3e15308a
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1303
diff changeset
   506
          outInterface->Send (packetCopy, destination);
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: 979
diff changeset
   507
        }
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: 979
diff changeset
   508
    }
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: 979
diff changeset
   509
  else
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   510
    {
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: 979
diff changeset
   511
      // XXX Note here that in most ipv4 stacks in the world,
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: 979
diff changeset
   512
      // the route calculation for an outgoing packet is not
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: 979
diff changeset
   513
      // done in the ip layer. It is done within the application
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: 979
diff changeset
   514
      // socket when the first packet is sent to avoid this
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: 979
diff changeset
   515
      // costly lookup on a per-packet basis.
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: 979
diff changeset
   516
      // That would require us to get the route from the 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: 979
diff changeset
   517
      // most likely with a packet tag. The higher layers do not
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: 979
diff changeset
   518
      // do this yet for us.
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: 979
diff changeset
   519
      Lookup (ipHeader, 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: 979
diff changeset
   520
              MakeCallback (&Ipv4L3Protocol::SendRealOut, this));
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: 979
diff changeset
   521
    }
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: 979
diff changeset
   522
}
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: 979
diff changeset
   523
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: 979
diff changeset
   524
void
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: 979
diff changeset
   525
Ipv4L3Protocol::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: 979
diff changeset
   526
                             Ipv4Route const &route,
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   527
                             Ptr<Packet> packet,
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: 979
diff changeset
   528
                             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: 979
diff changeset
   529
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   530
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   531
  NS_LOG_PARAMS (this << found << &route << packet << &ipHeader);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   532
2325
084b07dceafb Add the IPv4 header before deciding whether to drop packets. Closes bug #135.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2324
diff changeset
   533
  packet->AddHeader (ipHeader);
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: 979
diff changeset
   534
  if (!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: 979
diff changeset
   535
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   536
      NS_LOG_WARN ("No route to host.  Drop.");
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
   537
      m_dropTrace (packet);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   538
      return;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   539
    }
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 1429
diff changeset
   540
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   541
  NS_LOG_LOGIC ("Send via interface " << route.GetInterface ());
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 1429
diff changeset
   542
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
   543
  Ptr<Ipv4Interface> outInterface = GetInterface (route.GetInterface ());
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   544
  NS_ASSERT (packet->GetSize () <= outInterface->GetMtu ());
457
a468fac09924 add context information to tx and rx trace callbacks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   545
  m_txTrace (packet, route.GetInterface ());
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   546
  if (route.IsGateway ()) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   547
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   548
      NS_LOG_LOGIC ("Send to gateway " << route.GetGateway ());
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   549
      outInterface->Send (packet, route.GetGateway ());
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   550
    } 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   551
  else 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   552
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   553
      NS_LOG_LOGIC ("Send to destination " << ipHeader.GetDestination ());
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: 979
diff changeset
   554
      outInterface->Send (packet, ipHeader.GetDestination ());
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   555
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   556
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   557
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   558
bool
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   559
Ipv4L3Protocol::Forwarding (
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   560
  uint32_t ifIndex, 
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   561
  Ptr<Packet> packet, 
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   562
  Ipv4Header &ipHeader, 
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   563
  Ptr<NetDevice> device)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   564
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   565
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   566
  NS_LOG_PARAMS (ifIndex << packet << &ipHeader<< device);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   567
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   568
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   569
       i != m_interfaces.end (); i++) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   570
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   571
      if ((*i)->GetAddress ().IsEqual (ipHeader.GetDestination ())) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   572
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   573
          NS_LOG_LOGIC ("For me (destination match)");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   574
          return false;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   575
        }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   576
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   577
  
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   578
  for (Ipv4InterfaceList::const_iterator i = m_interfaces.begin ();
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   579
       i != m_interfaces.end (); i++) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   580
    {
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
   581
      Ptr<Ipv4Interface> interface = *i;
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
   582
      if (interface->GetDevice () == device)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   583
	{
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   584
	  if (ipHeader.GetDestination ().IsEqual (interface->GetBroadcast ())) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   585
	    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   586
              NS_LOG_LOGIC ("For me (interface broadcast address)");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   587
	      return false;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   588
	    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   589
	  break;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   590
	}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   591
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   592
      
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: 979
diff changeset
   593
  if (ipHeader.GetDestination ().IsBroadcast ()) 
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   594
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   595
      NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   596
      return false;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   597
    }
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 1429
diff changeset
   598
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   599
  if (ipHeader.GetDestination ().IsEqual (Ipv4Address::GetAny ())) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   600
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   601
      NS_LOG_LOGIC ("For me (Ipv4Addr any address)");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   602
      return false;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   603
    }
1430
25fa26a6533e many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 1429
diff changeset
   604
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   605
  if (ipHeader.GetTtl () == 1) 
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   606
    {
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   607
      // Should send ttl expired here
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   608
      // XXX
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   609
      NS_LOG_LOGIC ("Not for me (TTL expired).  Drop");
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
   610
      m_dropTrace (packet);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   611
      return true;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   612
    }
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   613
  ipHeader.SetTtl (ipHeader.GetTtl () - 1);
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: 979
diff changeset
   614
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   615
  NS_LOG_LOGIC ("Forwarding packet.");
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   616
  Lookup (ifIndex, ipHeader, packet,
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: 979
diff changeset
   617
          MakeCallback (&Ipv4L3Protocol::SendRealOut, this));
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   618
//
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   619
// If this is a to a multicast address and this node is a member of the 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   620
// indicated group we need to return false so the multicast is forwarded up.
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   621
// Note that we may have just forwarded this packet too.
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   622
//
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   623
  for (Ipv4MulticastGroupList::const_iterator i = m_multicastGroups.begin ();
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   624
       i != m_multicastGroups.end (); i++) 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   625
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   626
      if ((*i).first.IsEqual (ipHeader.GetSource ()) &&
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   627
          (*i).second.IsEqual (ipHeader.GetDestination ()))
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   628
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   629
          NS_LOG_LOGIC ("For me (Joined multicast group)");
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   630
          return false;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   631
        }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   632
    }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   633
  
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   634
  NS_LOG_LOGIC("Not for me.");
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   635
  return true;
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   636
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   637
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   638
void
1866
e7dbcc4df546 do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1524
diff changeset
   639
Ipv4L3Protocol::ForwardUp (Ptr<Packet> p, Ipv4Header const&ip,
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   640
                           Ptr<Ipv4Interface> incomingInterface)
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   641
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   642
  NS_LOG_FUNCTION;
1870
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1828 1867
diff changeset
   643
  NS_LOG_PARAMS (this << p << &ip);
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   644
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   645
  Ptr<Ipv4L4Demux> demux = m_node->GetObject<Ipv4L4Demux> ();
568
e1660959ecbb use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 555
diff changeset
   646
  Ptr<Ipv4L4Protocol> protocol = demux->GetProtocol (ip.GetProtocol ());
1524
3ead2b66f2e4 Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 1504
diff changeset
   647
  protocol->Receive (p, ip.GetSource (), ip.GetDestination (), incomingInterface);
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   648
}
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   649
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   650
void 
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   651
Ipv4L3Protocol::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   652
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   653
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   654
  NS_LOG_PARAMS (this << origin << group);
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   655
  m_multicastGroups.push_back(
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   656
    std::pair<Ipv4Address, Ipv4Address> (origin, group));
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   657
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   658
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   659
void
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   660
Ipv4L3Protocol::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   661
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   662
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   663
  NS_LOG_PARAMS (this << origin << group);
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   664
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   665
  for (Ipv4MulticastGroupList::iterator i = m_multicastGroups.begin ();
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   666
       i != m_multicastGroups.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   667
       i++)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   668
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   669
      if ((*i).first.IsEqual(origin) && (*i).second.IsEqual(group))
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   670
        {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   671
          m_multicastGroups.erase (i);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   672
          return;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   673
        }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   674
    }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   675
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   676
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 1235
diff changeset
   677
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   678
Ipv4L3Protocol::SetAddress (uint32_t i, Ipv4Address address)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   679
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   680
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   681
  NS_LOG_PARAMS (this << i << address);
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
   682
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   683
  interface->SetAddress (address);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   684
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   685
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   686
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   687
Ipv4L3Protocol::SetNetworkMask (uint32_t i, Ipv4Mask mask)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   688
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   689
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   690
  NS_LOG_PARAMS (this << i << mask);
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
   691
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   692
  interface->SetNetworkMask (mask);
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   693
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   694
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   695
Ipv4Mask 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   696
Ipv4L3Protocol::GetNetworkMask (uint32_t i) const
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   697
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   698
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   699
  NS_LOG_PARAMS (this << i);
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
   700
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   701
  return interface->GetNetworkMask ();
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   702
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   703
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   704
Ipv4Address 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   705
Ipv4L3Protocol::GetAddress (uint32_t i) const
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   706
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   707
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   708
  NS_LOG_PARAMS (this << i);
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
   709
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   710
  return interface->GetAddress ();
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   711
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   712
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: 1524
diff changeset
   713
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: 1524
diff changeset
   714
Ipv4L3Protocol::SetMetric (uint32_t i, 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: 1524
diff changeset
   715
{
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: 1524
diff changeset
   716
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   717
  NS_LOG_PARAMS ("(" << i << ", " << 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: 1524
diff changeset
   718
  Ptr<Ipv4Interface> interface = GetInterface (i);
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: 1524
diff changeset
   719
  interface->SetMetric (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: 1524
diff changeset
   720
}
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: 1524
diff changeset
   721
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: 1524
diff changeset
   722
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: 1524
diff changeset
   723
Ipv4L3Protocol::GetMetric (uint32_t i) 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: 1524
diff changeset
   724
{
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: 1524
diff changeset
   725
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   726
  NS_LOG_PARAMS ("(" << i << ")");
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: 1524
diff changeset
   727
  Ptr<Ipv4Interface> interface = GetInterface (i);
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: 1524
diff changeset
   728
  return interface->GetMetric ();
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: 1524
diff changeset
   729
}
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: 1524
diff changeset
   730
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   731
bool
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   732
Ipv4L3Protocol::GetIfIndexForDestination (
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   733
  Ipv4Address destination, uint32_t& ifIndex) const
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   734
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   735
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   736
  NS_LOG_PARAMS (this << destination << &ifIndex);
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   737
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   738
// The first thing we do in trying to determine a source address is to 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   739
// consult the routing protocols.  These will also check for a default route
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   740
// if one has been set.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   741
//
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   742
  for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin ();
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   743
       i != m_routingProtocols.end (); 
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   744
       i++)
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   745
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   746
      NS_LOG_LOGIC ("Requesting Source Address");
1435
a70de165a25a set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents: 1434
diff changeset
   747
      uint32_t ifIndexTmp;
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   748
1435
a70de165a25a set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents: 1434
diff changeset
   749
      if ((*i).second->RequestIfIndex (destination, ifIndexTmp))
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   750
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   751
          NS_LOG_LOGIC ("Found ifIndex " << ifIndexTmp);
1435
a70de165a25a set source IP address in udp-socket packets
Craig Dowell <craigdo@ee.washington.edu>
parents: 1434
diff changeset
   752
          ifIndex = ifIndexTmp;
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   753
          return true;
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   754
        }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   755
    }
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   756
//
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   757
// If there's no routing table entry telling us what *single* interface will 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   758
// be used to send a packet to this destination, we'll have to just pick one.  
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   759
// If there's only one interface on this node, a good answer isn't very hard
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   760
// to come up with.  Before jumping to any conclusions, remember that the 
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   761
// zeroth interface is the loopback interface, so what we actually want is
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   762
// a situation where there are exactly two interfaces on the node, in which
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   763
// case interface one is the "single" interface connected to the outside world.
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   764
//
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   765
  if (GetNInterfaces () == 2)
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   766
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   767
      NS_LOG_LOGIC ("One Interface.  Using interface 1.");
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   768
      ifIndex = 1;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   769
      return true;
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   770
    }
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   771
//
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   772
// If we fall through to here, we have a node with multiple interfaces and
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   773
// no routes to guide us in determining what interface to choose.  Either
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   774
// no default route was found (for unicast or multicast), or in the case of a
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   775
// multicast, the default route contained multiple outbound interfaces.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   776
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   777
// The fallback position is to just get the unicast default route and use 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   778
// the outgoing interface specified there.  We don't want to leave the source
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   779
// address unset, so we just assert here.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   780
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   781
// N.B. that in the case of a multicast with a route containing multiple
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   782
// outgoing interfaces, the source address of packets from that node will be
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   783
// set to the IP address of the interface set in the default unicast route.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   784
// Also, in the case of a broadcast, the same will be true.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1441
diff changeset
   785
//
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   786
  NS_LOG_LOGIC ("Using default unicast route");
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   787
  Ipv4Route *route = m_staticRouting->GetDefaultRoute ();
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   788
2324
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   789
  if (route == NULL)
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   790
    {
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   791
      NS_LOG_LOGIC ("Ipv4L3Protocol::GetIfIndexForDestination (): "
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   792
                    "Unable to determine outbound interface.  No default route set");
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   793
      return false;
a3e10db411b9 The message "Unable to determine outbound interface. No default route set"
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2257
diff changeset
   794
    }
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   795
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   796
  ifIndex = route->GetInterface ();
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   797
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   798
  NS_LOG_LOGIC ("Default route specifies interface " << ifIndex);
1440
c77745b2731c add ipv4 methods, remove source multicast route requirement, fix udp socket source address prob
Craig Dowell <craigdo@ee.washington.edu>
parents: 1435
diff changeset
   799
  return true;
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   800
}
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   801
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   802
uint16_t 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   803
Ipv4L3Protocol::GetMtu (uint32_t i) const
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   804
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   805
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   806
  NS_LOG_PARAMS (this << i);
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
   807
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   808
  return interface->GetMtu ();
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   809
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   810
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   811
bool 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   812
Ipv4L3Protocol::IsUp (uint32_t i) const
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   813
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   814
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   815
  NS_LOG_PARAMS (this << i);
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
   816
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   817
  return interface->IsUp ();
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   818
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   819
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   820
void 
734
039fb338b6e9 Ipv4 -> Ipv4L3Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 733
diff changeset
   821
Ipv4L3Protocol::SetUp (uint32_t i)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   822
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   823
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   824
  NS_LOG_PARAMS (this << i);
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
   825
  Ptr<Ipv4Interface> interface = GetInterface (i);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   826
  interface->SetUp ();
979
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   827
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   828
  // If interface address and network mask have been set, add a route
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   829
  // to the network of the interface (like e.g. ifconfig does on a
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   830
  // Linux box)
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   831
  if ((interface->GetAddress ()) != (Ipv4Address ())
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   832
      && (interface->GetNetworkMask ()) != (Ipv4Mask ()))
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   833
    {
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   834
      AddNetworkRouteTo (interface->GetAddress ().CombineMask (interface->GetNetworkMask ()),
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   835
                         interface->GetNetworkMask (), i);
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   836
    }
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   837
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   838
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   839
void 
979
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   840
Ipv4L3Protocol::SetDown (uint32_t ifaceIndex)
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   841
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1451
diff changeset
   842
  NS_LOG_FUNCTION;
1828
6ab68edddf45 nicer logging of parameters (bug 79 patch from Gustavo)
Tom Henderson <tomh@tomh.org>
parents: 1776
diff changeset
   843
  NS_LOG_PARAMS (this << ifaceIndex);
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
   844
  Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex);
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   845
  interface->SetDown ();
979
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   846
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   847
  // Remove all routes that are going through this interface
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   848
  bool modified = true;
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   849
  while (modified)
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   850
    {
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   851
      modified = false;
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   852
      for (uint32_t i = 0; i < GetNRoutes (); i++)
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   853
        {
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   854
          Ipv4Route *route = GetRoute (i);
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   855
          if (route->GetInterface () == ifaceIndex)
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   856
            {
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   857
              RemoveRoute (i);
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   858
              modified = true;
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   859
              break;
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   860
            }
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   861
        }
cb805f7a2e8d Add patch 49 (add/remove network route when bringing interface up/down)
Tom Henderson <tomh@tomh.org>
parents: 734
diff changeset
   862
    }
444
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   863
}
1647ca57f19d remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 345
diff changeset
   864
236
5673656dc2e7 a basic untested ipv4 implementation
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   865
}//namespace ns3