src/internet-node/ipv4-static-routing.cc
author Craig Dowell <craigdo@ee.washington.edu>
Thu, 13 Sep 2007 17:47:42 -0700
changeset 1504 36ecc970ba96
parent 1449 df86e6b876ef
child 1828 6ab68edddf45
child 1866 e7dbcc4df546
permissions -rw-r--r--
checkpoint debug to log
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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:
diff changeset
     1
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
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:
diff changeset
     2
//
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:
diff changeset
     3
// Copyright (c) 2006 Georgia Tech Research Corporation
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:
diff changeset
     4
// All rights reserved.
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:
diff changeset
     5
//
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:
diff changeset
     6
// This program is free software; you can redistribute it and/or modify
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:
diff changeset
     7
// it under the terms of the GNU General Public License version 2 as
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:
diff changeset
     8
// published by the Free Software Foundation;
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:
diff changeset
     9
//
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:
diff changeset
    10
// This program is distributed in the hope that it will be useful,
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:
diff changeset
    11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
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:
diff changeset
    12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
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:
diff changeset
    13
// GNU General Public License for more details.
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:
diff changeset
    14
//
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:
diff changeset
    15
// You should have received a copy of the GNU General Public License
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:
diff changeset
    16
// along with this program; if not, write to the Free Software
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:
diff changeset
    17
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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:
diff changeset
    18
//
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:
diff changeset
    19
// Author: George F. Riley<riley@ece.gatech.edu>
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:
diff changeset
    20
//         Gustavo Carneiro <gjc@inescporto.pt>
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:
diff changeset
    21
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    22
#include "ns3/log.h"
983
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    23
#include "ipv4-static-routing.h"
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:
diff changeset
    24
#include "ns3/packet.h"
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:
diff changeset
    25
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    26
NS_LOG_COMPONENT_DEFINE ("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:
diff changeset
    27
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:
diff changeset
    28
namespace ns3 {
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:
diff changeset
    29
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
    30
Ipv4StaticRouting::Ipv4StaticRouting () 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
    31
: m_defaultRoute (0), m_defaultMulticastRoute (0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
    32
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    33
  NS_LOG_FUNCTION;
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
    34
}
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:
diff changeset
    35
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:
diff changeset
    36
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:
diff changeset
    37
Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest, 
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:
diff changeset
    38
                                   Ipv4Address nextHop, 
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:
diff changeset
    39
                                   uint32_t interface)
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:
diff changeset
    40
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    41
  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:
diff changeset
    42
  Ipv4Route *route = new Ipv4Route ();
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:
diff changeset
    43
  *route = Ipv4Route::CreateHostRouteTo (dest, nextHop, interface);
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:
diff changeset
    44
  m_hostRoutes.push_back (route);
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    45
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    46
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:
diff changeset
    47
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:
diff changeset
    48
Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest, 
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:
diff changeset
    49
                                   uint32_t interface)
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:
diff changeset
    50
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    51
  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:
diff changeset
    52
  Ipv4Route *route = new Ipv4Route ();
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:
diff changeset
    53
  *route = Ipv4Route::CreateHostRouteTo (dest, interface);
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:
diff changeset
    54
  m_hostRoutes.push_back (route);
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    55
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    56
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:
diff changeset
    57
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:
diff changeset
    58
Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network, 
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:
diff changeset
    59
                                      Ipv4Mask networkMask, 
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:
diff changeset
    60
                                      Ipv4Address nextHop, 
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:
diff changeset
    61
                                      uint32_t interface)
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:
diff changeset
    62
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    63
  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:
diff changeset
    64
  Ipv4Route *route = new Ipv4Route ();
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:
diff changeset
    65
  *route = Ipv4Route::CreateNetworkRouteTo (network,
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:
diff changeset
    66
                                            networkMask,
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:
diff changeset
    67
                                            nextHop,
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:
diff changeset
    68
                                            interface);
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:
diff changeset
    69
  m_networkRoutes.push_back (route);
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    70
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    71
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:
diff changeset
    72
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:
diff changeset
    73
Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network, 
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:
diff changeset
    74
                                      Ipv4Mask networkMask, 
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:
diff changeset
    75
                                      uint32_t interface)
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:
diff changeset
    76
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    77
  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:
