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/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);
             }