public static Ipv6Address getDefaultInstance(String defaultValue) { return new Ipv6Address(defaultValue); }
public static Ipv6Address getDefaultInstance(String defaultValue) { return new Ipv6Address(defaultValue); }
public static Ipv6Address getDefaultInstance(String defaultValue) { return new Ipv6Address(defaultValue); }
static Ipv6Address parseLocator(@Nonnull final Ipv6Prefix prefix) { Matcher matcher = IP_PREFIX_PATTERN.matcher(prefix.getValue()); checkArgument(matcher.matches(), "Could`t parse Locator: {}", prefix); return new Ipv6Address(matcher.group(GROUP_IP)); } }
public static Ipv6MulticastSourceAddress getDefaultInstance(final String defaultValue) { return Enumeration.forName(defaultValue).map(ENUMERATED::get) .orElse(new Ipv6MulticastSourceAddress(new Ipv6Address(defaultValue))); }
/** * Creates address array from address part of {@link Ipv6Prefix} */ public static byte[] ipv6AddressPrefixToArray(@Nonnull final Ipv6Prefix ipv4Prefix) { checkNotNull(ipv4Prefix, "Cannot convert null prefix"); return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone( new Ipv6Address(ipv4Prefix.getValue().substring(0, ipv4Prefix.getValue().indexOf('/'))))); }
public static IpAddress getDefaultInstance(java.lang.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 IpAddress from \"%s\", matches both %s and %s", defaultValue, Ipv4Address.class.getSimpleName(), Ipv6Address.class.getSimpleName())); } return new IpAddress(new Ipv4Address(defaultValue)); } else if (IPV6_PATTERN1.matcher(defaultValue).matches() && IPV6_PATTERN2.matcher(defaultValue).matches()) { return new IpAddress(new Ipv6Address(defaultValue)); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
public static IpAddress getDefaultInstance(final String defaultValue) { return IPV4_PATTERN.matcher(defaultValue).matches() ? new IpAddress(new Ipv4Address(defaultValue)) : new IpAddress(new Ipv6Address(defaultValue)); } }
private static IpAddress resolveIpAddress(final InetAddress address) { String hostAddress = address.getHostAddress(); if (address instanceof Inet4Address) { return new IpAddress(new Ipv4Address(hostAddress)); } if (address instanceof Inet6Address) { return new IpAddress(new Ipv6Address(hostAddress)); } throw new IllegalArgumentException("Unsupported IP address type!"); }
/** * Creates uncompressed IP Address * * @param ip to be uncompressed * @return Ipv6Address with same, but uncompressed, value */ public static Ipv6Address getFullForm(final Ipv6Address ip) { return new Ipv6Address(InetAddresses.forString(ip.getValue()).getHostAddress()); }
private static IpAddress resolveIpAddress(final InetAddress address) { String hostAddress = address.getHostAddress(); if (address instanceof Inet4Address) { return new IpAddress(new Ipv4Address(hostAddress)); } if (address instanceof Inet6Address) { return new IpAddress(new Ipv6Address(hostAddress)); } throw new IllegalArgumentException("Unsupported IP address type!"); }
public static IpAddress convertStringToIpAddress(String ipAddressString) { Preconditions.checkNotNull(ipAddressString, "Supplied string value of ipAddress must not be null"); try { return new IpAddress(new Ipv4Address(ipAddressString)); } catch (Exception e) { LOG.debug("Supplied string value of ipAddress ({}) is not an instance of IPv4", ipAddressString); } try { return new IpAddress(new Ipv6Address(ipAddressString)); } catch (Exception e) { LOG.debug("Supplied string value of ipAddress ({}) is not an instance of IPv6", ipAddressString); } LOG.error("Supplied string value of ipAddress ({}) cannot be converted to IpAddress object!", ipAddressString); return null; }
public static IpAddress createIpAddress(Inet6Address address) { Ipv6Address ipv6 = new Ipv6Address(address.getHostAddress()); return new IpAddress(ipv6); }
public static Ipv6Address compressedIpv6AddressFormat(final Ipv6Address ipv6Address) { return new Ipv6Address(compressedIpv6FormatFromString(ipv6Address.getValue())); }
public static IpAddress createIpAddress(Inet6Address address) { Ipv6Address ipv6 = new Ipv6Address(address.getHostAddress()); return new IpAddress(ipv6); }
/** * This implementation does not use nameservice lookups (e.g. no DNS). * * @param ipAddress - format must be valid for regex in {@link Ipv4Address} or * {@link Ipv6Address} * @return the {@link IpAddress} having the given ipAddress string representation * @throws IllegalArgumentException - if the argument is not a valid IP address string */ public static IpAddress createIpAddress(String ipAddress) { checkArgument(!Strings.isNullOrEmpty(ipAddress), "Cannot be null or empty."); InetAddress ip = InetAddresses.forString(ipAddress); if (ip instanceof Inet4Address) { return new IpAddress(new Ipv4Address(ipAddress)); } return new IpAddress(new Ipv6Address(ipAddress)); }
private Ipv6Address parseSrv6SidAddress(final String locatorIp, final String locatorLength, final Long opcode) { com.googlecode.ipv6.IPv6Address ip = com.googlecode.ipv6.IPv6Address.fromString(locatorIp); IPv6NetworkMask mask = IPv6NetworkMask.fromPrefixLength(parseInt(locatorLength)); com.googlecode.ipv6.IPv6Address srv6Sid = ip.maskWithNetworkMask(mask); return new Ipv6Address(srv6Sid.add(opcode.intValue()).toString()); }
private Segment parseSrv6Sid(final long i, final Srv6Sid srv6Sid) { // shifting index by 1 so it matches original indexing long index = i + 1L; SegmentBuilder builder = new SegmentBuilder().withKey(new SegmentKey(index)).setState( new org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.oc.srte.policy.rev170918.segment.properties.StateBuilder() .setIndex(index) .setType(SegmentType.Type2) .setSidValue(new SidValueType( new IpAddress(new Ipv6Address(arrayToIpv6AddressNoZone(srv6Sid.addr))))) .build()); return builder.build(); }
private static AddressFamily serializeAddressFamily(final ChoiceNode addressFamily, final boolean ipv4Case) { if (ipv4Case) { return new Ipv4CaseBuilder() .setIpv4TunnelSenderAddress(new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).get().getValue())) .setIpv4TunnelEndpointAddress(new Ipv4Address((String) addressFamily.getChild(IPV4_TUNNEL_ENDPOINT_ADDRESS).get().getValue())) .build(); } return new Ipv6CaseBuilder() .setIpv6TunnelSenderAddress(new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_SENDER_ADDRESS).get().getValue())) .setIpv6TunnelEndpointAddress(new Ipv6Address((String) addressFamily.getChild(IPV6_TUNNEL_ENDPOINT_ADDRESS).get().getValue())) .build(); }
Ipv6Address resolveSidAddress(@Nonnull final Prefix locPrefix, @Nonnull Sid localSid) { com.googlecode.ipv6.IPv6Address ip = com.googlecode.ipv6.IPv6Address.fromString(locPrefix.getAddress().getValue()); IPv6NetworkMask mask = IPv6NetworkMask.fromPrefixLength(locPrefix.getLength().getValue()); // strip function part if present ip = ip.maskWithNetworkMask(mask); //add new function part based on opcode String locIp = ip.add(localSid.getOpcode().getValue().intValue()).toString(); return new Ipv6Address(locIp); }