author | Tom Henderson <tomh@tomh.org> |
Mon, 24 May 2010 10:52:58 -0700 | |
changeset 6317 | e4a750adf12c |
parent 6297 | d58f84b6191b |
permissions | -rw-r--r-- |
3962 | 1 |
// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- |
2 |
// |
|
3 |
// Copyright (c) 2008 University of Washington |
|
4 |
// |
|
5 |
// This program is free software; you can redistribute it and/or modify |
|
6 |
// it under the terms of the GNU General Public License version 2 as |
|
7 |
// published by the Free Software Foundation; |
|
8 |
// |
|
9 |
// This program is distributed in the hope that it will be useful, |
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
// GNU General Public License for more details. |
|
13 |
// |
|
14 |
// You should have received a copy of the GNU General Public License |
|
15 |
// along with this program; if not, write to the Free Software |
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
// |
|
18 |
||
19 |
#include "ns3/log.h" |
|
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
20 |
#include "ns3/simulator.h" |
3962 | 21 |
#include "ns3/object.h" |
22 |
#include "ns3/packet.h" |
|
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4603
diff
changeset
|
23 |
#include "ns3/net-device.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
24 |
#include "ns3/ipv4-route.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
25 |
#include "ns3/ipv4-routing-table-entry.h" |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
26 |
#include "ns3/boolean.h" |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
27 |
#include "ipv4-global-routing.h" |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
28 |
#include "global-route-manager.h" |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
29 |
#include <vector> |
3962 | 30 |
|
31 |
NS_LOG_COMPONENT_DEFINE ("Ipv4GlobalRouting"); |
|
32 |
||
33 |
namespace ns3 { |
|
34 |
||
35 |
NS_OBJECT_ENSURE_REGISTERED (Ipv4GlobalRouting); |
|
36 |
||
37 |
TypeId |
|
38 |
Ipv4GlobalRouting::GetTypeId (void) |
|
39 |
{ |
|
40 |
static TypeId tid = TypeId ("ns3::Ipv4GlobalRouting") |
|
41 |
.SetParent<Object> () |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
42 |
.AddAttribute ("RandomEcmpRouting", |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
43 |
"Set to true if packets are randomly routed among ECMP; set to false for using only one route consistently", |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
44 |
BooleanValue(false), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
45 |
MakeBooleanAccessor (&Ipv4GlobalRouting::m_randomEcmpRouting), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
46 |
MakeBooleanChecker ()) |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
47 |
.AddAttribute ("RespondToInterfaceEvents", |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
48 |
"Set to true if you want to dynamically recompute the global routes upon Interface notification events (up/down, or add/remove address)", |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
49 |
BooleanValue(false), |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
50 |
MakeBooleanAccessor (&Ipv4GlobalRouting::m_respondToInterfaceEvents), |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
51 |
MakeBooleanChecker ()) |
3962 | 52 |
; |
53 |
return tid; |
|
54 |
} |
|
55 |
||
56 |
Ipv4GlobalRouting::Ipv4GlobalRouting () |
|
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
57 |
: m_randomEcmpRouting (false), |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
58 |
m_respondToInterfaceEvents (false) |
3962 | 59 |
{ |
60 |
NS_LOG_FUNCTION_NOARGS (); |
|
61 |
} |
|
62 |
||
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
63 |
Ipv4GlobalRouting::~Ipv4GlobalRouting () |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
64 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
65 |
NS_LOG_FUNCTION_NOARGS (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
66 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
67 |
|
3962 | 68 |
void |
69 |
Ipv4GlobalRouting::AddHostRouteTo (Ipv4Address dest, |
|
70 |
Ipv4Address nextHop, |
|
71 |
uint32_t interface) |
|
72 |
{ |
|
73 |
NS_LOG_FUNCTION (dest << nextHop << interface); |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
74 |
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
75 |
*route = Ipv4RoutingTableEntry::CreateHostRouteTo (dest, nextHop, interface); |
3962 | 76 |
m_hostRoutes.push_back (route); |
77 |
} |
|
78 |
||
79 |
void |
|
80 |
Ipv4GlobalRouting::AddHostRouteTo (Ipv4Address dest, |
|
81 |
uint32_t interface) |
|
82 |
{ |
|
83 |
NS_LOG_FUNCTION (dest << interface); |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
84 |
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
85 |
*route = Ipv4RoutingTableEntry::CreateHostRouteTo (dest, interface); |
3962 | 86 |
m_hostRoutes.push_back (route); |
87 |
} |
|
88 |
||
89 |
void |
|
90 |
Ipv4GlobalRouting::AddNetworkRouteTo (Ipv4Address network, |
|
91 |
Ipv4Mask networkMask, |
|
92 |
Ipv4Address nextHop, |
|
93 |
uint32_t interface) |
|
94 |
{ |
|
95 |
NS_LOG_FUNCTION (network << networkMask << nextHop << interface); |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
96 |
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
97 |
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network, |
3962 | 98 |
networkMask, |
99 |
nextHop, |
|
100 |
interface); |
|
101 |
m_networkRoutes.push_back (route); |
|
102 |
} |
|
103 |
||
104 |
void |
|
105 |
Ipv4GlobalRouting::AddNetworkRouteTo (Ipv4Address network, |
|
106 |
Ipv4Mask networkMask, |
|
107 |
uint32_t interface) |
|
108 |
{ |
|
109 |
NS_LOG_FUNCTION (network << networkMask << interface); |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
110 |
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
111 |
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network, |
3962 | 112 |
networkMask, |
113 |
interface); |
|
114 |
m_networkRoutes.push_back (route); |
|
115 |
} |
|
116 |
||
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
117 |
void |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
118 |
Ipv4GlobalRouting::AddASExternalRouteTo (Ipv4Address network, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
119 |
Ipv4Mask networkMask, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
120 |
Ipv4Address nextHop, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
121 |
uint32_t interface) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
122 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
123 |
NS_LOG_FUNCTION (network << networkMask << nextHop); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
124 |
Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
125 |
*route = Ipv4RoutingTableEntry::CreateNetworkRouteTo (network, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
126 |
networkMask, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
127 |
nextHop, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
128 |
interface); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
129 |
m_ASexternalRoutes.push_back (route); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
130 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
131 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
132 |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
133 |
Ptr<Ipv4Route> |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
134 |
Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif) |
3962 | 135 |
{ |
136 |
NS_LOG_FUNCTION_NOARGS (); |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
137 |
NS_LOG_LOGIC ("Looking for route for destination " << dest); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
138 |
Ptr<Ipv4Route> rtentry = 0; |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
139 |
// store all available routes that bring packets to their destination |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
140 |
typedef std::vector<Ipv4RoutingTableEntry*> RouteVec_t; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
141 |
RouteVec_t allRoutes; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
142 |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
143 |
NS_LOG_LOGIC ("Number of m_hostRoutes = " << m_hostRoutes.size ()); |
3962 | 144 |
for (HostRoutesCI i = m_hostRoutes.begin (); |
145 |
i != m_hostRoutes.end (); |
|
146 |
i++) |
|
147 |
{ |
|
148 |
NS_ASSERT ((*i)->IsHost ()); |
|
149 |
if ((*i)->GetDest ().IsEqual (dest)) |
|
150 |
{ |
|
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
151 |
if (oif != 0) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
152 |
{ |
6164
fbd5ec1d7a2f
[bug 850] Ipv4GlobalRouting oif bug
Andrey Churin <aachurin@gmail.com>
parents:
5858
diff
changeset
|
153 |
if (oif != m_ipv4->GetNetDevice((*i)->GetInterface ())) |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
154 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
155 |
NS_LOG_LOGIC ("Not on requested interface, skipping"); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
156 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
157 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
158 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
159 |
allRoutes.push_back (*i); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
160 |
NS_LOG_LOGIC (allRoutes.size () << "Found global host route" << *i); |
3962 | 161 |
} |
162 |
} |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
163 |
if (allRoutes.size () == 0) // if no host route is found |
3962 | 164 |
{ |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
165 |
NS_LOG_LOGIC ("Number of m_networkRoutes" << m_networkRoutes.size ()); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
166 |
for (NetworkRoutesI j = m_networkRoutes.begin (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
167 |
j != m_networkRoutes.end (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
168 |
j++) |
3962 | 169 |
{ |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
170 |
Ipv4Mask mask = (*j)->GetDestNetworkMask (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
171 |
Ipv4Address entry = (*j)->GetDestNetwork (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
172 |
if (mask.IsMatch (dest, entry)) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
173 |
{ |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
174 |
if (oif != 0) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
175 |
{ |
6164
fbd5ec1d7a2f
[bug 850] Ipv4GlobalRouting oif bug
Andrey Churin <aachurin@gmail.com>
parents:
5858
diff
changeset
|
176 |
if (oif != m_ipv4->GetNetDevice((*j)->GetInterface ())) |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
177 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
178 |
NS_LOG_LOGIC ("Not on requested interface, skipping"); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
179 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
180 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
181 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
182 |
allRoutes.push_back (*j); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
183 |
NS_LOG_LOGIC (allRoutes.size () << "Found global network route" << *j); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
184 |
} |
3962 | 185 |
} |
186 |
} |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
187 |
if (allRoutes.size () == 0) // consider external if no host/network found |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
188 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
189 |
for (ASExternalRoutesI k = m_ASexternalRoutes.begin (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
190 |
k != m_ASexternalRoutes.end (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
191 |
k++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
192 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
193 |
Ipv4Mask mask = (*k)->GetDestNetworkMask (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
194 |
Ipv4Address entry = (*k)->GetDestNetwork (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
195 |
if (mask.IsMatch (dest, entry)) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
196 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
197 |
NS_LOG_LOGIC ("Found external route" << *k); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
198 |
if (oif != 0) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
199 |
{ |
6164
fbd5ec1d7a2f
[bug 850] Ipv4GlobalRouting oif bug
Andrey Churin <aachurin@gmail.com>
parents:
5858
diff
changeset
|
200 |
if (oif != m_ipv4->GetNetDevice((*k)->GetInterface ())) |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
201 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
202 |
NS_LOG_LOGIC ("Not on requested interface, skipping"); |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
203 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
204 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
205 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
206 |
allRoutes.push_back (*k); |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
207 |
break; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
208 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
209 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
210 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
211 |
if (allRoutes.size () > 0 ) // if route(s) is found |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
212 |
{ |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
213 |
// pick up one of the routes uniformly at random if random |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
214 |
// ECMP routing is enabled, or always select the first route |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
215 |
// consistently if random ECMP routing is disabled |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
216 |
uint32_t selectIndex; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
217 |
if (m_randomEcmpRouting) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
218 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
219 |
selectIndex = m_rand.GetInteger (0, allRoutes.size ()-1); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
220 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
221 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
222 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
223 |
selectIndex = 0; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
224 |
} |
6164
fbd5ec1d7a2f
[bug 850] Ipv4GlobalRouting oif bug
Andrey Churin <aachurin@gmail.com>
parents:
5858
diff
changeset
|
225 |
Ipv4RoutingTableEntry* route = allRoutes.at (selectIndex); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5856
diff
changeset
|
226 |
// create a Ipv4Route object from the selected routing table entry |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
227 |
rtentry = Create<Ipv4Route> (); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
228 |
rtentry->SetDestination (route->GetDest ()); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
229 |
// XXX handle multi-address case |
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
230 |
rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ()); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
231 |
rtentry->SetGateway (route->GetGateway ()); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
232 |
uint32_t interfaceIdx = route->GetInterface (); |
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
233 |
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
234 |
return rtentry; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
235 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
236 |
else |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
237 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
238 |
return 0; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
239 |
} |
3962 | 240 |
} |
241 |
||
242 |
uint32_t |
|
243 |
Ipv4GlobalRouting::GetNRoutes (void) |
|
244 |
{ |
|
245 |
NS_LOG_FUNCTION_NOARGS (); |
|
246 |
uint32_t n = 0; |
|
247 |
n += m_hostRoutes.size (); |
|
248 |
n += m_networkRoutes.size (); |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
249 |
n += m_ASexternalRoutes.size (); |
3962 | 250 |
return n; |
251 |
} |
|
252 |
||
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
253 |
Ipv4RoutingTableEntry * |
3962 | 254 |
Ipv4GlobalRouting::GetRoute (uint32_t index) |
255 |
{ |
|
256 |
NS_LOG_FUNCTION (index); |
|
257 |
if (index < m_hostRoutes.size ()) |
|
258 |
{ |
|
259 |
uint32_t tmp = 0; |
|
260 |
for (HostRoutesCI i = m_hostRoutes.begin (); |
|
261 |
i != m_hostRoutes.end (); |
|
262 |
i++) |
|
263 |
{ |
|
264 |
if (tmp == index) |
|
265 |
{ |
|
266 |
return *i; |
|
267 |
} |
|
268 |
tmp++; |
|
269 |
} |
|
270 |
} |
|
271 |
index -= m_hostRoutes.size (); |
|
272 |
uint32_t tmp = 0; |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
273 |
if (index < m_networkRoutes.size()) |
3962 | 274 |
{ |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
275 |
for (NetworkRoutesI j = m_networkRoutes.begin (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
276 |
j != m_networkRoutes.end (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
277 |
j++) |
3962 | 278 |
{ |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
279 |
if (tmp == index) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
280 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
281 |
return *j; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
282 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
283 |
tmp++; |
3962 | 284 |
} |
285 |
} |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
286 |
index -= m_networkRoutes.size(); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
287 |
tmp = 0; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
288 |
for (ASExternalRoutesI k = m_ASexternalRoutes.begin (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
289 |
k != m_ASexternalRoutes.end (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
290 |
k++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
291 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
292 |
if (tmp == index) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
293 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
294 |
return *k; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
295 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
296 |
tmp++; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
297 |
} |
3962 | 298 |
NS_ASSERT (false); |
299 |
// quiet compiler. |
|
300 |
return 0; |
|
301 |
} |
|
302 |
void |
|
303 |
Ipv4GlobalRouting::RemoveRoute (uint32_t index) |
|
304 |
{ |
|
305 |
NS_LOG_FUNCTION (index); |
|
306 |
if (index < m_hostRoutes.size ()) |
|
307 |
{ |
|
308 |
uint32_t tmp = 0; |
|
309 |
for (HostRoutesI i = m_hostRoutes.begin (); |
|
310 |
i != m_hostRoutes.end (); |
|
311 |
i++) |
|
312 |
{ |
|
313 |
if (tmp == index) |
|
314 |
{ |
|
315 |
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostRoutes.size()); |
|
316 |
delete *i; |
|
317 |
m_hostRoutes.erase (i); |
|
318 |
NS_LOG_LOGIC ("Done removing host route " << index << "; host route remaining size = " << m_hostRoutes.size()); |
|
319 |
return; |
|
320 |
} |
|
321 |
tmp++; |
|
322 |
} |
|
323 |
} |
|
324 |
index -= m_hostRoutes.size (); |
|
325 |
uint32_t tmp = 0; |
|
326 |
for (NetworkRoutesI j = m_networkRoutes.begin (); |
|
327 |
j != m_networkRoutes.end (); |
|
328 |
j++) |
|
329 |
{ |
|
330 |
if (tmp == index) |
|
331 |
{ |
|
332 |
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRoutes.size()); |
|
333 |
delete *j; |
|
334 |
m_networkRoutes.erase (j); |
|
335 |
NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size()); |
|
336 |
return; |
|
337 |
} |
|
338 |
tmp++; |
|
339 |
} |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
340 |
index -= m_networkRoutes.size (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
341 |
tmp = 0; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
342 |
for (ASExternalRoutesI k = m_ASexternalRoutes.begin (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
343 |
k != m_ASexternalRoutes.end (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
344 |
k++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
345 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
346 |
if (tmp == index) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
347 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
348 |
NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexternalRoutes.size()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
349 |
delete *k; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
350 |
m_ASexternalRoutes.erase (k); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
351 |
NS_LOG_LOGIC ("Done removing network route " << index << "; network route remaining size = " << m_networkRoutes.size()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
352 |
return; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
353 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
354 |
tmp++; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
355 |
} |
3962 | 356 |
NS_ASSERT (false); |
357 |
} |
|
358 |
||
359 |
void |
|
360 |
Ipv4GlobalRouting::DoDispose (void) |
|
361 |
{ |
|
362 |
NS_LOG_FUNCTION_NOARGS (); |
|
363 |
for (HostRoutesI i = m_hostRoutes.begin (); |
|
364 |
i != m_hostRoutes.end (); |
|
365 |
i = m_hostRoutes.erase (i)) |
|
366 |
{ |
|
367 |
delete (*i); |
|
368 |
} |
|
369 |
for (NetworkRoutesI j = m_networkRoutes.begin (); |
|
370 |
j != m_networkRoutes.end (); |
|
371 |
j = m_networkRoutes.erase (j)) |
|
372 |
{ |
|
373 |
delete (*j); |
|
374 |
} |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
375 |
for (ASExternalRoutesI l = m_ASexternalRoutes.begin (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
376 |
l != m_ASexternalRoutes.end (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
377 |
l = m_ASexternalRoutes.erase (l)) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
378 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
379 |
delete (*l); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
380 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4628
diff
changeset
|
381 |
|
3962 | 382 |
Ipv4RoutingProtocol::DoDispose (); |
383 |
} |
|
384 |
||
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
385 |
Ptr<Ipv4Route> |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
386 |
Ipv4GlobalRouting::RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
387 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
388 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
389 |
// |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
390 |
// First, see if this is a multicast packet we have a route for. If we |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
391 |
// have a route, then send the packet down each of the specified interfaces. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
392 |
// |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
393 |
if (header.GetDestination().IsMulticast ()) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
394 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
395 |
NS_LOG_LOGIC ("Multicast destination-- returning false"); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
396 |
return 0; // Let other routing protocols try to handle this |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
397 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
398 |
// |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
399 |
// See if this is a unicast packet we have a route for. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
400 |
// |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
401 |
NS_LOG_LOGIC ("Unicast destination- looking up"); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5352
diff
changeset
|
402 |
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination (), oif); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
403 |
if (rtentry) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
404 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
405 |
sockerr = Socket::ERROR_NOTERROR; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
406 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
407 |
else |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
408 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
409 |
sockerr = Socket::ERROR_NOROUTETOHOST; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
410 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
411 |
return rtentry; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
412 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
413 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
414 |
bool |
5352
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
415 |
Ipv4GlobalRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
416 |
LocalDeliverCallback lcb, ErrorCallback ecb) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
417 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
418 |
|
5352
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
419 |
NS_LOG_FUNCTION (this << p << header << header.GetSource () << header.GetDestination () << idev); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
420 |
// Check if input device supports IP |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
421 |
NS_ASSERT (m_ipv4->GetInterfaceForDevice (idev) >= 0); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
422 |
uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
423 |
|
5352
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
424 |
if (header.GetDestination ().IsMulticast ()) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
425 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
426 |
NS_LOG_LOGIC ("Multicast destination-- returning false"); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
427 |
return false; // Let other routing protocols try to handle this |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
428 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
429 |
|
5352
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
430 |
if (header.GetDestination ().IsBroadcast ()) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
431 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
432 |
NS_LOG_LOGIC ("For me (Ipv4Addr broadcast address)"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
433 |
// TODO: Local Deliver for broadcast |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
434 |
// TODO: Forward broadcast |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
435 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
436 |
|
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
437 |
// TODO: Configurable option to enable RFC 1222 Strong End System Model |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
438 |
// Right now, we will be permissive and allow a source to send us |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
439 |
// a packet to one of our other interface addresses; that is, the |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
440 |
// destination unicast address does not match one of the iif addresses, |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
441 |
// but we check our other interfaces. This could be an option |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
442 |
// (to remove the outer loop immediately below and just check iif). |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
443 |
for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
444 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
445 |
for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
446 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
447 |
Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
448 |
Ipv4Address addr = iaddr.GetLocal (); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
449 |
if (addr.IsEqual (header.GetDestination ())) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
450 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
451 |
if (j == iif) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
452 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
453 |
NS_LOG_LOGIC ("For me (destination " << addr << " match)"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
454 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
455 |
else |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
456 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
457 |
NS_LOG_LOGIC ("For me (destination " << addr << " match) on another interface " << header.GetDestination ()); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
458 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
459 |
lcb (p, header, iif); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
460 |
return true; |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
461 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
462 |
if (header.GetDestination ().IsEqual (iaddr.GetBroadcast ())) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
463 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
464 |
NS_LOG_LOGIC ("For me (interface broadcast address)"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
465 |
lcb (p, header, iif); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
466 |
return true; |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
467 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
468 |
NS_LOG_LOGIC ("Address "<< addr << " not a match"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
469 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
470 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
471 |
// Check if input device supports IP forwarding |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
472 |
if (m_ipv4->IsForwarding (iif) == false) |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
473 |
{ |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
474 |
NS_LOG_LOGIC ("Forwarding disabled for this interface"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
475 |
ecb (p, header, Socket::ERROR_NOROUTETOHOST); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
476 |
return false; |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
477 |
} |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
478 |
// Next, try to find a route |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
479 |
NS_LOG_LOGIC ("Unicast destination- looking up global route"); |
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
480 |
Ptr<Ipv4Route> rtentry = LookupGlobal (header.GetDestination ()); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
481 |
if (rtentry != 0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
482 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
483 |
NS_LOG_LOGIC ("Found unicast destination- calling unicast callback"); |
5352
54b51a1105d6
allow static and global routing to deliver local packets (bug 651)
Tom Henderson <tomh@tomh.org>
parents:
4745
diff
changeset
|
484 |
ucb (rtentry, p, header); |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
485 |
return true; |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
486 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
487 |
else |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
488 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
489 |
NS_LOG_LOGIC ("Did not find unicast destination- returning false"); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
490 |
return false; // Let other routing protocols try to handle this |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
491 |
// route request. |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
492 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
493 |
} |
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
494 |
void |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
495 |
Ipv4GlobalRouting::NotifyInterfaceUp (uint32_t i) |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
496 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
497 |
NS_LOG_FUNCTION (this << i); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
498 |
if (m_respondToInterfaceEvents && Simulator::Now ().GetSeconds () > 0) // avoid startup events |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
499 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
500 |
GlobalRouteManager::DeleteGlobalRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
501 |
GlobalRouteManager::BuildGlobalRoutingDatabase (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
502 |
GlobalRouteManager::InitializeRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
503 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
504 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
505 |
|
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
506 |
void |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
507 |
Ipv4GlobalRouting::NotifyInterfaceDown (uint32_t i) |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
508 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
509 |
NS_LOG_FUNCTION (this << i); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
510 |
if (m_respondToInterfaceEvents && Simulator::Now ().GetSeconds () > 0) // avoid startup events |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
511 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
512 |
GlobalRouteManager::DeleteGlobalRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
513 |
GlobalRouteManager::BuildGlobalRoutingDatabase (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
514 |
GlobalRouteManager::InitializeRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
515 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
516 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
517 |
|
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
518 |
void |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
519 |
Ipv4GlobalRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
520 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
521 |
NS_LOG_FUNCTION (this << interface << address); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
522 |
if (m_respondToInterfaceEvents && Simulator::Now ().GetSeconds () > 0) // avoid startup events |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
523 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
524 |
GlobalRouteManager::DeleteGlobalRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
525 |
GlobalRouteManager::BuildGlobalRoutingDatabase (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
526 |
GlobalRouteManager::InitializeRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
527 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
528 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
529 |
|
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
530 |
void |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
531 |
Ipv4GlobalRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) |
6317
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
532 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
533 |
NS_LOG_FUNCTION (this << interface << address); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
534 |
if (m_respondToInterfaceEvents && Simulator::Now ().GetSeconds () > 0) // avoid startup events |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
535 |
{ |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
536 |
GlobalRouteManager::DeleteGlobalRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
537 |
GlobalRouteManager::BuildGlobalRoutingDatabase (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
538 |
GlobalRouteManager::InitializeRoutes (); |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
539 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
540 |
} |
e4a750adf12c
bug 702: make global routing robust to link/device events
Tom Henderson <tomh@tomh.org>
parents:
6297
diff
changeset
|
541 |
|
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
542 |
void |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
543 |
Ipv4GlobalRouting::SetIpv4 (Ptr<Ipv4> ipv4) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
544 |
{ |
4560
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
545 |
NS_LOG_FUNCTION(this << ipv4); |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
546 |
NS_ASSERT (m_ipv4 == 0 && ipv4 != 0); |
2f106fd728ab
Remove static routing dependencies in code
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4527
diff
changeset
|
547 |
m_ipv4 = ipv4; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
548 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
549 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
550 |
|
3962 | 551 |
}//namespace ns3 |