src/internet/model/global-router-interface.cc
author Pedro Silva <pmms@inesctec.pt>
Wed, 29 Oct 2014 10:12:53 -0700
changeset 11040 cd2eda848730
parent 10968 2d29fee2b7b8
child 11259 ea2f6a3ed14e
permissions -rw-r--r--
bug 1791: TCP Endpoint never deallocates when closing
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
/*
1457
562a7017ed93 Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents: 1278
diff changeset
     3
 * Copyright 2007 University of Washington
562a7017ed93 Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents: 1278
diff changeset
     4
 * 
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     8
 *
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
 *
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
1457
562a7017ed93 Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents: 1278
diff changeset
    17
 *
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
    18
 * Authors:  Tom Henderson (tomhend@u.washington.edu)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
 */
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
    21
#include "ns3/log.h"
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
#include "ns3/assert.h"
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
    23
#include "ns3/abort.h"
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
#include "ns3/channel.h"
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
#include "ns3/net-device.h"
2827
4bcc29436feb do not include internet-node.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2602
diff changeset
    26
#include "ns3/node.h"
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
    27
#include "ns3/node-list.h"
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
#include "ns3/ipv4.h"
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
    29
#include "ns3/bridge-net-device.h"
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
    30
#include "ipv4-global-routing.h"
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
#include "global-router-interface.h"
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
    32
