PCEP protocol message update
Change-Id: Icdea6c105553cd3dec1cacea6e2951f9e422b676
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