[ONOS-4163] Provider side changes to support stateful PCE and PCECC
Change-Id: I0a57ed1d1e505a2e94921fd5f5d92426a105ad12
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
index 0b68845..a2a4d72 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLspObjectVer1.java
@@ -25,7 +25,7 @@
import org.onosproject.pcepio.types.PcepErrorDetailInfo;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.onosproject.pcepio.types.PcepValueType;
-import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
+import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
@@ -325,8 +325,8 @@
switch (hType) {
- case StatefulIPv4LspIdentidiersTlv.TYPE:
- tlv = StatefulIPv4LspIdentidiersTlv.read(cb);
+ case StatefulIPv4LspIdentifiersTlv.TYPE:
+ tlv = StatefulIPv4LspIdentifiersTlv.read(cb);
break;
case StatefulLspErrorCodeTlv.TYPE:
iValue = cb.readInt();
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
index 5fe0777..fd5a47a 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
@@ -45,7 +45,7 @@
*/
protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
- public static final short TYPE = 0; //TODO : need to reassign the value as per RFC
+ public static final short TYPE = 28;
public static final short LENGTH = 4;
private final byte pst;
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java
similarity index 90%
rename from protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
rename to protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java
index 3c9e9aa..a063d60 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlv.java
@@ -28,7 +28,7 @@
/**
* Provides StatefulIPv4LspIdentidiersTlv.
*/
-public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
+public class StatefulIPv4LspIdentifiersTlv implements PcepValueType {
/* IPV4-LSP-IDENTIFIERS TLV format
*
@@ -50,7 +50,7 @@
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
- protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
+ protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentifiersTlv.class);
public static final short TYPE = 18;
public static final short LENGTH = 16;
@@ -70,7 +70,7 @@
* @param extendedTunnelId extended tunnel id
* @param ipv4EgressAddress egress ipv4 address
*/
- public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
+ public StatefulIPv4LspIdentifiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
int ipv4EgressAddress) {
this.ipv4IngressAddress = ipv4IngressAddress;
@@ -90,9 +90,9 @@
* @param ipv4EgressAddress egress ipv4 address
* @return object of StatefulIPv4LspIdentidiersTlv
*/
- public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
+ public static StatefulIPv4LspIdentifiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
int extendedTunnelId, int ipv4EgressAddress) {
- return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
ipv4EgressAddress);
}
@@ -106,6 +106,15 @@
}
/**
+ * Returns LSP id.
+ *
+ * @return lspId
+ */
+ public short getLspId() {
+ return this.lspId;
+ }
+
+ /**
* Returns extendedTunnelId.
*
* @return extendedTunnelId
@@ -157,8 +166,8 @@
if (this == obj) {
return true;
}
- if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
- StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
+ if (obj instanceof StatefulIPv4LspIdentifiersTlv) {
+ StatefulIPv4LspIdentifiersTlv other = (StatefulIPv4LspIdentifiersTlv) obj;
return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
&& Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
&& Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
@@ -193,7 +202,7 @@
short tunnelId = c.readShort();
int extendedTunnelId = c.readInt();
int ipv4EgressAddress = c.readInt();
- return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
ipv4EgressAddress);
}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
index debef2f..ce8a452 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepOpenMsgTest.java
@@ -555,4 +555,40 @@
assertThat(testOpenMsg, is(openMsg));
}
+
+ /**
+ * This test case checks open object with LSR id encoded.
+ */
+ @Test
+ public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
+
+ byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
+ 0x01, 0x10, 0x00, 0x14, // common object header
+ 0x20, 0x05, 0x1E, 0x01, // OPEN object
+ (byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
+ 0x00, 0x11, 0x00, 0x04, // PCEP-LS-IPv4-ROUTER-ID sub tlv
+ 0x02, 0x02, 0x02, 0x02
+ };
+
+ byte[] testOpenMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(openMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+
+ assertThat(message, instanceOf(PcepOpenMsg.class));
+
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+ testOpenMsg = buf.array();
+
+ int readLen = buf.writerIndex() - 0;
+ testOpenMsg = new byte[readLen];
+ buf.readBytes(testOpenMsg, 0, readLen);
+ assertThat(testOpenMsg, is(openMsg));
+
+ }
}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
index 1804b38..9692119 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepReportMsgExtTest.java
@@ -184,14 +184,14 @@
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
- 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
- 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
+ 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
@@ -216,4 +216,83 @@
assertThat(testReportMsg, is(reportMsg));
}
+
+ /**
+ * Tests PCRpt msg with Path-Setup-Type TLV as SR.
+ *
+ * @throws PcepParseException
+ * @throws PcepOutOfBoundMessageException
+ */
+ @Test
+ public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
+ 0x00, 0x00, 0x00, 0x01,
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ };
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
+ /**
+ * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
+ *
+ * @throws PcepParseException
+ * @throws PcepOutOfBoundMessageException
+ */
+ @Test
+ public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
+
+ byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
+ 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
+ 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
+ 0x00, 0x00, 0x00, 0x02,
+ 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
+ 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
+ 0x07, 0x10, 0x00, 0x14, //ERO object
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
+ 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
+ };
+
+ byte[] testReportMsg = {0};
+ ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
+ buffer.writeBytes(reportMsg);
+
+ PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
+ PcepMessage message = null;
+
+ message = reader.readFrom(buffer);
+ assertThat(message, instanceOf(PcepReportMsg.class));
+ ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
+ message.writeTo(buf);
+
+ int readLen = buf.writerIndex();
+ testReportMsg = new byte[readLen];
+ buf.readBytes(testReportMsg, 0, readLen);
+
+ assertThat(testReportMsg, is(reportMsg));
+ }
+
}
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java
similarity index 75%
rename from protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java
rename to protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java
index f59a95c..46fc453 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlvTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentifiersTlvTest.java
@@ -18,7 +18,10 @@
import com.google.common.testing.EqualsTester;
import org.junit.Test;
-public class StatefulIPv4LspIdentidiersTlvTest {
+/**
+ * Tests class StatefulIPv4LspIdentifiersTlv.
+ */
+public class StatefulIPv4LspIdentifiersTlvTest {
private final int ipv4IngressAddress = 1;
private final short lspId = 1;
@@ -26,7 +29,7 @@
private final int extendedTunnelId = 1;
private final int ipv4EgressAddress = 1;
- private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId,
+ private final StatefulIPv4LspIdentifiersTlv tlv1 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress, lspId,
tunnelId, extendedTunnelId, ipv4EgressAddress);
private final int ipv4IngressAddress1 = 1;
@@ -35,7 +38,7 @@
private final int extendedTunnelId1 = 1;
private final int ipv4EgressAddress1 = 1;
- private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1,
+ private final StatefulIPv4LspIdentifiersTlv tlv2 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress1, lspId1,
tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
private final int ipv4IngressAddress2 = 2;
@@ -44,9 +47,12 @@
private final int extendedTunnelId2 = 2;
private final int ipv4EgressAddress2 = 2;
- private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2,
+ private final StatefulIPv4LspIdentifiersTlv tlv3 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress2, lspId2,
tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
+ /**
+ * Tests equality of objects of class StatefulIPv4LspIdentifiersTlv.
+ */
@Test
public void basics() {
new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();