#include <vector>
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    34
namespace ns3 {
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
10968
2d29fee2b7b8 [Bug 1551] Redux: NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10652
diff changeset
    36
NS_LOG_COMPONENT_DEFINE ("GlobalRouter");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    39
//
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    40
// GlobalRoutingLinkRecord Implementation
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    42
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    43
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    44
GlobalRoutingLinkRecord::GlobalRoutingLinkRecord ()
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    45
  :
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    46
    m_linkId ("0.0.0.0"),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    47
    m_linkData ("0.0.0.0"),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    48
    m_linkType (Unknown),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    49
    m_metric (0)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    51
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    54
GlobalRoutingLinkRecord::GlobalRoutingLinkRecord (
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
  LinkType    linkType, 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
  Ipv4Address linkId, 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  Ipv4Address linkData, 
1776
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1505
diff changeset
    58
  uint16_t    metric)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    59
  :
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    60
    m_linkId (linkId),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    61
    m_linkData (linkData),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    62
    m_linkType (linkType),
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    63
    m_metric (metric)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
    65
  NS_LOG_FUNCTION (this << linkType << linkId << linkData << metric);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    68
GlobalRoutingLinkRecord::~GlobalRoutingLinkRecord ()
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    70
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    73
Ipv4Address
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    74
GlobalRoutingLinkRecord::GetLinkId (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    75
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    76
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    77
  return m_linkId;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    78
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    79
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    80
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    81
GlobalRoutingLinkRecord::SetLinkId (Ipv4Address addr)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    82
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    83
  NS_LOG_FUNCTION (this << addr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    84
  m_linkId = addr;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    85
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    86
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    87
Ipv4Address
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    88
GlobalRoutingLinkRecord::GetLinkData (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    89
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    90
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    91
  return m_linkData;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    92
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    93
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
    94
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
    95
GlobalRoutingLinkRecord::SetLinkData (Ipv4Address addr)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    96
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
    97
  NS_LOG_FUNCTION (this << addr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    98
  m_linkData = addr;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    99
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   100
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   101
GlobalRoutingLinkRecord::LinkType
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   102
GlobalRoutingLinkRecord::GetLinkType (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   103
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   104
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   105
  return m_linkType;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   106
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   107
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   108
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   109
GlobalRoutingLinkRecord::SetLinkType (
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   110
  GlobalRoutingLinkRecord::LinkType linkType)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   111
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   112
  NS_LOG_FUNCTION (this << linkType);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   113
  m_linkType = linkType;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   114
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   115
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   116
uint16_t
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   117
GlobalRoutingLinkRecord::GetMetric (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   118
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   119
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   120
  return m_metric;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   121
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   122
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   123
void
1776
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1505
diff changeset
   124
GlobalRoutingLinkRecord::SetMetric (uint16_t metric)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   125
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   126
  NS_LOG_FUNCTION (this << metric);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   127
  m_metric = metric;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   128
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   129
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   130
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   131
//
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   132
// GlobalRoutingLSA Implementation
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   133
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   134
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   135
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   136
GlobalRoutingLSA::GlobalRoutingLSA()
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   137
  : 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   138
    m_lsType (GlobalRoutingLSA::Unknown),
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   139
    m_linkStateId ("0.0.0.0"),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   140
    m_advertisingRtr ("0.0.0.0"),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   141
    m_linkRecords (),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   142
    m_networkLSANetworkMask ("0.0.0.0"),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   143
    m_attachedRouters (),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   144
    m_status (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   145
    m_node_id (0)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   146
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   147
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   148
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   149
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   150
GlobalRoutingLSA::GlobalRoutingLSA (
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   151
  GlobalRoutingLSA::SPFStatus status,
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   152
  Ipv4Address linkStateId, 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   153
  Ipv4Address advertisingRtr)
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   154
  :
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   155
    m_lsType (GlobalRoutingLSA::Unknown),
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   156
    m_linkStateId (linkStateId),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   157
    m_advertisingRtr (advertisingRtr),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   158
    m_linkRecords (),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   159
    m_networkLSANetworkMask ("0.0.0.0"),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   160
    m_attachedRouters (),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   161
    m_status (status),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   162
    m_node_id (0)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   163
{
2983
e3a416fe9dd5 NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2827
diff changeset
   164
  NS_LOG_FUNCTION (this << status << linkStateId << advertisingRtr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   165
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   166
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   167
GlobalRoutingLSA::GlobalRoutingLSA (GlobalRoutingLSA& lsa)
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   168
  : m_lsType (lsa.m_lsType), m_linkStateId (lsa.m_linkStateId),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   169
    m_advertisingRtr (lsa.m_advertisingRtr),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   170
    m_networkLSANetworkMask (lsa.m_networkLSANetworkMask),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   171
    m_status (lsa.m_status),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   172
    m_node_id (lsa.m_node_id)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   173
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   174
  NS_LOG_FUNCTION (this << &lsa);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   175
  NS_ASSERT_MSG (IsEmpty (),
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   176
                 "GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   177
  CopyLinkRecords (lsa);
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   178
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   179
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   180
GlobalRoutingLSA&
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   181
GlobalRoutingLSA::operator= (const GlobalRoutingLSA& lsa)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   182
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   183
  NS_LOG_FUNCTION (this << &lsa);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   184
  m_lsType = lsa.m_lsType;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   185
  m_linkStateId = lsa.m_linkStateId;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   186
  m_advertisingRtr = lsa.m_advertisingRtr;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   187
  m_networkLSANetworkMask = lsa.m_networkLSANetworkMask, 
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   188
  m_status = lsa.m_status;
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   189
  m_node_id = lsa.m_node_id;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   190
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   191
  ClearLinkRecords ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   192
  CopyLinkRecords (lsa);
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   193
  return *this;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   194
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   195
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   196
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   197
GlobalRoutingLSA::CopyLinkRecords (const GlobalRoutingLSA& lsa)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   198
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   199
  NS_LOG_FUNCTION (this << &lsa);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   200
  for (ListOfLinkRecords_t::const_iterator i = lsa.m_linkRecords.begin ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   201
       i != lsa.m_linkRecords.end (); 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   202
       i++)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   203
    {
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   204
      GlobalRoutingLinkRecord *pSrc = *i;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   205
      GlobalRoutingLinkRecord *pDst = new GlobalRoutingLinkRecord;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   206
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   207
      pDst->SetLinkType (pSrc->GetLinkType ());
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   208
      pDst->SetLinkId (pSrc->GetLinkId ());
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   209
      pDst->SetLinkData (pSrc->GetLinkData ());
1776
0d5be0c3d229 Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents: 1505
diff changeset
   210
      pDst->SetMetric (pSrc->GetMetric ());
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   211
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   212
      m_linkRecords.push_back (pDst);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   213
      pDst = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   214
    }
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   215
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   216
  m_attachedRouters = lsa.m_attachedRouters;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   217
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   218
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   219
GlobalRoutingLSA::~GlobalRoutingLSA()
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   220
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   221
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   222
  ClearLinkRecords ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   223
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   224
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   225
void
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   226
GlobalRoutingLSA::ClearLinkRecords (void)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   227
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   228
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   229
  for ( ListOfLinkRecords_t::iterator i = m_linkRecords.begin ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   230
        i != m_linkRecords.end (); 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   231
        i++)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   232
    {
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
   233
      NS_LOG_LOGIC ("Free link record");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   234
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   235
      GlobalRoutingLinkRecord *p = *i;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   236
      delete p;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   237
      p = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   238
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   239
      *i = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   240
    }
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
   241
  NS_LOG_LOGIC ("Clear list");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   242
  m_linkRecords.clear ();
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   243
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   244
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   245
uint32_t
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   246
GlobalRoutingLSA::AddLinkRecord (GlobalRoutingLinkRecord* lr)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   247
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   248
  NS_LOG_FUNCTION (this << lr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   249
  m_linkRecords.push_back (lr);
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   250
  return m_linkRecords.size ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   251
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   252
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   253
uint32_t
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   254
GlobalRoutingLSA::GetNLinkRecords (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   255
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   256
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   257
  return m_linkRecords.size ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   258
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   259
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   260
GlobalRoutingLinkRecord *
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   261
GlobalRoutingLSA::GetLinkRecord (uint32_t n) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   262
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   263
  NS_LOG_FUNCTION (this << n);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   264
  uint32_t j = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   265
  for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   266
        i != m_linkRecords.end (); 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   267
        i++, j++)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   268
    {
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   269
      if (j == n) 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   270
        {
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   271
          return *i;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   272
        }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   273
    }
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   274
  NS_ASSERT_MSG (false, "GlobalRoutingLSA::GetLinkRecord (): invalid index");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   275
  return 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   276
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   277
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   278
bool
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   279
GlobalRoutingLSA::IsEmpty (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   280
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   281
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   282
  return m_linkRecords.size () == 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   283
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   284
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   285
GlobalRoutingLSA::LSType
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   286
GlobalRoutingLSA::GetLSType (void) const
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   287
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   288
  NS_LOG_FUNCTION (this);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   289
  return m_lsType;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   290
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   291
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   292
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   293
GlobalRoutingLSA::SetLSType (GlobalRoutingLSA::LSType typ) 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   294
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   295
  NS_LOG_FUNCTION (this << typ);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   296
  m_lsType = typ;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   297
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   298
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   299
Ipv4Address
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   300
GlobalRoutingLSA::GetLinkStateId (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   301
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   302
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   303
  return m_linkStateId;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   304
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   305
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   306
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   307
GlobalRoutingLSA::SetLinkStateId (Ipv4Address addr)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   308
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   309
  NS_LOG_FUNCTION (this << addr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   310
  m_linkStateId = addr;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   311
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   312
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   313
Ipv4Address
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   314
GlobalRoutingLSA::GetAdvertisingRouter (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   315
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   316
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   317
  return m_advertisingRtr;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   318
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   319
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   320
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   321
GlobalRoutingLSA::SetAdvertisingRouter (Ipv4Address addr)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   322
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   323
  NS_LOG_FUNCTION (this << addr);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   324
  m_advertisingRtr = addr;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   325
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   326
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   327
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   328
GlobalRoutingLSA::SetNetworkLSANetworkMask (Ipv4Mask mask)
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   329
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   330
  NS_LOG_FUNCTION (this << mask);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   331
  m_networkLSANetworkMask = mask;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   332
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   333
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   334
Ipv4Mask
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   335
GlobalRoutingLSA::GetNetworkLSANetworkMask (void) const
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   336
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   337
  NS_LOG_FUNCTION (this);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   338
  return m_networkLSANetworkMask;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   339
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   340
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   341
GlobalRoutingLSA::SPFStatus
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   342
GlobalRoutingLSA::GetStatus (void) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   343
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   344
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   345
  return m_status;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   346
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   347
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   348
uint32_t
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   349
GlobalRoutingLSA::AddAttachedRouter (Ipv4Address addr)
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   350
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   351
  NS_LOG_FUNCTION (this << addr);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   352
  m_attachedRouters.push_back (addr);
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   353
  return m_attachedRouters.size ();
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   354
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   355
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   356
uint32_t
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   357
GlobalRoutingLSA::GetNAttachedRouters (void) const
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   358
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   359
  NS_LOG_FUNCTION (this);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   360
  return m_attachedRouters.size (); 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   361
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   362
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   363
Ipv4Address
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   364
GlobalRoutingLSA::GetAttachedRouter (uint32_t n) const
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   365
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   366
  NS_LOG_FUNCTION (this << n);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   367
  uint32_t j = 0;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   368
  for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin ();
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   369
        i != m_attachedRouters.end (); 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   370
        i++, j++)
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   371
    {
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   372
      if (j == n) 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   373
        {
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   374
          return *i;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   375
        }
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   376
    }
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   377
  NS_ASSERT_MSG (false, "GlobalRoutingLSA::GetAttachedRouter (): invalid index");
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   378
  return Ipv4Address ("0.0.0.0");
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   379
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   380
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   381
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   382
GlobalRoutingLSA::SetStatus (GlobalRoutingLSA::SPFStatus status)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   383
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   384
  NS_LOG_FUNCTION (this << status);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   385
  m_status = status;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   386
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   387
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   388
Ptr<Node>
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   389
GlobalRoutingLSA::GetNode (void) const
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   390
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   391
  NS_LOG_FUNCTION (this);
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   392
  return NodeList::GetNode (m_node_id);
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   393
}
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   394
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   395
void
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   396
GlobalRoutingLSA::SetNode (Ptr<Node> node)
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   397
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   398
  NS_LOG_FUNCTION (this << node);
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   399
  m_node_id = node->GetId ();
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   400
}
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   401
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   402
void
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   403
GlobalRoutingLSA::Print (std::ostream &os) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   404
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   405
  NS_LOG_FUNCTION (this << &os);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   406
  os << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   407
  os << "========== Global Routing LSA ==========" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   408
  os << "m_lsType = " << m_lsType;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   409
  if (m_lsType == GlobalRoutingLSA::RouterLSA) 
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   410
    {
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   411
      os << " (GlobalRoutingLSA::RouterLSA)";
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   412
    }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   413
  else if (m_lsType == GlobalRoutingLSA::NetworkLSA) 
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   414
    {
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   415
      os << " (GlobalRoutingLSA::NetworkLSA)";
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   416
    }
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   417
  else if (m_lsType == GlobalRoutingLSA::ASExternalLSAs)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   418
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   419
      os << " (GlobalRoutingLSA::ASExternalLSA)";
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   420
    }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   421
  else
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   422
    {
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   423
      os << "(Unknown LSType)";
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   424
    }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   425
  os << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   426
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   427
  os << "m_linkStateId = " << m_linkStateId << " (Router ID)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   428
  os << "m_advertisingRtr = " << m_advertisingRtr << " (Router ID)" << std::endl;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   429
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   430
  if (m_lsType == GlobalRoutingLSA::RouterLSA) 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   431
    {
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   432
      for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin ();
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   433
            i != m_linkRecords.end (); 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   434
            i++)
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   435
        {
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   436
          GlobalRoutingLinkRecord *p = *i;
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   437
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   438
          os << "---------- RouterLSA Link Record ----------" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   439
          os << "m_linkType = " << p->m_linkType;
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   440
          if (p->m_linkType == GlobalRoutingLinkRecord::PointToPoint)
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   441
            {
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   442
              os << " (GlobalRoutingLinkRecord::PointToPoint)" << std::endl;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   443
              os << "m_linkId = " << p->m_linkId << std::endl;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   444
              os << "m_linkData = " << p->m_linkData << std::endl;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   445
              os << "m_metric = " << p->m_metric << std::endl;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   446
            }
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   447
          else if (p->m_linkType == GlobalRoutingLinkRecord::TransitNetwork)
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   448
            {
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   449
              os << " (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   450
              os << "m_linkId = " << p->m_linkId << " (Designated router for network)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   451
              os << "m_linkData = " << p->m_linkData << " (This router's IP address)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   452
              os << "m_metric = " << p->m_metric << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   453
            }
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   454
          else if (p->m_linkType == GlobalRoutingLinkRecord::StubNetwork)
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   455
            {
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   456
              os << " (GlobalRoutingLinkRecord::StubNetwork)" << std::endl;
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   457
              os << "m_linkId = " << p->m_linkId << " (Network number of attached network)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   458
              os << "m_linkData = " << p->m_linkData << " (Network mask of attached network)" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   459
              os << "m_metric = " << p->m_metric << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   460
            }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   461
          else
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   462
            {
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
   463
              os << " (Unknown LinkType)" << std::endl;
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   464
              os << "m_linkId = " << p->m_linkId << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   465
              os << "m_linkData = " << p->m_linkData << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   466
              os << "m_metric = " << p->m_metric << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   467
            }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   468
          os << "---------- End RouterLSA Link Record ----------" << std::endl;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   469
        }
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   470
    }
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   471
  else if (m_lsType == GlobalRoutingLSA::NetworkLSA) 
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   472
    {
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   473
      os << "---------- NetworkLSA Link Record ----------" << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   474
      os << "m_networkLSANetworkMask = " << m_networkLSANetworkMask << std::endl;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   475
      for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin (); i != m_attachedRouters.end (); i++)
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   476
        {
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   477
          Ipv4Address p = *i;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   478
          os << "attachedRouter = " << p << std::endl;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   479
        }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   480
      os << "---------- End NetworkLSA Link Record ----------" << std::endl;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   481
    }
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   482
  else if (m_lsType == GlobalRoutingLSA::ASExternalLSAs)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   483
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   484
      os << "---------- ASExternalLSA Link Record --------" << std::endl;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   485
      os << "m_linkStateId = " << m_linkStateId << std::endl;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   486
      os << "m_networkLSANetworkMask = " << m_networkLSANetworkMask << std::endl;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   487
    }
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   488
  else 
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   489
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   490
      NS_ASSERT_MSG (0, "Illegal LSA LSType: " << m_lsType);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   491
    }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   492
  os << "========== End Global Routing LSA ==========" << std::endl;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   493
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   494
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   495
std::ostream& operator<< (std::ostream& os, GlobalRoutingLSA& lsa)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   496
{
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   497
  lsa.Print (os);
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   498
  return os;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   499
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   500
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   501
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   502
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   503
// GlobalRouter Implementation
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   504
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   505
// ---------------------------------------------------------------------------
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   506
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10410
diff changeset
   507
NS_OBJECT_ENSURE_REGISTERED (GlobalRouter);
2249
3a1da26d61dc replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2238
diff changeset
   508
2250
18f432098389 InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2249
diff changeset
   509
TypeId 
2251
04963d8cca51 iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2250
diff changeset
   510
GlobalRouter::GetTypeId (void)
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
   511
{
2602
d9262bff6df2 add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2257
diff changeset
   512
  static TypeId tid = TypeId ("ns3::GlobalRouter")
2238
05affd9d0dc1 get rid of MakeInterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2232
diff changeset
   513
    .SetParent<Object> ();
2252
80595448707a iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2251
diff changeset
   514
  return tid;
2232
9abd038ee588 replace static const Interface iid; with static InterfaceId iid (void);
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2231
diff changeset
   515
}
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   516
1881
24285ca5e94f fix bug 113 on m_node parameter for GlobalRouter
Tom Henderson <tomh@tomh.org>
parents: 1828
diff changeset
   517
GlobalRouter::GlobalRouter ()
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   518
  : m_LSAs ()
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   519
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   520
  NS_LOG_FUNCTION (this);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   521
  m_routerId.Set (GlobalRouteManager::AllocateRouterId ());
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   522
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   523
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   524
GlobalRouter::~GlobalRouter ()
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   525
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   526
  NS_LOG_FUNCTION (this);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   527
  ClearLSAs ();
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   528
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   529
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   530
void 
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   531
GlobalRouter::SetRoutingProtocol (Ptr<Ipv4GlobalRouting> routing)
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   532
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   533
  NS_LOG_FUNCTION (this << routing);
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   534
  m_routingProtocol = routing;
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   535
}
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   536
Ptr<Ipv4GlobalRouting> 
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   537
GlobalRouter::GetRoutingProtocol (void)
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   538
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   539
  NS_LOG_FUNCTION (this);
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   540
  return m_routingProtocol;
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   541
}
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   542
1202
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   543
void
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   544
GlobalRouter::DoDispose ()
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   545
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   546
  NS_LOG_FUNCTION (this);
4616
a84f60b6cd12 bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 4607
diff changeset
   547
  m_routingProtocol = 0;
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   548
  for (InjectedRoutesI k = m_injectedRoutes.begin ();
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   549
       k != m_injectedRoutes.end ();
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   550
       k = m_injectedRoutes.erase (k))
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   551
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   552
      delete (*k);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   553
    }
1202
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   554
  Object::DoDispose ();
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   555
}
953cc2fadcef fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 1123
diff changeset
   556
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   557
void
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   558
GlobalRouter::ClearLSAs ()
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   559
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   560
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   561
  for ( ListOfLSAs_t::iterator i = m_LSAs.begin ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   562
        i != m_LSAs.end (); 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   563
        i++)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   564
    {
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
   565
      NS_LOG_LOGIC ("Free LSA");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   566
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   567
      GlobalRoutingLSA *p = *i;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   568
      delete p;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   569
      p = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   570
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   571
      *i = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   572
    }
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
   573
  NS_LOG_LOGIC ("Clear list of LSAs");
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   574
  m_LSAs.clear ();
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   575
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   576
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   577
Ipv4Address
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   578
GlobalRouter::GetRouterId (void) const
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   579
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   580
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   581
  return m_routerId;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   582
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   583
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   584
//
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   585
// DiscoverLSAs is called on all nodes in the system that have a GlobalRouter
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   586
// interface aggregated.  We need to go out and discover any adjacent routers 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   587
// and build the Link State Advertisements that reflect them and their associated
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   588
// networks.
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   589
// 
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   590
uint32_t 
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   591
GlobalRouter::DiscoverLSAs ()
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   592
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   593
  NS_LOG_FUNCTION (this);
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   594
  Ptr<Node> node = GetObject<Node> ();
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   595
  NS_ABORT_MSG_UNLESS (node, "GlobalRouter::DiscoverLSAs (): GetObject for <Node> interface failed");
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   596
  NS_LOG_LOGIC ("For node " << node->GetId () );
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   597
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   598
  ClearLSAs ();
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   599
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   600
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   601
  // While building the Router-LSA, keep a list of those NetDevices for
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   602
  // which the current node is the designated router and we will later build 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   603
  // a NetworkLSA for.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   604
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   605
  NetDeviceContainer c;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   606
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   607
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   608
  // We're aggregated to a node.  We need to ask the node for a pointer to its
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   609
  // Ipv4 interface.  This is where the information regarding the attached 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   610
  // interfaces lives.  If we're a router, we had better have an Ipv4 interface.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   611
  //
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
   612
  Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> ();
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   613
  NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::DiscoverLSAs (): GetObject for <Ipv4> interface failed");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   614
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   615
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   616
  // Every router node originates a Router-LSA
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   617
  //
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   618
  GlobalRoutingLSA *pLSA = new GlobalRoutingLSA;
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   619
  pLSA->SetLSType (GlobalRoutingLSA::RouterLSA);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   620
  pLSA->SetLinkStateId (m_routerId);
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   621
  pLSA->SetAdvertisingRouter (m_routerId);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   622
  pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED);
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
   623
  pLSA->SetNode (node);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   624
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   625
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   626
  // Ask the node for the number of net devices attached. This isn't necessarily 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   627
  // equal to the number of links to adjacent nodes (other routers) as the number
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   628
  // of devices may include those for stub networks (e.g., ethernets, etc.) and 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   629
  // bridge devices also take up an "extra" net device.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   630
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   631
  uint32_t numDevices = node->GetNDevices ();
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   632
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   633
  //
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   634
  // Iterate through the devices on the node and walk the channel to see what's
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   635
  // on the other side of the standalone devices..
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   636
  //
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   637
  for (uint32_t i = 0; i < numDevices; ++i)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   638
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   639
      Ptr<NetDevice> ndLocal = node->GetDevice (i);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   640
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   641
      //
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   642
      // There is an assumption that bridge ports must never have an IP address 
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   643
      // associated with them.  This turns out to be a very convenient place to
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   644
      // check and make sure that this is the case.
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   645
      //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   646
      if (NetDeviceIsBridged (ndLocal))
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   647
        {
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   648
          // Initialize to value out of bounds to silence compiler
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   649
          uint32_t interfaceBridge = ipv4Local->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   650
          bool rc = FindInterfaceForDevice (node, ndLocal, interfaceBridge);
3947
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   651
          NS_ABORT_MSG_IF (rc, "GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   652
        }
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   653
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   654
      //
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   655
      // Check to see if the net device we just got has a corresponding IP 
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   656
      // interface (could be a pure L2 NetDevice) -- for example a net device
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   657
      // associated with a bridge.  We are only going to involve devices with 
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   658
      // IP addresses in routing.
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   659
      //
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   660
      bool isForwarding = false;
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
   661
      for (uint32_t j = 0; j < ipv4Local->GetNInterfaces (); ++j )
3019
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   662
        {
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   663
          if (ipv4Local->GetNetDevice (j) == ndLocal && ipv4Local->IsUp (j) &&
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   664
              ipv4Local->IsForwarding (j)) 
3019
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   665
            {
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   666
              isForwarding = true;
3019
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   667
              break;
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   668
            }
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   669
        }
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
   670
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   671
      if (!isForwarding)
3019
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   672
        {
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   673
          NS_LOG_LOGIC ("Net device " << ndLocal << "has no IP interface or is not enabled for forwarding, skipping");
3019
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   674
          continue;
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   675
        }
4ac564369c63 GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 2983
diff changeset
   676
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   677
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   678
      // We have a net device that we need to check out.  If it suports 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   679
      // broadcast and is not a point-point link, then it will be either a stub 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   680
      // network or a transit network depending on the number of routers on
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   681
      // the segment.  We add the appropriate link record to the LSA.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   682
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   683
      // If the device is a point to point link, we treat it separately.  In
4590
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
   684
      // that case, there may be zero, one, or two link records added.
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   685
      //
4607
0e15594f67f3 bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents: 4590
diff changeset
   686
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   687
      if (ndLocal->IsBroadcast () && !ndLocal->IsPointToPoint () )
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   688
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
   689
          NS_LOG_LOGIC ("Broadcast link");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   690
          ProcessBroadcastLink (ndLocal, pLSA, c);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   691
        }
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   692
      else if (ndLocal->IsPointToPoint () )
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   693
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
   694
          NS_LOG_LOGIC ("Point=to-point link");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   695
          ProcessPointToPointLink (ndLocal, pLSA);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   696
        }
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   697
      else
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   698
        {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   699
          NS_ASSERT_MSG (0, "GlobalRouter::DiscoverLSAs (): unknown link type");
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   700
        }
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   701
    }
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   702
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   703
  NS_LOG_LOGIC ("========== LSA for node " << node->GetId () << " ==========");
1505
286ec92f4113 debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents: 1457
diff changeset
   704
  NS_LOG_LOGIC (*pLSA);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   705
  m_LSAs.push_back (pLSA);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   706
  pLSA = 0;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   707
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   708
  // 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   709
  // Now, determine whether we need to build a NetworkLSA.  This is the case if
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   710
  // we found at least one designated router.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   711
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   712
  uint32_t nDesignatedRouters = c.GetN ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   713
  if (nDesignatedRouters > 0)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   714
    {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   715
      NS_LOG_LOGIC ("Build Network LSAs");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   716
      BuildNetworkLSAs (c);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   717
    }
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
   718
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   719
  //
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   720
  // Build injected route LSAs as external routes
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   721
  // RFC 2328, section 12.4.4
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   722
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   723
  for (InjectedRoutesCI i = m_injectedRoutes.begin ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   724
       i != m_injectedRoutes.end ();
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   725
       i++)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   726
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   727
      GlobalRoutingLSA *pLSA = new GlobalRoutingLSA;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   728
      pLSA->SetLSType (GlobalRoutingLSA::ASExternalLSAs);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   729
      pLSA->SetLinkStateId ((*i)->GetDestNetwork ());
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   730
      pLSA->SetAdvertisingRouter (m_routerId);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   731
      pLSA->SetNetworkLSANetworkMask ((*i)->GetDestNetworkMask ());
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   732
      pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   733
      m_LSAs.push_back (pLSA); 
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
   734
    }
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   735
  return m_LSAs.size ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   736
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
   737
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   738
void
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   739
GlobalRouter::ProcessBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   740
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   741
  NS_LOG_FUNCTION (this << nd << pLSA << &c);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   742
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   743
  if (nd->IsBridge ())
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   744
    {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   745
      ProcessBridgedBroadcastLink (nd, pLSA, c);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   746
    }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   747
  else
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   748
    {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   749
      ProcessSingleBroadcastLink (nd, pLSA, c);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   750
    }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   751
}
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   752
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   753
void
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   754
GlobalRouter::ProcessSingleBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   755
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   756
  NS_LOG_FUNCTION (this << nd << pLSA << &c);
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   757
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   758
  GlobalRoutingLinkRecord *plr = new GlobalRoutingLinkRecord;
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   759
  NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessSingleBroadcastLink(): Can't alloc link record");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   760
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   761
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   762
  // We have some preliminaries to do to get enough information to proceed.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   763
  // This information we need comes from the internet stack, so notice that
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   764
  // there is an implied assumption that global routing is only going to 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   765
  // work with devices attached to the internet stack (have an ipv4 interface
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   766
  // associated to them.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   767
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   768
  Ptr<Node> node = nd->GetNode ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   769
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   770
  Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> ();
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   771
  NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed");
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   772
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   773
  // Initialize to value out of bounds to silence compiler
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   774
  uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   775
  bool rc = FindInterfaceForDevice (node, nd, interfaceLocal);
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   776
  NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessSingleBroadcastLink(): No interface index associated with device");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   777
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   778
  if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   779
    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   780
      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   781
    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   782
  Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   783
  Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   784
  NS_LOG_LOGIC ("Working with local address " << addrLocal);
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
   785
  uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   786
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   787
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   788
  // Check to see if the net device is connected to a channel/network that has
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   789
  // another router on it.  If there is no other router on the link (but us) then
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   790
  // this is a stub network.  If we find another router, then what we have here
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   791
  // is a transit network.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   792
  //
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   793
  if (AnotherRouterOnLink (nd, true) == false)
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   794
    {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   795
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   796
      // This is a net device connected to a stub network
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   797
      //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   798
      NS_LOG_LOGIC ("Router-LSA Stub Network");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   799
      plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   800
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   801
      // 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   802
      // According to OSPF, the Link ID is the IP network number of 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   803
      // the attached network.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   804
      //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   805
      plr->SetLinkId (addrLocal.CombineMask (maskLocal));
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   806
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   807
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   808
      // and the Link Data is the network mask; converted to Ipv4Address
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   809
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   810
      Ipv4Address maskLocalAddr;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   811
      maskLocalAddr.Set (maskLocal.Get ());
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   812
      plr->SetLinkData (maskLocalAddr);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   813
      plr->SetMetric (metricLocal);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   814
      pLSA->AddLinkRecord (plr);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   815
      plr = 0;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   816
    }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   817
  else
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   818
    {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   819
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   820
      // We have multiple routers on a broadcast interface, so this is
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   821
      // a transit network.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   822
      //
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
   823
      NS_LOG_LOGIC ("Router-LSA Transit Network");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   824
      plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   825
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   826
      // 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   827
      // By definition, the router with the lowest IP address is the
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   828
      // designated router for the network.  OSPF says that the Link ID
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   829
      // gets the IP interface address of the designated router in this 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   830
      // case.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   831
      //
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   832
      Ipv4Address desigRtr = FindDesignatedRouterForLink (nd, true);
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   833
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   834
      //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   835
      // Let's double-check that any designated router we find out on our
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   836
      // network is really on our network.
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   837
      //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   838
      if (desigRtr != "255.255.255.255")
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   839
        {
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   840
          Ipv4Address networkHere = addrLocal.CombineMask (maskLocal);
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   841
          Ipv4Address networkThere = desigRtr.CombineMask (maskLocal);
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   842
          NS_ABORT_MSG_UNLESS (networkHere == networkThere, 
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   843
                               "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   844
        }
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   845
      if (desigRtr == addrLocal) 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   846
        {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   847
          c.Add (nd);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   848
          NS_LOG_LOGIC ("Node " << node->GetId () << " elected a designated router");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   849
        }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   850
      plr->SetLinkId (desigRtr);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   851
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   852
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   853
      // OSPF says that the Link Data is this router's own IP address.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   854
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   855
      plr->SetLinkData (addrLocal);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   856
      plr->SetMetric (metricLocal);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   857
      pLSA->AddLinkRecord (plr);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   858
      plr = 0;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   859
    }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   860
}
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
   861
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
   862