diff changeset
    78
  Ipv4Route *route = new Ipv4Route ();
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:
diff changeset
    79
  *route = Ipv4Route::CreateNetworkRouteTo (network,
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:
diff changeset
    80
                                            networkMask,
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:
diff changeset
    81
                                            interface);
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:
diff changeset
    82
  m_networkRoutes.push_back (route);
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    83
}
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
    84
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:
diff changeset
    85
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:
diff changeset
    86
Ipv4StaticRouting::SetDefaultRoute (Ipv4Address nextHop, 
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:
diff changeset
    87
                                    uint32_t interface)
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:
diff changeset
    88
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
    89
  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:
diff changeset
    90
  Ipv4Route *route = new Ipv4Route ();
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:
diff changeset
    91
  *route = Ipv4Route::CreateDefaultRoute (nextHop, interface);
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:
diff changeset
    92
  delete m_defaultRoute;
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:
diff changeset
    93
  m_defaultRoute = route;
47c42bd66fb7 Support dynamic routing and multiple routing protocols; static routing table is refactored as a "routing protocol".
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
diff changeset
    94
}
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:
diff changeset
    95
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
    96
void 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
    97
Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
    98
                                     Ipv4Address group,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
    99
                                     uint32_t inputInterface,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   100
                                     std::vector<uint32_t> outputInterfaces)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   101
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   102
  NS_LOG_FUNCTION;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   103
  Ipv4MulticastRoute *route = new Ipv4MulticastRoute ();
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   104
  *route = Ipv4MulticastRoute::CreateMulticastRoute (origin, group, 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   105
    inputInterface, outputInterfaces);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   106
  m_multicastRoutes.push_back (route);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   107
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   108
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   109
void 
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   110
Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface)
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   111
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   112
  NS_LOG_FUNCTION;
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   113
  Ipv4Address origin = Ipv4Address::GetAny ();
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   114
  Ipv4Address group = Ipv4Address::GetAny ();
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   115
  uint32_t inputInterface = Ipv4RoutingProtocol::IF_INDEX_ANY;
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   116
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   117
  std::vector<uint32_t> outputInterfaces (1);
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   118
  outputInterfaces[0] = outputInterface;
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   119
  
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   120
  Ipv4MulticastRoute *route = new Ipv4MulticastRoute ();
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   121
  *route = Ipv4MulticastRoute::CreateMulticastRoute (origin, group, 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   122
    inputInterface, outputInterfaces);
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   123
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   124
  delete m_defaultMulticastRoute;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   125
  m_defaultMulticastRoute = route;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   126
}
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   127
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   128
uint32_t 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   129
Ipv4StaticRouting::GetNMulticastRoutes (void) const
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   130
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   131
  NS_LOG_FUNCTION;
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   132
  return m_multicastRoutes.size () + m_defaultMulticastRoute ? 1 : 0;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   133
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   134
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   135
Ipv4MulticastRoute *
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   136
Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   137
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   138
  NS_LOG_FUNCTION;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   139
  NS_ASSERT_MSG(index < m_multicastRoutes.size (),
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   140
    "Ipv4StaticRouting::GetMulticastRoute ():  Index out of range");
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   141
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   142
// From an external point of view the default route appears to be in slot 0
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   143
// of the routing table.  The implementation, however, puts it in a separate 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   144
// place.  So, if a client asks for index 0 and we have a default multicast
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   145
// route, we have to return it from that different place 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   146
// (m_defaultMulticastRoute).
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   147
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   148
  if (index == 0 && m_defaultMulticastRoute != 0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   149
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   150
      return m_defaultMulticastRoute;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   151
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   152
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   153
// If there is a default multicast route present, a client will just assume
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   154
// that it is in slot zero and there is one "extra" zeroth route in the table.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   155
// To return the correct indexed entry in our list, we have to decrement the
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   156
// index to take into account the default route not being in the actual list.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   157
// Since we fell through to here, we've taken care of the case where the
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   158
// index was zero.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   159
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   160
  if (m_defaultMulticastRoute != 0)
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   161
    {
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   162
      NS_ASSERT(index > 0);
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   163
      index--;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   164
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   165
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   166
  if (index < m_multicastRoutes.size ())
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   167
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   168
      uint32_t tmp = 0;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   169
      for (MulticastRoutesCI i = m_multicastRoutes.begin (); 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   170
           i != m_multicastRoutes.end (); 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   171
           i++) 
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   172
        {
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   173
          if (tmp  == index)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   174
            {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   175
              return *i;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   176
            }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   177
          tmp++;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   178
        }
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   179
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   180
  return 0;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   181
}
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   182
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   183
Ipv4MulticastRoute *
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   184
Ipv4StaticRouting::GetDefaultMulticastRoute () const
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   185
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   186
  NS_LOG_FUNCTION;
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   187
  if (m_defaultMulticastRoute != 0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   188
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   189
      return m_defaultMulticastRoute;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   190
    }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   191
  return 0;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   192
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   193
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   194
bool
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   195
Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   196
                                        Ipv4Address group,
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   197
                                        uint32_t inputInterface)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   198
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   199
  NS_LOG_FUNCTION;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   200
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   201
       i != m_multicastRoutes.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   202
       i++) 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   203
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   204
      Ipv4MulticastRoute *route = *i;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   205
      if (origin == route->GetOrigin () &&
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   206
          group == route->GetGroup () &&
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   207
          inputInterface == route->GetInputInterface ())
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   208
        {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   209
          delete *i;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   210
          m_multicastRoutes.erase (i);
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   211
          return true;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   212
        }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   213
    }
