Example usage for com.google.common.net InetAddresses increment

List of usage examples for com.google.common.net InetAddresses increment

Introduction

In this page you can find the example usage for com.google.common.net InetAddresses increment.

Prototype

public static InetAddress increment(InetAddress address) 

Source Link

Document

Returns a new InetAddress that is one more than the passed in address.

Usage

From source file:net.bican.iplib.IPAddressRangeUtil.java

static IPAddress next(final IPAddress endAddress, final IPAddress address) {
    if (address.equals(endAddress)) {
        return null;
    }/*w  w w. j a v  a2 s .c  om*/
    try {
        final InetAddress result = InetAddresses.increment(address.getAddressInstance());
        return IPAddress.getInstance(result);
    } catch (final IllegalArgumentException e) {
        return null;
    }
}

From source file:org.opendaylight.dhcpv6.server.Examplev6LeaseManager.java

@Override
protected InetAddress newIp(final Dhcp6RequestContext dhcp6RequestContext, final DuidOption.Duid duid,
        final IaOption iaOption) throws Dhcp6Exception {
    ip = InetAddresses.increment(ip);
    LOG.info("Examplev6LeaseManager.leaseMac leasing: {}", ip);
    return ip;/*from w  ww  .  j ava 2  s  .c om*/
}

From source file:org.opendaylight.protocol.bmp.mock.BmpMock.java

private static void deployClients(final BmpMockDispatcher dispatcher, final BmpMockArguments arguments) {
    final InetSocketAddress localAddress = arguments.getLocalAddress();
    final InetSocketAddress remoteAddress = arguments.getRemoteAddress();
    InetAddress currentLocal = localAddress.getAddress();
    final int port = localAddress.getPort();
    for (int i = 0; i < arguments.getRoutersCount(); i++) {
        dispatcher.createClient(new InetSocketAddress(currentLocal, port), remoteAddress);
        currentLocal = InetAddresses.increment(currentLocal);
    }//from ww  w . j a  v  a2 s .c o  m
}

From source file:org.opendaylight.dhcp.server.ExampleLeaseManager.java

@Override
protected InetAddress leaseMac(final DhcpRequestContext context, final DhcpMessage request,
        final InetAddress clientRequestedAddress, final long ttl) throws Exception {
    this.ip = InetAddresses.increment(ip);
    LOG.info("ExampleLeaseManager.leaseMac leasing: {}", ip);
    return ip;//from ww w.j  a v a  2s. c o  m
}

From source file:org.opendaylight.protocol.bmp.mock.BmpMock.java

private static void deployServers(final BmpMockDispatcher dispatcher, final BmpMockArguments arguments) {
    final InetSocketAddress localAddress = arguments.getLocalAddress();
    InetAddress currentLocal = localAddress.getAddress();
    final int port = localAddress.getPort();
    for (int i = 0; i < arguments.getRoutersCount(); i++) {
        dispatcher.createServer(new InetSocketAddress(currentLocal, port));
        currentLocal = InetAddresses.increment(currentLocal);
    }/*from  w w w .  j  a  va2  s . c o  m*/
}

From source file:org.opendaylight.protocol.pcep.pcc.mock.PCCsBuilder.java

void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler)
        throws InterruptedException, ExecutionException {
    InetAddress currentAddress = this.localAddress.getAddress();
    this.pccDispatcher = new PCCDispatcherImpl(
            ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry());
    if (timerHandler.isPresent()) {
        timerHandler.get().setPCCDispatcher(this.pccDispatcher);
    }//  ww  w  . j  a v  a 2  s . c  om
    for (int i = 0; i < this.pccCount; i++) {
        final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(this.lsps, currentAddress,
                this.redelegationTimeout, this.stateTimeout, this.timer, timerHandler);
        createPCC(new InetSocketAddress(currentAddress, localAddress.getPort()), tunnelManager,
                initialDBVersion);
        currentAddress = InetAddresses.increment(currentAddress);
    }
}

From source file:org.opendaylight.protocol.bgp.testtool.BGPTestTool.java

void start(final Arguments arguments) {
    final BGPDispatcher dispatcher = initializeActivator();

    final ArrayList<OptionalCapabilities> optCap = Lists.newArrayList(
            createMPCapability(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class),
            createMPCapability(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class),
            createAs4BytesMPCapability(arguments.getAs()));
    if (arguments.getMultiPathSupport()) {
        optCap.add(createAddPathCapability());
    }/*from  w ww . ja  v a 2 s .  c o m*/
    final BgpParameters bgpParameters = createBgpParameters(optCap);

    final InetSocketAddress localAddress = arguments.getLocalAddresses();
    final int port = localAddress.getPort();
    InetAddress address = localAddress.getAddress();
    int numberOfSpeakers = arguments.getSpeakerCount();
    do {
        final BGPSessionListener sessionListener = new TestingListener(arguments.getNumberOfPrefixes(),
                arguments.getExtendedCommunities(), arguments.getMultiPathSupport());
        this.listeners.put(address.getHostAddress(), sessionListener);
        createPeer(dispatcher, arguments, new InetSocketAddress(address, port), sessionListener, bgpParameters);
        numberOfSpeakers--;
        address = InetAddresses.increment(address);
    } while (numberOfSpeakers > 0);
}

From source file:org.opendaylight.protocol.bmp.mock.BmpMockUtil.java

private static String incrementIpv4Address(final String ipv4Address) {
    return InetAddresses.increment(InetAddresses.forString(ipv4Address)).getHostAddress();
}

From source file:org.opendaylight.protocol.util.Ipv4Util.java

/**
 * Increment Address//  w  w w  .  jav  a  2s . co m
 *
 * @param ipv4Address String containing Ipv4Address
 * @return String containing Ipv4Address incremented by 1
 */
public static String incrementIpv4Address(final String ipv4Address) {
    return InetAddresses.increment(InetAddresses.forString(ipv4Address)).getHostAddress();
}

From source file:google.registry.util.CidrAddressBlock.java

@Override
public Iterator<InetAddress> iterator() {
    return new AbstractSequentialIterator<InetAddress>(ip) {
        @Override//  ww  w  .  j  a  v a2  s  . c om
        protected InetAddress computeNext(InetAddress previous) {
            if (InetAddresses.isMaximum(previous)) {
                return null;
            }

            InetAddress next = InetAddresses.increment(previous);
            return (contains(next)) ? next : null;
        }
    };
}