author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 26 Jun 2009 15:34:16 +0200 | |
changeset 4616 | a84f60b6cd12 |
parent 4607 | 0e15594f67f3 |
child 4628 | a5a8c44e4240 |
permissions | -rw-r--r-- |
1111 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
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 | 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 |
|
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1278
diff
changeset
|
17 |
* |
1505 | 18 |
* Authors: Tom Henderson (tomhend@u.washington.edu) |
1111 | 19 |
*/ |
20 |
||
1505 | 21 |
#include "ns3/log.h" |
1111 | 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 | 24 |
#include "ns3/channel.h" |
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" |
1111 | 27 |
#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
|
28 |
#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
|
29 |
#include "ipv4-global-routing.h" |
1111 | 30 |
#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
|
31 |
#include <vector> |
1111 | 32 |
|
1505 | 33 |
NS_LOG_COMPONENT_DEFINE ("GlobalRouter"); |
1111 | 34 |
|
35 |
namespace ns3 { |
|
36 |
||
37 |
// --------------------------------------------------------------------------- |
|
38 |
// |
|
1278 | 39 |
// GlobalRoutingLinkRecord Implementation |
1111 | 40 |
// |
41 |
// --------------------------------------------------------------------------- |
|
42 |
||
1278 | 43 |
GlobalRoutingLinkRecord::GlobalRoutingLinkRecord () |
1111 | 44 |
: |
45 |
m_linkId ("0.0.0.0"), |
|
46 |
m_linkData ("0.0.0.0"), |
|
47 |
m_linkType (Unknown), |
|
48 |
m_metric (0) |
|
49 |
{ |
|
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
|
50 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 51 |
} |
52 |
||
1278 | 53 |
GlobalRoutingLinkRecord::GlobalRoutingLinkRecord ( |
1111 | 54 |
LinkType linkType, |
55 |
Ipv4Address linkId, |
|
56 |
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
|
57 |
uint16_t metric) |
1111 | 58 |
: |
59 |
m_linkId (linkId), |
|
60 |
m_linkData (linkData), |
|
61 |
m_linkType (linkType), |
|
62 |
m_metric (metric) |
|
63 |
{ |
|
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
|
64 |
NS_LOG_FUNCTION (this << linkType << linkId << linkData << metric); |
1111 | 65 |
} |
66 |
||
1278 | 67 |
GlobalRoutingLinkRecord::~GlobalRoutingLinkRecord () |
1111 | 68 |
{ |
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
|
69 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 70 |
} |
71 |
||
72 |
Ipv4Address |
|
1278 | 73 |
GlobalRoutingLinkRecord::GetLinkId (void) const |
1111 | 74 |
{ |
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
|
75 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 76 |
return m_linkId; |
77 |
} |
|
78 |
||
79 |
void |
|
1278 | 80 |
GlobalRoutingLinkRecord::SetLinkId (Ipv4Address addr) |
1111 | 81 |
{ |
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
|
82 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 83 |
m_linkId = addr; |
84 |
} |
|
85 |
||
86 |
Ipv4Address |
|
1278 | 87 |
GlobalRoutingLinkRecord::GetLinkData (void) const |
1111 | 88 |
{ |
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
|
89 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 90 |
return m_linkData; |
91 |
} |
|
92 |
||
93 |
void |
|
1278 | 94 |
GlobalRoutingLinkRecord::SetLinkData (Ipv4Address addr) |
1111 | 95 |
{ |
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
|
96 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 97 |
m_linkData = addr; |
98 |
} |
|
99 |
||
1278 | 100 |
GlobalRoutingLinkRecord::LinkType |
101 |
GlobalRoutingLinkRecord::GetLinkType (void) const |
|
1111 | 102 |
{ |
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
|
103 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 104 |
return m_linkType; |
105 |
} |
|
106 |
||
107 |
void |
|
1278 | 108 |
GlobalRoutingLinkRecord::SetLinkType ( |
109 |
GlobalRoutingLinkRecord::LinkType linkType) |
|
1111 | 110 |
{ |
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
|
111 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 112 |
m_linkType = linkType; |
113 |
} |
|
114 |
||
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
|
115 |
uint16_t |
1278 | 116 |
GlobalRoutingLinkRecord::GetMetric (void) const |
1111 | 117 |
{ |
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
|
118 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 119 |
return m_metric; |
120 |
} |
|
121 |
||
122 |
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
|
123 |
GlobalRoutingLinkRecord::SetMetric (uint16_t metric) |
1111 | 124 |
{ |
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
|
125 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 126 |
m_metric = metric; |
127 |
} |
|
128 |
||
129 |
// --------------------------------------------------------------------------- |
|
130 |
// |
|
1278 | 131 |
// GlobalRoutingLSA Implementation |
1111 | 132 |
// |
133 |
// --------------------------------------------------------------------------- |
|
134 |
||
1278 | 135 |
GlobalRoutingLSA::GlobalRoutingLSA() |
1111 | 136 |
: |
1278 | 137 |
m_lsType (GlobalRoutingLSA::Unknown), |
1111 | 138 |
m_linkStateId("0.0.0.0"), |
139 |
m_advertisingRtr("0.0.0.0"), |
|
140 |
m_linkRecords(), |
|
1278 | 141 |
m_networkLSANetworkMask("0.0.0.0"), |
142 |
m_attachedRouters(), |
|
143 |
m_status(GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED) |
|
1111 | 144 |
{ |
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
|
145 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 146 |
} |
147 |
||
1278 | 148 |
GlobalRoutingLSA::GlobalRoutingLSA ( |
149 |
GlobalRoutingLSA::SPFStatus status, |
|
1111 | 150 |
Ipv4Address linkStateId, |
151 |
Ipv4Address advertisingRtr) |
|
152 |
: |
|
1278 | 153 |
m_lsType (GlobalRoutingLSA::Unknown), |
1111 | 154 |
m_linkStateId(linkStateId), |
155 |
m_advertisingRtr(advertisingRtr), |
|
156 |
m_linkRecords(), |
|
1278 | 157 |
m_networkLSANetworkMask("0.0.0.0"), |
158 |
m_attachedRouters(), |
|
1111 | 159 |
m_status(status) |
160 |
{ |
|
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
|
161 |
NS_LOG_FUNCTION (this << status << linkStateId << advertisingRtr); |
1111 | 162 |
} |
163 |
||
1278 | 164 |
GlobalRoutingLSA::GlobalRoutingLSA (GlobalRoutingLSA& lsa) |
165 |
: m_lsType(lsa.m_lsType), m_linkStateId(lsa.m_linkStateId), |
|
166 |
m_advertisingRtr(lsa.m_advertisingRtr), |
|
167 |
m_networkLSANetworkMask(lsa.m_networkLSANetworkMask), |
|
1111 | 168 |
m_status(lsa.m_status) |
169 |
{ |
|
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
|
170 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 171 |
NS_ASSERT_MSG(IsEmpty(), |
1278 | 172 |
"GlobalRoutingLSA::GlobalRoutingLSA (): Non-empty LSA in constructor"); |
1111 | 173 |
CopyLinkRecords (lsa); |
174 |
} |
|
175 |
||
1278 | 176 |
GlobalRoutingLSA& |
177 |
GlobalRoutingLSA::operator= (const GlobalRoutingLSA& lsa) |
|
1111 | 178 |
{ |
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
|
179 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 180 |
m_lsType = lsa.m_lsType; |
1111 | 181 |
m_linkStateId = lsa.m_linkStateId; |
182 |
m_advertisingRtr = lsa.m_advertisingRtr; |
|
1278 | 183 |
m_networkLSANetworkMask = lsa.m_networkLSANetworkMask, |
1111 | 184 |
m_status = lsa.m_status; |
185 |
||
186 |
ClearLinkRecords (); |
|
187 |
CopyLinkRecords (lsa); |
|
188 |
return *this; |
|
189 |
} |
|
190 |
||
191 |
void |
|
1278 | 192 |
GlobalRoutingLSA::CopyLinkRecords (const GlobalRoutingLSA& lsa) |
1111 | 193 |
{ |
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
|
194 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 195 |
for (ListOfLinkRecords_t::const_iterator i = lsa.m_linkRecords.begin (); |
196 |
i != lsa.m_linkRecords.end (); |
|
197 |
i++) |
|
198 |
{ |
|
1278 | 199 |
GlobalRoutingLinkRecord *pSrc = *i; |
200 |
GlobalRoutingLinkRecord *pDst = new GlobalRoutingLinkRecord; |
|
1111 | 201 |
|
202 |
pDst->SetLinkType (pSrc->GetLinkType ()); |
|
203 |
pDst->SetLinkId (pSrc->GetLinkId ()); |
|
204 |
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
|
205 |
pDst->SetMetric (pSrc->GetMetric ()); |
1111 | 206 |
|
207 |
m_linkRecords.push_back(pDst); |
|
208 |
pDst = 0; |
|
209 |
} |
|
1278 | 210 |
|
211 |
m_attachedRouters = lsa.m_attachedRouters; |
|
1111 | 212 |
} |
213 |
||
1278 | 214 |
GlobalRoutingLSA::~GlobalRoutingLSA() |
1111 | 215 |
{ |
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
|
216 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 217 |
ClearLinkRecords (); |
218 |
} |
|
219 |
||
220 |
void |
|
1278 | 221 |
GlobalRoutingLSA::ClearLinkRecords(void) |
1111 | 222 |
{ |
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
|
223 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 224 |
for ( ListOfLinkRecords_t::iterator i = m_linkRecords.begin (); |
225 |
i != m_linkRecords.end (); |
|
226 |
i++) |
|
227 |
{ |
|
1505 | 228 |
NS_LOG_LOGIC ("Free link record"); |
1111 | 229 |
|
1278 | 230 |
GlobalRoutingLinkRecord *p = *i; |
1111 | 231 |
delete p; |
232 |
p = 0; |
|
233 |
||
234 |
*i = 0; |
|
235 |
} |
|
1505 | 236 |
NS_LOG_LOGIC ("Clear list"); |
1111 | 237 |
m_linkRecords.clear(); |
238 |
} |
|
239 |
||
240 |
uint32_t |
|
1278 | 241 |
GlobalRoutingLSA::AddLinkRecord (GlobalRoutingLinkRecord* lr) |
1111 | 242 |
{ |
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
|
243 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 244 |
m_linkRecords.push_back (lr); |
245 |
return m_linkRecords.size (); |
|
246 |
} |
|
247 |
||
248 |
uint32_t |
|
1278 | 249 |
GlobalRoutingLSA::GetNLinkRecords (void) const |
1111 | 250 |
{ |
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
|
251 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 252 |
return m_linkRecords.size (); |
253 |
} |
|
254 |
||
1278 | 255 |
GlobalRoutingLinkRecord * |
256 |
GlobalRoutingLSA::GetLinkRecord (uint32_t n) const |
|
1111 | 257 |
{ |
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
|
258 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 259 |
uint32_t j = 0; |
260 |
for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin (); |
|
261 |
i != m_linkRecords.end (); |
|
262 |
i++, j++) |
|
263 |
{ |
|
264 |
if (j == n) |
|
265 |
{ |
|
266 |
return *i; |
|
267 |
} |
|
268 |
} |
|
1278 | 269 |
NS_ASSERT_MSG(false, "GlobalRoutingLSA::GetLinkRecord (): invalid index"); |
1111 | 270 |
return 0; |
271 |
} |
|
272 |
||
273 |
bool |
|
1278 | 274 |
GlobalRoutingLSA::IsEmpty (void) const |
1111 | 275 |
{ |
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
|
276 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 277 |
return m_linkRecords.size () == 0; |
278 |
} |
|
279 |
||
1278 | 280 |
GlobalRoutingLSA::LSType |
281 |
GlobalRoutingLSA::GetLSType (void) const |
|
282 |
{ |
|
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
|
283 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 284 |
return m_lsType; |
285 |
} |
|
286 |
||
287 |
void |
|
288 |
GlobalRoutingLSA::SetLSType (GlobalRoutingLSA::LSType typ) |
|
289 |
{ |
|
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
|
290 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 291 |
m_lsType = typ; |
292 |
} |
|
293 |
||
1111 | 294 |
Ipv4Address |
1278 | 295 |
GlobalRoutingLSA::GetLinkStateId (void) const |
1111 | 296 |
{ |
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
|
297 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 298 |
return m_linkStateId; |
299 |
} |
|
300 |
||
301 |
void |
|
1278 | 302 |
GlobalRoutingLSA::SetLinkStateId (Ipv4Address addr) |
1111 | 303 |
{ |
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
|
304 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 305 |
m_linkStateId = addr; |
306 |
} |
|
307 |
||
308 |
Ipv4Address |
|
1278 | 309 |
GlobalRoutingLSA::GetAdvertisingRouter (void) const |
1111 | 310 |
{ |
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
|
311 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 312 |
return m_advertisingRtr; |
313 |
} |
|
314 |
||
315 |
void |
|
1278 | 316 |
GlobalRoutingLSA::SetAdvertisingRouter (Ipv4Address addr) |
1111 | 317 |
{ |
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
|
318 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 319 |
m_advertisingRtr = addr; |
320 |
} |
|
321 |
||
1278 | 322 |
void |
323 |
GlobalRoutingLSA::SetNetworkLSANetworkMask (Ipv4Mask mask) |
|
324 |
{ |
|
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
|
325 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 326 |
m_networkLSANetworkMask = mask; |
327 |
} |
|
328 |
||
329 |
Ipv4Mask |
|
330 |
GlobalRoutingLSA::GetNetworkLSANetworkMask (void) const |
|
331 |
{ |
|
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
|
332 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 333 |
return m_networkLSANetworkMask; |
334 |
} |
|
335 |
||
336 |
GlobalRoutingLSA::SPFStatus |
|
337 |
GlobalRoutingLSA::GetStatus (void) const |
|
1111 | 338 |
{ |
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
|
339 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 340 |
return m_status; |
341 |
} |
|
342 |
||
1278 | 343 |
uint32_t |
344 |
GlobalRoutingLSA::AddAttachedRouter (Ipv4Address addr) |
|
345 |
{ |
|
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
|
346 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 347 |
m_attachedRouters.push_back (addr); |
348 |
return m_attachedRouters.size (); |
|
349 |
} |
|
350 |
||
351 |
uint32_t |
|
352 |
GlobalRoutingLSA::GetNAttachedRouters (void) const |
|
353 |
{ |
|
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
|
354 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 355 |
return m_attachedRouters.size (); |
356 |
} |
|
357 |
||
358 |
Ipv4Address |
|
359 |
GlobalRoutingLSA::GetAttachedRouter (uint32_t n) const |
|
360 |
{ |
|
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
|
361 |
NS_LOG_FUNCTION_NOARGS (); |
1278 | 362 |
uint32_t j = 0; |
363 |
for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin (); |
|
364 |
i != m_attachedRouters.end (); |
|
365 |
i++, j++) |
|
366 |
{ |
|
367 |
if (j == n) |
|
368 |
{ |
|
369 |
return *i; |
|
370 |
} |
|
371 |
} |
|
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
372 |
NS_ASSERT_MSG(false, "GlobalRoutingLSA::GetAttachedRouter (): invalid index"); |
1278 | 373 |
return Ipv4Address("0.0.0.0"); |
374 |
} |
|
375 |
||
1111 | 376 |
void |
1278 | 377 |
GlobalRoutingLSA::SetStatus (GlobalRoutingLSA::SPFStatus status) |
1111 | 378 |
{ |
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
|
379 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 380 |
m_status = status; |
381 |
} |
|
382 |
||
383 |
void |
|
1278 | 384 |
GlobalRoutingLSA::Print (std::ostream &os) const |
1111 | 385 |
{ |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
386 |
os << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
387 |
os << "========== Global Routing LSA ==========" << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
388 |
os << "m_lsType = " << m_lsType; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
389 |
if (m_lsType == GlobalRoutingLSA::RouterLSA) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
390 |
{ |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
391 |
os << " (GlobalRoutingLSA::RouterLSA)"; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
392 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
393 |
else if (m_lsType == GlobalRoutingLSA::NetworkLSA) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
394 |
{ |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
395 |
os << " (GlobalRoutingLSA::NetworkLSA)"; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
396 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
397 |
else |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
398 |
{ |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
399 |
os << "(Unknown LSType)"; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
400 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
401 |
os << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
402 |
|
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
403 |
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
|
404 |
os << "m_advertisingRtr = " << m_advertisingRtr << " (Router ID)" << std::endl; |
1111 | 405 |
|
1278 | 406 |
if (m_lsType == GlobalRoutingLSA::RouterLSA) |
407 |
{ |
|
408 |
for ( ListOfLinkRecords_t::const_iterator i = m_linkRecords.begin (); |
|
409 |
i != m_linkRecords.end (); |
|
410 |
i++) |
|
411 |
{ |
|
412 |
GlobalRoutingLinkRecord *p = *i; |
|
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
413 |
|
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
414 |
os << "---------- RouterLSA Link Record ----------" << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
415 |
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
|
416 |
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
|
417 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
418 |
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
|
419 |
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
|
420 |
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
|
421 |
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
|
422 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
423 |
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
|
424 |
{ |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
425 |
os << " (GlobalRoutingLinkRecord::TransitNetwork)" << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
} |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
430 |
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
|
431 |
{ |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
432 |
os << " (GlobalRoutingLinkRecord::StubNetwork)" << std::endl; |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
433 |
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
|
434 |
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
|
435 |
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
|
436 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
437 |
else |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
438 |
{ |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
439 |
os << " (Unknown LinkType)" << std::endl; |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
440 |
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
|
441 |
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
|
442 |
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
|
443 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
444 |
os << "---------- End RouterLSA Link Record ----------" << std::endl; |
1278 | 445 |
} |
446 |
} |
|
447 |
else if (m_lsType == GlobalRoutingLSA::NetworkLSA) |
|
1111 | 448 |
{ |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
449 |
os << "---------- NetworkLSA Link Record ----------" << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
450 |
os << "m_networkLSANetworkMask = " << m_networkLSANetworkMask << std::endl; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
451 |
for ( ListOfAttachedRouters_t::const_iterator i = m_attachedRouters.begin (); i != m_attachedRouters.end (); i++) |
1278 | 452 |
{ |
453 |
Ipv4Address p = *i; |
|
454 |
os << "attachedRouter = " << p << std::endl; |
|
455 |
} |
|
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
456 |
os << "---------- End NetworkLSA Link Record ----------" << std::endl; |
1278 | 457 |
} |
458 |
else |
|
459 |
{ |
|
460 |
NS_ASSERT_MSG(0, "Illegal LSA LSType: " << m_lsType); |
|
1111 | 461 |
} |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
462 |
os << "========== End Global Routing LSA ==========" << std::endl; |
1111 | 463 |
} |
464 |
||
1278 | 465 |
std::ostream& operator<< (std::ostream& os, GlobalRoutingLSA& lsa) |
1111 | 466 |
{ |
467 |
lsa.Print (os); |
|
468 |
return os; |
|
469 |
} |
|
470 |
||
471 |
// --------------------------------------------------------------------------- |
|
472 |
// |
|
473 |
// GlobalRouter Implementation |
|
474 |
// |
|
475 |
// --------------------------------------------------------------------------- |
|
476 |
||
2249
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
477 |
NS_OBJECT_ENSURE_REGISTERED (GlobalRouter); |
3a1da26d61dc
replace ComponentManager::Create and ClassId with InterfaceId::CreateObjest and InterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2238
diff
changeset
|
478 |
|
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2249
diff
changeset
|
479 |
TypeId |
2251
04963d8cca51
iid (void) -> GetTypeId (void)
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
480 |
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
|
481 |
{ |
2602
d9262bff6df2
add back support for introspected doxygen.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
482 |
static TypeId tid = TypeId ("ns3::GlobalRouter") |
2238
05affd9d0dc1
get rid of MakeInterfaceId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2232
diff
changeset
|
483 |
.SetParent<Object> (); |
2252
80595448707a
iid -> tid
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2251
diff
changeset
|
484 |
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
|
485 |
} |
1111 | 486 |
|
1881
24285ca5e94f
fix bug 113 on m_node parameter for GlobalRouter
Tom Henderson <tomh@tomh.org>
parents:
1828
diff
changeset
|
487 |
GlobalRouter::GlobalRouter () |
24285ca5e94f
fix bug 113 on m_node parameter for GlobalRouter
Tom Henderson <tomh@tomh.org>
parents:
1828
diff
changeset
|
488 |
: m_LSAs() |
1111 | 489 |
{ |
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
|
490 |
NS_LOG_FUNCTION_NOARGS (); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
491 |
m_routerId.Set(GlobalRouteManager::AllocateRouterId ()); |
1111 | 492 |
} |
493 |
||
494 |
GlobalRouter::~GlobalRouter () |
|
495 |
{ |
|
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
|
496 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 497 |
ClearLSAs(); |
498 |
} |
|
499 |
||
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
|
500 |
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
|
501 |
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
|
502 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4607
diff
changeset
|
503 |
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
|
504 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4607
diff
changeset
|
505 |
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
|
506 |
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
|
507 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4607
diff
changeset
|
508 |
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
|
509 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4607
diff
changeset
|
510 |
|
1202
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
511 |
void |
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
512 |
GlobalRouter::DoDispose () |
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
513 |
{ |
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
|
514 |
NS_LOG_FUNCTION_NOARGS (); |
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
|
515 |
m_routingProtocol = 0; |
1202
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
516 |
Object::DoDispose (); |
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
517 |
} |
953cc2fadcef
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1123
diff
changeset
|
518 |
|
1111 | 519 |
void |
520 |
GlobalRouter::ClearLSAs () |
|
521 |
{ |
|
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
|
522 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 523 |
for ( ListOfLSAs_t::iterator i = m_LSAs.begin (); |
524 |
i != m_LSAs.end (); |
|
525 |
i++) |
|
526 |
{ |
|
1505 | 527 |
NS_LOG_LOGIC ("Free LSA"); |
1111 | 528 |
|
1278 | 529 |
GlobalRoutingLSA *p = *i; |
1111 | 530 |
delete p; |
531 |
p = 0; |
|
532 |
||
533 |
*i = 0; |
|
534 |
} |
|
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
535 |
NS_LOG_LOGIC ("Clear list of LSAs"); |
1111 | 536 |
m_LSAs.clear(); |
537 |
} |
|
538 |
||
539 |
Ipv4Address |
|
540 |
GlobalRouter::GetRouterId (void) const |
|
541 |
{ |
|
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
|
542 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 543 |
return m_routerId; |
544 |
} |
|
545 |
||
546 |
// |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
547 |
// 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
|
548 |
// 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
|
549 |
// 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
|
550 |
// networks. |
1111 | 551 |
// |
552 |
uint32_t |
|
553 |
GlobalRouter::DiscoverLSAs (void) |
|
554 |
{ |
|
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
|
555 |
NS_LOG_FUNCTION_NOARGS (); |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2252
diff
changeset
|
556 |
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
|
557 |
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
|
558 |
NS_LOG_LOGIC ("For node " << node->GetId () ); |
1111 | 559 |
|
560 |
ClearLSAs (); |
|
1278 | 561 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
562 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
563 |
// 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
|
564 |
// 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
|
565 |
// a NetworkLSA for. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
566 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
567 |
NetDeviceContainer c; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
568 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
569 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
570 |
// 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
|
571 |
// 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
|
572 |
// 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
|
573 |
// |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2252
diff
changeset
|
574 |
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
|
575 |
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
|
576 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
577 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
578 |
// Every router node originates a Router-LSA |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
579 |
// |
1278 | 580 |
GlobalRoutingLSA *pLSA = new GlobalRoutingLSA; |
581 |
pLSA->SetLSType (GlobalRoutingLSA::RouterLSA); |
|
1111 | 582 |
pLSA->SetLinkStateId (m_routerId); |
583 |
pLSA->SetAdvertisingRouter (m_routerId); |
|
1278 | 584 |
pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
585 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
586 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
587 |
// 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
|
588 |
// 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
|
589 |
// 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
|
590 |
// 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
|
591 |
// |
1881
24285ca5e94f
fix bug 113 on m_node parameter for GlobalRouter
Tom Henderson <tomh@tomh.org>
parents:
1828
diff
changeset
|
592 |
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
|
593 |
|
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
594 |
// |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
595 |
// 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
|
596 |
// 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
|
597 |
// |
1111 | 598 |
for (uint32_t i = 0; i < numDevices; ++i) |
599 |
{ |
|
1881
24285ca5e94f
fix bug 113 on m_node parameter for GlobalRouter
Tom Henderson <tomh@tomh.org>
parents:
1828
diff
changeset
|
600 |
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
|
601 |
|
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
602 |
// |
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
|
603 |
// 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
|
604 |
// 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
|
605 |
// 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
|
606 |
// |
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
|
607 |
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
|
608 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
609 |
uint32_t interfaceBridge; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
610 |
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
|
611 |
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
|
612 |
} |
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
|
613 |
|
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
|
614 |
// |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
615 |
// 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
|
616 |
// 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
|
617 |
// 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
|
618 |
// 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
|
619 |
// |
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
620 |
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
|
621 |
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
|
622 |
{ |
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
623 |
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
|
624 |
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
|
625 |
{ |
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
626 |
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
|
627 |
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
|
628 |
} |
4ac564369c63
GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2983
diff
changeset
|
629 |
} |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
630 |
|
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
631 |
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
|
632 |
{ |
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
633 |
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
|
634 |
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
|
635 |
} |
4ac564369c63
GlobalRoutingManager: don't abort with non-IP NetDevices, just skip them.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2983
diff
changeset
|
636 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
637 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
638 |
// 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
|
639 |
// 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
|
640 |
// 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
|
641 |
// 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
|
642 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
643 |
// 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
|
644 |
// 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
|
645 |
// |
4607
0e15594f67f3
bug 63: allow enabling or disabling ip forwarding on a per-interface basis
Tom Henderson <tomh@tomh.org>
parents:
4590
diff
changeset
|
646 |
|
1278 | 647 |
if (ndLocal->IsBroadcast () && !ndLocal->IsPointToPoint () ) |
1111 | 648 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
649 |
NS_LOG_LOGIC ("Broadcast link"); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
650 |
ProcessBroadcastLink (ndLocal, pLSA, c); |
1111 | 651 |
} |
1278 | 652 |
else if (ndLocal->IsPointToPoint () ) |
653 |
{ |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
654 |
NS_LOG_LOGIC ("Point=to-point link"); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
655 |
ProcessPointToPointLink (ndLocal, pLSA); |
1278 | 656 |
} |
657 |
else |
|
658 |
{ |
|
659 |
NS_ASSERT_MSG(0, "GlobalRouter::DiscoverLSAs (): unknown link type"); |
|
660 |
} |
|
1111 | 661 |
} |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
662 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
663 |
NS_LOG_LOGIC ("========== LSA for node " << node->GetId () << " =========="); |
1505 | 664 |
NS_LOG_LOGIC (*pLSA); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
665 |
m_LSAs.push_back (pLSA); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
666 |
pLSA = 0; |
1278 | 667 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
668 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
669 |
// 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
|
670 |
// we found at least one designated router. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
671 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
672 |
uint32_t nDesignatedRouters = c.GetN (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
673 |
if (nDesignatedRouters > 0) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
674 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
675 |
NS_LOG_LOGIC ("Build Network LSAs"); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
676 |
BuildNetworkLSAs (c); |
1278 | 677 |
} |
678 |
||
1111 | 679 |
return m_LSAs.size (); |
680 |
} |
|
681 |
||
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
682 |
void |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
683 |
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
|
684 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
685 |
NS_LOG_FUNCTION (nd << pLSA << &c); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
686 |
|
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
687 |
if (nd->IsBridge ()) |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
688 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
689 |
ProcessBridgedBroadcastLink (nd, pLSA, c); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
690 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
691 |
else |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
692 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
693 |
ProcessSingleBroadcastLink (nd, pLSA, c); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
694 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
695 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
696 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
697 |
void |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
698 |
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
|
699 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
700 |
NS_LOG_FUNCTION (nd << pLSA << &c); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
701 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
702 |
GlobalRoutingLinkRecord *plr = new GlobalRoutingLinkRecord; |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
703 |
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
|
704 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
705 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
706 |
// 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
|
707 |
// 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
|
708 |
// 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
|
709 |
// 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
|
710 |
// associated to them. |
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 |
Ptr<Node> node = nd->GetNode (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
713 |
|
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
714 |
uint32_t interfaceLocal; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
715 |
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
|
716 |
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
|
717 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
718 |
Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> (); |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
719 |
NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessSingleBroadcastLink (): GetObject for <Ipv4> interface failed"); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
720 |
|
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
721 |
if (ipv4Local->GetNAddresses (interfaceLocal) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
722 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
723 |
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
|
724 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
725 |
Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal (); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
726 |
Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
727 |
NS_LOG_LOGIC ("Working with local address " << addrLocal); |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
728 |
uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
729 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
730 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
731 |
// 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
|
732 |
// 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
|
733 |
// 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
|
734 |
// is a transit network. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
735 |
// |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
736 |
if (AnotherRouterOnLink (nd, true) == false) |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
737 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
738 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
739 |
// 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
|
740 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
741 |
NS_LOG_LOGIC("Router-LSA Stub Network"); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
742 |
plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
743 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
744 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
745 |
// 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
|
746 |
// the attached network. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
747 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
748 |
plr->SetLinkId (addrLocal.CombineMask(maskLocal)); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
749 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
750 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
751 |
// 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
|
752 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
753 |
Ipv4Address maskLocalAddr; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
754 |
maskLocalAddr.Set(maskLocal.Get ()); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
755 |
plr->SetLinkData (maskLocalAddr); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
756 |
plr->SetMetric (metricLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
757 |
pLSA->AddLinkRecord(plr); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
758 |
plr = 0; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
759 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
760 |
else |
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 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
763 |
// 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
|
764 |
// a transit network. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
765 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
766 |
NS_LOG_LOGIC ("Router-LSA Transit Network"); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
767 |
plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
768 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
769 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
770 |
// 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
|
771 |
// 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
|
772 |
// 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
|
773 |
// case. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
774 |
// |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
775 |
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
|
776 |
|
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
|
777 |
// |
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
|
778 |
// 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
|
779 |
// 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
|
780 |
// |
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
|
781 |
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
|
782 |
{ |
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
|
783 |
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
|
784 |
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
|
785 |
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
|
786 |
"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
|
787 |
} |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
788 |
if (desigRtr == addrLocal) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
789 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
790 |
c.Add (nd); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
791 |
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
|
792 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
793 |
plr->SetLinkId (desigRtr); |
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 |
// 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
|
797 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
798 |
plr->SetLinkData (addrLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
799 |
plr->SetMetric (metricLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
800 |
pLSA->AddLinkRecord (plr); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
801 |
plr = 0; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
802 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
803 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
804 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
805 |
void |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
806 |
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
|
807 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
808 |
NS_LOG_FUNCTION (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
|
809 |
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
|
810 |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
811 |
#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
|
812 |
// |
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
813 |
// 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
|
814 |
// 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
|
815 |
// 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
|
816 |
// 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
|
817 |
// 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
|
818 |
// 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
|
819 |
// 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
|
820 |
// |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
821 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
822 |
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
|
823 |
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
|
824 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
825 |
// |
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
|
826 |
// 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
|
827 |
// 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
|
828 |
// 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
|
829 |
// 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
|
830 |
// 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
|
831 |
// |
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
|
832 |
Ptr<Node> node = nd->GetNode (); |
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 |
|
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
834 |
uint32_t interfaceLocal; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
835 |
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
|
836 |
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
|
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 |
Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> (); |
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 |
NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessBridgedBroadcastLink (): GetObject for <Ipv4> interface failed"); |
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 |
|
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
841 |
if (ipv4Local->GetNAddresses (interfaceLocal) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
842 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
843 |
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
|
844 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
845 |
Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal (); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
846 |
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
|
847 |
NS_LOG_LOGIC ("Working with local address " << addrLocal); |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
848 |
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
|
849 |
|
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
|
850 |
// |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
851 |
// 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
|
852 |
// 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
|
853 |
// 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
|
854 |
// 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
|
855 |
// 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
|
856 |
// 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
|
857 |
// |
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
858 |
|
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
859 |
bool areTransitNetwork = false; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
860 |
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
|
861 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
862 |
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
|
863 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
864 |
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
|
865 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
866 |
// |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
867 |
// 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
|
868 |
// 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
|
869 |
// 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
|
870 |
// |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
871 |
if (AnotherRouterOnLink (ndTemp, true)) |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
872 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
873 |
areTransitNetwork = true; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
874 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
875 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
876 |
// 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
|
877 |
// 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
|
878 |
// 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
|
879 |
// 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
|
880 |
// all. |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
881 |
// |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
882 |
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
|
883 |
|
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 |
// |
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 |
// 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
|
886 |
// 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
|
887 |
// |
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 |
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
|
889 |
{ |
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
|
890 |
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
|
891 |
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
|
892 |
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
|
893 |
"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
|
894 |
} |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
895 |
if (desigRtrTemp < desigRtr) |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
896 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
897 |
desigRtr = desigRtrTemp; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
898 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
899 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
900 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
901 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
902 |
// 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
|
903 |
// 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
|
904 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
905 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
906 |
GlobalRoutingLinkRecord *plr = new GlobalRoutingLinkRecord; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
907 |
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
|
908 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
909 |
if (areTransitNetwork == false) |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
910 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
911 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
912 |
// 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
|
913 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
914 |
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
|
915 |
plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
916 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
917 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
918 |
// 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
|
919 |
// the attached network. |
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 |
plr->SetLinkId (addrLocal.CombineMask(maskLocal)); |
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 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
924 |
// 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
|
925 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
926 |
Ipv4Address maskLocalAddr; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
927 |
maskLocalAddr.Set(maskLocal.Get ()); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
928 |
plr->SetLinkData (maskLocalAddr); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
929 |
plr->SetMetric (metricLocal); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
930 |
pLSA->AddLinkRecord(plr); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
931 |
plr = 0; |
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 |
else |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
934 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
935 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
936 |
// 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
|
937 |
// a transit network. |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
938 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
939 |
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
|
940 |
plr->SetLinkType (GlobalRoutingLinkRecord::TransitNetwork); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
941 |
|
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
942 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
943 |
// 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
|
944 |
// 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
|
945 |
// 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
|
946 |
// case. |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
947 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
948 |
if (desigRtr == addrLocal) |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
949 |
{ |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
950 |
c.Add (nd); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
951 |
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
|
952 |
} |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
953 |
plr->SetLinkId (desigRtr); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
954 |
|
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 |
// 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
|
957 |
// |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
958 |
plr->SetLinkData (addrLocal); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
959 |
plr->SetMetric (metricLocal); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
960 |
pLSA->AddLinkRecord (plr); |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
961 |
plr = 0; |
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
962 |
} |
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
963 |
#endif |
3940
49b432aefbd0
deal with bridged stub/transit networks on routers
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
964 |
} |
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 |
void |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
967 |
GlobalRouter::ProcessPointToPointLink (Ptr<NetDevice> ndLocal, GlobalRoutingLSA *pLSA) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
968 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
969 |
NS_LOG_FUNCTION (ndLocal << pLSA); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
970 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
971 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
972 |
// 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
|
973 |
// 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
|
974 |
// 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
|
975 |
// 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
|
976 |
// associated to them. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
977 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
978 |
Ptr<Node> nodeLocal = ndLocal->GetNode (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
979 |
|
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
980 |
uint32_t interfaceLocal; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
981 |
bool rc = FindInterfaceForDevice(nodeLocal, ndLocal, interfaceLocal); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
982 |
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
|
983 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
984 |
Ptr<Ipv4> ipv4Local = nodeLocal->GetObject<Ipv4> (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
985 |
NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed"); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
986 |
|
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
987 |
if (ipv4Local->GetNAddresses (interfaceLocal) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
988 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
989 |
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
|
990 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
991 |
Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal (); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
992 |
Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
993 |
NS_LOG_LOGIC ("Working with local address " << addrLocal); |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
994 |
uint16_t metricLocal = ipv4Local->GetMetric (interfaceLocal); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
995 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
996 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
997 |
// 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
|
998 |
// the point-to-point channel we know we have. This is where our adjacent |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
999 |
// router (to use OSPF lingo) is running. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1000 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1001 |
Ptr<Channel> ch = ndLocal->GetChannel(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1002 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1003 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1004 |
// 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
|
1005 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1006 |
Ptr<NetDevice> ndRemote = GetAdjacent(ndLocal, ch); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1007 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1008 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1009 |
// 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
|
1010 |
// 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
|
1011 |
// 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
|
1012 |
// 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
|
1013 |
// with bridging. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1014 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1015 |
Ptr<Node> nodeRemote = ndRemote->GetNode(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1016 |
Ptr<Ipv4> ipv4Remote = nodeRemote->GetObject<Ipv4> (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1017 |
NS_ABORT_MSG_UNLESS (ipv4Remote, |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1018 |
"GlobalRouter::ProcessPointToPointLink(): GetObject for remote <Ipv4> failed"); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1019 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1020 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1021 |
// 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
|
1022 |
// 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
|
1023 |
// interface aggregated. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1024 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1025 |
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
|
1026 |
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
|
1027 |
{ |
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
|
1028 |
// 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
|
1029 |
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
|
1030 |
} |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1031 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1032 |
// 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
|
1033 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1034 |
Ipv4Address rtrIdRemote = rtrRemote->GetRouterId(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1035 |
NS_LOG_LOGIC ("Working with remote router " << rtrIdRemote); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1036 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1037 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1038 |
// 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
|
1039 |
// 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
|
1040 |
// |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1041 |
uint32_t interfaceRemote; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1042 |
rc = FindInterfaceForDevice(nodeRemote, ndRemote, interfaceRemote); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1043 |
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
|
1044 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1045 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1046 |
// 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
|
1047 |
// mask we need. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1048 |
// |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1049 |
if (ipv4Remote->GetNAddresses (interfaceRemote) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1050 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1051 |
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
|
1052 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1053 |
Ipv4Address addrRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetLocal (); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1054 |
Ipv4Mask maskRemote = ipv4Remote->GetAddress (interfaceRemote, 0).GetMask (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1055 |
NS_LOG_LOGIC ("Working with remote address " << addrRemote); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1056 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1057 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1058 |
// 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
|
1059 |
// 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
|
1060 |
// 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
|
1061 |
// |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1062 |
GlobalRoutingLinkRecord *plr; |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1063 |
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
|
1064 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1065 |
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
|
1066 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1067 |
plr = new GlobalRoutingLinkRecord; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1068 |
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
|
1069 |
plr->SetLinkType (GlobalRoutingLinkRecord::PointToPoint); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1070 |
plr->SetLinkId (rtrIdRemote); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1071 |
plr->SetLinkData (addrLocal); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1072 |
plr->SetMetric (metricLocal); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1073 |
pLSA->AddLinkRecord (plr); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1074 |
plr = 0; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1075 |
} |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1076 |
|
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1077 |
// 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
|
1078 |
plr = new GlobalRoutingLinkRecord; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1079 |
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
|
1080 |
plr->SetLinkType (GlobalRoutingLinkRecord::StubNetwork); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1081 |
plr->SetLinkId (addrRemote); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1082 |
plr->SetLinkData (Ipv4Address(maskRemote.Get())); // Frown |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1083 |
plr->SetMetric (metricLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1084 |
pLSA->AddLinkRecord (plr); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1085 |
plr = 0; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1086 |
} |
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 |
void |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1089 |
GlobalRouter::BuildNetworkLSAs (NetDeviceContainer c) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1090 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1091 |
NS_LOG_FUNCTION (&c); |
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 |
uint32_t nDesignatedRouters = c.GetN (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1094 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1095 |
for (uint32_t i = 0; i < nDesignatedRouters; ++i) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1096 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1097 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1098 |
// 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
|
1099 |
// 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
|
1100 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1101 |
Ptr<NetDevice> ndLocal = c.Get (i); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1102 |
Ptr<Node> node = ndLocal->GetNode (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1103 |
|
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1104 |
uint32_t interfaceLocal; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1105 |
bool rc = FindInterfaceForDevice(node, ndLocal, interfaceLocal); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1106 |
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
|
1107 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1108 |
Ptr<Ipv4> ipv4Local = node->GetObject<Ipv4> (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1109 |
NS_ABORT_MSG_UNLESS (ipv4Local, "GlobalRouter::ProcessPointToPointLink (): GetObject for <Ipv4> interface failed"); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1110 |
|
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1111 |
if (ipv4Local->GetNAddresses (interfaceLocal) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1112 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1113 |
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
|
1114 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1115 |
Ipv4Address addrLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetLocal (); |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1116 |
Ipv4Mask maskLocal = ipv4Local->GetAddress (interfaceLocal, 0).GetMask (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1117 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1118 |
GlobalRoutingLSA *pLSA = new GlobalRoutingLSA; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1119 |
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
|
1120 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1121 |
pLSA->SetLSType (GlobalRoutingLSA::NetworkLSA); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1122 |
pLSA->SetLinkStateId (addrLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1123 |
pLSA->SetAdvertisingRouter (m_routerId); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1124 |
pLSA->SetNetworkLSANetworkMask (maskLocal); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1125 |
pLSA->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1126 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1127 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1128 |
// 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
|
1129 |
// and, if we find a node with a GlobalRouter interface and an IPv4 |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1130 |
// interface associated with that device, we call it an attached router. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1131 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1132 |
Ptr<Channel> ch = ndLocal->GetChannel(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1133 |
uint32_t nDevices = ch->GetNDevices(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1134 |
NS_ASSERT (nDevices); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1135 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1136 |
for (uint32_t i = 0; i < nDevices; i++) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1137 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1138 |
Ptr<NetDevice> tempNd = ch->GetDevice (i); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1139 |
NS_ASSERT (tempNd); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1140 |
Ptr<Node> tempNode = tempNd->GetNode (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1141 |
|
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 |
// 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
|
1144 |
// hardly be considered an attached router. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1145 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1146 |
Ptr<GlobalRouter> rtr = tempNode->GetObject<GlobalRouter> (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1147 |
if (rtr == 0) |
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 |
continue; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1150 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1151 |
|
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 |
// 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
|
1154 |
// If not, it can't play router. |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1155 |
// |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1156 |
uint32_t tempInterface; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1157 |
if (FindInterfaceForDevice (tempNode, tempNd, tempInterface)) |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1158 |
{ |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1159 |
Ptr<Ipv4> tempIpv4 = tempNode->GetObject<Ipv4> (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1160 |
NS_ASSERT (tempIpv4); |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1161 |
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
|
1162 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1163 |
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
|
1164 |
} |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
1165 |
else |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
1166 |
{ |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1167 |
if (tempIpv4->GetNAddresses (tempInterface) > 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 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
|
1172 |
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
|
1173 |
} |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1174 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1175 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1176 |
m_LSAs.push_back (pLSA); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1177 |
pLSA = 0; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1178 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1179 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1180 |
|
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1181 |
// |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1182 |
// 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
|
1183 |
// 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
|
1184 |
// 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
|
1185 |
// 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
|
1186 |
// |
1278 | 1187 |
Ipv4Address |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1188 |
GlobalRouter::FindDesignatedRouterForLink (Ptr<NetDevice> ndLocal, bool allowRecursion) const |
1278 | 1189 |
{ |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1190 |
NS_LOG_FUNCTION (ndLocal << allowRecursion); |
1278 | 1191 |
|
1192 |
Ptr<Channel> ch = ndLocal->GetChannel(); |
|
1193 |
uint32_t nDevices = ch->GetNDevices(); |
|
1194 |
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
|
1195 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1196 |
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
|
1197 |
ndLocal->GetNode ()->GetId ()); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1198 |
|
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1199 |
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
|
1200 |
|
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1201 |
// |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1202 |
// 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
|
1203 |
// in question is attached. |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1204 |
// |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1205 |
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
|
1206 |
{ |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1207 |
Ptr<NetDevice> ndOther = ch->GetDevice (i); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1208 |
NS_ASSERT (ndOther); |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1209 |
|
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1210 |
Ptr<Node> nodeOther = ndOther->GetNode (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1211 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1212 |
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
|
1213 |
|
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1214 |
// |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1215 |
// 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
|
1216 |
// 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
|
1217 |
// 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
|
1218 |
// 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
|
1219 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1220 |
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
|
1221 |
Ptr<BridgeNetDevice> bnd = NetDeviceIsBridged (ndOther); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1222 |
if (bnd) |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1223 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1224 |
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
|
1225 |
|
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1226 |
// |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1227 |
// 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
|
1228 |
// 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
|
1229 |
// 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
|
1230 |
// |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1231 |
// 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
|
1232 |
// 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
|
1233 |
// it can't play router. |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1234 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1235 |
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
|
1236 |
Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1237 |
Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1238 |
if (rtr && ipv4) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1239 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1240 |
uint32_t interfaceOther; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1241 |
if (FindInterfaceForDevice(nodeOther, bnd, interfaceOther)) |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1242 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1243 |
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
|
1244 |
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
|
1245 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1246 |
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
|
1247 |
continue; |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
1248 |
} |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1249 |
if (ipv4->GetNAddresses (interfaceOther) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1250 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1251 |
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
|
1252 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1253 |
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
|
1254 |
desigRtr = addrOther < desigRtr ? addrOther : desigRtr; |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1255 |
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
|
1256 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1257 |
} |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1258 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1259 |
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
|
1260 |
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
|
1261 |
{ |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1262 |
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
|
1263 |
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
|
1264 |
if (ndBridged == ndOther) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1265 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1266 |
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
|
1267 |
continue; |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1268 |
} |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1269 |
|
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1270 |
if (allowRecursion) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1271 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1272 |
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
|
1273 |
Ipv4Address addrOther = FindDesignatedRouterForLink (ndBridged, false); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1274 |
desigRtr = addrOther < desigRtr ? addrOther : desigRtr; |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1275 |
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
|
1276 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1277 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1278 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1279 |
else |
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 ("This device is not bridged"); |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1282 |
Ptr<Node> nodeOther = ndOther->GetNode (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1283 |
NS_ASSERT (nodeOther); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1284 |
|
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1285 |
// |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1286 |
// 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
|
1287 |
// 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
|
1288 |
// |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1289 |
Ptr<GlobalRouter> rtr = nodeOther->GetObject<GlobalRouter> (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1290 |
Ptr<Ipv4> ipv4 = nodeOther->GetObject<Ipv4> (); |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1291 |
if (rtr && ipv4) |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1292 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1293 |
uint32_t interfaceOther; |
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1294 |
if (FindInterfaceForDevice(nodeOther, ndOther, interfaceOther)) |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1295 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1296 |
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
|
1297 |
{ |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1298 |
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
|
1299 |
continue; |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
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 net device " << ndOther); |
4375
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1302 |
if (ipv4->GetNAddresses (interfaceOther) > 1) |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1303 |
{ |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1304 |
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
|
1305 |
} |
db81fdcb06e7
Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1306 |
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
|
1307 |
desigRtr = addrOther < desigRtr ? addrOther : desigRtr; |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1308 |
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
|
1309 |
} |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1310 |
} |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1311 |
} |
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1312 |
} |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1313 |
return desigRtr; |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1314 |
} |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1315 |
|
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1316 |
// |
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1317 |
// 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
|
1318 |
// 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
|
1319 |
// 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
|
1320 |
// 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
|
1321 |
// |
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1322 |
bool |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1323 |
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
|
1324 |
{ |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1325 |
NS_LOG_FUNCTION (nd << allowRecursion); |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1326 |
|
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1327 |
Ptr<Channel> ch = nd->GetChannel(); |
4012
7dc122811f0c
add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents:
3960
diff
changeset
|
1328 |
if (!ch) |
7dc122811f0c
add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents:
3960
diff
changeset
|
1329 |
{ |
7dc122811f0c
add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents:
3960
diff
changeset
|
1330 |
// 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
|
1331 |
return false; |
7dc122811f0c
add dynamic global routing example script
Tom Henderson <tomh@tomh.org>
parents:
3960
diff
changeset
|
1332 |
} |
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1333 |
uint32_t nDevices = ch->GetNDevices(); |
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1334 |
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
|
1335 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1336 |
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
|
1337 |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1338 |
// |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1339 |
// 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
|
1340 |
// in question is attached. |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1341 |
// |
1278 | 1342 |
for (uint32_t i = 0; i < nDevices; i++) |
1343 |
{ |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1344 |
Ptr<NetDevice> ndOther = ch->GetDevice (i); |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1345 |
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
|
1346 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1347 |
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
|
1348 |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1349 |
// |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1350 |
// Ignore the net device itself. |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1351 |
// |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1352 |
if (ndOther == nd) |
1278 | 1353 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1354 |
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
|
1355 |
continue; |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1356 |
} |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1357 |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1358 |
// |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1359 |
// 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
|
1360 |
// 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
|
1361 |
// 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
|
1362 |
// bridge. |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1363 |
// |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1364 |
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
|
1365 |
Ptr<BridgeNetDevice> bnd = NetDeviceIsBridged (ndOther); |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1366 |
if (bnd) |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1367 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1368 |
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
|
1369 |
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
|
1370 |
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
|
1371 |
{ |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1372 |
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
|
1373 |
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
|
1374 |
if (ndBridged == ndOther) |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1375 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1376 |
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
|
1377 |
continue; |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1378 |
} |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1379 |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1380 |
if (allowRecursion) |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1381 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1382 |
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
|
1383 |
if (AnotherRouterOnLink (ndBridged, false)) |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1384 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1385 |
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
|
1386 |
return true; |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1387 |
} |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1388 |
} |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1389 |
} |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1390 |
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
|
1391 |
return false; |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1392 |
} |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1393 |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1394 |
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
|
1395 |
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
|
1396 |
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
|
1397 |
|
3938
972310213d07
Admit possibility that not all nodes are routers.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
1398 |
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
|
1399 |
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
|
1400 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1401 |
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
|
1402 |
return true; |
1278 | 1403 |
} |
3942
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
diff
changeset
|
1404 |
else |
eef10dbce686
fix bug 114 and bug 66
Craig Dowell <craigdo@ee.washington.edu>
parents:
3941
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 ("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
|
1407 |
} |
1278 | 1408 |
} |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1409 |
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
|
1410 |
return false; |
1278 | 1411 |
} |
1412 |
||
1111 | 1413 |
uint32_t |
1414 |
GlobalRouter::GetNumLSAs (void) const |
|
1415 |
{ |
|
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
|
1416 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 1417 |
return m_LSAs.size (); |
1418 |
} |
|
1419 |
||
1420 |
// |
|
1421 |
// Get the nth link state advertisement from this router. |
|
1422 |
// |
|
1423 |
bool |
|
1278 | 1424 |
GlobalRouter::GetLSA (uint32_t n, GlobalRoutingLSA &lsa) const |
1111 | 1425 |
{ |
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
|
1426 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 1427 |
NS_ASSERT_MSG(lsa.IsEmpty(), "GlobalRouter::GetLSA (): Must pass empty LSA"); |
1428 |
// |
|
1429 |
// All of the work was done in GetNumLSAs. All we have to do here is to |
|
1430 |
// walk the list of link state advertisements created there and return the |
|
1431 |
// one the client is interested in. |
|
1432 |
// |
|
1433 |
ListOfLSAs_t::const_iterator i = m_LSAs.begin (); |
|
1434 |
uint32_t j = 0; |
|
1435 |
||
1436 |
for (; i != m_LSAs.end (); i++, j++) |
|
1437 |
{ |
|
1438 |
if (j == n) |
|
1439 |
{ |
|
1278 | 1440 |
GlobalRoutingLSA *p = *i; |
1111 | 1441 |
lsa = *p; |
1442 |
return true; |
|
1443 |
} |
|
1444 |
} |
|
1445 |
||
1446 |
return false; |
|
1447 |
} |
|
1448 |
||
1449 |
// |
|
1450 |
// Link through the given channel and find the net device that's on the |
|
1451 |
// other end. This only makes sense with a point-to-point channel. |
|
1452 |
// |
|
1453 |
Ptr<NetDevice> |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1454 |
GlobalRouter::GetAdjacent (Ptr<NetDevice> nd, Ptr<Channel> ch) const |
1111 | 1455 |
{ |
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
|
1456 |
NS_LOG_FUNCTION_NOARGS (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1457 |
NS_ASSERT_MSG(ch->GetNDevices() == 2, "GlobalRouter::GetAdjacent (): Channel with other than two devices"); |
1111 | 1458 |
// |
1459 |
// This is a point to point channel with two endpoints. Get both of them. |
|
1460 |
// |
|
1461 |
Ptr<NetDevice> nd1 = ch->GetDevice(0); |
|
1462 |
Ptr<NetDevice> nd2 = ch->GetDevice(1); |
|
1463 |
// |
|
1464 |
// One of the endpoints is going to be "us" -- that is the net device attached |
|
1465 |
// to the node on which we're running -- i.e., "nd". The other endpoint (the |
|
1466 |
// one to which we are connected via the channel) is the adjacent router. |
|
1467 |
// |
|
1468 |
if (nd1 == nd) |
|
1469 |
{ |
|
1470 |
return nd2; |
|
1471 |
} |
|
1472 |
else if (nd2 == nd) |
|
1473 |
{ |
|
1474 |
return nd1; |
|
1475 |
} |
|
1476 |
else |
|
1477 |
{ |
|
1478 |
NS_ASSERT_MSG(false, |
|
1479 |
"GlobalRouter::GetAdjacent (): Wrong or confused channel?"); |
|
1480 |
return 0; |
|
1481 |
} |
|
1482 |
} |
|
1483 |
||
1484 |
// |
|
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1485 |
// 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
|
1486 |
// 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
|
1487 |
// 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
|
1488 |
// 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
|
1489 |
// is bridged, there will not be an interface associated directly with the device. |
1111 | 1490 |
// |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1491 |
bool |
4372
d99061f1167c
Ipv4::ifIndex -> Ipv4::interface
Tom Henderson <tomh@tomh.org>
parents:
4012
diff
changeset
|
1492 |
GlobalRouter::FindInterfaceForDevice (Ptr<Node> node, Ptr<NetDevice> nd, uint32_t &index) const |
1111 | 1493 |
{ |
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
|
1494 |
NS_LOG_FUNCTION_NOARGS (); |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1495 |
NS_LOG_LOGIC("For node " << node->GetId () << " for net device " << nd ); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1496 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2252
diff
changeset
|
1497 |
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
|
1498 |
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
|
1499 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1500 |
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
|
1501 |
return false; |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1502 |
} |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1503 |
|
1111 | 1504 |
for (uint32_t i = 0; i < ipv4->GetNInterfaces(); ++i ) |
1505 |
{ |
|
1506 |
if (ipv4->GetNetDevice(i) == nd) |
|
1507 |
{ |
|
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1508 |
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
|
1509 |
index = i; |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3179
diff
changeset
|
1510 |
return true; |
1111 | 1511 |
} |
1512 |
} |
|
1513 |
||
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1514 |
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
|
1515 |
return false; |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1516 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1517 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1518 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1519 |
// 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
|
1520 |
// |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1521 |
Ptr<BridgeNetDevice> |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1522 |
GlobalRouter::NetDeviceIsBridged (Ptr<NetDevice> nd) const |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1523 |
{ |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1524 |
NS_LOG_FUNCTION (nd); |
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1525 |
|
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1526 |
Ptr<Node> node = nd->GetNode (); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1527 |
uint32_t nDevices = node->GetNDevices(); |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1528 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1529 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1530 |
// 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
|
1531 |
// 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
|
1532 |
// 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
|
1533 |
// 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
|
1534 |
// |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1535 |
for (uint32_t i = 0; i < nDevices; ++i) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1536 |
{ |
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1537 |
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
|
1538 |
NS_LOG_LOGIC ("Examine device " << i << " " << ndTest); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1539 |
|
3941
476c3bed16c0
teach global routing about bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
3940
diff
changeset
|
1540 |
if (ndTest->IsBridge ()) |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1541 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1542 |
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
|
1543 |
Ptr<BridgeNetDevice> bnd = ndTest->GetObject<BridgeNetDevice> (); |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1544 |
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
|
1545 |
|
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1546 |
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
|
1547 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1548 |
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
|
1549 |
if (bnd->GetBridgePort (j) == nd) |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1550 |
{ |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1551 |
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
|
1552 |
return bnd; |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1553 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1554 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1555 |
} |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3938
diff
changeset
|
1556 |
} |
3944
6a47ccdf2c5d
remove some hey-look-here debugging flags
Craig Dowell <craigdo@ee.washington.edu>
parents:
3942
diff
changeset
|
1557 |
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
|
1558 |
return 0; |
1111 | 1559 |
} |
1560 |
||
1561 |
} // namespace ns3 |