1444
7c81b4e2617d piles of doxygen, changes to SetDefaultMulticastRoute plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1442
diff changeset
   214
  return false;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   215
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   216
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   217
void 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   218
Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   219
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   220
  NS_LOG_FUNCTION;
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   221
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   222
// From an external point of view the default route appears to be in slot 0
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   223
// of the routing table.  The implementation, however, puts it in a separate 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   224
// place.  So, if a client asks to delete index 0 and we have a default
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   225
// multicast route set, we have to delete it from that different place 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   226
// (m_defaultMulticastRoute).
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   227
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   228
  if (index == 0 && m_defaultMulticastRoute != 0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   229
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   230
      delete m_defaultMulticastRoute;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   231
      m_defaultMulticastRoute = 0;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   232
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   233
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   234
// If there is a default multicast route present, a client will just assume
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   235
// that it is in slot zero and there is one "extra" zeroth route in the table.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   236
// To return the correct indexed entry in our list, we have to decrement the
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   237
// index to take into account the default route not being in the actual list.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   238
// Since we fell through to here, we've taken care of the case where the
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   239
// index was zero.
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   240
//
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   241
  if (m_defaultMulticastRoute != 0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   242
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   243
      NS_ASSERT(index > 0);
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   244
      index--;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   245
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   246
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   247
  uint32_t tmp = 0;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   248
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   249
       i != m_multicastRoutes.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   250
       i++) 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   251
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   252
      if (tmp  == index)
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   253
        {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   254
          delete *i;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   255
          m_multicastRoutes.erase (i);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   256
          return;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   257
        }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   258
      tmp++;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   259
    }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   260
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   261
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:
diff changeset
   262
Ipv4Route *
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:
diff changeset
   263
Ipv4StaticRouting::LookupStatic (Ipv4Address dest)
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:
diff changeset
   264
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   265
  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:
