LEFT | RIGHT |
(no file at all) | |
1 // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- | 1 // -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- |
2 // | 2 // |
3 // Copyright (c) 2008 University of Washington | 3 // Copyright (c) 2008 University of Washington |
4 // | 4 // |
5 // This program is free software; you can redistribute it and/or modify | 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 | 6 // it under the terms of the GNU General Public License version 2 as |
7 // published by the Free Software Foundation; | 7 // published by the Free Software Foundation; |
8 // | 8 // |
9 // This program is distributed in the hope that it will be useful, | 9 // This program is distributed in the hope that it will be useful, |
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } | 215 } |
216 } | 216 } |
217 if (allRoutes.size () > 0 ) // if route(s) is found | 217 if (allRoutes.size () > 0 ) // if route(s) is found |
218 { | 218 { |
219 // pick up one of the routes uniformly at random if random | 219 // pick up one of the routes uniformly at random if random |
220 // ECMP routing is enabled, or always select the first route | 220 // ECMP routing is enabled, or always select the first route |
221 // consistently if random ECMP routing is disabled | 221 // consistently if random ECMP routing is disabled |
222 uint32_t selectIndex; | 222 uint32_t selectIndex; |
223 if (m_randomEcmpRouting) | 223 if (m_randomEcmpRouting) |
224 { | 224 { |
225 selectIndex = m_rand->GetInteger (0, allRoutes.size ()-1); | 225 selectIndex = m_rand->GetInteger (0, static_cast<uint32_t> (allRoutes.
size ()-1)); |
226 } | 226 } |
227 else· | 227 else· |
228 { | 228 { |
229 selectIndex = 0; | 229 selectIndex = 0; |
230 } | 230 } |
231 Ipv4RoutingTableEntry* route = allRoutes.at (selectIndex);· | 231 Ipv4RoutingTableEntry* route = allRoutes.at (selectIndex);· |
232 // create a Ipv4Route object from the selected routing table entry | 232 // create a Ipv4Route object from the selected routing table entry |
233 rtentry = Create<Ipv4Route> (); | 233 rtentry = Create<Ipv4Route> (); |
234 rtentry->SetDestination (route->GetDest ()); | 234 rtentry->SetDestination (route->GetDest ()); |
235 /// \todo handle multi-address case | 235 /// \todo handle multi-address case |
236 rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface (), 0).GetLoca
l ()); | 236 rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface (), 0).GetLoca
l ()); |
237 rtentry->SetGateway (route->GetGateway ()); | 237 rtentry->SetGateway (route->GetGateway ()); |
238 uint32_t interfaceIdx = route->GetInterface (); | 238 uint32_t interfaceIdx = route->GetInterface (); |
239 rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); | 239 rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx)); |
240 return rtentry; | 240 return rtentry; |
241 } | 241 } |
242 else· | 242 else· |
243 { | 243 { |
244 return 0; | 244 return 0; |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 uint32_t· | 248 uint32_t· |
249 Ipv4GlobalRouting::GetNRoutes (void) const | 249 Ipv4GlobalRouting::GetNRoutes (void) const |
250 { | 250 { |
251 NS_LOG_FUNCTION (this); | 251 NS_LOG_FUNCTION (this); |
252 uint32_t n = 0; | 252 size_t n = 0; |
253 n += m_hostRoutes.size (); | 253 n += m_hostRoutes.size (); |
254 n += m_networkRoutes.size (); | 254 n += m_networkRoutes.size (); |
255 n += m_ASexternalRoutes.size (); | 255 n += m_ASexternalRoutes.size (); |
256 return n; | 256 return static_cast<uint32_t> (n); |
257 } | 257 } |
258 | 258 |
259 Ipv4RoutingTableEntry * | 259 Ipv4RoutingTableEntry * |
260 Ipv4GlobalRouting::GetRoute (uint32_t index) const | 260 Ipv4GlobalRouting::GetRoute (uint32_t index) const |
261 { | 261 { |
262 NS_LOG_FUNCTION (this << index); | 262 NS_LOG_FUNCTION (this << index); |
263 if (index < m_hostRoutes.size ()) | 263 if (index < m_hostRoutes.size ()) |
264 { | 264 { |
265 uint32_t tmp = 0; | 265 uint32_t tmp = 0; |
266 for (HostRoutesCI i = m_hostRoutes.begin ();· | 266 for (HostRoutesCI i = m_hostRoutes.begin ();· |
267 i != m_hostRoutes.end ();· | 267 i != m_hostRoutes.end ();· |
268 i++)· | 268 i++)· |
269 { | 269 { |
270 if (tmp == index) | 270 if (tmp == index) |
271 { | 271 { |
272 return *i; | 272 return *i; |
273 } | 273 } |
274 tmp++; | 274 tmp++; |
275 } | 275 } |
276 } | 276 } |
277 index -= m_hostRoutes.size (); | 277 index -= static_cast<uint32_t> (m_hostRoutes.size ()); |
278 uint32_t tmp = 0; | 278 uint32_t tmp = 0; |
279 if (index < m_networkRoutes.size ()) | 279 if (index < m_networkRoutes.size ()) |
280 { | 280 { |
281 for (NetworkRoutesCI j = m_networkRoutes.begin ();· | 281 for (NetworkRoutesCI j = m_networkRoutes.begin ();· |
282 j != m_networkRoutes.end (); | 282 j != m_networkRoutes.end (); |
283 j++) | 283 j++) |
284 { | 284 { |
285 if (tmp == index) | 285 if (tmp == index) |
286 { | 286 { |
287 return *j; | 287 return *j; |
288 } | 288 } |
289 tmp++; | 289 tmp++; |
290 } | 290 } |
291 } | 291 } |
292 index -= m_networkRoutes.size (); | 292 index -= static_cast<uint32_t> (m_networkRoutes.size ()); |
293 tmp = 0; | 293 tmp = 0; |
294 for (ASExternalRoutesCI k = m_ASexternalRoutes.begin ();· | 294 for (ASExternalRoutesCI k = m_ASexternalRoutes.begin ();· |
295 k != m_ASexternalRoutes.end ();· | 295 k != m_ASexternalRoutes.end ();· |
296 k++)· | 296 k++)· |
297 { | 297 { |
298 if (tmp == index) | 298 if (tmp == index) |
299 { | 299 { |
300 return *k; | 300 return *k; |
301 } | 301 } |
302 tmp++; | 302 tmp++; |
(...skipping 17 matching lines...) Expand all Loading... |
320 { | 320 { |
321 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostR
outes.size ()); | 321 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_hostR
outes.size ()); |
322 delete *i; | 322 delete *i; |
323 m_hostRoutes.erase (i); | 323 m_hostRoutes.erase (i); |
324 NS_LOG_LOGIC ("Done removing host route " << index << "; host rout
e remaining size = " << m_hostRoutes.size ()); | 324 NS_LOG_LOGIC ("Done removing host route " << index << "; host rout
e remaining size = " << m_hostRoutes.size ()); |
325 return; | 325 return; |
326 } | 326 } |
327 tmp++; | 327 tmp++; |
328 } | 328 } |
329 } | 329 } |
330 index -= m_hostRoutes.size (); | 330 index -= static_cast<uint32_t> (m_hostRoutes.size ()); |
331 uint32_t tmp = 0; | 331 uint32_t tmp = 0; |
332 for (NetworkRoutesI j = m_networkRoutes.begin ();· | 332 for (NetworkRoutesI j = m_networkRoutes.begin ();· |
333 j != m_networkRoutes.end ();· | 333 j != m_networkRoutes.end ();· |
334 j++)· | 334 j++)· |
335 { | 335 { |
336 if (tmp == index) | 336 if (tmp == index) |
337 { | 337 { |
338 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRo
utes.size ()); | 338 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_networkRo
utes.size ()); |
339 delete *j; | 339 delete *j; |
340 m_networkRoutes.erase (j); | 340 m_networkRoutes.erase (j); |
341 NS_LOG_LOGIC ("Done removing network route " << index << "; network ro
ute remaining size = " << m_networkRoutes.size ()); | 341 NS_LOG_LOGIC ("Done removing network route " << index << "; network ro
ute remaining size = " << m_networkRoutes.size ()); |
342 return; | 342 return; |
343 } | 343 } |
344 tmp++; | 344 tmp++; |
345 } | 345 } |
346 index -= m_networkRoutes.size (); | 346 index -= static_cast<uint32_t> (m_networkRoutes.size ()); |
347 tmp = 0; | 347 tmp = 0; |
348 for (ASExternalRoutesI k = m_ASexternalRoutes.begin ();· | 348 for (ASExternalRoutesI k = m_ASexternalRoutes.begin ();· |
349 k != m_ASexternalRoutes.end (); | 349 k != m_ASexternalRoutes.end (); |
350 k++) | 350 k++) |
351 { | 351 { |
352 if (tmp == index) | 352 if (tmp == index) |
353 { | 353 { |
354 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexterna
lRoutes.size ()); | 354 NS_LOG_LOGIC ("Removing route " << index << "; size = " << m_ASexterna
lRoutes.size ()); |
355 delete *k; | 355 delete *k; |
356 m_ASexternalRoutes.erase (k); | 356 m_ASexternalRoutes.erase (k); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 void· | 582 void· |
583 Ipv4GlobalRouting::SetIpv4 (Ptr<Ipv4> ipv4) | 583 Ipv4GlobalRouting::SetIpv4 (Ptr<Ipv4> ipv4) |
584 { | 584 { |
585 NS_LOG_FUNCTION (this << ipv4); | 585 NS_LOG_FUNCTION (this << ipv4); |
586 NS_ASSERT (m_ipv4 == 0 && ipv4 != 0); | 586 NS_ASSERT (m_ipv4 == 0 && ipv4 != 0); |
587 m_ipv4 = ipv4; | 587 m_ipv4 = ipv4; |
588 } | 588 } |
589 | 589 |
590 | 590 |
591 } // namespace ns3 | 591 } // namespace ns3 |
LEFT | RIGHT |