@Test public void testGenerateLocalRoute() { String nextHopInterface = "Eth0"; ConcreteInterfaceAddress address = ConcreteInterfaceAddress.parse("1.1.1.1/24"); Prefix prefix = address.getIp().toPrefix(); assertThat( generateLocalRoute(address, nextHopInterface, null), equalTo( LocalRoute.builder() .setNetwork(prefix) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(nextHopInterface) .build())); assertThat( generateLocalRoute( address, nextHopInterface, ConnectedRouteMetadata.builder().setTag(7).build()), equalTo( LocalRoute.builder() .setNetwork(prefix) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(nextHopInterface) .setTag(7L) .build())); }
@VisibleForTesting @Nonnull static LocalRoute generateLocalRoute( @Nonnull ConcreteInterfaceAddress address, @Nonnull String ifaceName, @Nullable ConnectedRouteMetadata metadata) { LocalRoute.Builder builder = LocalRoute.builder() .setNetwork(address.getIp().toPrefix()) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(ifaceName); if (metadata != null) { if (metadata.getAdmin() != null) { builder.setAdmin(metadata.getAdmin()); } if (metadata.getTag() != null) { builder.setTag(metadata.getTag()); } } return builder.build(); }
VirtualRouter { @VisibleForTesting @Nonnull static LocalRoute generateLocalRoute( @Nonnull ConcreteInterfaceAddress address, @Nonnull String ifaceName, @Nullable ConnectedRouteMetadata metadata) { LocalRoute.Builder builder = LocalRoute.builder() .setNetwork(address.getIp().toPrefix()) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(ifaceName); if (metadata != null) { if (metadata.getAdmin() != null) { builder.setAdmin(metadata.getAdmin()); } if (metadata.getTag() != null) { builder.setTag(metadata.getTag()); } } return builder.build(); } }
VirtualRouter { @VisibleForTesting @Nonnull static LocalRoute generateLocalRoute( @Nonnull ConcreteInterfaceAddress address, @Nonnull String ifaceName, @Nullable ConnectedRouteMetadata metadata) { LocalRoute.Builder builder = LocalRoute.builder() .setNetwork(address.getIp().toPrefix()) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(ifaceName); if (metadata != null) { if (metadata.getAdmin() != null) { builder.setAdmin(metadata.getAdmin()); } if (metadata.getTag() != null) { builder.setTag(metadata.getTag()); } } return builder.build(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); }
VirtualRouter { @VisibleForTesting @Nonnull static LocalRoute generateLocalRoute( @Nonnull ConcreteInterfaceAddress address, @Nonnull String ifaceName, @Nullable ConnectedRouteMetadata metadata) { LocalRoute.Builder builder = LocalRoute.builder() .setNetwork(address.getIp().toPrefix()) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(ifaceName); if (metadata != null) { if (metadata.getAdmin() != null) { builder.setAdmin(metadata.getAdmin()); } if (metadata.getTag() != null) { builder.setTag(metadata.getTag()); } } return builder.build(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); void computeFib(); Configuration getConfiguration(); Fib getFib(); void enqueueCrossVrfRoutes(
      @Nonnull CrossVrfEdgeId remoteVrfToOurRib,
      @Nonnull Stream<RouteAdvertisement<AnnotatedRoute<AbstractRoute>>> routeAdverts,
      @Nullable String policyName); Map<String, OspfRoutingProcess> getOspfProcesses(); Set<Layer2Vni> getLayer2Vnis(); Set<Layer3Vni> getLayer3Vnis(); @Nonnull String getName(); }
VirtualRouter { @VisibleForTesting @Nonnull static LocalRoute generateLocalRoute( @Nonnull ConcreteInterfaceAddress address, @Nonnull String ifaceName, @Nullable ConnectedRouteMetadata metadata) { LocalRoute.Builder builder = LocalRoute.builder() .setNetwork(address.getIp().toPrefix()) .setSourcePrefixLength(address.getNetworkBits()) .setNextHopInterface(ifaceName); if (metadata != null) { if (metadata.getAdmin() != null) { builder.setAdmin(metadata.getAdmin()); } if (metadata.getTag() != null) { builder.setTag(metadata.getTag()); } } return builder.build(); } VirtualRouter(@Nonnull String name, @Nonnull Node node); void computeFib(); Configuration getConfiguration(); Fib getFib(); void enqueueCrossVrfRoutes(
      @Nonnull CrossVrfEdgeId remoteVrfToOurRib,
      @Nonnull Stream<RouteAdvertisement<AnnotatedRoute<AbstractRoute>>> routeAdverts,
      @Nullable String policyName); Map<String, OspfRoutingProcess> getOspfProcesses(); Set<Layer2Vni> getLayer2Vnis(); Set<Layer3Vni> getLayer3Vnis(); @Nonnull String getName();  }