public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
public static Ipv4AddressNoZone getDefaultInstance(String defaultValue) { return new Ipv4AddressNoZone(defaultValue); }
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
public static IpAddressNoZone getDefaultInstance(final String defaultValue) { if (IPV4_NO_ZONE_PATTERN.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv4AddressNoZone(defaultValue))); } else if (IPV6_NO_ZONE_PATTERN1.matcher(defaultValue).matches()) { return new IpAddressNoZone((new Ipv6AddressNoZone(defaultValue))); } else { throw new IllegalArgumentException("Cannot create IpAddress from " + defaultValue); } } }
public static Ipv4AddressNoZone getIpv4Address(FcPort port) { String hostname = port.getNode().getValue(); String loopback = loopbackMap.get(hostname); if (loopback == null) { LOG.warn("No loopback address found for {}", hostname); loopback = DEFAULT_LOOPBACK; } return new Ipv4AddressNoZone(loopback); } }
/** * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order. * * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv4AddressNoZone arrayToIpv4AddressNoZone(@Nonnull byte[] ip) { // VPP sends ipv4 in a 16 byte array if (ip.length == 16) { ip = Arrays.copyOfRange(ip, 0, 4); } try { // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order // compared to byte order it was submitted return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv4", e); } }
/** * Parse byte array returned by VPP representing an Ipv4 address. Vpp returns IP byte arrays in reversed order. * * @return Ipv4AddressNoZone containing string representation of IPv4 address constructed from submitted bytes. No * change in order. */ @Nonnull public static Ipv4AddressNoZone arrayToIpv4AddressNoZoneReversed(@Nonnull byte[] ip) { // VPP sends ipv4 in a 16 byte array if (ip.length == 16) { ip = Arrays.copyOfRange(ip, 0, 4); } ip = reverseBytes(ip); try { // Not reversing the byte array here!! because the IP coming from VPP is in reversed byte order // compared to byte order it was submitted return new Ipv4AddressNoZone(InetAddresses.toAddrString(InetAddresses.fromLittleEndianByteArray(ip))); } catch (UnknownHostException e) { throw new IllegalArgumentException("Unable to parse ipv4", e); } }
/** * Converts {@link IpAddress} to array representing {@link Ipv4Address} or {@link Ipv6Address} */ public static byte[] ipAddressToArray(boolean isIpv6, @Nonnull IpAddress address) { checkNotNull(address, "Cannot convert null Address"); if (isIpv6) { return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address())); } else { return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address())); } }
public static final byte[] ipAddressToArray(IpAddress address) { checkNotNull(address, "Cannot resolve null adddress"); if (isIpv6(address)) { return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(address.getIpv6Address())); } else { return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(address.getIpv4Address())); } }
default byte[] resolveByteArray(EidType type, Address address) { switch (type) { case IPV4: return ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(((Ipv4) address).getIpv4())); case IPV6: return ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(((Ipv6) address).getIpv6())); case MAC: return parseMac(((Mac) address).getMac().getValue()); case IPV4_PREFIX: return ipv4AddressPrefixToArray(v4LispPrefixToInetPrefix(Ipv4Prefix.class.cast(address))); case IPV6_PREFIX: return ipv6AddressPrefixToArray(v6LispPrefixToInetPrefix(Ipv6Prefix.class.cast(address))); default: throw new IllegalArgumentException("Unsupported type"); } }
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) { final BdIpMacAddDel request = new BdIpMacAddDel(); request.bdId = bdId; request.isAdd = booleanToByte(isAdd); request.macAddress = TranslateUtils.parseMac(entry.getPhysAddress().getValue()); final IpAddress ipAddress = entry.getIpAddress(); if (ipAddress.getIpv6Address() != null) { // FIXME: vpp does not support ipv6 in arp-termination table (based on analysis of l2_bd.c) throw new UnsupportedOperationException("IPv6 address for ARP termination table is not supported yet"); } request.ipAddress = TranslateUtils.ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(ipAddress.getIpv4Address())); return request; } }
tapConnect.hostIp4Gw = ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(hostIpv4GW)); tapConnect.hostIp4GwSet = 1; } else {