use of org.batfish.datamodel.OspfIntraAreaRoute in project batfish by batfish.
the class VirtualRouter method propagateOspfInternalRoutesFromNeighbor.
/**
* Propagate OSPF Internal routes from a single neighbor.
*
* @param proc The receiving OSPF process
* @param neighbor the neighbor
* @param connectingInterface interface on which we are connected to the neighbor
* @param neighborInterface interface that the neighbor uses to connect to us
* @param adminCost route administrative distance
* @return true if new routes have been added to our staging RIB
*/
boolean propagateOspfInternalRoutesFromNeighbor(OspfProcess proc, Node neighbor, Interface connectingInterface, Interface neighborInterface, int adminCost) {
OspfArea area = connectingInterface.getOspfArea();
OspfArea neighborArea = neighborInterface.getOspfArea();
// Ensure that the link (i.e., both interfaces) has OSPF enabled and OSPF areas are set
if (!connectingInterface.getOspfEnabled() || connectingInterface.getOspfPassive() || !neighborInterface.getOspfEnabled() || neighborInterface.getOspfPassive() || area == null || neighborArea == null || !area.getName().equals(neighborArea.getName())) {
return false;
}
/*
* An OSPF neighbor relationship exists on this edge. So we examine all intra- and inter-area
* routes belonging to the neighbor to see what should be propagated to this router. We add the
* incremental cost associated with our settings and the connecting interface, and use the
* neighborInterface's address as the next hop ip.
*/
int connectingInterfaceCost = connectingInterface.getOspfCost();
long incrementalCost = proc.getMaxMetricTransitLinks() != null ? proc.getMaxMetricTransitLinks() : connectingInterfaceCost;
Long areaNum = area.getName();
VirtualRouter neighborVirtualRouter = neighbor._virtualRouters.get(neighborInterface.getVrfName());
boolean changed = false;
for (OspfIntraAreaRoute neighborRoute : neighborVirtualRouter._ospfIntraAreaRib.getRoutes()) {
changed |= propagateOspfIntraAreaRoute(neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
changed |= propagateOspfInterAreaRouteFromIntraAreaRoute(neighbor, neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
}
for (OspfInterAreaRoute neighborRoute : neighborVirtualRouter._ospfInterAreaRib.getRoutes()) {
changed |= propagateOspfInterAreaRouteFromInterAreaRoute(neighbor, neighborRoute, incrementalCost, neighborInterface, adminCost, areaNum);
}
return changed;
}
Aggregations