private String getAddressString(final IpAddress address) { Preconditions.checkArgument(address.getIpv4Address() != null || address.getIpv6Address() != null, "Address %s is invalid", address); if (address.getIpv4Address() != null) { return address.getIpv4Address().getValue(); } return address.getIpv6Address().getValue(); }
private String getAddressString(final IpAddress address) { Preconditions.checkArgument(address.getIpv4Address() != null || address.getIpv6Address() != null, "Address %s is invalid", address); if (address.getIpv4Address() != null) { return address.getIpv4Address().getValue(); } return address.getIpv6Address().getValue(); }
private static String getStringIpAddress(final IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
private static String getStringIpAddress(IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
public static String getStringIpAddress(IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
/** * Creates an UNI node Id with an IP Address. * @param ipAddress The IP address of the UNI * @return A NodeId for a Specific UNI Node Id */ public static NodeId createUniNodeId(IpAddress ipAddress) { return new NodeId(UnimgrConstants.UNI_PREFIX + ipAddress.getIpv4Address().getValue().toString()); }
private static void serializeForwardingAddress(final IpAddress forwardingAddress, final ByteBuf byteAggregator) { if (forwardingAddress != null) { final ByteBuf ospfBuf = Unpooled.buffer(); if (forwardingAddress.getIpv4Address() != null) { ospfBuf.writeBytes(Ipv4Util.bytesForAddress(forwardingAddress.getIpv4Address())); } else if (forwardingAddress.getIpv6Address() != null) { ospfBuf.writeBytes(Ipv6Util.bytesForAddress(forwardingAddress.getIpv6Address())); } TlvUtil.writeTLV(FORWARDING_ADDRESS, ospfBuf, byteAggregator); } } }
public static IpPrefix createDefaultPrefix(IpAddress ipAddress) { if (ipAddress.getIpv4Address() == null) { return null; } String ipv4 = ipAddress.getIpv4Address().getValue(); long mask = getDefaultMask(ipv4); return new IpPrefix(new Ipv4Prefix(String.format("%s/%d", ipv4, mask))); }
/** * 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())); } }
private boolean isIpv6(final VxlanGpe vxlanGpe) { if (vxlanGpe.getLocal().getIpv4Address() == null) { checkArgument(vxlanGpe.getRemote().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(), vxlanGpe.getRemote()); return true; } else { checkArgument(vxlanGpe.getRemote().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", vxlanGpe.getLocal(), vxlanGpe.getRemote()); return false; } }
private InetSocketAddress getAddress() { final InetAddress inetAddr; try { inetAddr = InetAddress.getByName(getBindingAddress() .getIpv4Address() != null ? getBindingAddress() .getIpv4Address().getValue() : getBindingAddress() .getIpv6Address().getValue()); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Illegal binding address " + getBindingAddress(), e); } return new InetSocketAddress(inetAddr, getBindingPort().getValue()); }
private boolean isIpv6(final Gre gre) { if (gre.getSrc().getIpv4Address() == null) { checkArgument(gre.getDst().getIpv4Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(), gre.getDst()); return true; } else { checkArgument(gre.getDst().getIpv6Address() == null, "Inconsistent ip addresses: %s, %s", gre.getSrc(), gre.getDst()); return false; } }
@Override public void start(final RIB rib, final Neighbor neighbor, final BGPOpenConfigMappingService mappingService, final WriteConfiguration configurationWriter) { this.currentConfiguration = neighbor; this.mappingService = mappingService; this.bgpAppPeerSingletonService = new BgpAppPeerSingletonService(rib, createAppRibId(neighbor), neighbor.getNeighborAddress().getIpv4Address(), configurationWriter); }
@Override protected void add(InstanceIdentifier<Floatingip> identifier, Floatingip input) { if (LOG.isTraceEnabled()) { LOG.trace("Neutron Floating IP created: key: " + identifier + ", value=" + input); } IpAddress fixedIp = input.getFixedIpAddress(); if (fixedIp != null) { addToFloatingIpInfo(input.getRouterId().getValue(), input.getFloatingNetworkId(), input.getPortId() .getValue(), fixedIp.getIpv4Address().getValue(), input.getFloatingIpAddress().getIpv4Address() .getValue()); } }
@Override protected void remove(InstanceIdentifier<Floatingip> identifier, Floatingip input) { if (LOG.isTraceEnabled()) { LOG.trace("Neutron Floating IP deleted : key: " + identifier + ", value=" + input); } IpAddress fixedIp = input.getFixedIpAddress(); if (fixedIp != null) { clearFromFloatingIpInfo(input.getRouterId().getValue(), input.getPortId().getValue(), fixedIp .getIpv4Address().getValue()); } }
private String touniqueIpAddress(IpAddress ipAddress) { Ipv4Address ipv4 = ipAddress.getIpv4Address(); if (ipv4 != null) { return ipv4.getValue(); } Ipv6Address ipv6 = ipAddress.getIpv6Address(); if (ipv6 != null) { return uniqueIpv6String(ipv6.getValue()); } return null; } private static String uniqueIpv6String(String ipv6) {
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())); } }
private static ApplicationRibId createAppRibId(final Neighbor neighbor) { final Config config = neighbor.getConfig(); if (config != null && !Strings.isNullOrEmpty(config.getDescription())) { return new ApplicationRibId(config.getDescription()); } return new ApplicationRibId(neighbor.getNeighborAddress().getIpv4Address().getValue()); }
private @Nullable Ipv4Address createSenderIpAddress(EndpointL3 l3Ep, ReadTransaction rTx) { Subnet subnetOfL3Ep = readSubnet(l3Ep, rTx); if (subnetOfL3Ep == null) { return null; } SubnetInfo subnetInfo = new SubnetUtils(subnetOfL3Ep.getIpPrefix().getIpv4Prefix().getValue()).getInfo(); String senderIp = subnetInfo.getHighAddress(); if (senderIp.equals(l3Ep.getKey().getIpAddress().getIpv4Address().getValue())) { senderIp = subnetInfo.getLowAddress(); } return new Ipv4Address(senderIp); }
private static BgpApplicationPeerBuilder toBgpPeerConfig(final Neighbor neighbor, final TargetRib rib) { final BgpApplicationPeerBuilder bgpAppPeerBuilder = new BgpApplicationPeerBuilder(); bgpAppPeerBuilder.setTargetRib(rib); final Ipv4Address address = neighbor.getNeighborAddress().getIpv4Address(); bgpAppPeerBuilder.setBgpPeerId(new BgpId(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715. Ipv4Address(address.getValue()))); bgpAppPeerBuilder.setApplicationRibId(new ApplicationRibId(createAppRibName(address))); return bgpAppPeerBuilder; }