@Override protected Ipv4Address maybeIpv4Address(final IpAddress addr) { return addr.getIpv4Address(); }
public static String getStringIpAddress(IpAddress ipAddress) { if (ipAddress.getIpv4Address() != null) { return ipAddress.getIpv4Address().getValue(); } return ipAddress.getIpv6Address().getValue(); }
private String getIpAddress(EndpointType endpoint) { String ipAddress = ""; if( endpoint instanceof IpAddress) { ipAddress = ((IpAddress) endpoint).getIpAddress().getIpv4Address().getValue(); } else if (endpoint instanceof Interface) { ipAddress = ((Interface)endpoint).getInterfaceIp().getIpv4Address().getValue(); } return ipAddress; }
protected DhcpInfo setDnsServersIpAddrs(List<IpAddress> dnsServers) { for (IpAddress ipAddr: dnsServers) { addDnsServer(ipAddr.getIpv4Address().getValue()); } return this; }
private String getIpAddress(EndpointType source) { String ipAddress = null; if( source instanceof IpAddress) { ipAddress = ((IpAddress) source).getIpAddress().getIpv4Address().getValue(); } else if (source instanceof Interface) { ipAddress = ((Interface)source).getInterfaceIp().getIpv4Address().getValue(); } return ipAddress; }
private InetSocketAddress getInetAddress() { try { final InetAddress inetAd = InetAddress.getByName(getBindingAddress().getIpv4Address() == null ? getBindingAddress().getIpv6Address().getValue() : getBindingAddress().getIpv4Address().getValue()); return new InetSocketAddress(inetAd, getPort().getValue()); } catch (final UnknownHostException e) { throw new IllegalArgumentException("Unable to bind netconf endpoint to address " + getBindingAddress(), e); } }
public static String getEndpointIpAddressForDPN(DataBroker broker, BigInteger dpnId) { String nextHopIp = null; InstanceIdentifier<DPNTEPsInfo> tunnelInfoId = InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(dpnId)).build(); Optional<DPNTEPsInfo> tunnelInfo = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId); if (tunnelInfo.isPresent()) { List<TunnelEndPoints> nexthopIpList = tunnelInfo.get().getTunnelEndPoints(); if (nexthopIpList != null && !nexthopIpList.isEmpty()) { nextHopIp = nexthopIpList.get(0).getIpAddress().getIpv4Address().getValue(); } } return nextHopIp; }
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 protected void remove(InstanceIdentifier<Interface> identifier, Interface intrf) { LOG.trace("Removing interface : key: " + identifier + ", value=" + intrf ); if (intrf.getType().equals(L3tunnel.class)) { BigInteger dpnId = interfaceManager.getDpnForInterface(intrf); IfL3tunnel intfData = intrf.getAugmentation(IfL3tunnel.class); IpAddress gatewayIp = intfData.getGatewayIp(); IpAddress remoteIp = (gatewayIp == null) ? intfData.getRemoteIp() : gatewayIp; nexthopManager.removeRemoteNextHop(dpnId, intrf.getName(), remoteIp.getIpv4Address().getValue()); } }
m.invoke(toObj, ipAddr.getIpv4Address());
private InetSocketAddress getSocketAddress() { if(getAddress().getDomainName() != null) { return new InetSocketAddress(getAddress().getDomainName().getValue(), getPort().getValue()); } else { final IpAddress ipAddress = getAddress().getIpAddress(); final String ip = ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(); return new InetSocketAddress(ip, getPort().getValue()); } }
private boolean isHostAddressPresent(final Host address) { return address.getDomainName() != null || address.getIpAddress() != null && (address.getIpAddress().getIpv4Address() != null || address.getIpAddress().getIpv6Address() != null); }
@Override protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) { LOG.trace("Adding Interface : key: " + identifier + ", value=" + intrf ); if (intrf.getType().equals(L3tunnel.class)) { IfL3tunnel intfData = intrf.getAugmentation(IfL3tunnel.class); IpAddress gatewayIp = intfData.getGatewayIp(); IpAddress remoteIp = (gatewayIp == null) ? intfData.getRemoteIp() : gatewayIp; NodeConnectorId ofPort = intrf.getAugmentation(BaseIds.class).getOfPortId(); nexthopManager.createRemoteNextHop(intrf.getName(), ofPort.toString(), remoteIp.getIpv4Address().getValue()); } }
@Override public void serializeTlv(final Tlv tlv, final ByteBuf buffer) { Preconditions.checkArgument(tlv instanceof RsvpErrorSpec, "RSVPErrorSpecTlv is mandatory."); final RsvpErrorSpec rsvpTlv = (RsvpErrorSpec) tlv; final RsvpError rsvp = rsvpTlv.getRsvpError(); final ByteBuf body = Unpooled.buffer(); final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE); final Flags f = rsvp.getFlags(); if (f.isInPlace() != null) { flags.set(IN_PLACE_FLAG_OFFSET, f.isInPlace()); } if (f.isNotGuilty() != null) { flags.set(NOT_GUILTY_FLAGS_OFFSET, f.isNotGuilty()); } final IpAddress node = rsvp.getNode(); Preconditions.checkArgument(node != null, "Node is mandatory."); if (node.getIpv4Address() != null) { writeIpv4Address(node.getIpv4Address(), body); } else { writeIpv6Address(node.getIpv6Address(), body); } writeBitSet(flags, FLAGS_F_LENGTH, body); Preconditions.checkArgument(rsvp.getCode() != null, "Code is mandatory."); writeUnsignedByte(rsvp.getCode(), body); Preconditions.checkArgument(rsvp.getValue() != null, "Value is mandatory."); writeUnsignedShort(rsvp.getValue(), body); TlvUtil.formatTlv(TYPE, body, buffer); } }
private Subnet createSubnet(List<L3Address> endPoints, NetworkDomainId networkDomainId , L2FloodDomainId floodDomainId) { L3Address endPoint = endPoints.get(0); String ip = endPoint.getIpAddress().getIpv4Address().getValue(); ip = ip.substring(0, ip.lastIndexOf('.')) + ".1"; return new SubnetBuilder() .setId(new SubnetId(networkDomainId.getValue())) .setParent(new ContextId(floodDomainId.getValue())) .setVirtualRouterIp( GBPRendererHelper.createIpAddress(ip)) .setIpPrefix(GBPRendererHelper.createIpPrefix(ip + "/24")) .build(); }
private DhcpInfo getDhcpInfo(Port nPort, Subnet nSubnet) { DhcpInfo dhcpInfo = null; if( (nPort != null) && (nSubnet != null) ) { String clientIp = nPort.getFixedIps().get(0).getIpAddress().getIpv4Address().getValue(); String serverIp = nSubnet.getGatewayIp().getIpv4Address().getValue(); List<IpAddress> dnsServers = nSubnet.getDnsNameservers(); dhcpInfo = new DhcpInfo(); dhcpInfo.setClientIp(clientIp).setServerIp(serverIp) .setCidr(nSubnet.getCidr()).setHostRoutes(nSubnet.getHostRoutes()) .setDnsServersIpAddrs(dnsServers).setGatewayIp(serverIp); } else { //FIXME: Delete this test code LOG.error("TestOnly Code"); dhcpInfo = new DhcpInfo(); dhcpInfo.setClientIp("1.1.1.3").setServerIp("1.1.1.1") .setCidr("1.1.1.0/24").addDnsServer("1.1.1.1"); LOG.warn("Failed to get Subnet info for DHCP reply"); } return dhcpInfo; }
if(flowCapableNode != null) { IpAddress ip = flowCapableNode.getIpAddress(); ipStr = ip.getIpv4Address().getValue(); } else {
if (memberIpAddress.getIpv4Address() != null) { result.setPoolMemberAddress(memberIpAddress.getIpv4Address().getValue()); } else if (memberIpAddress.getIpv6Address() != null) { result.setPoolMemberAddress(memberIpAddress.getIpv6Address().getValue());