void
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   863
GlobalRouter::ProcessBridgedBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   864
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
   865
  NS_LOG_FUNCTION (this << nd << pLSA << &c);
3947
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   866
  NS_ASSERT_MSG (nd->IsBridge (), "GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   867
3947
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   868
#if 0
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   869
  //
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   870
  // It is possible to admit the possibility that a bridge device on a node
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   871
  // can also participate in routing.  This would surprise people who don't
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   872
  // come from Microsoft-land where they do use such a construct.  Based on
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   873
  // the principle of least-surprise, we will leave the relatively simple
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   874
  // code in place to do this, but not enable it until someone really wants
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   875
  // the capability.  Even then, we will not enable this code as a default
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   876
  // but rather something you will have to go and turn on.
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   877
  //
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   878
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   879
  Ptr<BridgeNetDevice> bnd = nd->GetObject<BridgeNetDevice> ();
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   880
  NS_ABORT_MSG_UNLESS (bnd, "GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   881
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   882
  //
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   883
  // We have some preliminaries to do to get enough information to proceed.
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   884
  // This information we need comes from the internet stack, so notice that
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   885
  // there is an implied assumption that global routing is only going to 
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   886
  // work with devices attached to the internet stack (have an ipv4 interface
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   887
  // associated to them.
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   888
  //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   889
  Ptr<Node> node = nd->GetNode ();
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   890
  Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> ();
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   891
  NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed");
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   892
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   893
  // Initialize to value out of bounds to silence compiler
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
   894
  uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   895
  bool rc = FindInterfaceForDevice (node, nd, interfaceLocal);
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   896
  NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessBridgedBroadcastLink(): No interface index associated with device");
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   897
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   898
  if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   899
    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   900
      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   901
    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   902
  Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
   903
  Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();;
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   904
  NS_LOG_LOGIC ("Working with local address " << addrLocal);
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
   905
  uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   906
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   907
  //
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   908
  // We need to handle a bridge on the router.  This means that we have been 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   909
  // given a net device that is a BridgeNetDevice.  It has an associated Ipv4
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   910
  // interface index and address.  Some number of other net devices live "under"
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   911
  // the bridge device as so-called bridge ports.  In a nutshell, what we have
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   912
  // to do is to repeat what is done for a single broadcast link on all of 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   913
  // those net devices living under the bridge (trolls?)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   914
  //
3947
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
   915
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   916
  bool areTransitNetwork = false;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   917
  Ipv4Address desigRtr ("255.255.255.255");
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   918
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   919
  for (uint32_t i = 0; i < bnd->GetNBridgePorts (); ++i)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   920
    {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   921
      Ptr<NetDevice> ndTemp = bnd->GetBridgePort (i);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   922
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   923
      //
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   924
      // We have to decide if we are a transit network.  This is characterized
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   925
      // by the presence of another router on the network segment.  If we find
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   926
      // another router on any of our bridged links, we are a transit network.
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   927
      //
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
   928
      if (AnotherRouterOnLink (ndTemp, true))
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   929
        {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   930
          areTransitNetwork = true;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   931
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   932
          //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   933
          // If we're going to be a transit network, then we have got to elect
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   934
          // a designated router for the whole bridge.  This means finding the
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   935
          // router with the lowest IP address on the whole bridge.  We ask 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   936
          // for the lowest address on each segment and pick the lowest of them
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   937
          // all.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   938
          //
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
   939
          Ipv4Address desigRtrTemp = FindDesignatedRouterForLink (ndTemp, true);
3946
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   940
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   941
          //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   942
          // Let's double-check that any designated router we find out on our
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   943
          // network is really on our network.
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   944
          //
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   945
          if (desigRtrTemp != "255.255.255.255")
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   946
            {
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   947
              Ipv4Address networkHere = addrLocal.CombineMask (maskLocal);
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   948
              Ipv4Address networkThere = desigRtrTemp.CombineMask (maskLocal);
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   949
              NS_ABORT_MSG_UNLESS (networkHere == networkThere, 
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   950
                                   "GlobalRouter::ProcessSingleBroadcastLink(): Network number confusion");
6a20c485ddb5 document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents: 3944
diff changeset
   951
            }
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   952
          if (desigRtrTemp < desigRtr)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   953
            {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   954
              desigRtr = desigRtrTemp;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   955
            }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   956
        }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   957
    }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   958
  //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   959
  // That's all the information we need to put it all together, just like we did
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   960
  // in the case of a single broadcast link.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   961
  //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   962
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   963
  GlobalRoutingLinkRecord *plr = new GlobalRoutingLinkRecord;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   964
  NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessBridgedBroadcastLink(): Can't alloc link record");
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   965
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   966
  if (areTransitNetwork == false)
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   967
    {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   968
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   969
      // This is a net device connected to a bridge of stub networks
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   970
      //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   971
      NS_LOG_LOGIC ("Router-LSA Stub Network");
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   972
      plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   973
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   974
      // 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   975
      // According to OSPF, the Link ID is the IP network number of 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   976
      // the attached network.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   977
      //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   978
      plr->SetLinkId (addrLocal.CombineMask (maskLocal));
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   979
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   980
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   981
      // and the Link Data is the network mask; converted to Ipv4Address
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   982
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   983
      Ipv4Address maskLocalAddr;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   984
      maskLocalAddr.Set (maskLocal.Get ());
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   985
      plr->SetLinkData (maskLocalAddr);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   986
      plr->SetMetric (metricLocal);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
   987
      pLSA->AddLinkRecord (plr);
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   988
      plr = 0;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   989
    }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   990
  else
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   991
    {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   992
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   993
      // We have multiple routers on a bridged broadcast interface, so this is
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   994
      // a transit network.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   995
      //
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
   996
      NS_LOG_LOGIC ("Router-LSA Transit Network");
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   997
      plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   998
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
   999
      // 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1000
      // By definition, the router with the lowest IP address is the
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1001
      // designated router for the network.  OSPF says that the Link ID
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1002
      // gets the IP interface address of the designated router in this 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1003
      // case.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1004
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1005
      if (desigRtr == addrLocal) 
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1006
        {
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1007
          c.Add (nd);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1008
          NS_LOG_LOGIC ("Node " << node->GetId () << " elected a designated router");
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1009
        }
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1010
      plr->SetLinkId (desigRtr);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1011
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1012
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1013
      // OSPF says that the Link Data is this router's own IP address.
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1014
      //
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1015
      plr->SetLinkData (addrLocal);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1016
      plr->SetMetric (metricLocal);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1017
      pLSA->AddLinkRecord (plr);
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1018
      plr = 0;
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1019
    }
3947
756887a9bbea disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents: 3946
diff changeset
  1020
#endif
3940
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1021
}
49b432aefbd0 deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents: 3939
diff changeset
  1022
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1023
void
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1024
GlobalRouter::ProcessPointToPointLink (Ptr<NetDevice> ndLocal, GlobalRoutingLSA *pLSA)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1025
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1026
  NS_LOG_FUNCTION (this << ndLocal << pLSA);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1027
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1028
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1029
  // We have some preliminaries to do to get enough information to proceed.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1030
  // This information we need comes from the internet stack, so notice that
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1031
  // there is an implied assumption that global routing is only going to 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1032
  // work with devices attached to the internet stack (have an ipv4 interface
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1033
  // associated to them.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1034
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1035
  Ptr<Node> nodeLocal = ndLocal->GetNode ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1036
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1037
  Ptr<Ipv4> ipv4Local = nodeLocal->GetObject<Ipv4> ();
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1038
  NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1039
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1040
  uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1041
  bool rc = FindInterfaceForDevice (nodeLocal, ndLocal, interfaceLocal);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1042
  NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessPointToPointLink (): No interface index associated with device");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1043
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1044
  if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1045
    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1046
      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1047
    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1048
  Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1049
  NS_LOG_LOGIC ("Working with local address " << addrLocal);
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1050
  uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1051
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1052
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1053
  // Now, we're going to walk over to the remote net device on the other end of 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1054
  // the point-to-point channel we know we have.  This is where our adjacent 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1055
  // router (to use OSPF lingo) is running.
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1056
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1057
  Ptr<Channel> ch = ndLocal->GetChannel ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1058
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1059
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1060
  // Get the net device on the other side of the point-to-point channel.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1061
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1062
  Ptr<NetDevice> ndRemote = GetAdjacent (ndLocal, ch);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1063
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1064
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1065
  // The adjacent net device is aggregated to a node.  We need to ask that net 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1066
  // device for its node, then ask that node for its Ipv4 interface.  Note a
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1067
  // requirement that nodes on either side of a point-to-point link must have 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1068
  // internet stacks; and an assumption that point-to-point links are incompatible 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1069
  // with bridging.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1070
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1071
  Ptr<Node> nodeRemote = ndRemote->GetNode ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1072
  Ptr<Ipv4> ipv4Remote = nodeRemote->GetObject<Ipv4> ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1073
  NS_ABORT_MSG_UNLESS (ipv4Remote, 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1074
                       "GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1075
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1076
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1077
  // Further note the requirement that nodes on either side of a point-to-point 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1078
  // link must participate in global routing and therefore have a GlobalRouter
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1079
  // interface aggregated.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1080
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1081
  Ptr<GlobalRouter> rtrRemote = nodeRemote->GetObject<GlobalRouter> ();
4590
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
  1082
  if (rtrRemote == 0)
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
  1083
    {
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
  1084
      // This case is possible if the remote does not participate in global routing
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
  1085
      return;
3370e6e78caf do not assert if remote side of a PointToPoint link doesn't participate in global routing
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
  1086
    }
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1087
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1088
  // We're going to need the remote router ID, so we might as well get it now.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1089
  //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1090
  Ipv4Address rtrIdRemote = rtrRemote->GetRouterId ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1091
  NS_LOG_LOGIC ("Working with remote router " << rtrIdRemote);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1092
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1093
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1094
  // Now, just like we did above, we need to get the IP interface index for the 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1095
  // net device on the other end of the point-to-point channel.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1096
  //
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1097
  uint32_t interfaceRemote = ipv4Remote->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1098
  rc = FindInterfaceForDevice (nodeRemote, ndRemote, interfaceRemote);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1099
  NS_ABORT_MSG_IF (rc == false, "GlobalRouter::ProcessPointToPointLinks(): No interface index associated with remote device");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1100
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1101
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1102
  // Now that we have the Ipv4 interface, we can get the (remote) address and
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1103
  // mask we need.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1104
  //
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1105
  if (ipv4Remote->GetNAddresses (interfaceRemote) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1106
    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1107
      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1108
    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1109
  Ipv4Address addrRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetLocal ();
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1110
  Ipv4Mask maskRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetMask ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1111
  NS_LOG_LOGIC ("Working with remote address " << addrRemote);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1112
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1113
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1114
  // Now we can fill out the link records for this link.  There are always two
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1115
  // link records; the first is a point-to-point record describing the link and
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1116
  // the second is a stub network record with the network number.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1117
  //
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1118
  GlobalRoutingLinkRecord *plr;
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1119
  if (ipv4Remote->IsUp (interfaceRemote))
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1120
    {
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1121
      NS_LOG_LOGIC ("Remote side interface " << interfaceRemote << " is up-- add a type 1 link");
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1122
 
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1123
      plr  = new GlobalRoutingLinkRecord;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1124
      NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1125
      plr->SetLinkType (GlobalRoutingLinkRecord::PointToPoint);
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1126
      plr->SetLinkId (rtrIdRemote);
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1127
      plr->SetLinkData (addrLocal);
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1128
      plr->SetMetric (metricLocal);
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1129
      pLSA->AddLinkRecord (plr);
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1130
      plr = 0;
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1131
    }
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1132
3960
34908804c029 Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents: 3959
diff changeset
  1133
  // Regardless of state of peer, add a type 3 link (RFC 2328: 12.4.1.1)
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1134
  plr = new GlobalRoutingLinkRecord;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1135
  NS_ABORT_MSG_IF (plr == 0, "GlobalRouter::ProcessPointToPointLink(): Can't alloc link record");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1136
  plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1137
  plr->SetLinkId (addrRemote);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1138
  plr->SetLinkData (Ipv4Address (maskRemote.Get ()));  // Frown
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1139
  plr->SetMetric (metricLocal);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1140
  pLSA->AddLinkRecord (plr);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1141
  plr = 0;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1142
}
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1143
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1144
void
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1145
GlobalRouter::BuildNetworkLSAs (NetDeviceContainer c)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1146
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1147
  NS_LOG_FUNCTION (this << &c);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1148
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1149
  uint32_t nDesignatedRouters = c.GetN ();
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1150
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1151
  for (uint32_t i = 0; i < nDesignatedRouters; ++i)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1152
    {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1153
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1154
      // Build one NetworkLSA for each net device talking to a network that we are the 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1155
      // designated router for.  These devices are in the provided container.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1156
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1157
      Ptr<NetDevice> ndLocal = c.Get (i);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1158
      Ptr<Node> node = ndLocal->GetNode ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1159
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1160
      Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> ();
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1161
      NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed");
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1162
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1163
      uint32_t interfaceLocal = ipv4Local->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1164
      bool rc = FindInterfaceForDevice (node, ndLocal, interfaceLocal);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1165
      NS_ABORT_MSG_IF (rc == false, "GlobalRouter::BuildNetworkLSAs (): No interface index associated with device");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1166
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1167
      if (ipv4Local->GetNAddresses (interfaceLocal) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1168
        {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1169
          NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1170
        }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1171
      Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal ();
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1172
      Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1173
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1174
      GlobalRoutingLSA *pLSA = new GlobalRoutingLSA;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1175
      NS_ABORT_MSG_IF (pLSA == 0, "GlobalRouter::BuildNetworkLSAs(): Can't alloc link record");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1176
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1177
      pLSA->SetLSType (GlobalRoutingLSA::NetworkLSA);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1178
      pLSA->SetLinkStateId (addrLocal);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1179
      pLSA->SetAdvertisingRouter (m_routerId);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1180
      pLSA->SetNetworkLSANetworkMask (maskLocal);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1181
      pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED);
4628
a5a8c44e4240 bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents: 4616
diff changeset
  1182
      pLSA->SetNode (node);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1183
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1184
      //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1185
      // Build a list of AttachedRouters by walking the devices in the channel
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1186
      // and, if we find a node with a GlobalRouter interface and an IPv4 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1187
      // interface associated with that device, we call it an attached router.
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1188
      //
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1189
      Ptr<Channel> ch = ndLocal->GetChannel ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1190
      uint32_t nDevices = ch->GetNDevices ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1191
      NS_ASSERT (nDevices);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1192
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1193
      for (uint32_t i = 0; i < nDevices; i++)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1194
        {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1195
          Ptr<NetDevice> tempNd = ch->GetDevice (i);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1196
          NS_ASSERT (tempNd);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1197
          Ptr<Node> tempNode = tempNd->GetNode ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1198
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1199
          //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1200
          // Does the node in question have a GlobalRouter interface?  If not it can
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1201
          // hardly be considered an attached router.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1202
          //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1203
          Ptr<GlobalRouter> rtr = tempNode->GetObject<GlobalRouter> ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1204
          if (rtr == 0)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1205
            { 
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1206
              continue;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1207
            }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1208
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1209
          //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1210
          // Does the attached node have an ipv4 interface for the device we're probing?
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1211
          // If not, it can't play router.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1212
          //
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1213
          uint32_t tempInterface = 0;
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1214
          if (FindInterfaceForDevice (tempNode, tempNd, tempInterface))
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1215
            {
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1216
              Ptr<Ipv4> tempIpv4 = tempNode->GetObject<Ipv4> ();
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1217
              NS_ASSERT (tempIpv4);
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1218
              if (!tempIpv4->IsUp (tempInterface))
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1219
                {
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1220
                  NS_LOG_LOGIC ("Remote side interface " << tempInterface << " not up");
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1221
                }
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1222
              else 
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1223
                {
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1224
                  if (tempIpv4->GetNAddresses (tempInterface) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1225
                    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1226
                      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1227
                    }
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1228
                  Ipv4Address tempAddr = tempIpv4->GetAddress (tempInterface, 0).GetLocal ();
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1229
                  pLSA->AddAttachedRouter (tempAddr);
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1230
                }
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1231
            }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1232
        }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1233
      m_LSAs.push_back (pLSA);
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1234
      pLSA = 0;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1235
    }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1236
}
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1237
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1238
//
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1239
// Given a local net device, we need to walk the channel to which the net device is
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1240
// attached and look for nodes with GlobalRouter interfaces on them (one of them 
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1241
// will be us).  Of these, the router with the lowest IP address on the net device 
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1242
// connecting to the channel becomes the designated router for the link.
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1243
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1244
Ipv4Address
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1245
GlobalRouter::FindDesignatedRouterForLink (Ptr<NetDevice> ndLocal, bool allowRecursion) const
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1246
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1247
  NS_LOG_FUNCTION (this << ndLocal << allowRecursion);
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1248
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1249
  Ptr<Channel> ch = ndLocal->GetChannel ();
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1250
  uint32_t nDevices = ch->GetNDevices ();
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1251
  NS_ASSERT (nDevices);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1252
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1253
  NS_LOG_LOGIC ("Looking for designated router off of net device " << ndLocal << " on node " << 
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1254
                ndLocal->GetNode ()->GetId ());
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1255
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1256
  Ipv4Address desigRtr ("255.255.255.255");
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1257
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1258
  //
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1259
  // Look through all of the devices on the channel to which the net device
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1260
  // in question is attached.
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1261
  //
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1262
  for (uint32_t i = 0; i < nDevices; i++)
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1263
    {
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1264
      Ptr<NetDevice> ndOther = ch->GetDevice (i);
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1265
      NS_ASSERT (ndOther);
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1266
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1267
      Ptr<Node> nodeOther = ndOther->GetNode ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1268
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1269
      NS_LOG_LOGIC ("Examine channel device " << i << " on node " << nodeOther->GetId ());
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1270
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1271
      //
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1272
      // For all other net devices, we need to check and see if a router
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1273
      // is present.  If the net device on the other side is a bridged
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1274
      // device, we need to consider all of the other devices on the 
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1275
      // bridge as well (all of the bridge ports.
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1276
      //
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1277
      NS_LOG_LOGIC ("checking to see if the device is bridged");
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1278
      Ptr<BridgeNetDevice> bnd = NetDeviceIsBridged (ndOther);
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1279
      if (bnd)
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1280
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1281
          NS_LOG_LOGIC ("Device is bridged by BridgeNetDevice " << bnd);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1282
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1283
          //
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1284
          // It is possible that the bridge net device is sitting under a
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1285
          // router, so we have to check for the presence of that router
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1286
          // before we run off and follow all the links
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1287
          //
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1288
          // We require a designated router to have a GlobalRouter interface and
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1289
          // an internet stack that includes the Ipv4 interface.  If it doesn't
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1290
          // it can't play router.
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1291
          //
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1292
          NS_LOG_LOGIC ("Checking for router on bridge net device " << bnd);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1293
          Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1294
          Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1295
          if (rtr && ipv4)
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1296
            {
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1297
              // Initialize to value out of bounds to silence compiler
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1298
              uint32_t interfaceOther = ipv4->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1299
              if (FindInterfaceForDevice (nodeOther, bnd, interfaceOther))
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1300
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1301
                  NS_LOG_LOGIC ("Found router on bridge net device " << bnd);
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1302
                  if (!ipv4->IsUp (interfaceOther))
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1303
                    {
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1304
                      NS_LOG_LOGIC ("Remote side interface " << interfaceOther << " not up");
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1305
                      continue;
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1306
                    }
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1307
                  if (ipv4->GetNAddresses (interfaceOther) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1308
                    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1309
                      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1310
                    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1311
                  Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1312
                  desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1313
                  NS_LOG_LOGIC ("designated router now " << desigRtr);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1314
                }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1315
            }
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1316
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1317
          NS_LOG_LOGIC ("Looking through bridge ports of bridge net device " << bnd);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1318
          for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1319
            {
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1320
              Ptr<NetDevice> ndBridged = bnd->GetBridgePort (j);
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1321
              NS_LOG_LOGIC ("Examining bridge port " << j << " device " << ndBridged);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1322
              if (ndBridged == ndOther)
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1323
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1324
                  NS_LOG_LOGIC ("That bridge port is me, don't walk backward");
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1325
                  continue;
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1326
                }
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1327
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1328
              if (allowRecursion)
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1329
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1330
                  NS_LOG_LOGIC ("Recursively looking for routers down bridge port " << ndBridged);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1331
                  Ipv4Address addrOther = FindDesignatedRouterForLink (ndBridged, false);
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1332
                  desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1333
                  NS_LOG_LOGIC ("designated router now " << desigRtr);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1334
                }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1335
            }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1336
        }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1337
      else
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1338
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1339
          NS_LOG_LOGIC ("This device is not bridged");
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1340
          Ptr<Node> nodeOther = ndOther->GetNode ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1341
          NS_ASSERT (nodeOther);
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1342
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1343
          //
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1344
          // We require a designated router to have a GlobalRouter interface and
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1345
          // an internet stack that includes the Ipv4 interface.  If it doesn't
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1346
          //
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1347
          Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1348
          Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> ();
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1349
          if (rtr && ipv4)
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1350
            {
7136
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1351
              // Initialize to value out of bounds to silence compiler
3c78ec58343f bug 1126: fix uninitialized variables
Tom Henderson <tomh@tomh.org>
parents: 6834
diff changeset
  1352
              uint32_t interfaceOther = ipv4->GetNInterfaces () + 1;
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1353
              if (FindInterfaceForDevice (nodeOther, ndOther, interfaceOther))
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1354
                {
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1355
                  if (!ipv4->IsUp (interfaceOther))
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1356
                    {
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1357
                      NS_LOG_LOGIC ("Remote side interface " << interfaceOther << " not up");
3959
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1358
                      continue;
ec65107df095 Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents: 3947
diff changeset
  1359
                    }
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1360
                  NS_LOG_LOGIC ("Found router on net device " << ndOther);
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1361
                  if (ipv4->GetNAddresses (interfaceOther) > 1)
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1362
                    {
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1363
                      NS_LOG_WARN ("Warning, interface has multiple IP addresses; using only the primary one");
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1364
                    }
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4372
diff changeset
  1365
                  Ipv4Address addrOther = ipv4->GetAddress (interfaceOther, 0).GetLocal ();
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1366
                  desigRtr = addrOther < desigRtr ? addrOther : desigRtr;
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1367
                  NS_LOG_LOGIC ("designated router now " << desigRtr);
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1368
                }
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1369
            }
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1370
        }
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1371
    }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1372
  return desigRtr;
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1373
}
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1374
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1375
//
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1376
// Given a node and an attached net device, take a look off in the channel to 
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1377
// which the net device is attached and look for a node on the other side
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1378
// that has a GlobalRouter interface aggregated.  Life gets more complicated
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1379
// when there is a bridged net device on the other side.
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1380
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1381
bool
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1382
GlobalRouter::AnotherRouterOnLink (Ptr<NetDevice> nd, bool allowRecursion) const
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1383
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1384
  NS_LOG_FUNCTION (this << nd << allowRecursion);
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1385
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1386
  Ptr<Channel> ch = nd->GetChannel ();
