Cherry picks from 1.6 branch

Change-Id: I596247425802fc759463bcf77ea3c885f3161581
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
index 00a7a20..46768a7 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientControllerImpl.java
@@ -438,6 +438,7 @@
                 // When there are no LSPs to sync, directly end-of-sync PCRpt will come and the
                 // list will be null.
                 syncStateRptList = Collections.EMPTY_LIST;
+                log.debug("No LSPs reported from PCC during sync.");
             }
 
             Iterator<PcepStateReport> stateRptListIterator = syncStateRptList.iterator();
@@ -502,8 +503,8 @@
                         } catch (PcepParseException e) {
                             log.error("Exception occured while sending initiate delete message {}", e.getMessage());
                         }
+                        continue;
                     }
-                    continue;
                 }
 
                 if (!lspObj.getCFlag()) {
diff --git a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
index 42d4b07..927b4c7 100644
--- a/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
+++ b/protocols/pcep/ctl/src/main/java/org/onosproject/pcep/controller/impl/PcepClientImpl.java
@@ -186,6 +186,7 @@
 
     @Override
     public void setLspDbSyncStatus(PcepSyncStatus syncStatus) {
+        log.debug("LSP DB sync status set from {} to {}", this.lspDbSyncStatus, syncStatus);
         this.lspDbSyncStatus = syncStatus;
     }
 
@@ -199,7 +200,7 @@
 
         PcepSyncStatus syncOldStatus = labelDbSyncStatus();
         this.labelDbSyncStatus = syncStatus;
-
+        log.debug("Label DB sync status set from {} to {}", syncOldStatus, syncStatus);
         if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) {
             // Perform end of LSP DB sync actions.
             this.agent.analyzeSyncMsgList(pccId);
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
index 7716873..5d01912 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
@@ -59,6 +59,14 @@
         return ST_TYPE;
     }
 
+    public int getLocalIpv4Addr() {
+        return localIpv4Addr;
+    }
+
+    public int getRemoteIpv4Addr() {
+        return remoteIpv4Addr;
+    }
+
     @Override
     public int write(ChannelBuffer bb) {
         int iLenStartIndex = bb.writerIndex();
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
index 57b719e..947ba28 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
@@ -84,7 +84,7 @@
      */
     protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
 
-    public static final short TYPE = 0x60; //TODO : type to be defined
+    public static final short TYPE = 0x24; //TODO : type to be defined
     public static final short LENGTH = 12;
     public static final short VALUE_LENGTH = 10;
     public static final int SET = 1;
@@ -243,9 +243,10 @@
     @Override
     public int write(ChannelBuffer c) {
         int iLenStartIndex = c.writerIndex();
-
-        c.writeShort(TYPE);
-        c.writeShort(LENGTH);
+        c.writeByte(TYPE);
+        // Store the position of object length
+        int objectLenIndex = c.writerIndex();
+        c.writeByte(0);
 
         short temp = 0;
         if (bMFlag) {
@@ -264,13 +265,14 @@
         temp = (short) (temp | tempST);
         c.writeShort(temp);
         if (bMFlag) {
-            int tempSid = (int) sid << 12;
+            int tempSid = sid << 12;
             c.writeInt(tempSid);
         } else {
             c.writeInt(sid);
         }
         nai.write(c);
 
+        c.setByte(objectLenIndex, (c.writerIndex() - iLenStartIndex));
         return c.writerIndex() - iLenStartIndex;
     }