PCEP protocol message update
Change-Id: Icdea6c105553cd3dec1cacea6e2951f9e422b676
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java
index 0c76894..a66d7ce 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/ver1/PcepLabelObjectVer1.java
@@ -38,19 +38,19 @@
public class PcepLabelObjectVer1 implements PcepLabelObject {
/*
- * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.4.
+ * ref : draft-zhao-pce-pcep-extension-for-pce-controller-03, section : 7.3.
- 0 1 2 3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Reserved | Flags |O|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Label |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | |
- // Optional TLV //
- | |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Reserved | Flags |O|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Label | Reserved |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Optional TLV //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The LABEL Object format
*/
protected static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class);
@@ -65,6 +65,7 @@
public static final short LABEL_OBJ_MINIMUM_LENGTH = 12;
public static final int OFLAG_SET = 1;
+ public static final int SHIFT_LABEL = 12;
public static final int OFLAG_RESET = 0;
public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
@@ -72,45 +73,45 @@
PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LABEL_OBJ_MINIMUM_LENGTH);
private PcepObjectHeader labelObjHeader;
- private boolean bOFlag;
+ private boolean oBit;
private int label;
// Optional TLV
- private LinkedList<PcepValueType> llOptionalTlv;
+ private LinkedList<PcepValueType> optionalTlv;
/**
* Constructor to initialize parameters for PCEP label object.
*
* @param labelObjHeader label object header
- * @param bOFlag O flag
+ * @param oBit O flag
* @param label label
- * @param llOptionalTlv list of optional tlvs
+ * @param optionalTlv list of optional tlvs
*/
- public PcepLabelObjectVer1(PcepObjectHeader labelObjHeader, boolean bOFlag, int label,
- LinkedList<PcepValueType> llOptionalTlv) {
+ public PcepLabelObjectVer1(PcepObjectHeader labelObjHeader, boolean oBit, int label,
+ LinkedList<PcepValueType> optionalTlv) {
this.labelObjHeader = labelObjHeader;
- this.bOFlag = bOFlag;
+ this.oBit = oBit;
this.label = label;
- this.llOptionalTlv = llOptionalTlv;
+ this.optionalTlv = optionalTlv;
}
@Override
public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
+ return this.optionalTlv;
}
@Override
- public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
+ public void setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
+ this.optionalTlv = optionalTlv;
}
@Override
public boolean getOFlag() {
- return this.bOFlag;
+ return this.oBit;
}
@Override
public void setOFlag(boolean value) {
- this.bOFlag = value;
+ this.oBit = value;
}
@Override
@@ -134,23 +135,24 @@
PcepObjectHeader labelObjHeader;
- boolean bOFlag;
+ boolean oBit;
int label;
// Optional TLV
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+ LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
labelObjHeader = PcepObjectHeader.read(cb);
//take only LspObject buffer.
ChannelBuffer tempCb = cb.readBytes(labelObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
int iTemp = tempCb.readInt();
- bOFlag = (iTemp & (byte) 0x01) == 1;
- label = tempCb.readInt();
+ oBit = (iTemp & (byte) OFLAG_SET) == OFLAG_SET;
+ iTemp = tempCb.readInt();
+ label = (int) iTemp >> SHIFT_LABEL;
// parse optional TLV
- llOptionalTlv = parseOptionalTlv(tempCb);
- return new PcepLabelObjectVer1(labelObjHeader, bOFlag, label, llOptionalTlv);
+ optionalTlv = parseOptionalTlv(tempCb);
+ return new PcepLabelObjectVer1(labelObjHeader, oBit, label, optionalTlv);
}
@Override
@@ -166,9 +168,11 @@
byte oFlag;
- oFlag = (byte) ((bOFlag) ? OFLAG_SET : OFLAG_RESET);
+ oFlag = (byte) ((oBit) ? OFLAG_SET : OFLAG_RESET);
cb.writeInt(oFlag);
- cb.writeInt(label);
+ int temp = label;
+ temp = (int) label << SHIFT_LABEL;
+ cb.writeInt(temp);
// Add optional TLV
packOptionalTlv(cb);
@@ -245,7 +249,7 @@
*/
protected int packOptionalTlv(ChannelBuffer cb) {
- ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
+ ListIterator<PcepValueType> listIterator = optionalTlv.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
@@ -269,10 +273,10 @@
private boolean bIsLabelSet = false;
private PcepObjectHeader labelObjHeader;
- private boolean bOFlag;
+ private boolean oBit;
private int label;
- LinkedList<PcepValueType> llOptionalTlv = new LinkedList<>();
+ LinkedList<PcepValueType> optionalTlv = new LinkedList<>();
private boolean bIsPFlagSet = false;
private boolean bPFlag;
@@ -283,7 +287,7 @@
@Override
public PcepLabelObject build() throws PcepParseException {
PcepObjectHeader labelObjHeader = this.bIsHeaderSet ? this.labelObjHeader : DEFAULT_LABEL_OBJECT_HEADER;
- boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG;
+ boolean oBit = this.bIsOFlagSet ? this.oBit : DEFAULT_OFLAG;
if (!this.bIsLabelSet) {
throw new PcepParseException(" Label NOT Set while building PcepLabelObject.");
@@ -294,7 +298,7 @@
if (bIsIFlagSet) {
labelObjHeader.setIFlag(bIFlag);
}
- return new PcepLabelObjectVer1(labelObjHeader, bOFlag, this.label, this.llOptionalTlv);
+ return new PcepLabelObjectVer1(labelObjHeader, oBit, this.label, this.optionalTlv);
}
@Override
@@ -311,12 +315,12 @@
@Override
public boolean getOFlag() {
- return this.bOFlag;
+ return this.oBit;
}
@Override
public Builder setOFlag(boolean value) {
- this.bOFlag = value;
+ this.oBit = value;
this.bIsOFlagSet = true;
return this;
}
@@ -335,12 +339,12 @@
@Override
public LinkedList<PcepValueType> getOptionalTlv() {
- return this.llOptionalTlv;
+ return this.optionalTlv;
}
@Override
- public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
- this.llOptionalTlv = llOptionalTlv;
+ public Builder setOptionalTlv(LinkedList<PcepValueType> optionalTlv) {
+ this.optionalTlv = optionalTlv;
return this;
}
@@ -362,9 +366,9 @@
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
- .add("OFlag", bOFlag)
+ .add("oBit", oBit)
.add("label", label)
- .add("OptionalTlvList", llOptionalTlv)
+ .add("optionalTlv", optionalTlv)
.toString();
}
}
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 13d2584..f043af5 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
@@ -25,10 +25,12 @@
import org.onosproject.pcepio.protocol.PcepType;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.GmplsCapabilityTlv;
+import org.onosproject.pcepio.types.NodeAttributesTlv;
import org.onosproject.pcepio.types.PceccCapabilityTlv;
import org.onosproject.pcepio.types.PcepLabelDbVerTlv;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.onosproject.pcepio.types.PcepValueType;
+import org.onosproject.pcepio.types.SrPceCapabilityTlv;
import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
import org.onosproject.pcepio.types.LsCapabilityTlv;
@@ -268,6 +270,20 @@
lValue = cb.readLong();
tlv = new PcepLabelDbVerTlv(lValue);
break;
+ case NodeAttributesTlv.TYPE:
+ log.debug("NodeAttributesTlv");
+ if (cb.readableBytes() < hLength) {
+ throw new PcepParseException("Invalid length for NodeAttributesTlv.");
+ }
+ tlv = NodeAttributesTlv.read(cb.readBytes(hLength), hLength);
+ break;
+ case SrPceCapabilityTlv.TYPE:
+ log.debug("SrPceCapabilityTlv");
+ if (SrPceCapabilityTlv.LENGTH != hLength) {
+ throw new PcepParseException("Invalid length received for SrPceCapabilityTlv.");
+ }
+ tlv = SrPceCapabilityTlv.read(cb);
+ break;
default:
log.debug("Unsupported TLV: " + hType);
cb.skipBytes(hLength);
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 9c75b3a..9c1c167 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
@@ -22,6 +22,7 @@
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.onosproject.pcepio.types.PathSetupTypeTlv;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.SymbolicPathNameTlv;
@@ -221,12 +222,18 @@
short hLength = cb.readShort();
switch (hType) {
-
case SymbolicPathNameTlv.TYPE:
+ if (cb.readableBytes() < hLength) {
+ throw new PcepParseException("Length is not valid in SymbolicPathNameTlv");
+ }
tlv = SymbolicPathNameTlv.read(cb, hLength);
- cb.skipBytes(hLength);
break;
-
+ case PathSetupTypeTlv.TYPE:
+ if (cb.readableBytes() != PathSetupTypeTlv.LENGTH) {
+ throw new PcepParseException("Length is not valid in PathSetupTypeTlv");
+ }
+ tlv = PathSetupTypeTlv.of(cb.readInt());
+ break;
default:
throw new PcepParseException("Unsupported TLV received in SRP Object.");
}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
index b8ae1e8..ce868ab 100644
--- a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
@@ -29,27 +29,25 @@
public class PceccCapabilityTlv implements PcepValueType {
/* PCECC CAPABILITY TLV
- * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, section-7.1.1
+ * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-03, section-7.1.1
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Type=32 | Length=4 |
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | Flags |G|L|
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |S|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
- public static final short TYPE = 32;
+ public static final short TYPE = (short) 65287;
public static final short LENGTH = 4;
public static final int SET = 1;
- public static final byte LFLAG_CHECK = 0x01;
- public static final byte GFLAG_CHECK = 0x02;
+ public static final byte SBIT_CHECK = 0x01;
- private final boolean bGFlag;
- private final boolean bLFlag;
+ private final boolean sBit;
private final int rawValue;
private final boolean isRawValueSet;
@@ -63,18 +61,16 @@
this.rawValue = rawValue;
this.isRawValueSet = true;
- bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK;
- bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK;
+ sBit = (rawValue & SBIT_CHECK) == SBIT_CHECK;
}
/**
* Constructor to initialize G-flag L-flag.
- * @param bGFlag G-flag
- * @param bLFlag L-flag
+ *
+ * @param sBit pcecc sr capbaility bit
*/
- public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) {
- this.bGFlag = bGFlag;
- this.bLFlag = bLFlag;
+ public PceccCapabilityTlv(boolean sBit) {
+ this.sBit = sBit;
this.rawValue = 0;
this.isRawValueSet = false;
}
@@ -95,23 +91,17 @@
}
/**
- * Returns G-flag.
- * @return bGFlag G-flag
+ * Returns sBit.
+ *
+ * @return sBit S bit
*/
- public boolean getGFlag() {
- return bGFlag;
- }
-
- /**
- * Returns L-flag.
- * @return bLFlag L-flag
- */
- public boolean getLFlag() {
- return bLFlag;
+ public boolean sBit() {
+ return sBit;
}
/**
* Returns the raw value.
+ *
* @return rawValue Flags
*/
public int getInt() {
@@ -133,7 +123,7 @@
if (isRawValueSet) {
return Objects.hash(rawValue);
} else {
- return Objects.hash(bLFlag, bGFlag);
+ return Objects.hash(sBit);
}
}
@@ -147,7 +137,7 @@
if (isRawValueSet) {
return Objects.equals(this.rawValue, other.rawValue);
} else {
- return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag);
+ return Objects.equals(this.sBit, other.sBit);
}
}
return false;
@@ -162,11 +152,8 @@
if (isRawValueSet) {
c.writeInt(rawValue);
} else {
- if (bGFlag) {
- temp = temp | GFLAG_CHECK;
- }
- if (bLFlag) {
- temp = temp | LFLAG_CHECK;
+ if (sBit) {
+ temp = temp | SBIT_CHECK;
}
c.writeInt(temp);
}
@@ -188,7 +175,7 @@
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
.add("Length", LENGTH)
- .add("Value", rawValue)
+ .add("rawValue", rawValue)
.toString();
}
}
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 e2b4a6b..464c018 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
@@ -30,7 +30,8 @@
*/
public class SrEroSubObject implements PcepValueType {
/*
- SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
+ SR-ERO subobject: (draft-ietf-pce-segment-routing-06)
+
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -40,7 +41,8 @@
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// NAI (variable) //
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
+ When M bit is reset, SID is 32 bit Index.
+ When M bit is set, SID is 20 bit Label.
NAI
@@ -98,7 +100,8 @@
private final boolean bMFlag;
private final byte st;
- private final int sID;
+ //If m bit is set SID will store label else store 32 bit value
+ private final int sid;
private final PcepNai nai;
/**
@@ -109,17 +112,17 @@
* @param bSFlag S flag
* @param bCFlag C flag
* @param bMFlag M flag
- * @param sID segment identifier value
+ * @param sid segment identifier value
* @param nai NAI associated with SID
*/
- public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sid,
PcepNai nai) {
this.st = st;
this.bFFlag = bFFlag;
this.bSFlag = bSFlag;
this.bCFlag = bCFlag;
this.bMFlag = bMFlag;
- this.sID = sID;
+ this.sid = sid;
this.nai = nai;
}
@@ -131,18 +134,19 @@
* @param bSFlag S flag
* @param bCFlag C flag
* @param bMFlag M flag
- * @param sID segment identifier value
+ * @param sid segment identifier value
* @param nai NAI associated with SID
* @return object of SrEroSubObject
*/
- public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sid,
PcepNai nai) {
- return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
}
/**
* Returns SID type.
- * @return st sid type
+ *
+ * @return st SID type
*/
public byte getSt() {
return st;
@@ -150,6 +154,7 @@
/**
* Returns bFFlag.
+ *
* @return bFFlag
*/
public boolean getFFlag() {
@@ -158,6 +163,7 @@
/**
* Returns bSFlag.
+ *
* @return bSFlag
*/
public boolean getSFlag() {
@@ -166,6 +172,7 @@
/**
* Returns bCFlag.
+ *
* @return bCFlag
*/
public boolean getCFlag() {
@@ -174,6 +181,7 @@
/**
* Returns bMFlag.
+ *
* @return bMFlag
*/
public boolean getMFlag() {
@@ -182,10 +190,11 @@
/**
* Returns sID.
- * @return sID
+ *
+ * @return sid
*/
public int getSid() {
- return sID;
+ return sid;
}
/**
@@ -213,7 +222,7 @@
@Override
public int hashCode() {
- return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
}
@Override
@@ -225,7 +234,7 @@
SrEroSubObject other = (SrEroSubObject) obj;
return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag)
&& Objects.equals(this.bSFlag, other.bSFlag) && Objects.equals(this.bCFlag, other.bCFlag)
- && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sID, other.sID)
+ && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sid, other.sid)
&& Objects.equals(this.nai, other.nai);
}
return false;
@@ -254,7 +263,12 @@
short tempST = (short) (st << SHIFT_ST);
temp = (short) (temp | tempST);
c.writeShort(temp);
- c.writeInt(sID);
+ if (bMFlag) {
+ int tempSid = (int) sid << 12;
+ c.writeInt(tempSid);
+ } else {
+ c.writeInt(sid);
+ }
nai.write(c);
return c.writerIndex() - iLenStartIndex;
@@ -281,21 +295,24 @@
st = (byte) (temp >> SHIFT_ST);
- int sID = c.readInt();
+ int sid = c.readInt();
+ if (bMFlag) {
+ sid = sid >> 12;
+ }
switch (st) {
- case 0x01:
+ case PcepNaiIpv4NodeId.ST_TYPE:
nai = PcepNaiIpv4NodeId.read(c);
break;
- case 0x02:
+ case PcepNaiIpv6NodeId.ST_TYPE:
nai = PcepNaiIpv6NodeId.read(c);
break;
- case 0x03:
+ case PcepNaiIpv4Adjacency.ST_TYPE:
nai = PcepNaiIpv4Adjacency.read(c);
break;
- case 0x04:
+ case PcepNaiIpv6Adjacency.ST_TYPE:
nai = PcepNaiIpv6Adjacency.read(c);
break;
- case 0x05:
+ case PcepNaiUnnumberedAdjacencyIpv4.ST_TYPE:
nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
break;
default:
@@ -303,7 +320,7 @@
break;
}
- return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sid, nai);
}
@Override
@@ -316,7 +333,7 @@
.add("bSFlag", bSFlag)
.add("bCFlag", bCFlag)
.add("bMFlag", bMFlag)
- .add("sID", sID)
+ .add("sid", sid)
.add("nAI", nai)
.toString();
}
diff --git a/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java
new file mode 100644
index 0000000..703d0b2
--- /dev/null
+++ b/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrPceCapabilityTlv.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.pcepio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides SR PCE Capability Tlv.
+ */
+public class SrPceCapabilityTlv implements PcepValueType {
+
+ /*
+ *
+ reference : draft-ietf-pce-segment-routing-06, section 5.1.1
+
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Reserved | Flags | MSD |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ fig: SR-PCE-CAPABILITY TLV format
+ */
+ protected static final Logger log = LoggerFactory.getLogger(SrPceCapabilityTlv.class);
+
+ public static final short TYPE = 26;
+ public static final short LENGTH = 4;
+
+ private final byte msd;
+
+ /**
+ * Constructor to initialize its parameter.
+ *
+ * @param msd maximum SID depth
+ */
+ public SrPceCapabilityTlv(byte msd) {
+ this.msd = msd;
+ }
+
+ /**
+ * Obtains newly created SrPceCapabilityTlv object.
+ *
+ * @param msd maximum SID depth
+ * @return object of SrPceCapabilityTlv
+ */
+ public static SrPceCapabilityTlv of(final byte msd) {
+ return new SrPceCapabilityTlv(msd);
+ }
+
+ /**
+ * Obtains msd.
+ *
+ * @return msd
+ */
+ public byte msd() {
+ return msd;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(msd);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SrPceCapabilityTlv) {
+ SrPceCapabilityTlv other = (SrPceCapabilityTlv) obj;
+ return Objects.equals(msd, other.msd);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(msd);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of SrPceCapabilityTlv.
+ *
+ * @param cb channel buffer
+ * @return object of Gmpls-Capability-Tlv
+ */
+ public static SrPceCapabilityTlv read(ChannelBuffer cb) {
+ //read reserved bits
+ cb.readShort();
+ //read flags
+ cb.readByte();
+ return SrPceCapabilityTlv.of(cb.readByte());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("msd", msd)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
index 71655b5..5b84822 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepErrorMsgTest.java
@@ -46,7 +46,7 @@
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
0x00, 0x00, 0x00, 0x00};
@@ -86,7 +86,7 @@
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
0x00, 0x00, 0x00, 0x00};
@@ -125,7 +125,7 @@
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
diff --git a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
index 2256496..8e10f0e 100644
--- a/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
+++ b/protocols/pcep/pcepio/src/test/java/org/onosproject/pcepio/protocol/PcepLabelUpdateMsgTest.java
@@ -43,7 +43,7 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66};
+ 0x00, 0x10, 0x10, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(labelUpdate);
@@ -83,10 +83,10 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77};
+ 0x00, 0x79, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(labelUpdate);
@@ -122,7 +122,7 @@
0x00, 0x00, 0x00, 0x10,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x79, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0B, 0x0B};
@@ -162,10 +162,10 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x66, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77,
+ 0x00, 0x68, 0x00, 0x00,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x11,
@@ -173,7 +173,7 @@
0x00, 0x02, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x44};
+ 0x00, 0x44, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(labelUpdate);
@@ -209,7 +209,7 @@
0x00, 0x00, 0x00, 0x10,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x01,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0B, 0x0B,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
@@ -217,7 +217,7 @@
0x00, 0x00, 0x00, 0x11,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0C, 0x0C};
@@ -257,16 +257,16 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77,
+ 0x00, 0x44, 0x00, 0x00,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x12,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0D, 0x0D};
@@ -304,7 +304,7 @@
0x00, 0x00, 0x00, 0x12,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0D, 0x0D,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
@@ -314,10 +314,10 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77};
+ 0x00, 0x44, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(labelUpdate);
@@ -354,7 +354,7 @@
0x00, 0x00, 0x00, 0x12,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE2, 0x10, 0x00, 0x08, // FEC Object Header
0x0A, 0x0A, 0x0D, 0x0D,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
@@ -364,10 +364,10 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77,
+ 0x00, 0x44, 0x00, 0x00,
0x21, 0x10, 0x00, 0x0C, // SRP Object Header
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x10,
@@ -375,10 +375,10 @@
0x00, 0x01, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x66,
+ 0x00, 0x44, 0x00, 0x00,
(byte) 0xE1, 0x10, 0x00, 0x0C, // LABEL Object Header
0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x77};
+ 0x00, 0x44, 0x00, 0x00};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(labelUpdate);
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 eea8a26..9fef361 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
@@ -39,7 +39,7 @@
byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x24, 0x01, 0x10, 0x00, 0x20, 0x20, 0x1e, 0x78, (byte) 0xbd,
0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
};
byte[] testOpenMsg = {0};
@@ -204,7 +204,7 @@
0x20, 0x1e, 0x78, (byte) 0xbd,
0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, // STATEFUL-PCE-CAPABILITY
0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
};
byte[] testOpenMsg = {0};
@@ -240,7 +240,7 @@
0x20, 0x1e, 0x78, (byte) 0xbd,
0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
};
byte[] testOpenMsg = {0};
@@ -279,7 +279,7 @@
0x20, 0x1e, 0x78, (byte) 0xbd,
0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
};
byte[] testOpenMsg = {0};
@@ -315,7 +315,7 @@
0x20, 0x1e, 0x78, 0x00, //invalid sessionID
0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0f, //STATEFUL-PCE-CAPABILITY
0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //GMPLS-CAPABILITY-TLV
- 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
+ (byte) 0xff, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, //PCECC-CAPABILITY-TLV
};
byte[] testOpenMsg = {0};
@@ -390,7 +390,7 @@
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03, (byte) 0xFF, (byte) 0x00, 0x00, 0x04, // LS Capability TLV
0x00, 0x00, 0x00, 0x00 };
@@ -427,7 +427,7 @@
0x20, 0x05, 0x1E, 0x01, // OPEN object
0x00, 0x10, 0x00, 0x04, // STATEFUL-PCE-CAPABILITY
0x00, 0x00, 0x00, 0x05, 0x00, 0x0E, 0x00, 0x04, // GMPLS-CAPABILITY-TLV
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, // PCECC-CAPABILITY-TLV
+ 0x00, 0x00, 0x00, 0x00, (byte) 0xff, 0x07, 0x00, 0x04, // PCECC-CAPABILITY-TLV
0x00, 0x00, 0x00, 0x03};
byte[] testOpenMsg = {0};