[ONOS-4718] Initial implementation of LISP address deserializer
Change-Id: I522e16e7fd197380cf4c99038561fe9aa8f93730
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
index b8b600c..ea528a0 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispAppDataLcafAddressTest.java
@@ -35,13 +35,48 @@
@Before
public void setup() {
- LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
- address1 = new LispAppDataLcafAddress((byte) 0x01, 1, (short) 10, (short) 20, ipv4Address1);
+ LispAppDataLcafAddress.AppDataAddressBuilder builder1 =
+ new LispAppDataLcafAddress.AppDataAddressBuilder();
- sameAsAddress1 = new LispAppDataLcafAddress((byte) 0x01, 1, (short) 10, (short) 20, ipv4Address1);
+ LispAfiAddress ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+
+ address1 = builder1
+ .withProtocol((byte) 0x01)
+ .withIpTos((short) 10)
+ .withLocalPortLow((short) 1)
+ .withLocalPortHigh((short) 255)
+ .withRemotePortLow((short) 2)
+ .withRemotePortHigh((short) 254)
+ .withAddress(ipv4Address1)
+ .build();
+
+ LispAppDataLcafAddress.AppDataAddressBuilder builder2 =
+ new LispAppDataLcafAddress.AppDataAddressBuilder();
+
+ sameAsAddress1 = builder2
+ .withProtocol((byte) 0x01)
+ .withIpTos((short) 10)
+ .withLocalPortLow((short) 1)
+ .withLocalPortHigh((short) 255)
+ .withRemotePortLow((short) 2)
+ .withRemotePortHigh((short) 254)
+ .withAddress(ipv4Address1)
+ .build();
+
+ LispAppDataLcafAddress.AppDataAddressBuilder builder3 =
+ new LispAppDataLcafAddress.AppDataAddressBuilder();
LispAfiAddress ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
- address2 = new LispAppDataLcafAddress((byte) 0x02, 2, (short) 20, (short) 40, ipv4Address2);
+
+ address2 = builder3
+ .withProtocol((byte) 0x02)
+ .withIpTos((short) 20)
+ .withLocalPortLow((short) 1)
+ .withLocalPortHigh((short) 255)
+ .withRemotePortLow((short) 2)
+ .withRemotePortHigh((short) 254)
+ .withAddress(ipv4Address2)
+ .build();
}
@Test
@@ -58,9 +93,11 @@
LispAfiAddress ipv4Address = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
assertThat(appDataLcafAddress.getProtocol(), is((byte) 0x01));
- assertThat(appDataLcafAddress.getIpTos(), is(1));
- assertThat(appDataLcafAddress.getLocalPort(), is((short) 10));
- assertThat(appDataLcafAddress.getRemotePort(), is((short) 20));
+ assertThat(appDataLcafAddress.getIpTos(), is(10));
+ assertThat(appDataLcafAddress.getLocalPortLow(), is((short) 1));
+ assertThat(appDataLcafAddress.getLocalPortHigh(), is((short) 255));
+ assertThat(appDataLcafAddress.getRemotePortLow(), is((short) 2));
+ assertThat(appDataLcafAddress.getRemotePortHigh(), is((short) 254));
assertThat(appDataLcafAddress.getAddress(), is(ipv4Address));
}
}
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
index 8931de8..b1f811c 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSegmentLcafAddressTest.java
@@ -35,13 +35,35 @@
@Before
public void setup() {
- LispIpv4Address ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
- address1 = new LispSegmentLcafAddress((byte) 0x01, 1, ipv4Address1);
+ LispSegmentLcafAddress.SegmentAddressBuilder builder1 =
+ new LispSegmentLcafAddress.SegmentAddressBuilder();
- sameAsAddress1 = new LispSegmentLcafAddress((byte) 0x01, 1, ipv4Address1);
+ LispIpv4Address ipv4Address1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
+
+ address1 = builder1
+ .withIdMaskLength((byte) 0x01)
+ .withInstanceId(1)
+ .withAddress(ipv4Address1)
+ .build();
+
+ LispSegmentLcafAddress.SegmentAddressBuilder builder2 =
+ new LispSegmentLcafAddress.SegmentAddressBuilder();
+
+ sameAsAddress1 = builder2
+ .withIdMaskLength((byte) 0x01)
+ .withInstanceId(1)
+ .withAddress(ipv4Address1)
+ .build();
+
+ LispSegmentLcafAddress.SegmentAddressBuilder builder3 =
+ new LispSegmentLcafAddress.SegmentAddressBuilder();
LispIpv4Address ipv4Address2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
- address2 = new LispSegmentLcafAddress((byte) 0x02, 2, ipv4Address2);
+ address2 = builder3
+ .withIdMaskLength((byte) 0x02)
+ .withInstanceId(2)
+ .withAddress(ipv4Address2)
+ .build();
}
@Test
diff --git a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
index 8296b43..e212a1c 100644
--- a/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
+++ b/protocols/lisp/msg/src/test/java/org/onosproject/lisp/msg/types/LispSourceDestLcafAddressTest.java
@@ -35,20 +35,44 @@
@Before
public void setup() {
+ LispSourceDestLcafAddress.SourceDestAddressBuilder builder1 =
+ new LispSourceDestLcafAddress.SourceDestAddressBuilder();
+
LispIpv4Address srcAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.1"));
LispIpv4Address dstAddress1 = new LispIpv4Address(IpAddress.valueOf("192.168.1.2"));
- address1 = new LispSourceDestLcafAddress((short) 1, (byte) 0x01,
- (byte) 0x01, srcAddress1, dstAddress1);
+ address1 = builder1
+ .withReserved((short) 1)
+ .withSrcMaskLength((byte) 0x01)
+ .withDstMaskLength((byte) 0x01)
+ .withSrcPrefix(srcAddress1)
+ .withDstPrefix(dstAddress1)
+ .build();
- sameAsAddress1 = new LispSourceDestLcafAddress((short) 1, (byte) 0x01,
- (byte) 0x01, srcAddress1, dstAddress1);
+ LispSourceDestLcafAddress.SourceDestAddressBuilder builder2 =
+ new LispSourceDestLcafAddress.SourceDestAddressBuilder();
+
+ sameAsAddress1 = builder2
+ .withReserved((short) 1)
+ .withSrcMaskLength((byte) 0x01)
+ .withDstMaskLength((byte) 0x01)
+ .withSrcPrefix(srcAddress1)
+ .withDstPrefix(dstAddress1)
+ .build();
+
+ LispSourceDestLcafAddress.SourceDestAddressBuilder builder3 =
+ new LispSourceDestLcafAddress.SourceDestAddressBuilder();
LispIpv4Address srcAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.1"));
LispIpv4Address dstAddress2 = new LispIpv4Address(IpAddress.valueOf("192.168.2.2"));
- address2 = new LispSourceDestLcafAddress((short) 2, (byte) 0x02,
- (byte) 0x02, srcAddress2, dstAddress2);
+ address2 = builder3
+ .withReserved((short) 2)
+ .withSrcMaskLength((byte) 0x02)
+ .withDstMaskLength((byte) 0x02)
+ .withSrcPrefix(srcAddress2)
+ .withDstPrefix(dstAddress2)
+ .build();
}
@Test