Priyanka B
Committed by Gerrit Code Review

PCEP protocol message update

Change-Id: Icdea6c105553cd3dec1cacea6e2951f9e422b676
......@@ -38,14 +38,14 @@ import com.google.common.base.MoreObjects;
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 |
| Label | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
// Optional TLV //
......@@ -65,6 +65,7 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
*/
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
@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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
@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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
@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 @@ public class PcepLabelObjectVer1 implements PcepLabelObject {
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("OFlag", bOFlag)
.add("oBit", oBit)
.add("label", label)
.add("OptionalTlvList", llOptionalTlv)
.add("optionalTlv", optionalTlv)
.toString();
}
}
......
......@@ -25,10 +25,12 @@ import org.onosproject.pcepio.protocol.PcepOpenObject;
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 @@ public class PcepOpenObjectVer1 implements PcepOpenObject {
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);
......
......@@ -22,6 +22,7 @@ import java.util.ListIterator;
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 @@ public class PcepSrpObjectVer1 implements PcepSrpObject {
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.");
}
......
......@@ -29,27 +29,25 @@ import com.google.common.base.MoreObjects;
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 |
| Type=[TBD] | Length=4 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Flags |G|L|
| 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 @@ public class PceccCapabilityTlv implements PcepValueType {
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 @@ public class PceccCapabilityTlv implements PcepValueType {
}
/**
* Returns G-flag.
* @return bGFlag G-flag
*/
public boolean getGFlag() {
return bGFlag;
}
/**
* Returns L-flag.
* @return bLFlag L-flag
* Returns sBit.
*
* @return sBit S bit
*/
public boolean getLFlag() {
return bLFlag;
public boolean sBit() {
return sBit;
}
/**
* Returns the raw value.
*
* @return rawValue Flags
*/
public int getInt() {
......@@ -133,7 +123,7 @@ public class PceccCapabilityTlv implements PcepValueType {
if (isRawValueSet) {
return Objects.hash(rawValue);
} else {
return Objects.hash(bLFlag, bGFlag);
return Objects.hash(sBit);
}
}
......@@ -147,7 +137,7 @@ public class PceccCapabilityTlv implements PcepValueType {
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 @@ public class PceccCapabilityTlv implements PcepValueType {
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 @@ public class PceccCapabilityTlv implements PcepValueType {
return MoreObjects.toStringHelper(getClass())
.add("Type", TYPE)
.add("Length", LENGTH)
.add("Value", rawValue)
.add("rawValue", rawValue)
.toString();
}
}
......
......@@ -30,7 +30,8 @@ import java.util.Objects;
*/
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 @@ public class SrEroSubObject implements PcepValueType {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// 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 @@ public class SrEroSubObject implements PcepValueType {
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 @@ public class SrEroSubObject implements PcepValueType {
* @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 @@ public class SrEroSubObject implements PcepValueType {
* @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 @@ public class SrEroSubObject implements PcepValueType {
/**
* Returns bFFlag.
*
* @return bFFlag
*/
public boolean getFFlag() {
......@@ -158,6 +163,7 @@ public class SrEroSubObject implements PcepValueType {
/**
* Returns bSFlag.
*
* @return bSFlag
*/
public boolean getSFlag() {
......@@ -166,6 +172,7 @@ public class SrEroSubObject implements PcepValueType {
/**
* Returns bCFlag.
*
* @return bCFlag
*/
public boolean getCFlag() {
......@@ -174,6 +181,7 @@ public class SrEroSubObject implements PcepValueType {
/**
* Returns bMFlag.
*
* @return bMFlag
*/
public boolean getMFlag() {
......@@ -182,10 +190,11 @@ public class SrEroSubObject implements PcepValueType {
/**
* Returns sID.
* @return sID
*
* @return sid
*/
public int getSid() {
return sID;
return sid;
}
/**
......@@ -213,7 +222,7 @@ public class SrEroSubObject implements PcepValueType {
@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 @@ public class SrEroSubObject implements PcepValueType {
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 @@ public class SrEroSubObject implements PcepValueType {
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 @@ public class SrEroSubObject implements PcepValueType {
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 @@ public class SrEroSubObject implements PcepValueType {
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 @@ public class SrEroSubObject implements PcepValueType {
.add("bSFlag", bSFlag)
.add("bCFlag", bCFlag)
.add("bMFlag", bMFlag)
.add("sID", sID)
.add("sid", sid)
.add("nAI", nai)
.toString();
}
......
/*
* 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
......@@ -46,7 +46,7 @@ public class PcepErrorMsgTest {
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 @@ public class PcepErrorMsgTest {
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 @@ public class PcepErrorMsgTest {
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();
......
......@@ -43,7 +43,7 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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 @@ public class PcepLabelUpdateMsgTest {
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);
......
......@@ -39,7 +39,7 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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 @@ public class PcepOpenMsgTest {
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};
......