@Test public void testInitializeRoutesByArea_p2mp() { NetworkFactory nf = new NetworkFactory(); _c = nf.configurationBuilder() .setConfigurationFormat(ConfigurationFormat.CISCO_IOS) .setHostname(HOSTNAME) .build(); Vrf vrf = nf.vrfBuilder().setName(VRF_NAME).setOwner(_c).build(); OspfInterfaceSettings.Builder ospf = OspfInterfaceSettings.defaultSettingsBuilder().setProcess("1").setEnabled(true); Interface activeIface = nf.interfaceBuilder() .setActive(true) .setVrf(vrf) .setOwner(_c) .setType(InterfaceType.PHYSICAL) .setBandwidth(1e8) .setName(ACTIVE_IFACE_NAME) .setAddresses(ACTIVE_ADDR_1) .setOspfSettings( ospf.setCost(1).setNetworkType(OspfNetworkType.POINT_TO_MULTIPOINT).build()) .build(); AREA0_CONFIG = OspfArea.builder() .setNumber(0) .setInterfaces(ImmutableSet.of(activeIface.getName())) .build(); OspfNeighborConfigId id = new OspfNeighborConfigId(HOSTNAME, VRF_NAME, "1", ACTIVE_IFACE_NAME, ACTIVE_ADDR_1); OspfProcess ospfProcess = nf.ospfProcessBuilder() .setProcessId("1") .setRouterId(ACTIVE_ADDR_1.getIp()) .setReferenceBandwidth(10e9) .setVrf(vrf) .setAreas(ImmutableSortedMap.of(0L, AREA0_CONFIG)) .setAdminCosts(ADMIN_COSTS) .setNeighborConfigs( ImmutableMap.of( id, OspfNeighborConfig.builder() .setHostname(HOSTNAME) .setVrfName(VRF_NAME) .setInterfaceName(ACTIVE_IFACE_NAME) .setIp(ACTIVE_ADDR_1.getIp()) .setArea(0L) .build())) .build(); _routingProcess = new OspfRoutingProcess(ospfProcess, VRF_NAME, _c, _emptyOspfTopology); RibDelta<OspfIntraAreaRoute> routes = _routingProcess.initializeRoutesByArea(AREA0_CONFIG); assertThat( routes.getActions().collect(ImmutableList.toImmutableList()), contains( new RouteAdvertisement<>( new OspfIntraAreaRoute( Prefix.parse("2.2.2.2/32"), Ip.parse("2.2.2.2"), 100, 1, 0, -1, false, false)))); }
@Nonnull @VisibleForTesting RibDelta<OspfIntraAreaRoute> initializeRoutesByArea(OspfArea area) { RibDelta.Builder<OspfIntraAreaRoute> deltaBuilder = RibDelta.builder(); for (String ifaceName : area.getInterfaces()) { Interface iface = _c.getAllInterfaces().get(ifaceName); if (iface == null || !iface.getActive() || !iface.getOspfEnabled()) { continue; } Set<OspfIntraAreaRoute> allRoutes = getIfaceAddressesForIntraAreaRoutes(iface) .map( ifaceAddr -> computeIntraAreaRouteFromInterface(area.getAreaNumber(), iface, ifaceAddr)) .collect(ImmutableSet.toImmutableSet()); allRoutes.forEach(r -> deltaBuilder.from(_intraAreaRib.mergeRouteGetDelta(r))); } return deltaBuilder.build(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting RibDelta<OspfIntraAreaRoute> initializeRoutesByArea(OspfArea area) { RibDelta.Builder<OspfIntraAreaRoute> deltaBuilder = RibDelta.builder(); for (String ifaceName : area.getInterfaces()) { Interface iface = _c.getAllInterfaces().get(ifaceName); if (iface == null || !iface.getActive() || !iface.getOspfEnabled()) { continue; } Set<OspfIntraAreaRoute> allRoutes = getIfaceAddressesForIntraAreaRoutes(iface) .map( ifaceAddr -> computeIntraAreaRouteFromInterface(area.getAreaNumber(), iface, ifaceAddr)) .collect(ImmutableSet.toImmutableSet()); allRoutes.forEach(r -> deltaBuilder.from(_intraAreaRib.mergeRouteGetDelta(r))); } return deltaBuilder.build(); } }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting RibDelta<OspfIntraAreaRoute> initializeRoutesByArea(OspfArea area) { RibDelta.Builder<OspfIntraAreaRoute> deltaBuilder = RibDelta.builder(); for (String ifaceName : area.getInterfaces()) { Interface iface = _c.getAllInterfaces().get(ifaceName); if (iface == null || !iface.getActive() || !iface.getOspfEnabled()) { continue; } Set<OspfIntraAreaRoute> allRoutes = getIfaceAddressesForIntraAreaRoutes(iface) .map( ifaceAddr -> computeIntraAreaRouteFromInterface(area.getAreaNumber(), iface, ifaceAddr)) .collect(ImmutableSet.toImmutableSet()); allRoutes.forEach(r -> deltaBuilder.from(_intraAreaRib.mergeRouteGetDelta(r))); } return deltaBuilder.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting RibDelta<OspfIntraAreaRoute> initializeRoutesByArea(OspfArea area) { RibDelta.Builder<OspfIntraAreaRoute> deltaBuilder = RibDelta.builder(); for (String ifaceName : area.getInterfaces()) { Interface iface = _c.getAllInterfaces().get(ifaceName); if (iface == null || !iface.getActive() || !iface.getOspfEnabled()) { continue; } Set<OspfIntraAreaRoute> allRoutes = getIfaceAddressesForIntraAreaRoutes(iface) .map( ifaceAddr -> computeIntraAreaRouteFromInterface(area.getAreaNumber(), iface, ifaceAddr)) .collect(ImmutableSet.toImmutableSet()); allRoutes.forEach(r -> deltaBuilder.from(_intraAreaRib.mergeRouteGetDelta(r))); } return deltaBuilder.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty(); }
OspfRoutingProcess implements RoutingProcess<OspfTopology, OspfRoute> { @Nonnull @VisibleForTesting RibDelta<OspfIntraAreaRoute> initializeRoutesByArea(OspfArea area) { RibDelta.Builder<OspfIntraAreaRoute> deltaBuilder = RibDelta.builder(); for (String ifaceName : area.getInterfaces()) { Interface iface = _c.getAllInterfaces().get(ifaceName); if (iface == null || !iface.getActive() || !iface.getOspfEnabled()) { continue; } Set<OspfIntraAreaRoute> allRoutes = getIfaceAddressesForIntraAreaRoutes(iface) .map( ifaceAddr -> computeIntraAreaRouteFromInterface(area.getAreaNumber(), iface, ifaceAddr)) .collect(ImmutableSet.toImmutableSet()); allRoutes.forEach(r -> deltaBuilder.from(_intraAreaRib.mergeRouteGetDelta(r))); } return deltaBuilder.build(); } OspfRoutingProcess(
      OspfProcess process, String vrfName, Configuration configuration, OspfTopology topology); @Override void initialize(Node n); @Override void executeIteration(Map<String, Node> allNodes); @Override void updateTopology(OspfTopology topology); @Nonnull @Override RibDelta<OspfRoute> getUpdatesForMainRib(); @Override void redistribute(RibDelta<? extends AnnotatedRoute<AbstractRoute>> mainRibDelta); @Override boolean isDirty();  }