@Override protected IpPrefix ipv4Prefix(Ipv4Prefix addr) { return new IpPrefix(addr); }
public static String getStringIpPrefix(IpPrefix ipPrefix) { if (ipPrefix.getIpv4Prefix() != null) { return ipPrefix.getIpv4Prefix().getValue(); } return ipPrefix.getIpv6Prefix().getValue(); }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PrefixKey other = (PrefixKey) obj; if (_prefix == null) { if (other._prefix != null) { return false; } } else if(!_prefix.equals(other._prefix)) { return false; } return true; }
private void setOptionClasslessRoute(DHCP reply, DhcpInfo dhcpInfo) { List<HostRoutes> hostRoutes = dhcpInfo.getHostRoutes(); if(hostRoutes == null) { //we can't set this option, so return return; } ByteArrayOutputStream result = new ByteArrayOutputStream(); Iterator<HostRoutes> iter = hostRoutes.iterator(); while(iter.hasNext()) { HostRoutes hostRoute = iter.next(); if(hostRoute.getNexthop().getIpv4Address() == null || hostRoute.getDestination().getIpv4Prefix() == null ) { // we only deal with IPv4 addresses return; } String router = hostRoute.getNexthop().getIpv4Address().getValue(); String dest = hostRoute.getDestination().getIpv4Prefix().getValue(); try { result.write(convertToClasslessRouteOption(dest, router)); } catch (IOException | NullPointerException e) { LOG.debug("Exception {}",e.getMessage()); } } if (result.size() > 0) { reply.setOptionBytes(DHCPConstants.OPT_CLASSLESS_ROUTE , result.toByteArray()); } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); return result; }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); return result; }
@Override protected IpPrefix ipv6Prefix(Ipv6Prefix addr) { return new IpPrefix(addr); }
m.invoke(toObj, ipPrefix.getIpv4Prefix()); m.invoke(toObj, ipPrefix.getIpv6Prefix());
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_flag == null) ? 0 : _flag.hashCode()); result = prime * result + ((_metric == null) ? 0 : _metric.hashCode()); result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
@Override public boolean equals(java.lang.Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } PrefixKey other = (PrefixKey) obj; if (_prefix == null) { if (other._prefix != null) { return false; } } else if(!_prefix.equals(other._prefix)) { return false; } return true; }
public static IpPrefix getDefaultInstance(final String defaultValue) { final Matcher ipv4Matcher = IPV4_PATTERN.matcher(defaultValue); if (ipv4Matcher.matches()) { if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { throw new IllegalArgumentException( String.format("Cannot create IpPrefix from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpPrefix(new Ipv4Prefix(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpPrefix(new Ipv6Prefix(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpPrefix from " + defaultValue); } }
answer.setSecurityRuleRemoteIpPrefix(rule.getRemoteIpPrefix().getIpv4Prefix()!= null? rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_flag == null) ? 0 : _flag.hashCode()); result = prime * result + ((_metric == null) ? 0 : _metric.hashCode()); result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
return false; } else if(!_prefix.equals(other.getPrefix())) { return false;
public static IpPrefix getDefaultInstance(final String defaultValue) { final Matcher ipv4Matcher = IPV4_PATTERN.matcher(defaultValue); if (ipv4Matcher.matches()) { if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { throw new IllegalArgumentException( String.format("Cannot create IpPrefix from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpPrefix(new Ipv4Prefix(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpPrefix(new Ipv6Prefix(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpPrefix from " + defaultValue); } }
answer.setSecurityRuleRemoteIpPrefix(rule.getRemoteIpPrefix().getIpv4Prefix() != null? rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_flag == null) ? 0 : _flag.hashCode()); result = prime * result + ((_key == null) ? 0 : _key.hashCode()); result = prime * result + ((_metric == null) ? 0 : _metric.hashCode()); result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }
return false; } else if(!_prefix.equals(other.getPrefix())) { return false;
/** * This implementation does not use nameservice lookups (e.g. no DNS). * * @param cidr - format must be valid for regex in {@link Ipv4Prefix} or {@link Ipv6Prefix} * @return the {@link IpPrefix} having the given cidr string representation * @throws IllegalArgumentException - if the argument is not a valid CIDR string */ public static IpPrefix createIpPrefix(String cidr) { checkArgument(!Strings.isNullOrEmpty(cidr), "Cannot be null or empty."); String[] ipAndPrefix = cidr.split("/"); checkArgument(ipAndPrefix.length == 2, "Bad format."); InetAddress ip = InetAddresses.forString(ipAndPrefix[0]); if (ip instanceof Inet4Address) { return new IpPrefix(new Ipv4Prefix(cidr)); } return new IpPrefix(new Ipv6Prefix(cidr)); }
@Override public int hashCode() { if (hashValid) { return hash; } final int prime = 31; int result = 1; result = prime * result + ((_flag == null) ? 0 : _flag.hashCode()); result = prime * result + ((_key == null) ? 0 : _key.hashCode()); result = prime * result + ((_metric == null) ? 0 : _metric.hashCode()); result = prime * result + ((_prefix == null) ? 0 : _prefix.hashCode()); result = prime * result + ((augmentation == null) ? 0 : augmentation.hashCode()); hash = result; hashValid = true; return result; }