public static @Nullable Ipv4Address bytesToIp(byte[] ipv4AsBytes) { try { return new Ipv4Address(InetAddress.getByAddress(ipv4AsBytes).getHostAddress()); } catch (UnknownHostException e) { return null; } }
public static @Nullable Ipv4Address bytesToIp(byte[] ipv4AsBytes) { try { return new Ipv4Address(InetAddress.getByAddress(ipv4AsBytes).getHostAddress()); } catch (UnknownHostException e) { return null; } }
public static @Nullable Ipv4Address bytesToIp(byte[] ipv4AsBytes) { try { return new Ipv4Address(InetAddress.getByAddress(ipv4AsBytes).getHostAddress()); } catch (UnknownHostException e) { return null; } }
public static Ipv4Address longToIpv4Address(long ip) { long tmpIp = ip; StringBuilder sb = new StringBuilder(15); for (int i = 0; i < 4; i++) { sb.insert(0, Long.toString(tmpIp & 0xff)); if (i < 3) { sb.insert(0, '.'); } tmpIp >>= 8; } return new Ipv4Address(sb.toString()); }
/** * {@inheritDoc} */ @Override public IpAddress getIpAddress() { return new IpAddress(new Ipv4Address(getHostAddress())); }
private Uuid getSubnetIdOfIp(String ip) { if (ip != null) { IpAddress externalIpv4Address = new IpAddress(new Ipv4Address(ip)); Port port = NatUtil.getNeutronPortForRouterGetewayIp(dataBroker, externalIpv4Address); Uuid subnetId = NatUtil.getSubnetIdForFloatingIp(port, externalIpv4Address); return subnetId; } return null; }
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!"); }
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 getDefaultInstance(final String defaultValue) { return IPV4_PATTERN.matcher(defaultValue).matches() ? new IpAddress(new Ipv4Address(defaultValue)) : new IpAddress(new Ipv6Address(defaultValue)); } }
/** * Increment Address * * @param ipv4Address ipv4 address to be incremented * @return new ipv4 address */ public static Ipv4Address incrementIpv4Address(final Ipv4Address ipv4Address) { return new Ipv4Address(incrementIpv4Address(ipv4Address.getValue())); }
private static void setSrcIpv4MatchArbitraryBitMaskBuilderFields( final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder, final DottedQuad mask, final String ipv4AddressStr) { if (mask != null) { ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceArbitraryBitmask(mask); } ipv4MatchArbitraryBitMaskBuilder.setIpv4SourceAddressNoMask(new Ipv4Address(ipv4AddressStr)); }
private static void setDstIpv4MatchArbitraryBitMaskBuilderFields( final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder, final DottedQuad mask, final String ipv4AddressStr) { if (mask != null) { ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(mask); } ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address(ipv4AddressStr)); }
private static void setDstIpv4MatchArbitraryBitMaskBuilderFields( final Ipv4MatchArbitraryBitMaskBuilder ipv4MatchArbitraryBitMaskBuilder, final DottedQuad mask, final String ipv4AddressStr) { if (mask != null) { ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationArbitraryBitmask(mask); } ipv4MatchArbitraryBitMaskBuilder.setIpv4DestinationAddressNoMask(new Ipv4Address(ipv4AddressStr)); }
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(); }
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; }
public synchronized void delUpdateSource(String nbrIp) { Ipv4Address nbrAddr = new Ipv4Address(nbrIp); InstanceIdentifier.InstanceIdentifierBuilder<UpdateSource> iib = InstanceIdentifier.builder(Bgp.class) .child(Neighbors.class, new NeighborsKey(nbrAddr)) .child(UpdateSource.class); InstanceIdentifier<UpdateSource> iid = iib.build(); delete(iid); }
public synchronized void delEbgpMultihop(String nbrIp) { Ipv4Address nbrAddr = new Ipv4Address(nbrIp); InstanceIdentifier.InstanceIdentifierBuilder<EbgpMultihop> iib = InstanceIdentifier.builder(Bgp.class) .child(Neighbors.class, new NeighborsKey(nbrAddr)) .child(EbgpMultihop.class); InstanceIdentifier<EbgpMultihop> iid = iib.build(); delete(iid); }
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); }
public synchronized void startConfig(String bgpHost, int thriftPort) { InstanceIdentifier.InstanceIdentifierBuilder<ConfigServer> iib = InstanceIdentifier.builder(Bgp.class).child(ConfigServer.class); InstanceIdentifier<ConfigServer> iid = iib.build(); Ipv4Address ipAddr = new Ipv4Address(bgpHost); ConfigServer dto = new ConfigServerBuilder().setHost(ipAddr) .setPort((long) thriftPort).build(); update(iid, dto); }
@Override public Neighbor fromApplicationPeer(final ApplicationRibId applicationRibId, final BgpId bgpId) { final NeighborBuilder neighborBuilder = new NeighborBuilder(); neighborBuilder.setNeighborAddress(new IpAddress(new Ipv4Address(bgpId.getValue()))); neighborBuilder.setKey(new NeighborKey(neighborBuilder.getNeighborAddress())); neighborBuilder.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder() .setDescription(applicationRibId.getValue()) .addAugmentation(Config2.class, new Config2Builder().setPeerGroup(APPLICATION_PEER_GROUP_NAME).build()) .build()); return neighborBuilder.build(); }