4012
7dc122811f0c add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents: 3960
diff changeset
  1387
  if (!ch)
7dc122811f0c add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents: 3960
diff changeset
  1388
    {
7dc122811f0c add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents: 3960
diff changeset
  1389
      // It may be that this net device is a stub device, without a channel
7dc122811f0c add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents: 3960
diff changeset
  1390
      return false;
7dc122811f0c add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents: 3960
diff changeset
  1391
    }
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1392
  uint32_t nDevices = ch->GetNDevices ();
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1393
  NS_ASSERT (nDevices);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1394
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1395
  NS_LOG_LOGIC ("Looking for routers off of net device " << nd << " on node " << nd->GetNode ()->GetId ());
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1396
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1397
  //
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1398
  // Look through all of the devices on the channel to which the net device
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1399
  // in question is attached.
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1400
  //
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1401
  for (uint32_t i = 0; i < nDevices; i++)
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1402
    {
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1403
      Ptr<NetDevice> ndOther = ch->GetDevice (i);
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1404
      NS_ASSERT (ndOther);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1405
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1406
      NS_LOG_LOGIC ("Examine channel device " << i << " on node " << ndOther->GetNode ()->GetId ());
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1407
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1408
      // 
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1409
      // Ignore the net device itself.
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1410
      //
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1411
      if (ndOther == nd)
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1412
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1413
          NS_LOG_LOGIC ("Myself, skip");
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1414
          continue;
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1415
        }
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1416
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1417
      //
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1418
      // For all other net devices, we need to check and see if a router
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1419
      // is present.  If the net device on the other side is a bridged
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1420
      // device, we need to consider all of the other devices on the 
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1421
      // bridge.
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1422
      //
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1423
      NS_LOG_LOGIC ("checking to see if device is bridged");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1424
      Ptr<BridgeNetDevice> bnd = NetDeviceIsBridged (ndOther);
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1425
      if (bnd)
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1426
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1427
          NS_LOG_LOGIC ("Device is bridged by net device " << bnd);
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1428
          NS_LOG_LOGIC ("Looking through bridge ports of bridge net device " << bnd);
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1429
          for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1430
            {
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1431
              Ptr<NetDevice> ndBridged = bnd->GetBridgePort (j);
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1432
              NS_LOG_LOGIC ("Examining bridge port " << j << " device " << ndBridged);
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1433
              if (ndBridged == ndOther)
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1434
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1435
                  NS_LOG_LOGIC ("That bridge port is me, skip");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1436
                  continue;
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1437
                }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1438
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1439
              if (allowRecursion)
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1440
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1441
                  NS_LOG_LOGIC ("Recursively looking for routers on bridge port " << ndBridged);
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1442
                  if (AnotherRouterOnLink (ndBridged, false))
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1443
                    {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1444
                      NS_LOG_LOGIC ("Found routers on bridge port, return true");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1445
                      return true;
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1446
                    }
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1447
                }
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1448
            }
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1449
          NS_LOG_LOGIC ("No routers on bridged net device, return false");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1450
          return false;
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1451
        }
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1452
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1453
      NS_LOG_LOGIC ("This device is not bridged");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1454
      Ptr<Node> nodeTemp = ndOther->GetNode ();
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1455
      NS_ASSERT (nodeTemp);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1456
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1457
      Ptr<GlobalRouter> rtr = nodeTemp->GetObject<GlobalRouter> ();
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1458
      if (rtr)
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1459
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1460
          NS_LOG_LOGIC ("Found GlobalRouter interface, return true");
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1461
          return true;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1462
        }
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1463
      else 
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1464
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1465
          NS_LOG_LOGIC ("No GlobalRouter interface on device, continue search");
