|
|
| 36 |
{} |
36 |
{} |
| 37 |
|
37 |
|
| 38 |
uint32_t |
38 |
uint32_t |
| 39 |
Ipv4::GetIfIndexByAddress (Ptr<Node> node, Ipv4Address a, Ipv4Mask amask) |
39 |
Ipv4::GetIfIndexByAddress (Ipv4Address addr, Ipv4Mask mask) |
| 40 |
{ |
40 |
{ |
| 41 |
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid); |
41 |
for (uint32_t i = 0; i < GetNInterfaces (); i++) |
| 42 |
NS_ASSERT_MSG (ipv4, "Ipv4::GetIfIndexByAddress: No Ipv4 interface"); |
|
|
| 43 |
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++) |
| 44 |
{ |
42 |
{ |
| 45 |
if (ipv4->GetAddress (i).CombineMask(amask) == a.CombineMask(amask) ) |
43 |
if (GetAddress (i).CombineMask(mask) == addr.CombineMask(mask) ) |
| 46 |
{ |
44 |
{ |
| 47 |
return i; |
45 |
return i; |
| 48 |
} |
46 |
} |
|
Lines 52-95
Ipv4::GetIfIndexByAddress (Ptr<Node> nod
|
Link Here
|
|---|
|
| 52 |
return 0; |
50 |
return 0; |
| 53 |
} |
51 |
} |
| 54 |
|
52 |
|
| 55 |
// |
|
|
| 56 |
// XXX BUGBUG I don't think this is really the right approach here. The call |
| 57 |
// to GetRoute () filters down into Ipv4L3Protocol where it translates into |
| 58 |
// a call into the Ipv4 static routing package. This bypasses any other |
| 59 |
// routing packages. At a minimum, the name is misleading. |
| 60 |
// |
| 61 |
bool |
| 62 |
Ipv4::GetRouteToDestination ( |
| 63 |
Ptr<Node> node, |
| 64 |
Ipv4Route& route, |
| 65 |
Ipv4Address a, |
| 66 |
Ipv4Mask amask) |
| 67 |
{ |
| 68 |
Ipv4Route tempRoute; |
| 69 |
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid); |
| 70 |
NS_ASSERT_MSG (ipv4, "Ipv4::GetRouteToDestination: No Ipv4 interface"); |
| 71 |
for (uint32_t i = 0; i < ipv4->GetNRoutes (); i++) |
| 72 |
{ |
| 73 |
tempRoute = ipv4->GetRoute (i); |
| 74 |
// Host route found |
| 75 |
if ( tempRoute.IsNetwork () == false && tempRoute.GetDest () == a ) |
| 76 |
{ |
| 77 |
route = tempRoute; |
| 78 |
return true; |
| 79 |
} |
| 80 |
else if ( tempRoute.IsNetwork () && |
| 81 |
tempRoute.GetDestNetwork () == a.CombineMask(amask) ) |
| 82 |
{ |
| 83 |
route = tempRoute; |
| 84 |
return true; |
| 85 |
} |
| 86 |
else if ( tempRoute.IsDefault () ) |
| 87 |
{ |
| 88 |
route = tempRoute; |
| 89 |
return true; |
| 90 |
} |
| 91 |
} |
| 92 |
return false; |
| 93 |
} |
| 94 |
|
| 95 |
} // namespace ns3 |
53 |
} // namespace ns3 |