diff changeset
   266
  for (HostRoutesCI i = m_hostRoutes.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:
diff changeset
   267
       i != m_hostRoutes.end (); 
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:
diff changeset
   268
       i++) 
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:
diff changeset
   269
    {
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:
diff changeset
   270
      NS_ASSERT ((*i)->IsHost ());
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:
diff changeset
   271
      if ((*i)->GetDest ().IsEqual (dest)) 
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:
diff changeset
   272
        {
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:
diff changeset
   273
          return (*i);
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:
diff changeset
   274
        }
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:
diff changeset
   275
    }
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:
diff changeset
   276
  for (NetworkRoutesI j = m_networkRoutes.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:
diff changeset
   277
       j != m_networkRoutes.end (); 
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:
diff changeset
   278
       j++) 
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:
diff changeset
   279
    {
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:
diff changeset
   280
      NS_ASSERT ((*j)->IsNetwork ());
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:
diff changeset
   281
      Ipv4Mask mask = (*j)->GetDestNetworkMask ();
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:
diff changeset
   282
      Ipv4Address entry = (*j)->GetDestNetwork ();
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:
diff changeset
   283
      if (mask.IsMatch (dest, entry)) 
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:
diff changeset
   284
        {
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:
diff changeset
   285
          return (*j);
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:
diff changeset
   286
        }
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:
diff changeset
   287
    }
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:
diff changeset
   288
  if (m_defaultRoute != 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:
diff changeset
   289
    {
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:
diff changeset
   290
      NS_ASSERT (m_defaultRoute->IsDefault ());
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:
diff changeset
   291
      return m_defaultRoute;
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:
diff changeset
   292
    }
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:
diff changeset
   293
  return 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:
diff changeset
   294
}
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:
diff changeset
   295
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   296
Ipv4MulticastRoute *
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   297
Ipv4StaticRouting::LookupStatic (
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   298
  Ipv4Address origin, 
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   299
  Ipv4Address group,
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   300
  uint32_t    ifIndex)
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   301
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   302
  NS_LOG_FUNCTION;
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   303
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   304
// We treat the "any" address (typically 0.0.0.0) as a wildcard in our matching
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   305
// scheme.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   306
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   307
  Ipv4Address wildcard = Ipv4Address::GetAny ();
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   308
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   309
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   310
       i != m_multicastRoutes.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   311
       i++) 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   312
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   313
      Ipv4MulticastRoute *route = *i;
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   314
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   315
// We've been passed an origin address, a multicast group address and an 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   316
// interface index.  We have to decide if the current route in the list is
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   317
// a match.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   318
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   319
// The first case is the restrictive case where the origin, group and index
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   320
// matches.  This picks up exact routes during forwarded and exact routes from
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   321
// the local node (in which case the ifIndex is a wildcard).
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   322
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   323
      if (origin == route->GetOrigin () && group == route->GetGroup ())
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   324
        {
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   325
          if (ifIndex == Ipv4RoutingProtocol::IF_INDEX_ANY || 
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   326
              ifIndex == route->GetInputInterface ())
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   327
            {
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   328
              return *i;
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   329
            }
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   330
        }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   331
    }
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   332
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   333
// If the input interface index is not a wildcard (that means that the packet 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   334
// did not originally come from this node), we're done.  We don't
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   335
// just happily forward packets we don't really know what to do with.  
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   336
// Multicast storms are not generally considered a good thing.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   337
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   338
  if (ifIndex != Ipv4RoutingProtocol::IF_INDEX_ANY)
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   339
    {
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   340
      return 0;
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   341
    }
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   342
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   343
// Now, we're going to get a litle less restricive.  This only applies in the
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   344
// case where the packet in question is coming from the local node.  In order
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   345
// to avoid dependencies on the order in which routes were added, we will 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   346
// actually walk the list two more times, the first time looking for routes
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   347
// with a single wildcard, and the last time looking for the first route
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   348
// with two wildcards.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   349
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   350
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   351
       i != m_multicastRoutes.end (); 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   352
       i++) 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   353
    {
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   354
      Ipv4MulticastRoute *route = *i;
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   355
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   356
// Here we will ignore the origin.  We know that a single source address must
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   357
// be picked for a packet, but we may want to send multicast packets out
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   358
// multiple interfaces.  To support this case, a user would need to add
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   359
// a Multicast route with the route's origin set to wildcard.  N.B As a
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   360
// result, packets sourced from a node with multiple interface may have a
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   361
// source IP address different from that of the interface actually used to
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   362
// send the packet.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   363
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   364
      if (route->GetOrigin () == wildcard && group == route->GetGroup ())
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   365
        {
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   366
          return *i;
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   367
        }
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   368
    }
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   369
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   370
// Finally we want to allow users to specify a default route that specifies
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   371
// sending all multicast packets out multiple interfaces.  The standard
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   372
// default multicast route is patterned after other systems and limits the 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   373
// number of outputs to one.  If, however a client manually adds a multicast
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   374
// route with the origin, the multicast group and the input interface index
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   375
// all set to wildcard, she has created a default route with multiple output
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   376
// interfaces.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   377
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   378
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   379
       i != m_multicastRoutes.end (); 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   380
       i++) 
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   381
    {
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   382
      Ipv4MulticastRoute *route = *i;
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   383
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   384
      if (route->GetOrigin () == wildcard && route->GetGroup () == wildcard)
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   385
        {
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   386
          return *i;
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   387
        }
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   388
    }
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   389
//
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   390
// We also allow users to specify a typical default multicast route.  This
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   391
// default route is limited to specifying a single output interface.
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   392
//
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   393
  if (m_defaultMulticastRoute != 0) 
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   394
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   395
      return m_defaultMulticastRoute;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   396
    }
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   397
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   398
  return 0;
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   399
}
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   400
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:
diff changeset
   401