3942
eef10dbce686 fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents: 3941
diff changeset
  1466
        }
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1467
    }
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1468
  NS_LOG_LOGIC ("No routers found, return false");
3938
972310213d07 Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents: 3937
diff changeset
  1469
  return false;
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1470
}
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1471
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1472
uint32_t
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1473
GlobalRouter::GetNumLSAs (void) const
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1474
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1475
  NS_LOG_FUNCTION (this);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1476
  return m_LSAs.size ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1477
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1478
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1479
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1480
// Get the nth link state advertisement from this router.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1481
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1482
bool
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1483
GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1484
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1485
  NS_LOG_FUNCTION (this << n << &lsa);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1486
  NS_ASSERT_MSG (lsa.IsEmpty (), "GlobalRouter::GetLSA (): Must pass empty LSA");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1487
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1488
// All of the work was done in GetNumLSAs.  All we have to do here is to
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1489
// walk the list of link state advertisements created there and return the 
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1490
// one the client is interested in.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1491
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1492
  ListOfLSAs_t::const_iterator i = m_LSAs.begin ();
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1493
  uint32_t j = 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1494
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1495
  for (; i != m_LSAs.end (); i++, j++)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1496
    {
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1497
      if (j == n)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1498
        {
1278
41bf67d701a5 global routing csma patch
Tom Henderson <tomh@tomh.org>
parents: 1202
diff changeset
  1499
          GlobalRoutingLSA *p = *i;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1500
          lsa = *p;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1501
          return true;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1502
        }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1503
    }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1504
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1505
  return false;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1506
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1507
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1508
void
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1509
GlobalRouter::InjectRoute (Ipv4Address network, Ipv4Mask networkMask)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1510
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1511
  NS_LOG_FUNCTION (this << network << networkMask);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1512
  Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1513
