2 * Copyright (c) 2017 Cisco Systems. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.vpp.lisp.util;
11 import org.apache.commons.lang3.tuple.ImmutablePair;
12 import org.apache.commons.lang3.tuple.Pair;
13 import org.apache.commons.net.util.SubnetUtils;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
18 * Created by Shakib Ahmed on 5/3/17.
20 public class IpAddressUtil {
22 public static Pair<Ipv4Address, Ipv4Address> getStartAndEndIp(Ipv4Prefix ipv4Prefix) {
23 SubnetUtils subnetUtils = new SubnetUtils(ipv4Prefix.getValue());
24 SubnetUtils.SubnetInfo prefixSubnetInfo = subnetUtils.getInfo();
25 Ipv4Address lowIp = new Ipv4Address(prefixSubnetInfo.getLowAddress());
26 Ipv4Address highIp = new Ipv4Address(prefixSubnetInfo.getHighAddress());
27 return new ImmutablePair<>(lowIp, highIp);