Updated SDN-IP to use Ip4Address and Ip4Prefix instead of IpAddress and
IpPrefix, because so far we haven't implemented IPv6.
Also, some of the BGP-related attributes (e.g., BGP Speaker ID)
are IPv4 by definition.
The following components are updated:
* BGP implementation
* Router component and relevant state (e.g., RouteEntry)
Other components (e.g., configuration) will continue to use
the more generic IpAddress and IpPrefix.
Change-Id: I1936ca9871fd5a9709cb4f2c2850d78ebc1472c4
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/IntentSyncTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/IntentSyncTest.java
index 45b0c90..7be7d11 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/IntentSyncTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/IntentSyncTest.java
@@ -42,7 +42,9 @@
import org.onlab.onos.sdnip.config.Interface;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpAddress;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -209,36 +211,36 @@
// 6. RouteEntry6 was newly added, but the intent was not submitted.
//
RouteEntry routeEntry1 = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
RouteEntry routeEntry2 = new RouteEntry(
- IpPrefix.valueOf("2.2.2.0/24"),
- IpAddress.valueOf("192.168.20.1"));
+ Ip4Prefix.valueOf("2.2.2.0/24"),
+ Ip4Address.valueOf("192.168.20.1"));
RouteEntry routeEntry3 = new RouteEntry(
- IpPrefix.valueOf("3.3.3.0/24"),
- IpAddress.valueOf("192.168.30.1"));
+ Ip4Prefix.valueOf("3.3.3.0/24"),
+ Ip4Address.valueOf("192.168.30.1"));
RouteEntry routeEntry4 = new RouteEntry(
- IpPrefix.valueOf("4.4.4.0/24"),
- IpAddress.valueOf("192.168.30.1"));
+ Ip4Prefix.valueOf("4.4.4.0/24"),
+ Ip4Address.valueOf("192.168.30.1"));
RouteEntry routeEntry4Update = new RouteEntry(
- IpPrefix.valueOf("4.4.4.0/24"),
- IpAddress.valueOf("192.168.20.1"));
+ Ip4Prefix.valueOf("4.4.4.0/24"),
+ Ip4Address.valueOf("192.168.20.1"));
RouteEntry routeEntry5 = new RouteEntry(
- IpPrefix.valueOf("5.5.5.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("5.5.5.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
RouteEntry routeEntry6 = new RouteEntry(
- IpPrefix.valueOf("6.6.6.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("6.6.6.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
RouteEntry routeEntry7 = new RouteEntry(
- IpPrefix.valueOf("7.7.7.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("7.7.7.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
MultiPointToSinglePointIntent intent1 = intentBuilder(
routeEntry1.prefix(), "00:00:00:00:00:01", SW1_ETH1);
@@ -286,7 +288,7 @@
routeEntry7);
TestUtils.setField(router, "bgpRoutes", bgpRoutes);
- ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent>
+ ConcurrentHashMap<Ip4Prefix, MultiPointToSinglePointIntent>
pushedRouteIntents = new ConcurrentHashMap<>();
pushedRouteIntents.put(routeEntry1.prefix(), intent1);
pushedRouteIntents.put(routeEntry3.prefix(), intent3);
@@ -355,7 +357,7 @@
* @param egressPoint to which packets should be sent
* @return the constructed MultiPointToSinglePointIntent
*/
- private MultiPointToSinglePointIntent intentBuilder(IpPrefix ipPrefix,
+ private MultiPointToSinglePointIntent intentBuilder(Ip4Prefix ipPrefix,
String nextHopMacAddress, ConnectPoint egressPoint) {
TrafficSelector.Builder selectorBuilder =
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouteEntryTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouteEntryTest.java
index 9af90a7..ca5b1f8 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouteEntryTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouteEntryTest.java
@@ -20,8 +20,8 @@
import static org.junit.Assert.assertThat;
import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
/**
* Unit tests for the RouteEntry class.
@@ -32,8 +32,8 @@
*/
@Test
public void testConstructor() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
assertThat(routeEntry.toString(),
@@ -45,8 +45,8 @@
*/
@Test(expected = NullPointerException.class)
public void testInvalidConstructorNullPrefix() {
- IpPrefix prefix = null;
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = null;
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
new RouteEntry(prefix, nextHop);
}
@@ -56,8 +56,8 @@
*/
@Test(expected = NullPointerException.class)
public void testInvalidConstructorNullNextHop() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = null;
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = null;
new RouteEntry(prefix, nextHop);
}
@@ -67,8 +67,8 @@
*/
@Test
public void testGetFields() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
assertThat(routeEntry.prefix(), is(prefix));
@@ -80,28 +80,28 @@
*/
@Test
public void testCreateBinaryString() {
- IpPrefix prefix;
+ Ip4Prefix prefix;
- prefix = IpPrefix.valueOf("0.0.0.0/0");
+ prefix = Ip4Prefix.valueOf("0.0.0.0/0");
assertThat(RouteEntry.createBinaryString(prefix), is(""));
- prefix = IpPrefix.valueOf("192.168.166.0/22");
+ prefix = Ip4Prefix.valueOf("192.168.166.0/22");
assertThat(RouteEntry.createBinaryString(prefix),
is("1100000010101000101001"));
- prefix = IpPrefix.valueOf("192.168.166.0/23");
+ prefix = Ip4Prefix.valueOf("192.168.166.0/23");
assertThat(RouteEntry.createBinaryString(prefix),
is("11000000101010001010011"));
- prefix = IpPrefix.valueOf("192.168.166.0/24");
+ prefix = Ip4Prefix.valueOf("192.168.166.0/24");
assertThat(RouteEntry.createBinaryString(prefix),
is("110000001010100010100110"));
- prefix = IpPrefix.valueOf("130.162.10.1/25");
+ prefix = Ip4Prefix.valueOf("130.162.10.1/25");
assertThat(RouteEntry.createBinaryString(prefix),
is("1000001010100010000010100"));
- prefix = IpPrefix.valueOf("255.255.255.255/32");
+ prefix = Ip4Prefix.valueOf("255.255.255.255/32");
assertThat(RouteEntry.createBinaryString(prefix),
is("11111111111111111111111111111111"));
}
@@ -111,12 +111,12 @@
*/
@Test
public void testEquality() {
- IpPrefix prefix1 = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop1 = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
- IpPrefix prefix2 = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop2 = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
assertThat(routeEntry1, is(routeEntry2));
@@ -127,16 +127,16 @@
*/
@Test
public void testNonEquality() {
- IpPrefix prefix1 = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop1 = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix1 = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop1 = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry1 = new RouteEntry(prefix1, nextHop1);
- IpPrefix prefix2 = IpPrefix.valueOf("1.2.3.0/25"); // Different
- IpAddress nextHop2 = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix2 = Ip4Prefix.valueOf("1.2.3.0/25"); // Different
+ Ip4Address nextHop2 = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry2 = new RouteEntry(prefix2, nextHop2);
- IpPrefix prefix3 = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop3 = IpAddress.valueOf("5.6.7.9"); // Different
+ Ip4Prefix prefix3 = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop3 = Ip4Address.valueOf("5.6.7.9"); // Different
RouteEntry routeEntry3 = new RouteEntry(prefix3, nextHop3);
assertThat(routeEntry1, is(not(routeEntry2)));
@@ -148,8 +148,8 @@
*/
@Test
public void testToString() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
RouteEntry routeEntry = new RouteEntry(prefix, nextHop);
assertThat(routeEntry.toString(),
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java
index b361123..b4b0551 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTest.java
@@ -57,7 +57,9 @@
import org.onlab.onos.sdnip.config.SdnIpConfigService;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpAddress;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -228,8 +230,8 @@
public void testProcessRouteAdd() throws TestUtilsException {
// Construct a route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct a MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
@@ -281,8 +283,8 @@
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
@@ -305,8 +307,8 @@
// Start to construct a new route entry and new intent
RouteEntry routeEntryUpdate = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.20.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.20.1"));
// Construct a new MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilderNew =
@@ -359,8 +361,8 @@
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilder =
@@ -406,7 +408,8 @@
public void testLocalRouteAdd() throws TestUtilsException {
// Construct a route entry, the next hop is the local BGP speaker
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"), IpAddress.valueOf("0.0.0.0"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("0.0.0.0"));
// Reset intentService to check whether the submit method is called
reset(intentService);
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java
index 2ea5f17..6798670 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/RouterTestWithAsyncArp.java
@@ -58,7 +58,9 @@
import org.onlab.onos.sdnip.config.SdnIpConfigService;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpAddress;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Prefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -191,8 +193,8 @@
// Construct a route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct a route intent
MultiPointToSinglePointIntent intent = staticIntentBuilder();
@@ -243,8 +245,8 @@
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
MultiPointToSinglePointIntent intent = staticIntentBuilder();
@@ -256,8 +258,8 @@
// Start to construct a new route entry and new intent
RouteEntry routeEntryUpdate = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.20.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.20.1"));
// Construct a new MultiPointToSinglePointIntent intent
TrafficSelector.Builder selectorBuilderNew =
@@ -323,8 +325,8 @@
// Construct the existing route entry
RouteEntry routeEntry = new RouteEntry(
- IpPrefix.valueOf("1.1.1.0/24"),
- IpAddress.valueOf("192.168.10.1"));
+ Ip4Prefix.valueOf("1.1.1.0/24"),
+ Ip4Address.valueOf("192.168.10.1"));
// Construct the existing MultiPointToSinglePointIntent intent
MultiPointToSinglePointIntent intent = staticIntentBuilder();
@@ -401,8 +403,8 @@
MultiPointToSinglePointIntent intent)
throws TestUtilsException {
- ConcurrentHashMap<IpPrefix, MultiPointToSinglePointIntent>
- pushedRouteIntents = new ConcurrentHashMap<>();
+ ConcurrentHashMap<Ip4Prefix, MultiPointToSinglePointIntent>
+ pushedRouteIntents = new ConcurrentHashMap<>();
pushedRouteIntents.put(routeEntry.prefix(), intent);
TestUtils.setField(router, "pushedRouteIntents", pushedRouteIntents);
}
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/SdnIpTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/SdnIpTest.java
index 5f18bca..348a62fd 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/SdnIpTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/SdnIpTest.java
@@ -207,7 +207,7 @@
reset(intentService);
for (RouteUpdate update : routeUpdates) {
- IpAddress nextHopAddress = update.routeEntry().nextHop();
+ Ip4Address nextHopAddress = update.routeEntry().nextHop();
// Find out the egress ConnectPoint
ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress);
@@ -268,7 +268,7 @@
reset(intentService);
for (RouteUpdate update : routeUpdates) {
- IpAddress nextHopAddress = update.routeEntry().nextHop();
+ Ip4Address nextHopAddress = update.routeEntry().nextHop();
// Find out the egress ConnectPoint
ConnectPoint egressConnectPoint = getConnectPoint(nextHopAddress);
@@ -342,11 +342,6 @@
prefixLength);
// We have to ensure we don't generate the same prefix twice
// (this is quite easy to happen with small prefix lengths).
- // TODO:
- // The IpPrefix does the comparison using 32 bits length,
- // but we need to compare only the prefix length. So I use
- // Ip4Prefix for this moment and changed to IpPrefix. This
- // can be improved in the future.
} while (prefixes.contains(prefix));
prefixes.add(prefix);
@@ -366,9 +361,9 @@
assertNotNull(nextHop);
RouteUpdate update =
- new RouteUpdate(RouteUpdate.Type.UPDATE,
- new RouteEntry(prefix,
- nextHop.ipAddress()));
+ new RouteUpdate(RouteUpdate.Type.UPDATE,
+ new RouteEntry(prefix,
+ nextHop.ipAddress().getIp4Address()));
routeUpdates.add(update);
}
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpRouteEntryTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpRouteEntryTest.java
index aa54874..d1ad3d4 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpRouteEntryTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpRouteEntryTest.java
@@ -26,30 +26,30 @@
import org.junit.Before;
import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
/**
* Unit tests for the BgpRouteEntry class.
*/
public class BgpRouteEntryTest {
private BgpSession bgpSession;
- private static final IpAddress BGP_SESSION_BGP_ID =
- IpAddress.valueOf("10.0.0.1");
- private static final IpAddress BGP_SESSION_IP_ADDRESS =
- IpAddress.valueOf("20.0.0.1");
+ private static final Ip4Address BGP_SESSION_BGP_ID =
+ Ip4Address.valueOf("10.0.0.1");
+ private static final Ip4Address BGP_SESSION_IP_ADDRESS =
+ Ip4Address.valueOf("20.0.0.1");
private BgpSession bgpSession2;
- private static final IpAddress BGP_SESSION_BGP_ID2 =
- IpAddress.valueOf("10.0.0.2");
- private static final IpAddress BGP_SESSION_IP_ADDRESS2 =
- IpAddress.valueOf("20.0.0.1");
+ private static final Ip4Address BGP_SESSION_BGP_ID2 =
+ Ip4Address.valueOf("10.0.0.2");
+ private static final Ip4Address BGP_SESSION_IP_ADDRESS2 =
+ Ip4Address.valueOf("20.0.0.1");
private BgpSession bgpSession3;
- private static final IpAddress BGP_SESSION_BGP_ID3 =
- IpAddress.valueOf("10.0.0.1");
- private static final IpAddress BGP_SESSION_IP_ADDRESS3 =
- IpAddress.valueOf("20.0.0.2");
+ private static final Ip4Address BGP_SESSION_BGP_ID3 =
+ Ip4Address.valueOf("10.0.0.1");
+ private static final Ip4Address BGP_SESSION_IP_ADDRESS3 =
+ Ip4Address.valueOf("20.0.0.2");
@Before
public void setUp() throws Exception {
@@ -85,8 +85,8 @@
* @return a generated BGP Route Entry
*/
private BgpRouteEntry generateBgpRouteEntry() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -143,8 +143,8 @@
@Test(expected = NullPointerException.class)
public void testInvalidConstructorNullBgpSession() {
BgpSession bgpSessionNull = null;
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -161,8 +161,8 @@
*/
@Test(expected = NullPointerException.class)
public void testInvalidConstructorNullAsPath() {
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
BgpRouteEntry.AsPath asPath = null;
long localPref = 100;
@@ -177,8 +177,8 @@
@Test
public void testGetFields() {
// Create the fields to compare against
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -231,8 +231,8 @@
//
// Test local route with AS Path that begins with AS_SET
//
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -291,8 +291,8 @@
//
// Get neighbor AS for a local route
//
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -341,8 +341,8 @@
//
// Compare two routes with different LOCAL_PREF
//
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
@@ -460,8 +460,8 @@
BgpRouteEntry bgpRouteEntry1 = generateBgpRouteEntry();
// Setup BGP Route 2
- IpPrefix prefix = IpPrefix.valueOf("1.2.3.0/24");
- IpAddress nextHop = IpAddress.valueOf("5.6.7.8");
+ Ip4Prefix prefix = Ip4Prefix.valueOf("1.2.3.0/24");
+ Ip4Address nextHop = Ip4Address.valueOf("5.6.7.8");
byte origin = BgpConstants.Update.Origin.IGP;
// Setup the AS Path
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpSessionManagerTest.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpSessionManagerTest.java
index 4b288af..5fdd6eb 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpSessionManagerTest.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/BgpSessionManagerTest.java
@@ -45,8 +45,8 @@
import org.onlab.junit.TestUtils.TestUtilsException;
import org.onlab.onos.sdnip.RouteListener;
import org.onlab.onos.sdnip.RouteUpdate;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
import com.google.common.net.InetAddresses;
@@ -54,9 +54,10 @@
* Unit tests for the BgpSessionManager class.
*/
public class BgpSessionManagerTest {
- private static final IpAddress IP_LOOPBACK_ID =
- IpAddress.valueOf("127.0.0.1");
- private static final IpAddress BGP_PEER1_ID = IpAddress.valueOf("10.0.0.1");
+ private static final Ip4Address IP_LOOPBACK_ID =
+ Ip4Address.valueOf("127.0.0.1");
+ private static final Ip4Address BGP_PEER1_ID =
+ Ip4Address.valueOf("10.0.0.1");
private static final long DEFAULT_LOCAL_PREF = 10;
private static final long DEFAULT_MULTI_EXIT_DISC = 20;
@@ -245,7 +246,7 @@
@Test
public void testProcessedBgpUpdateMessages() throws InterruptedException {
BgpSession bgpSession;
- IpAddress nextHopRouter;
+ Ip4Address nextHopRouter;
BgpRouteEntry bgpRouteEntry;
ChannelBuffer message;
Collection<BgpRouteEntry> bgpRibIn;
@@ -265,18 +266,18 @@
bgpSession = bgpSessionManager.getBgpSessions().iterator().next();
// Prepare routes to add/delete
- nextHopRouter = IpAddress.valueOf("10.20.30.40");
- Collection<IpPrefix> addedRoutes = new LinkedList<>();
- Collection<IpPrefix> withdrawnRoutes = new LinkedList<>();
- addedRoutes.add(IpPrefix.valueOf("0.0.0.0/0"));
- addedRoutes.add(IpPrefix.valueOf("20.0.0.0/8"));
- addedRoutes.add(IpPrefix.valueOf("30.0.0.0/16"));
- addedRoutes.add(IpPrefix.valueOf("40.0.0.0/24"));
- addedRoutes.add(IpPrefix.valueOf("50.0.0.0/32"));
- withdrawnRoutes.add(IpPrefix.valueOf("60.0.0.0/8"));
- withdrawnRoutes.add(IpPrefix.valueOf("70.0.0.0/16"));
- withdrawnRoutes.add(IpPrefix.valueOf("80.0.0.0/24"));
- withdrawnRoutes.add(IpPrefix.valueOf("90.0.0.0/32"));
+ nextHopRouter = Ip4Address.valueOf("10.20.30.40");
+ Collection<Ip4Prefix> addedRoutes = new LinkedList<>();
+ Collection<Ip4Prefix> withdrawnRoutes = new LinkedList<>();
+ addedRoutes.add(Ip4Prefix.valueOf("0.0.0.0/0"));
+ addedRoutes.add(Ip4Prefix.valueOf("20.0.0.0/8"));
+ addedRoutes.add(Ip4Prefix.valueOf("30.0.0.0/16"));
+ addedRoutes.add(Ip4Prefix.valueOf("40.0.0.0/24"));
+ addedRoutes.add(Ip4Prefix.valueOf("50.0.0.0/32"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("60.0.0.0/8"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("70.0.0.0/16"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("80.0.0.0/24"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("90.0.0.0/32"));
// Write the routes
message = peerChannelHandler.prepareBgpUpdate(nextHopRouter,
addedRoutes,
@@ -314,7 +315,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("0.0.0.0/0"),
+ Ip4Prefix.valueOf("0.0.0.0/0"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -324,7 +325,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("20.0.0.0/8"),
+ Ip4Prefix.valueOf("20.0.0.0/8"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -334,7 +335,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("30.0.0.0/16"),
+ Ip4Prefix.valueOf("30.0.0.0/16"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -344,7 +345,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("40.0.0.0/24"),
+ Ip4Prefix.valueOf("40.0.0.0/24"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -354,7 +355,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("50.0.0.0/32"),
+ Ip4Prefix.valueOf("50.0.0.0/32"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -365,8 +366,8 @@
// Delete some routes
addedRoutes = new LinkedList<>();
withdrawnRoutes = new LinkedList<>();
- withdrawnRoutes.add(IpPrefix.valueOf("0.0.0.0/0"));
- withdrawnRoutes.add(IpPrefix.valueOf("50.0.0.0/32"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("0.0.0.0/0"));
+ withdrawnRoutes.add(Ip4Prefix.valueOf("50.0.0.0/32"));
// Write the routes
message = peerChannelHandler.prepareBgpUpdate(nextHopRouter,
@@ -382,7 +383,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("20.0.0.0/8"),
+ Ip4Prefix.valueOf("20.0.0.0/8"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -392,7 +393,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("30.0.0.0/16"),
+ Ip4Prefix.valueOf("30.0.0.0/16"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
@@ -402,7 +403,7 @@
//
bgpRouteEntry =
new BgpRouteEntry(bgpSession,
- IpPrefix.valueOf("40.0.0.0/24"),
+ Ip4Prefix.valueOf("40.0.0.0/24"),
nextHopRouter,
(byte) BgpConstants.Update.Origin.IGP,
asPath,
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerChannelHandler.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerChannelHandler.java
index 4d94e1d..22f8a0a 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerChannelHandler.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerChannelHandler.java
@@ -22,8 +22,8 @@
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.SimpleChannelHandler;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.Ip4Prefix;
/**
* Class for handling the remote BGP Peer session.
@@ -31,7 +31,7 @@
class TestBgpPeerChannelHandler extends SimpleChannelHandler {
static final long PEER_AS = 65001;
static final int PEER_HOLDTIME = 120; // 120 seconds
- final IpAddress bgpId; // The BGP ID
+ final Ip4Address bgpId; // The BGP ID
final long localPref; // Local preference for routes
final long multiExitDisc = 20; // MED value
@@ -43,8 +43,7 @@
* @param bgpId the BGP ID to use
* @param localPref the local preference for the routes to use
*/
- TestBgpPeerChannelHandler(IpAddress bgpId,
- long localPref) {
+ TestBgpPeerChannelHandler(Ip4Address bgpId, long localPref) {
this.bgpId = bgpId;
this.localPref = localPref;
}
@@ -99,9 +98,9 @@
* @param withdrawnRoutes the routes to withdraw
* @return the message to transmit (BGP header included)
*/
- ChannelBuffer prepareBgpUpdate(IpAddress nextHopRouter,
- Collection<IpPrefix> addedRoutes,
- Collection<IpPrefix> withdrawnRoutes) {
+ ChannelBuffer prepareBgpUpdate(Ip4Address nextHopRouter,
+ Collection<Ip4Prefix> addedRoutes,
+ Collection<Ip4Prefix> withdrawnRoutes) {
int attrFlags;
ChannelBuffer message =
ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH);
@@ -178,24 +177,24 @@
* @param prefixes the prefixes to encode
* @return the buffer with the encoded prefixes
*/
- private ChannelBuffer encodePackedPrefixes(Collection<IpPrefix> prefixes) {
+ private ChannelBuffer encodePackedPrefixes(Collection<Ip4Prefix> prefixes) {
ChannelBuffer message =
ChannelBuffers.buffer(BgpConstants.BGP_MESSAGE_MAX_LENGTH);
// Write each of the prefixes
- for (IpPrefix prefix : prefixes) {
+ for (Ip4Prefix prefix : prefixes) {
int prefixBitlen = prefix.prefixLength();
int prefixBytelen = (prefixBitlen + 7) / 8; // Round-up
message.writeByte(prefixBitlen);
- IpAddress address = prefix.address();
+ Ip4Address address = prefix.address();
long value = address.toInt() & 0xffffffffL;
- for (int i = 0; i < IpAddress.INET_BYTE_LENGTH; i++) {
+ for (int i = 0; i < Ip4Address.BYTE_LENGTH; i++) {
if (prefixBytelen-- == 0) {
break;
}
long nextByte =
- (value >> ((IpAddress.INET_BYTE_LENGTH - i - 1) * 8)) & 0xff;
+ (value >> ((Ip4Address.BYTE_LENGTH - i - 1) * 8)) & 0xff;
message.writeByte((int) nextByte);
}
}
diff --git a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerFrameDecoder.java b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerFrameDecoder.java
index 970f0ed..2aa8bd0 100644
--- a/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerFrameDecoder.java
+++ b/apps/sdnip/src/test/java/org/onlab/onos/sdnip/bgp/TestBgpPeerFrameDecoder.java
@@ -21,7 +21,7 @@
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.handler.codec.frame.FrameDecoder;
-import org.onlab.packet.IpAddress;
+import org.onlab.packet.Ip4Address;
/**
* Class for handling the decoding of the BGP messages at the remote
@@ -31,7 +31,7 @@
int remoteBgpVersion; // 1 octet
long remoteAs; // 2 octets
long remoteHoldtime; // 2 octets
- IpAddress remoteBgpIdentifier; // 4 octets -> IPv4 address
+ Ip4Address remoteBgpIdentifier; // 4 octets -> IPv4 address
final CountDownLatch receivedOpenMessageLatch = new CountDownLatch(1);
final CountDownLatch receivedKeepaliveMessageLatch = new CountDownLatch(1);
@@ -144,7 +144,8 @@
remoteBgpVersion = message.readUnsignedByte();
remoteAs = message.readUnsignedShort();
remoteHoldtime = message.readUnsignedShort();
- remoteBgpIdentifier = IpAddress.valueOf((int) message.readUnsignedInt());
+ remoteBgpIdentifier =
+ Ip4Address.valueOf((int) message.readUnsignedInt());
// Optional Parameters
int optParamLen = message.readUnsignedByte();
if (message.readableBytes() < optParamLen) {