uint32_t 
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:
diff changeset
   402
Ipv4StaticRouting::GetNRoutes (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:
diff changeset
   403
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   404
  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:
diff changeset
   405
  uint32_t n = 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:
diff changeset
   406
  if (m_defaultRoute != 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:
diff changeset
   407
    {
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:
diff changeset
   408
      n++;
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:
diff changeset
   409
    }
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:
diff changeset
   410
  n += m_hostRoutes.size ();
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:
diff changeset
   411
  n += m_networkRoutes.size ();
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:
diff changeset
   412
  return n;
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:
diff changeset
   413
}
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
   414
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
Ipv4Route *
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
Ipv4StaticRouting::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
   417
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   418
  NS_LOG_FUNCTION;
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
   419
  if (m_defaultRoute != 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
   420
    {
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
   421
      return m_defaultRoute;
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
   422
    }
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
   423
  else
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
   424
    {
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
   425
      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
   426
    }
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
   427
}
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
   428
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:
diff changeset
   429
Ipv4Route *
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:
diff changeset
   430
Ipv4StaticRouting::GetRoute (uint32_t index)
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:
diff changeset
   431
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   432
  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:
diff changeset
   433
  if (index == 0 && m_defaultRoute != 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:
diff changeset
   434
    {
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:
diff changeset
   435
      return m_defaultRoute;
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:
diff changeset
   436
    }
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:
diff changeset
   437
  if (index > 0 && m_defaultRoute != 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:
diff changeset
   438
    {
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:
diff changeset
   439
      index--;
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:
diff changeset
   440
    }
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:
diff changeset
   441
  if (index < m_hostRoutes.size ())
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:
diff changeset
   442
    {
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:
diff changeset
   443
      uint32_t tmp = 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:
diff changeset
   444
      for (HostRoutesCI i = m_hostRoutes.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:
diff changeset
   445
           i != m_hostRoutes.end (); 
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:
diff changeset
   446
           i++) 
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:
diff changeset
   447
        {
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:
diff changeset
   448
          if (tmp  == index)
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:
diff changeset
   449
            {
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:
diff changeset
   450
              return *i;
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:
diff changeset
   451
            }
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:
diff changeset
   452
          tmp++;
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:
diff changeset
   453
        }
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:
diff changeset
   454
    }
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:
diff changeset
   455
  index -= m_hostRoutes.size ();
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:
diff changeset
   456
  uint32_t tmp = 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:
diff changeset
   457
  for (NetworkRoutesI j = m_networkRoutes.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:
diff changeset
   458
       j != m_networkRoutes.end (); 
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:
diff changeset
   459
       j++) 
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:
diff changeset
   460
    {
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:
diff changeset
   461
      if (tmp == index)
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:
diff changeset
   462
        {
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:
diff changeset
   463
          return *j;
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:
diff changeset
   464
        }
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:
diff changeset
   465
      tmp++;
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:
diff changeset
   466
    }
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:
diff changeset
   467
  NS_ASSERT (false);
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:
diff changeset
   468
  // quiet compiler.
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:
diff changeset
   469
  return 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:
diff changeset
   470
}
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:
diff changeset
   471
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:
diff changeset
   472
Ipv4StaticRouting::RemoveRoute (uint32_t index)
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:
diff changeset
   473
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   474
  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:
diff changeset
   475
  if (index == 0 && m_defaultRoute != 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:
diff changeset
   476
    {
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:
diff changeset
   477
      delete m_defaultRoute;
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:
diff changeset
   478
      m_defaultRoute = 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:
diff changeset
   479
    }
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:
diff changeset
   480
  if (index > 0 && m_defaultRoute != 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:
diff changeset
   481
    {
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:
diff changeset
   482
      index--;
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:
diff changeset
   483
    }
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:
diff changeset
   484
  if (index < m_hostRoutes.size ())
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:
diff changeset
   485
    {
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:
diff changeset
   486
      uint32_t tmp = 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:
diff changeset
   487
      for (HostRoutesI i = m_hostRoutes.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:
diff changeset
   488
           i != m_hostRoutes.end (); 
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:
diff changeset
   489
           i++) 
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:
diff changeset
   490
        {
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:
diff changeset
   491
          if (tmp  == index)
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:
diff changeset
   492
            {
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:
diff changeset
   493
              delete *i;
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:
diff changeset
   494
              m_hostRoutes.erase (i);
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:
diff changeset
   495
              return;
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:
diff changeset
   496
            }
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:
diff changeset
   497
          tmp++;
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:
diff changeset
   498
        }
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:
diff changeset
   499
    }
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:
diff changeset
   500
  index -= m_hostRoutes.size ();
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:
diff changeset
   501
  uint32_t tmp = 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:
diff changeset
   502
  for (NetworkRoutesI j = m_networkRoutes.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:
diff changeset
   503
       j != m_networkRoutes.end (); 
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:
diff changeset
   504
       j++) 
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:
diff changeset
   505
    {
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:
diff changeset
   506
      if (tmp == index)
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:
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:
diff changeset
   508
          delete *j;
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:
diff changeset
   509
          m_networkRoutes.erase (j);
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:
diff changeset
   510
          return;
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:
diff changeset
   511
        }
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:
diff changeset
   512
      tmp++;
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:
diff changeset
   513
    }
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:
diff changeset
   514
  NS_ASSERT (false);
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:
diff changeset
   515
}
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:
diff changeset
   516
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:
diff changeset
   517
bool
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   518
Ipv4StaticRouting::RequestRoute (
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   519
  uint32_t ifIndex,
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   520
  Ipv4Header const &ipHeader,
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   521
  Packet packet,
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   522
  RouteReplyCallback 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:
diff changeset
   523
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   524
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   525
  NS_LOG_PARAM ("(" << ifIndex << &ipHeader << ", " << &packet << ", " << 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   526
    &routeReply << ")");
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   527
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   528
  NS_LOG_LOGIC ("source = " << ipHeader.GetSource ());
1429
31cb0668defd debug prints to make validation easier
Craig Dowell <craigdo@ee.washington.edu>
parents: 1428
diff changeset
   529
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   530
  NS_LOG_LOGIC ("destination = " << ipHeader.GetDestination ());
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
   531
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   532
  if (ipHeader.GetDestination ().IsMulticast ())
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   533
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   534
      NS_LOG_LOGIC ("Multicast destination");
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   535
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   536
      Ipv4MulticastRoute *mRoute = LookupStatic(ipHeader.GetSource (),
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   537
        ipHeader.GetDestination (), ifIndex);
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   538
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   539
      if (mRoute)
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   540
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   541
          NS_LOG_LOGIC ("Multicast route found");
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   542
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   543
          for (uint32_t i = 0; i < mRoute->GetNOutputInterfaces (); ++i)
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   544
            {
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   545
              Packet p = packet;
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
   546
              Ipv4Header h = ipHeader;
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   547
              Ipv4Route 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
   548
                Ipv4Route::CreateHostRouteTo(h.GetDestination (), 
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   549
                  mRoute->GetOutputInterface(i));
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   550
              NS_LOG_LOGIC ( "Send via interface " << 
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   551
                mRoute->GetOutputInterface(i));
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
   552
              routeReply (true, route, p, h);
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   553
            }
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
   554
          return true;
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   555
        }
1432
3aef7d7a71c2 more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents: 1430
diff changeset
   556
      return false; // Let other routing protocols try to handle this
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   557
    }
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   558
//
1446
f9bc98cbe5fe clarify use of wildcards in multicast routes versus default mulicast routes.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1444
diff changeset
   559
// This is a unicast packet.  Check to see if we have a route for it.
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   560
//
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   561
  NS_LOG_LOGIC ("Unicast 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:
diff changeset
   562
  Ipv4Route *route = LookupStatic (ipHeader.GetDestination ());
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:
diff changeset
   563
  if (route != 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:
diff changeset
   564
    {
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:
diff changeset
   565
      routeReply (true, *route, 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:
diff changeset
   566
      return true;
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:
diff changeset
   567
    }
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:
diff changeset
   568
  else
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:
diff changeset
   569
    {
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:
diff changeset
   570
      return false; // Let other routing protocols try to handle 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:
diff changeset
   571
                    // route request.
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:
diff changeset
   572
    }
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:
diff changeset
   573
}
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:
diff changeset
   574
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   575
bool
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   576
Ipv4StaticRouting::RequestIfIndex (Ipv4Address destination, uint32_t& ifIndex)
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   577
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   578
  NS_LOG_FUNCTION;
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   579
  NS_LOG_PARAM ("(" << destination << ", " << &ifIndex << ")");
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   580
//
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   581
// First, see if this is a multicast packet we have a route for.  If we
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   582
// have a route, then send the packet down each of the specified interfaces.
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   583
//
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   584
  if (destination.IsMulticast ())
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   585
    {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   586
      NS_LOG_LOGIC ("Multicast destination");
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   587
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   588
      Ipv4MulticastRoute *mRoute = LookupStatic(Ipv4Address::GetAny (),
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   589
        destination, Ipv4RoutingProtocol::IF_INDEX_ANY);
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   590
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   591
      if (mRoute)
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   592
        {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   593
          NS_LOG_LOGIC ("Multicast route found");
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   594
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   595
          if (mRoute->GetNOutputInterfaces () != 1)
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   596
            {
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   597
              NS_LOG_LOGIC ("Route is to multiple interfaces.  Ignoring.");
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   598
              return false;
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   599
            }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   600
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   601
          ifIndex = mRoute->GetOutputInterface(0);
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   602
          NS_LOG_LOGIC ("Found ifIndex " << ifIndex);
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   603
          return true;
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   604
        }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   605
      return false; // Let other routing protocols try to handle this
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   606
    }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   607
//
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   608
// See if this is a unicast packet we have a route for.
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   609
//
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   610
  NS_LOG_LOGIC ("Unicast destination");
1434
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   611
  Ipv4Route *route = LookupStatic (destination);
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   612
  if (route)
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   613
    {
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   614
      ifIndex = route->GetInterface ();
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   615
      return true;
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   616
    }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   617
  else
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   618
    {
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   619
      return false;
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   620
    }
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   621
}
2b63aafb050b set source address in socket
Craig Dowell <craigdo@ee.washington.edu>
parents: 1432
diff changeset
   622
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:
diff changeset
   623
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:
diff changeset
   624
Ipv4StaticRouting::DoDispose (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:
diff changeset
   625
{
1504
36ecc970ba96 checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1449
diff changeset
   626
  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:
diff changeset
   627
  for (HostRoutesI i = m_hostRoutes.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:
diff changeset
   628
       i != m_hostRoutes.end (); 
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:
diff changeset
   629
       i = m_hostRoutes.erase (i)) 
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:
diff changeset
   630
    {
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:
diff changeset
   631
      delete (*i);
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:
diff changeset
   632
    }
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:
diff changeset
   633
  for (NetworkRoutesI j = m_networkRoutes.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:
diff changeset
   634
       j != m_networkRoutes.end (); 
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:
diff changeset
   635
       j = m_networkRoutes.erase (j)) 
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:
diff changeset
   636
    {
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:
diff changeset
   637
      delete (*j);
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:
diff changeset
   638
    }
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:
diff changeset
   639
  if (m_defaultRoute != 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:
diff changeset
   640
    {
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:
diff changeset
   641
      delete m_defaultRoute;
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:
diff changeset
   642
      m_defaultRoute = 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:
diff changeset
   643
    }
1428
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   644
  for (MulticastRoutesI i = m_multicastRoutes.begin (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   645
       i != m_multicastRoutes.end (); 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   646
       i = m_multicastRoutes.erase (i)) 
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   647
    {
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   648
      delete (*i);
a8f3d01d4a2c untested multicast support
Craig Dowell <craigdo@ee.washington.edu>
parents: 983
diff changeset
   649
    }
1442
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   650
  if (m_defaultMulticastRoute != 0)
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   651
    {
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   652
      delete m_defaultMulticastRoute;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   653
      m_defaultMulticastRoute = 0;
bb5cf98c0c64 real multicast enet addr, more source routes, default multicast route
Craig Dowell <craigdo@ee.washington.edu>
parents: 1440
diff changeset
   654
    }
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:
diff changeset
   655
  Ipv4RoutingProtocol::DoDispose ();
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:
diff changeset
   656
}
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:
diff changeset
   657
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:
diff changeset
   658
}//namespace ns3