@Test public void testNextHopSelfAll() { BgpNeighbor bgpNeighbor = new BgpIpNeighbor("10.0.0.1"); BgpVrf bgpVrf = new BgpVrf("bgpVrf"); { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(20000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(false); ipv4af.setNextHopSelfAll(false); assertThat(getSetNextHop(bgpNeighbor, bgpVrf), equalTo(null)); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(20000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(true); ipv4af.setNextHopSelfAll(false); assertThat( getSetNextHop(bgpNeighbor, bgpVrf), equalTo(new SetNextHop(SelfNextHop.getInstance()))); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(20000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(true); ipv4af.setNextHopSelfAll(true); assertThat( getSetNextHop(bgpNeighbor, bgpVrf), equalTo(new SetNextHop(SelfNextHop.getInstance()))); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(10000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(false); ipv4af.setNextHopSelfAll(false); assertThat(getSetNextHop(bgpNeighbor, bgpVrf), equalTo(null)); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(10000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(true); ipv4af.setNextHopSelfAll(false); assertThat(getSetNextHop(bgpNeighbor, bgpVrf), equalTo(null)); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(10000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelf(true); ipv4af.setNextHopSelfAll(true); assertThat( getSetNextHop(bgpNeighbor, bgpVrf), equalTo(new SetNextHop(SelfNextHop.getInstance()))); } { bgpNeighbor.setRemoteAs(10000L); bgpVrf.setAutonomousSystem(10000L); BgpNeighborIpv4UnicastAddressFamily ipv4af = new BgpNeighborIpv4UnicastAddressFamily(); bgpNeighbor.setIpv4UnicastAddressFamily(ipv4af); ipv4af.setNextHopSelfAll(true); assertThat(getSetNextHop(bgpNeighbor, bgpVrf), equalTo(null)); } }
@VisibleForTesting static @Nullable SetNextHop getSetNextHop(BgpNeighbor neighbor, BgpVrf bgpVrf) { if (neighbor.getRemoteAs() == null || bgpVrf.getAutonomousSystem() == null) { return null; } boolean isIBgp = neighbor.getRemoteAs().equals(bgpVrf.getAutonomousSystem()); boolean nextHopSelf = Optional.ofNullable(neighbor.getIpv4UnicastAddressFamily()) .map(BgpNeighborIpv4UnicastAddressFamily::getNextHopSelf) .orElse(false); if (isIBgp) { BgpNeighborIpv4UnicastAddressFamily ipv4af = neighbor.getIpv4UnicastAddressFamily(); if (ipv4af != null) { Boolean nextHopSelfAll = ipv4af.getNextHopSelfAll(); if (nextHopSelfAll == null || !nextHopSelfAll) { nextHopSelf = false; } } } return nextHopSelf ? new SetNextHop(SelfNextHop.getInstance()) : null; }
CumulusConversions { @VisibleForTesting static @Nullable SetNextHop getSetNextHop(BgpNeighbor neighbor, BgpVrf bgpVrf) { if (neighbor.getRemoteAs() == null || bgpVrf.getAutonomousSystem() == null) { return null; } boolean isIBgp = neighbor.getRemoteAs().equals(bgpVrf.getAutonomousSystem()); boolean nextHopSelf = Optional.ofNullable(neighbor.getIpv4UnicastAddressFamily()) .map(BgpNeighborIpv4UnicastAddressFamily::getNextHopSelf) .orElse(false); if (isIBgp) { BgpNeighborIpv4UnicastAddressFamily ipv4af = neighbor.getIpv4UnicastAddressFamily(); if (ipv4af != null) { Boolean nextHopSelfAll = ipv4af.getNextHopSelfAll(); if (nextHopSelfAll == null || !nextHopSelfAll) { nextHopSelf = false; } } } return nextHopSelf ? new SetNextHop(SelfNextHop.getInstance()) : null; } }
CumulusConversions { @VisibleForTesting static @Nullable SetNextHop getSetNextHop(BgpNeighbor neighbor, BgpVrf bgpVrf) { if (neighbor.getRemoteAs() == null || bgpVrf.getAutonomousSystem() == null) { return null; } boolean isIBgp = neighbor.getRemoteAs().equals(bgpVrf.getAutonomousSystem()); boolean nextHopSelf = Optional.ofNullable(neighbor.getIpv4UnicastAddressFamily()) .map(BgpNeighborIpv4UnicastAddressFamily::getNextHopSelf) .orElse(false); if (isIBgp) { BgpNeighborIpv4UnicastAddressFamily ipv4af = neighbor.getIpv4UnicastAddressFamily(); if (ipv4af != null) { Boolean nextHopSelfAll = ipv4af.getNextHopSelfAll(); if (nextHopSelfAll == null || !nextHopSelfAll) { nextHopSelf = false; } } } return nextHopSelf ? new SetNextHop(SelfNextHop.getInstance()) : null; }  }
CumulusConversions { @VisibleForTesting static @Nullable SetNextHop getSetNextHop(BgpNeighbor neighbor, BgpVrf bgpVrf) { if (neighbor.getRemoteAs() == null || bgpVrf.getAutonomousSystem() == null) { return null; } boolean isIBgp = neighbor.getRemoteAs().equals(bgpVrf.getAutonomousSystem()); boolean nextHopSelf = Optional.ofNullable(neighbor.getIpv4UnicastAddressFamily()) .map(BgpNeighborIpv4UnicastAddressFamily::getNextHopSelf) .orElse(false); if (isIBgp) { BgpNeighborIpv4UnicastAddressFamily ipv4af = neighbor.getIpv4UnicastAddressFamily(); if (ipv4af != null) { Boolean nextHopSelfAll = ipv4af.getNextHopSelfAll(); if (nextHopSelfAll == null || !nextHopSelfAll) { nextHopSelf = false; } } } return nextHopSelf ? new SetNextHop(SelfNextHop.getInstance()) : null; }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); }
CumulusConversions { @VisibleForTesting static @Nullable SetNextHop getSetNextHop(BgpNeighbor neighbor, BgpVrf bgpVrf) { if (neighbor.getRemoteAs() == null || bgpVrf.getAutonomousSystem() == null) { return null; } boolean isIBgp = neighbor.getRemoteAs().equals(bgpVrf.getAutonomousSystem()); boolean nextHopSelf = Optional.ofNullable(neighbor.getIpv4UnicastAddressFamily()) .map(BgpNeighborIpv4UnicastAddressFamily::getNextHopSelf) .orElse(false); if (isIBgp) { BgpNeighborIpv4UnicastAddressFamily ipv4af = neighbor.getIpv4UnicastAddressFamily(); if (ipv4af != null) { Boolean nextHopSelfAll = ipv4af.getNextHopSelfAll(); if (nextHopSelfAll == null || !nextHopSelfAll) { nextHopSelf = false; } } } return nextHopSelf ? new SetNextHop(SelfNextHop.getInstance()) : null; }  static @Nonnull String computeBgpCommonExportPolicyName(String vrfName); @VisibleForTesting static @Nonnull String computeBgpPeerExportPolicyName(
      String vrfName, String peerInterface); static @Nonnull String computeBgpPeerImportPolicyName(String vrf, String peer); static String computeBgpGenerationPolicyName(boolean ipv4, String vrfName, String prefix); static String computeMatchSuppressedSummaryOnlyPolicyName(String vrfName); static String computeOspfExportPolicyName(String vrfName); static final int DEFAULT_STATIC_ROUTE_ADMINISTRATIVE_DISTANCE; static final int DEFAULT_STATIC_ROUTE_METRIC; static final Ip CLAG_LINK_LOCAL_IP; static final long DEFAULT_MAX_MED; static final double SPEED_CONVERSION_FACTOR; static final double DEFAULT_LOOPBACK_BANDWIDTH; static final double DEFAULT_PORT_BANDWIDTH; }