//
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1514
// Interface number does not matter here, using 1.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1515
//
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1516
  *route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network,
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1517
                                                        networkMask,
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1518
                                                        1);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1519
  m_injectedRoutes.push_back (route);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1520
}
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1521
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1522
Ipv4RoutingTableEntry *
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1523
GlobalRouter::GetInjectedRoute (uint32_t index)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1524
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1525
  NS_LOG_FUNCTION (this << index);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1526
  if (index < m_injectedRoutes.size ())
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1527
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1528
      uint32_t tmp = 0;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1529
      for (InjectedRoutesCI i = m_injectedRoutes.begin ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1530
           i != m_injectedRoutes.end ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1531
           i++)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1532
        {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1533
          if (tmp  == index)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1534
            {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1535
              return *i;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1536
            }
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1537
          tmp++;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1538
        }
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1539
    }
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1540
  NS_ASSERT (false);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1541
  // quiet compiler.
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1542
  return 0;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1543
}
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1544
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1545
uint32_t
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1546
GlobalRouter::GetNInjectedRoutes ()
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1547
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1548
  NS_LOG_FUNCTION (this);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1549
  return m_injectedRoutes.size ();
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1550
}
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1551
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1552
void
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1553
GlobalRouter::RemoveInjectedRoute (uint32_t index)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1554
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1555
  NS_LOG_FUNCTION (this << index);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1556
  NS_ASSERT (index < m_injectedRoutes.size ());
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1557
  uint32_t tmp = 0;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1558
  for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1559
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1560
      if (tmp  == index)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1561
        {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1562
          NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_injectedRoutes.size ());
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1563
          delete *i;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1564
          m_injectedRoutes.erase (i);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1565
          return;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1566
        }
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1567
      tmp++;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1568
    }
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1569
}
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1570
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1571
bool
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1572
GlobalRouter::WithdrawRoute (Ipv4Address network, Ipv4Mask networkMask)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1573
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1574
  NS_LOG_FUNCTION (this << network << networkMask);
