Making ERO non-mandatory (for end of LSP DB sync msg from cisco)
Change-Id: I28e35520b5bd5737117d8c2b84f9effa3c46bfaf
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 13469e9..8de5125 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
@@ -340,7 +340,7 @@
while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
- PcepValueType tlv;
+ PcepValueType tlv = null;
short hType = cb.readShort();
short hLength = cb.readShort();
int iValue = 0;
@@ -364,7 +364,10 @@
tlv = StatefulLspDbVerTlv.read(cb);
break;
default:
- throw new PcepParseException("Received unsupported TLV type :" + hType);
+ // Skip the unknown TLV.
+ cb.skipBytes(hLength);
+ tlv = null;
+ log.info("Received unsupported TLV type :" + hType + " in LSP object.");
}
// Check for the padding
int pad = hLength % 4;
@@ -375,7 +378,9 @@
}
}
- llOutOptionalTlv.add(tlv);
+ if (tlv != null) {
+ llOutOptionalTlv.add(tlv);
+ }
}
if (0 < cb.readableBytes()) {
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
index fbe02a8..48382ec 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepOpenObjectVer1.java
@@ -287,10 +287,21 @@
default:
log.debug("Unsupported TLV: " + hType);
cb.skipBytes(hLength);
- continue;
+ tlv = null;
}
- llOptionalTlv.add(tlv);
+ // Check for the padding
+ int pad = hLength % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= cb.readableBytes()) {
+ cb.skipBytes(pad);
+ }
+ }
+
+ if (tlv != null) {
+ llOptionalTlv.add(tlv);
+ }
}
if (0 < cb.readableBytes()) {
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
index 757dd1c..1867b5a 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepReportMsgVer1.java
@@ -65,8 +65,8 @@
protected static final Logger log = LoggerFactory.getLogger(PcepReportMsgVer1.class);
public static final byte PACKET_VERSION = 1;
- //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+LspObjMinLen(8)+EroObjMinLen(4)
- public static final int PACKET_MINIMUM_LENGTH = 16;
+ //PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+LspObjMinLen(8)
+ public static final int PACKET_MINIMUM_LENGTH = 12;
public static final PcepType MSG_TYPE = PcepType.REPORT;
public static final byte REPORT_OBJ_TYPE = 1;
//Optional TLV
@@ -164,9 +164,25 @@
lspObj = PcepLspObjectVer1.read(cb);
pcestateReq.setLspObject(lspObj);
- //store path
- PcepStateReport.PcepMsgPath msgPath = new PcepStateReportVer1().new PcepMsgPath().read(cb);
- pcestateReq.setMsgPath(msgPath);
+ if (cb.readableBytes() > 0) {
+
+ //mark the reader index to reset
+ cb.markReaderIndex();
+ tempObjHeader = PcepObjectHeader.read(cb);
+
+ yObjectClass = tempObjHeader.getObjClass();
+ yObjectType = tempObjHeader.getObjType();
+
+ //reset reader index
+ cb.resetReaderIndex();
+
+ if ((PcepEroObjectVer1.ERO_OBJ_CLASS == yObjectClass)
+ && (PcepEroObjectVer1.ERO_OBJ_TYPE == yObjectType)) {
+ // store path
+ PcepStateReport.PcepMsgPath msgPath = new PcepStateReportVer1().new PcepMsgPath().read(cb);
+ pcestateReq.setMsgPath(msgPath);
+ }
+ }
llStateReportList.add(pcestateReq);
}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
index b88a1a4..fab25e1 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepSrpObjectVer1.java
@@ -251,7 +251,10 @@
tlv = PathSetupTypeTlv.of(cb.readInt());
break;
default:
- throw new PcepParseException("Unsupported TLV received in SRP Object.");
+ // Skip the unknown TLV.
+ cb.skipBytes(hLength);
+ tlv = null;
+ log.info("Received unsupported TLV type :" + hType + " in SRP object.");
}
// Check for the padding
@@ -262,7 +265,10 @@
cb.skipBytes(pad);
}
}
- llOutOptionalTlv.add(tlv);
+
+ if (tlv != null) {
+ llOutOptionalTlv.add(tlv);
+ }
}
return llOutOptionalTlv;