|
Lines 1089-1100
GlobalRouteManagerImpl::SPFCalculate (Ip
|
Link Here
|
|---|
|
| 1089 |
} |
1089 |
} |
| 1090 |
|
1090 |
|
| 1091 |
// |
1091 |
// |
| 1092 |
// XXX This should probably be a method on Ipv4 |
|
|
| 1093 |
// |
| 1094 |
// Return the interface index corresponding to a given IP address |
1092 |
// Return the interface index corresponding to a given IP address |
|
|
1093 |
// This is a wrapper around GetIfIndexByIpv4Address(), but we first |
| 1094 |
// have to find the right node pointer to pass to that function. |
| 1095 |
// |
1095 |
// |
| 1096 |
uint32_t |
1096 |
uint32_t |
| 1097 |
GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a) |
1097 |
GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask) |
| 1098 |
{ |
1098 |
{ |
| 1099 |
// |
1099 |
// |
| 1100 |
// We have an IP address <a> and a vertex ID of the root of the SPF tree. |
1100 |
// We have an IP address <a> and a vertex ID of the root of the SPF tree. |
|
Lines 1143-1232
GlobalRouteManagerImpl::FindOutgoingInte
|
Link Here
|
|---|
|
| 1143 |
// we're looking for. If we find one, return the corresponding interface |
1143 |
// we're looking for. If we find one, return the corresponding interface |
| 1144 |
// index. |
1144 |
// index. |
| 1145 |
// |
1145 |
// |
| 1146 |
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++) |
1146 |
return (GetIfIndexByIpv4Address (node, a, amask) ); |
| 1147 |
{ |
|
|
| 1148 |
if (ipv4->GetAddress (i) == a) |
| 1149 |
{ |
| 1150 |
NS_DEBUG ( |
| 1151 |
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): " |
| 1152 |
"Interface match for " << a); |
| 1153 |
return i; |
| 1154 |
} |
| 1155 |
} |
| 1156 |
} |
| 1157 |
} |
| 1158 |
// |
| 1159 |
// Couldn't find it. |
| 1160 |
// |
| 1161 |
return 0; |
| 1162 |
} |
| 1163 |
|
| 1164 |
// |
| 1165 |
// XXX This should probably be a method on Ipv4 |
| 1166 |
// |
| 1167 |
// Return the interface index corresponding to a given IP address |
| 1168 |
// |
| 1169 |
uint32_t |
| 1170 |
GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask) |
| 1171 |
{ |
| 1172 |
// |
| 1173 |
// We have an IP address <a> and a vertex ID of the root of the SPF tree. |
| 1174 |
// The question is what interface index does this address correspond to. |
| 1175 |
// The answer is a little complicated since we have to find a pointer to |
| 1176 |
// the node corresponding to the vertex ID, find the Ipv4 interface on that |
| 1177 |
// node in order to iterate the interfaces and find the one corresponding to |
| 1178 |
// the address in question. |
| 1179 |
// |
| 1180 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
| 1181 |
// |
| 1182 |
// Walk the list of nodes in the system looking for the one corresponding to |
| 1183 |
// the node at the root of the SPF tree. This is the node for which we are |
| 1184 |
// building the routing table. |
| 1185 |
// |
| 1186 |
NodeList::Iterator i = NodeList::Begin (); |
| 1187 |
for (; i != NodeList::End (); i++) |
| 1188 |
{ |
| 1189 |
Ptr<Node> node = *i; |
| 1190 |
|
| 1191 |
Ptr<GlobalRouter> rtr = |
| 1192 |
node->QueryInterface<GlobalRouter> (GlobalRouter::iid); |
| 1193 |
// |
| 1194 |
// If the node doesn't have a GlobalRouter interface it can't be the one |
| 1195 |
// we're interested in. |
| 1196 |
// |
| 1197 |
if (rtr == 0) |
| 1198 |
{ |
| 1199 |
continue; |
| 1200 |
} |
| 1201 |
|
| 1202 |
if (rtr->GetRouterId () == routerId) |
| 1203 |
{ |
| 1204 |
// |
| 1205 |
// This is the node we're building the routing table for. We're going to need |
| 1206 |
// the Ipv4 interface to look for the ipv4 interface index. Since this node |
| 1207 |
// is participating in routing IP version 4 packets, it certainly must have |
| 1208 |
// an Ipv4 interface. |
| 1209 |
// |
| 1210 |
Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid); |
| 1211 |
NS_ASSERT_MSG (ipv4, |
| 1212 |
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): " |
| 1213 |
"QI for <Ipv4> interface failed"); |
| 1214 |
// |
| 1215 |
// Look through the interfaces on this node for one that has the IP address |
| 1216 |
// we're looking for. If we find one, return the corresponding interface |
| 1217 |
// index. |
| 1218 |
// |
| 1219 |
for (uint32_t i = 0; i < ipv4->GetNInterfaces (); i++) |
| 1220 |
{ |
| 1221 |
if (ipv4->GetAddress (i).CombineMask(amask) == |
| 1222 |
a.CombineMask(amask) ) |
| 1223 |
{ |
| 1224 |
NS_DEBUG ( |
| 1225 |
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): " |
| 1226 |
"Interface match for " << a); |
| 1227 |
return i; |
| 1228 |
} |
| 1229 |
} |
| 1230 |
} |
1147 |
} |
| 1231 |
} |
1148 |
} |
| 1232 |
// |
1149 |
// |
|
Lines 1693-1698
GlobalRouteManagerImplTest::RunTests (vo
|
Link Here
|
|---|
|
| 1693 |
srm->DebugSPFCalculate (lsa0->GetLinkStateId ()); // node n0 |
1610 |
srm->DebugSPFCalculate (lsa0->GetLinkStateId ()); // node n0 |
| 1694 |
|
1611 |
|
| 1695 |
Simulator::Run (); |
1612 |
Simulator::Run (); |
|
|
1613 |
|
| 1614 |
// XXX here we should do some verification of the routes built |
| 1615 |
|
| 1696 |
Simulator::Destroy (); |
1616 |
Simulator::Destroy (); |
| 1697 |
|
1617 |
|
| 1698 |
// This delete clears the srm, which deletes the LSDB, which clears |
1618 |
// This delete clears the srm, which deletes the LSDB, which clears |
|
Lines 1703-1709
GlobalRouteManagerImplTest::RunTests (vo
|
Link Here
|
|---|
|
| 1703 |
} |
1623 |
} |
| 1704 |
|
1624 |
|
| 1705 |
// Instantiate this class for the unit tests |
1625 |
// Instantiate this class for the unit tests |
| 1706 |
// XXX here we should do some verification of the routes built |
|
|
| 1707 |
static GlobalRouteManagerImplTest g_globalRouteManagerTest; |
1626 |
static GlobalRouteManagerImplTest g_globalRouteManagerTest; |
| 1708 |
|
1627 |
|
| 1709 |
} // namespace ns3 |
1628 |
} // namespace ns3 |