4745
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1575
  for (InjectedRoutesI i = m_injectedRoutes.begin (); i != m_injectedRoutes.end (); i++)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1576
    {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1577
      if ((*i)->GetDestNetwork () == network && (*i)->GetDestNetworkMask () == networkMask)
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1578
        {
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1579
          NS_LOG_LOGIC ("Withdrawing route to network/mask " << network << "/" << networkMask);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1580
          delete *i;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1581
          m_injectedRoutes.erase (i);
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1582
          return true;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1583
        }
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1584
    }
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1585
  return false;
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1586
}
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1587
a0e27af57c8d Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents: 4628
diff changeset
  1588
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1589
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1590
// Link through the given channel and find the net device that's on the
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1591
// other end.  This only makes sense with a point-to-point channel.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1592
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1593
Ptr<NetDevice>
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1594
GlobalRouter::GetAdjacent (Ptr<NetDevice> nd, Ptr<Channel> ch) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1595
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1596
  NS_LOG_FUNCTION (this << nd << ch);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1597
  NS_ASSERT_MSG (ch->GetNDevices () == 2, "GlobalRouter::GetAdjacent (): Channel with other than two devices");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1598
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1599
// This is a point to point channel with two endpoints.  Get both of them.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1600
//
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1601
  Ptr<NetDevice> nd1 = ch->GetDevice (0);
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1602
  Ptr<NetDevice> nd2 = ch->GetDevice (1);
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1603
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1604
// One of the endpoints is going to be "us" -- that is the net device attached
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1605
// to the node on which we're running -- i.e., "nd".  The other endpoint (the
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1606
// one to which we are connected via the channel) is the adjacent router.
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1607
//
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1608
  if (nd1 == nd)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1609
    {
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1610
      return nd2;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1611
    }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1612
  else if (nd2 == nd)
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1613
    {
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1614
      return nd1;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1615
    }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1616
  else
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1617
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1618
      NS_ASSERT_MSG (false,
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1619
                     "GlobalRouter::GetAdjacent (): Wrong or confused channel?");
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1620
      return 0;
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1621
    }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1622
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1623
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1624
//
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1625
// Given a node and a net device, find an IPV4 interface index that corresponds
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1626
// to that net device.  This function may fail for various reasons.  If a node
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1627
// does not have an internet stack (for example if it is a bridge) we won't have
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1628
// an IPv4 at all.  If the node does have a stack, but the net device in question
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1629
// is bridged, there will not be an interface associated directly with the device.
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1630
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1631
bool
4372
d99061f1167c Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents: 4012
diff changeset
  1632
