/** * 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); }
/** * Adds a BGP route. The route can be either IPv4 or IPv6. * * @param bgpRouteEntry the BGP route entry to use */ void addBgpRoute(BgpRouteEntry bgpRouteEntry) { if (bgpRouteEntry.isIp4()) { bgpRoutes4.put(bgpRouteEntry.prefix().getIp4Prefix(), // IPv4 bgpRouteEntry); } else { bgpRoutes6.put(bgpRouteEntry.prefix().getIp6Prefix(), // IPv6 bgpRouteEntry); } }
/** * Adds a BGP route. The route can be either IPv4 or IPv6. * * @param bgpRouteEntry the BGP route entry to use */ void addBgpRoute(BgpRouteEntry bgpRouteEntry) { if (bgpRouteEntry.isIp4()) { // IPv4 route Ip4Prefix ip4Prefix = bgpRouteEntry.prefix().getIp4Prefix(); bgpRibIn4.put(ip4Prefix, bgpRouteEntry); } else { // IPv6 route Ip6Prefix ip6Prefix = bgpRouteEntry.prefix().getIp6Prefix(); bgpRibIn6.put(ip6Prefix, bgpRouteEntry); } }
/** * 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()); }
private void buildMatchRemoteIp(TrafficSelector.Builder sBuilder, IpPrefix remoteIpPrefix, OpenstackSecurityGroupRule.Direction direction) { if (remoteIpPrefix != null && !remoteIpPrefix.getIp4Prefix().equals(IP_PREFIX_ANY)) { if (direction.equals(OpenstackSecurityGroupRule.Direction.EGRESS)) { sBuilder.matchIPDst(remoteIpPrefix); } else { sBuilder.matchIPSrc(remoteIpPrefix); } } }
@Override public int write(ChannelBuffer cb) { int iLenStartIndex = cb.writerIndex(); cb.writeByte(FLOW_SPEC_TYPE); cb.writeByte(length); cb.writeInt(ipPrefix.getIp4Prefix().address().toInt()); return cb.writerIndex() - iLenStartIndex; }
@Override public int write(ChannelBuffer cb) { int iLenStartIndex = cb.writerIndex(); cb.writeByte(FLOW_SPEC_TYPE); cb.writeByte(length); cb.writeInt(ipPrefix.getIp4Prefix().address().toInt()); return cb.writerIndex() - iLenStartIndex; }
case IPV4_SRC: ipCriterion = (IPCriterion) c; ip4Prefix = ipCriterion.ip().getIp4Prefix(); if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { Ip4Address maskAddr = case IPV4_DST: ipCriterion = (IPCriterion) c; ip4Prefix = ipCriterion.ip().getIp4Prefix(); if (ip4Prefix.prefixLength() != Ip4Prefix.MAX_MASK_LENGTH) { Ip4Address maskAddr =