Avantika-Huawei
Committed by Gerrit Code Review

Making ERO non-mandatory (for end of LSP DB sync msg from cisco)

Change-Id: I28e35520b5bd5737117d8c2b84f9effa3c46bfaf
......@@ -340,7 +340,7 @@ public class PcepLspObjectVer1 implements PcepLspObject {
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 @@ public class PcepLspObjectVer1 implements PcepLspObject {
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 @@ public class PcepLspObjectVer1 implements PcepLspObject {
}
}
llOutOptionalTlv.add(tlv);
if (tlv != null) {
llOutOptionalTlv.add(tlv);
}
}
if (0 < cb.readableBytes()) {
......
......@@ -287,10 +287,21 @@ public class PcepOpenObjectVer1 implements PcepOpenObject {
default:
log.debug("Unsupported TLV: " + hType);
cb.skipBytes(hLength);
continue;
tlv = null;
}
// Check for the padding
int pad = hLength % 4;
if (0 < pad) {
pad = 4 - pad;
if (pad <= cb.readableBytes()) {
cb.skipBytes(pad);
}
}
llOptionalTlv.add(tlv);
if (tlv != null) {
llOptionalTlv.add(tlv);
}
}
if (0 < cb.readableBytes()) {
......
......@@ -65,8 +65,8 @@ class PcepReportMsgVer1 implements PcepReportMsg {
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 @@ class PcepReportMsgVer1 implements PcepReportMsg {
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);
}
......
......@@ -251,7 +251,10 @@ public class PcepSrpObjectVer1 implements PcepSrpObject {
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 @@ public class PcepSrpObjectVer1 implements PcepSrpObject {
cb.skipBytes(pad);
}
}
llOutOptionalTlv.add(tlv);
if (tlv != null) {
llOutOptionalTlv.add(tlv);
}
}
return llOutOptionalTlv;
......