GlobalRouter::FindInterfaceForDevice (Ptr<Node> node, Ptr<NetDevice> nd, uint32_t &index) const
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1633
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1634
  NS_LOG_FUNCTION (this << node << nd << &index);
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1635
  NS_LOG_LOGIC ("For node " << node->GetId () << " for net device " << nd );
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1636
2257
71a58e70c671 QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2252
diff changeset
  1637
  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1638
  if (ipv4 == 0)
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1639
    {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1640
      NS_LOG_LOGIC ("No Ipv4 interface on node " << node->GetId ());
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1641
      return false;
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1642
    }
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1643
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1644
  for (uint32_t i = 0; i < ipv4->GetNInterfaces (); ++i )
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1645
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1646
      if (ipv4->GetNetDevice (i) == nd)
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1647
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1648
          NS_LOG_LOGIC ("Device " << nd << " has associated ipv4 index " << i);
3937
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1649
          index = i;
04f9377661b8 convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3179
diff changeset
  1650
          return true;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1651
        }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1652
    }
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1653
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1654
  NS_LOG_LOGIC ("Device " << nd << " has no associated ipv4 index");
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1655
  return false;
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1656
}
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1657
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1658
//
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1659
// Decide whether or not a given net device is being bridged by a BridgeNetDevice.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1660
//
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 7136
diff changeset
  1661
Ptr<BridgeNetDevice>
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1662
GlobalRouter::NetDeviceIsBridged (Ptr<NetDevice> nd) const
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1663
{
9704
1db7690f8e8f Partially clean up function logging of internet module.
Kristijan Lenković <k.lenkovic@me.com>
parents: 7256
diff changeset
  1664
  NS_LOG_FUNCTION (this << nd);
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1665
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1666
  Ptr<Node> node = nd->GetNode ();
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1667
  uint32_t nDevices = node->GetNDevices ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1668
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1669
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1670
  // There is no bit on a net device that says it is being bridged, so we have
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1671
  // to look for bridges on the node to which the device is attached.  If we
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1672
  // find a bridge, we need to look through its bridge ports (the devices it
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1673
  // bridges) to see if we find the device in question.
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1674
  //
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1675
  for (uint32_t i = 0; i < nDevices; ++i)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1676
    {
7256
b04ba6772f8c rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents: 7213
diff changeset
  1677
      Ptr<NetDevice> ndTest = node->GetDevice (i);
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1678
      NS_LOG_LOGIC ("Examine device " << i << " " << ndTest);
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1679
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1680
      if (ndTest->IsBridge ())
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1681
        {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1682
          NS_LOG_LOGIC ("device " << i << " is a bridge net device");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1683
          Ptr<BridgeNetDevice> bnd = ndTest->GetObject<BridgeNetDevice> ();
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1684
          NS_ABORT_MSG_UNLESS (bnd, "GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1685
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1686
          for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1687
            {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1688
              NS_LOG_LOGIC ("Examine bridge port " << j << " " << bnd->GetBridgePort (j));
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1689
              if (bnd->GetBridgePort (j) == nd)
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1690
                {
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1691
                  NS_LOG_LOGIC ("Net device " << nd << " is bridged by " << bnd);
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1692
                  return bnd;
3939
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1693
                }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1694
            }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1695
        }
206f627bd5af factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents: 3938
diff changeset
  1696
    }
3944
6a47ccdf2c5d remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents: 3942
diff changeset
  1697
  NS_LOG_LOGIC ("Net device " << nd << " is not bridged");
3941
476c3bed16c0 teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents: 3940
diff changeset
  1698
  return 0;
1111
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1699
}
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1700
835cd416a0a8 rename party
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
  1701
} // namespace ns3