/** * Tests whether the IP version of this entry is IPv4. * * @return true if the IP version of this entry is IPv4, otherwise false. */ public boolean isIp4() { return ipPrefix.isIp4(); }
/** * Removes a BGP route for a prefix. The prefix can be either IPv4 or IPv6. * * @param prefix the prefix to use * @return true if the route was found and removed, otherwise false */ boolean removeBgpRoute(IpPrefix prefix) { if (prefix.isIp4()) { return (bgpRibIn4.remove(prefix.getIp4Prefix()) != null); // IPv4 } return (bgpRibIn6.remove(prefix.getIp6Prefix()) != null); // IPv6 }
/** * Finds a BGP route for a prefix. The prefix can be either IPv4 or IPv6. * * @param prefix the prefix to use * @return the BGP route if found, otherwise null */ BgpRouteEntry findBgpRoute(IpPrefix prefix) { if (prefix.isIp4()) { return bgpRoutes4.get(prefix.getIp4Prefix()); // IPv4 } return bgpRoutes6.get(prefix.getIp6Prefix()); // IPv6 }
/** * Removes a BGP route for a prefix. The prefix can be either IPv4 or IPv6. * * @param prefix the prefix to use * @return true if the route was found and removed, otherwise false */ boolean removeBgpRoute(IpPrefix prefix) { if (prefix.isIp4()) { return (bgpRoutes4.remove(prefix.getIp4Prefix()) != null); // IPv4 } return (bgpRoutes6.remove(prefix.getIp6Prefix()) != null); // IPv6 }
/** * Finds a BGP routing entry for a prefix in the BGP RIB-IN. The prefix * can be either IPv4 or IPv6. * * @param prefix the IP prefix of the route to search for * @return the BGP routing entry if found, otherwise null */ public BgpRouteEntry findBgpRoute(IpPrefix prefix) { if (prefix.isIp4()) { // IPv4 prefix Ip4Prefix ip4Prefix = prefix.getIp4Prefix(); return bgpRibIn4.get(ip4Prefix); } // IPv6 prefix Ip6Prefix ip6Prefix = prefix.getIp6Prefix(); return bgpRibIn6.get(ip6Prefix); }
private int getPriorityFromPrefix(IpPrefix prefix) { return (prefix.isIp4()) ? 2000 * prefix.prefixLength() + MIN_IP_PRIORITY : 500 * prefix.prefixLength() + MIN_IP_PRIORITY; }
/** * Gets the {@link Ip4Prefix} view of the IP prefix. * * @return the {@link Ip4Prefix} view of the IP prefix if it is IPv4, * otherwise null */ public Ip4Prefix getIp4Prefix() { if (!isIp4()) { return null; } // Return this object itself if it is already instance of Ip4Prefix if (this instanceof Ip4Prefix) { return (Ip4Prefix) this; } return Ip4Prefix.valueOf(address.getIp4Address(), prefixLength); }
/** * Finds a route in the RIB for a prefix. The prefix can be either IPv4 or * IPv6. * * @param prefix the prefix to use * @return the route if found, otherwise null */ RouteEntry findRibRoute(IpPrefix prefix) { String binaryString = createBinaryString(prefix); if (prefix.isIp4()) { // IPv4 return ribTable4.getValueForExactKey(binaryString); } // IPv6 return ribTable6.getValueForExactKey(binaryString); }
/** * Check if this IP prefix is a multicast prefix. * * @return true if this prefix a multicast prefix */ public boolean isMulticast() { return isIp4() ? IPV4_MULTICAST_PREFIX.contains(this.getIp4Prefix()) : IPV6_MULTICAST_PREFIX.contains(this.getIp6Prefix()); }
/** * Removes a route for a prefix from the RIB. The prefix can be either IPv4 * or IPv6. * * @param prefix the prefix to use * @return true if the route was found and removed, otherwise false */ boolean removeRibRoute(IpPrefix prefix) { if (prefix.isIp4()) { // IPv4 return ribTable4.remove(createBinaryString(prefix)); } // IPv6 return ribTable6.remove(createBinaryString(prefix)); }
if (prefix.isIp4()) { selector.matchEthType(Ethernet.TYPE_IPV4);