[ONOS-2363]Implementation of Open and Error messages.
Change-Id: Id4aa762caf1847a6b5e56517cb159608fd54eefb
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java
new file mode 100644
index 0000000..cf4396d
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2015 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 Administrative Group Tlv which contains value (32 Bit ).
+ */
+public class AdministrativeGroupTlv implements PcepValueType {
+
+ /* REFERENCE :[RFC5305]/3.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=[TDB33] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | value (32 Bit ) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AdministrativeGroupTlv.class);
+
+ public static final short TYPE = 3; //TDB33
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue of Administrative-Group-Tlv.
+ */
+ public AdministrativeGroupTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created AdministrativeGroupTlv object.
+ *
+ * @param raw value.
+ * @return object of Administrative-Group-Tlv
+ */
+ public static AdministrativeGroupTlv of(final int raw) {
+ return new AdministrativeGroupTlv(raw);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue raw value
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AdministrativeGroupTlv) {
+ AdministrativeGroupTlv other = (AdministrativeGroupTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Administrative-Group-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of Administrative-Group-Tlv
+ */
+ public static AdministrativeGroupTlv read(ChannelBuffer c) {
+ return AdministrativeGroupTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java
new file mode 100644
index 0000000..7453686
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2014 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 BGP LS identifier which contains opaque value (32 Bit ID).
+ */
+public class BGPLSidentifierTlv implements PcepValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-10
+ * 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=[TBD11] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit ID). |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPLSidentifierTlv.class);
+
+ public static final short TYPE = 17; //TODD:change this TBD11
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue BGP LS identifier Tlv
+ */
+ public BGPLSidentifierTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created BGPLSidentifierTlv object.
+ *
+ * @param raw value
+ * @return object of BGPLSidentifierTlv
+ */
+ public static BGPLSidentifierTlv of(final int raw) {
+ return new BGPLSidentifierTlv(raw);
+ }
+
+ /**
+ * Returns opaque value.
+ *
+ * @return rawValue opaque value
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof BGPLSidentifierTlv) {
+ BGPLSidentifierTlv other = (BGPLSidentifierTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of BGPLSidentifierTlv.
+ *
+ * @param c input channel buffer
+ * @return object of BGP LS identifier Tlv
+ */
+ public static BGPLSidentifierTlv read(ChannelBuffer c) {
+ return BGPLSidentifierTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
new file mode 100644
index 0000000..37bb053
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2015 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 GMPLS Capability Tlv.
+ */
+public class GmplsCapabilityTlv implements PcepValueType {
+
+ /*
+ * GMPLS-CAPABILITY TLV format
+ * reference :draft-ietf-pce-gmpls-pcep-extensions -2.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=14 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class);
+
+ public static final short TYPE = 14;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue of Gmpls-Capability-Tlv
+ */
+ public GmplsCapabilityTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created GmplsCapabilityTlv object.
+ *
+ * @param raw Flags value
+ * @return object of Gmpls-Capability-Tlv
+ */
+ public static GmplsCapabilityTlv of(final int raw) {
+ return new GmplsCapabilityTlv(raw);
+ }
+
+ /**
+ * Returns value of Flags.
+ *
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof GmplsCapabilityTlv) {
+ GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Gmpls-Capability-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of Gmpls-Capability-Tlv
+ */
+ public static GmplsCapabilityTlv read(ChannelBuffer c) {
+ return GmplsCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java
new file mode 100644
index 0000000..5381508
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IGP Link Metric .
+ */
+public class IGPMetricTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.4
+ * 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=TDB40 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // IGP Link Metric (variable length) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IGPMetricTlv.class);
+
+ public static final short TYPE = 1095; //TODO:NEED TO HANDLE TDB40
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue IGP Link Metric
+ * @param hLength length
+ */
+ public IGPMetricTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ this.hLength = hLength;
+ }
+
+ /**
+ * Returns newly created IGPMetricTlv object.
+ *
+ * @param raw value of IGP Link Metric
+ * @param hLength length
+ * @return object of IGPMetricTlv
+ */
+ public static IGPMetricTlv of(final byte[] raw, short hLength) {
+ return new IGPMetricTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of IGP Link Metric.
+ *
+ * @return rawValue of IGP Link Metric
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IGPMetricTlv) {
+ IGPMetricTlv other = (IGPMetricTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IGPMetricTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of IGPMetricTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iIGPMetric = new byte[hLength];
+ c.readBytes(iIGPMetric, 0, hLength);
+ return new IGPMetricTlv(iIGPMetric, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java
new file mode 100644
index 0000000..71bfac5
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2015 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 IPv4 Interface Address .
+ */
+public class IPv4InterfaceAddressTlv implements PcepValueType {
+
+ /*
+ * reference :[RFC5305]/3.2
+ 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=6 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Interface Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressTlv.class);
+
+ public static final short TYPE = 6;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue of IPv4-Interface-Address.
+ */
+ public IPv4InterfaceAddressTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4InterfaceAddressTlv object.
+ *
+ * @param raw value of IPv4-Interface-Address
+ * @return object of IPv4-Interface-Address-Tlv
+ */
+ public static IPv4InterfaceAddressTlv of(final int raw) {
+ return new IPv4InterfaceAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 Interface Address.
+ *
+ * @return rawValue IPv4 Interface Address
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4InterfaceAddressTlv) {
+ IPv4InterfaceAddressTlv other = (IPv4InterfaceAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4InterfaceAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4-Interface-Address-Tlv
+ */
+ public static IPv4InterfaceAddressTlv read(ChannelBuffer c) {
+ return IPv4InterfaceAddressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java
new file mode 100644
index 0000000..9f78b2c
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2015 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 IPv4 Neighbor Address .
+ */
+public class IPv4NeighborAddressTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=8 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Neighbor Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressTlv.class);
+
+ public static final short TYPE = 8;
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4-Neighbor-Address-Tlv
+ */
+ public IPv4NeighborAddressTlv(int rawValue) {
+ log.debug("IPv4NeighborAddressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4NeighborAddressTlv object.
+ *
+ * @param raw value of IPv4-Neighbor-Address
+ * @return object of IPv4NeighborAddressTlv
+ */
+ public static IPv4NeighborAddressTlv of(final int raw) {
+ return new IPv4NeighborAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 Neighbor Address.
+ *
+ * @return rawValue IPv4 Neighbor Address
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4NeighborAddressTlv) {
+ IPv4NeighborAddressTlv other = (IPv4NeighborAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4-Neighbor-Address-Tlv
+ */
+ public static IPv4NeighborAddressTlv read(ChannelBuffer c) {
+ return IPv4NeighborAddressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
\ No newline at end of file
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java
new file mode 100644
index 0000000..33b7f36
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2015 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 IPv4 TE Router Id Of Local Node.
+ */
+public class IPv4TERouterIdOfLocalNodeTlv implements PcepValueType {
+
+ /* Reference:[RFC5305]/4.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB25] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 TE Router Id Of Local Node |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfLocalNodeTlv.class);
+
+ public static final short TYPE = 134; //TDB25
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4-TE-RouterId-Of-Local-Node-Tlv
+ */
+ public IPv4TERouterIdOfLocalNodeTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4TERouterIdOfLocalNodeTlv object.
+ *
+ * @param raw value of IPv4-TE-RouterId-Of-Local-Node
+ * @return object of IPv4TERouterIdOfLocalNodeTlv
+ */
+ public static IPv4TERouterIdOfLocalNodeTlv of(final int raw) {
+ return new IPv4TERouterIdOfLocalNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 TE Router Id Of Local Node.
+ *
+ * @return rawValue IPv4 TE Router Id Of Local Node
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4TERouterIdOfLocalNodeTlv) {
+ IPv4TERouterIdOfLocalNodeTlv other = (IPv4TERouterIdOfLocalNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4TERouterIdOfLocalNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4TERouterIdOfLocalNodeTlv
+ */
+ public static IPv4TERouterIdOfLocalNodeTlv read(ChannelBuffer c) {
+ return IPv4TERouterIdOfLocalNodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java
new file mode 100644
index 0000000..937d33a
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2015 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 IPv4 TE Router Id Of Remote Node.
+ */
+public class IPv4TERouterIdOfRemoteNodeTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/4.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB28] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 TE Router Id Of Remote Node |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfRemoteNodeTlv.class);
+
+ public static final short TYPE = 1340; //TDB28
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv4 TE RouterId Of Remote Node Tlv
+ */
+ public IPv4TERouterIdOfRemoteNodeTlv(int rawValue) {
+ log.debug("IPv4TERouterIdOfRemoteNodeTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv4TERouterIdOfRemoteNodeTlv object.
+ *
+ * @param raw IPv4 TE RouterId Of Remote Node
+ * @return object of IPv4TERouterIdOfRemoteNodeTlv
+ */
+ public static IPv4TERouterIdOfRemoteNodeTlv of(final int raw) {
+ return new IPv4TERouterIdOfRemoteNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv4 TE Router Id Of Remote Node.
+ *
+ * @return rawValue IPv4 TE Router Id Of Remote Node
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4TERouterIdOfRemoteNodeTlv) {
+ IPv4TERouterIdOfRemoteNodeTlv other = (IPv4TERouterIdOfRemoteNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4TERouterIdOfRemoteNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv4TERouterIdOfRemoteNodeTlv
+ */
+ public static IPv4TERouterIdOfRemoteNodeTlv read(ChannelBuffer c) {
+ return IPv4TERouterIdOfRemoteNodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java
new file mode 100644
index 0000000..725fb5d
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java
@@ -0,0 +1,181 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2.
+ */
+public class IPv6InterfaceAddressTlv implements PcepValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressTlv.class);
+
+ public static final short TYPE = 12; //TDB18
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6InterfaceAddressTlv NONE = new IPv6InterfaceAddressTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6InterfaceAddressTlv NO_MASK = new IPv6InterfaceAddressTlv(NO_MASK_VAL);
+ public static final IPv6InterfaceAddressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6 Interface Address Tlv
+ */
+ public IPv6InterfaceAddressTlv(byte[] rawValue) {
+ log.debug("IPv6InterfaceAddressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6InterfaceAddressTlv object.
+ *
+ * @param raw IPv6 Interface Address
+ * @return object of IPv6InterfaceAddressTlv
+ */
+ public static IPv6InterfaceAddressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6InterfaceAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Interface Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 Interface Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6InterfaceAddressTlv) {
+ IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6InterfaceAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6InterfaceAddressTlv
+ */
+ public static IPv6InterfaceAddressTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6InterfaceAddressTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java
new file mode 100644
index 0000000..5bb33ef
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3.
+ */
+public class IPv6NeighborAddressTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressTlv.class);
+
+ public static final short TYPE = 13; // TDB19
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6NeighborAddressTlv NONE = new IPv6NeighborAddressTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6NeighborAddressTlv NO_MASK = new IPv6NeighborAddressTlv(NO_MASK_VAL);
+ public static final IPv6NeighborAddressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6 Neighbor Address Tlv
+ */
+ public IPv6NeighborAddressTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6NeighborAddressTlv object.
+ *
+ * @param raw IPv6 Neighbor Address
+ * @return object of IPv6 Neighbor Address Tlv
+ */
+ public static IPv6NeighborAddressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6NeighborAddressTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Neighbor Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 Neighbor Address.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6NeighborAddressTlv) {
+ IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6NeighborAddressTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6NeighborAddressTlv
+ */
+ public static IPv6NeighborAddressTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6NeighborAddressTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java
new file mode 100644
index 0000000..4da8b14
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1.
+ */
+public class IPv6TERouterIdofLocalNodeTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofLocalNodeTlv.class);
+
+ public static final short TYPE = 140; //TDB26
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ public static final IPv6TERouterIdofLocalNodeTlv NONE = new IPv6TERouterIdofLocalNodeTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ public static final IPv6TERouterIdofLocalNodeTlv NO_MASK = new IPv6TERouterIdofLocalNodeTlv(NO_MASK_VAL);
+ public static final IPv6TERouterIdofLocalNodeTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6TERouterIdofLocalNodeTlv
+ */
+ public IPv6TERouterIdofLocalNodeTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6TERouterIdofLocalNodeTlv object.
+ *
+ * @param raw IPv6 TE Router Id of Local Node
+ * @return object of IPv6TERouterIdofLocalNodeTlv
+ */
+ public static IPv6TERouterIdofLocalNodeTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6TERouterIdofLocalNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Local Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Local Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofLocalNodeTlv) {
+ IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6TERouterIdofLocalNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6TERouterIdofLocalNodeTlv
+ */
+ public static IPv6TERouterIdofLocalNodeTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6TERouterIdofLocalNodeTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java
new file mode 100644
index 0000000..3e47088
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1.
+ */
+public class IPv6TERouterIdofRemoteNodeTlv implements PcepValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofRemoteNodeTlv.class);
+
+ public static final short TYPE = 1400; //TDB29
+ public static final short LENGTH = 20;
+ public static final byte VALUE_LENGTH = 18;
+
+ private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ public static final IPv6TERouterIdofRemoteNodeTlv NONE = new IPv6TERouterIdofRemoteNodeTlv(NONE_VAL);
+
+ private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
+ public static final IPv6TERouterIdofRemoteNodeTlv NO_MASK = new IPv6TERouterIdofRemoteNodeTlv(NO_MASK_VAL);
+ public static final IPv6TERouterIdofRemoteNodeTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue IPv6TERouterIdofRemoteNodeTlv
+ */
+ public IPv6TERouterIdofRemoteNodeTlv(byte[] rawValue) {
+ log.debug("IPv6TERouterIdofRemoteNodeTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created IPv6TERouterIdofRemoteNodeTlv object.
+ *
+ * @param raw IPv6 TE Router Id of RemoteNode
+ * @return object of IPv6TERouterIdofRemoteNodeTlv
+ */
+ public static IPv6TERouterIdofRemoteNodeTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (NONE_VAL[i] != raw[i]) {
+ bFoundNONE = false;
+ }
+ }
+
+ if (bFoundNONE) {
+ return NONE;
+ }
+
+ //check NO_MASK_VAL
+ boolean bFoundNoMask = true;
+ //value starts from 3rd byte.
+ for (int i = 2; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+
+ return new IPv6TERouterIdofRemoteNodeTlv(raw);
+ }
+
+ /**
+ * Returns value of IPv6 TE Router Id of Remote Node.
+ *
+ * @return byte array value of rawValue
+ */
+ public byte[] getBytes() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) {
+ IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv6TERouterIdofRemoteNodeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of IPv6TERouterIdofRemoteNodeTlv
+ */
+ public static IPv6TERouterIdofRemoteNodeTlv read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6TERouterIdofRemoteNodeTlv.of(yTemp);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", LENGTH);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java
new file mode 100644
index 0000000..1a0f2f8
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides ISIS Area Identifier.
+ */
+public class ISISAreaIdentifierTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.2
+ * 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=[TBD24] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Area Identifier (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(ISISAreaIdentifierTlv.class);
+
+ public static final short TYPE = 107; //TODO:NEED TO HANDLE TBD24
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue ISIS-Area-Identifier
+ * @param hLength length
+ */
+ public ISISAreaIdentifierTlv(byte[] rawValue, short hLength) {
+ log.debug("ISISAreaIdentifierTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created ISISAreaIdentifierTlv object.
+ *
+ * @param raw ISIS-Area-Identifier
+ * @param hLength length
+ * @return object of ISISAreaIdentifierTlv
+ */
+ public static ISISAreaIdentifierTlv of(final byte[] raw, short hLength) {
+ return new ISISAreaIdentifierTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of ISIS-Area-Identifier.
+ *
+ * @return byte array of rawValue
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof ISISAreaIdentifierTlv) {
+ ISISAreaIdentifierTlv other = (ISISAreaIdentifierTlv) obj;
+ return Objects.equals(hLength, other.hLength) && Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of ISISAreaIdentifierTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of ISISAreaIdentifierTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iISISAreaIdentifier = new byte[hLength];
+ c.readBytes(iISISAreaIdentifier, 0, hLength);
+ return new ISISAreaIdentifierTlv(iISISAreaIdentifier, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java
new file mode 100644
index 0000000..1d391fa
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java
@@ -0,0 +1,152 @@
+/*
+ * Copyright 2015 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 Local and remote Link Identifiers.
+ */
+public class LinkLocalRemoteIdentifiersTlv implements PcepValueType {
+
+ /* Reference :RFC5307
+ * 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=4 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Link Local Identifier |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Link Remote Identifier |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
+
+ public static final short TYPE = 4;
+ public static final short LENGTH = 8;
+ private final int iLinkLocalIdentifier;
+ private final int iLinkRemoteIdentifier;
+
+ /**
+ * Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier.
+ *
+ * @param iLinkLocalIdentifier Link Local identifier
+ * @param iLinkRemoteIdentifier Link Remote identifier
+ */
+ public LinkLocalRemoteIdentifiersTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
+ this.iLinkLocalIdentifier = iLinkLocalIdentifier;
+ this.iLinkRemoteIdentifier = iLinkRemoteIdentifier;
+ }
+
+ /**
+ * Retruns an object of Link Local Remote Identifiers Tlv.
+ *
+ * @param iLinkLocalIdentifier Link Local identifier
+ * @param iLinkRemoteIdentifier Link Remote identifier
+ * @return object of LinkLocalRemoteIdentifiersTlv
+ */
+ public static LinkLocalRemoteIdentifiersTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
+ return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ /**
+ * Returns Link-Local-Identifier.
+ *
+ * @return iLinkLocalIdentifier Link Local Identifier
+ */
+ public int getLinkLocalIdentifier() {
+ return iLinkLocalIdentifier;
+ }
+
+ /**
+ * Returns Link-Remote-Identifier.
+ *
+ * @return iLinkRemoteIdentifier Link Remote Identifier.
+ */
+ public int getLinkRemoteIdentifier() {
+ return iLinkRemoteIdentifier;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkLocalRemoteIdentifiersTlv) {
+ LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj;
+ return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier)
+ && Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(iLinkLocalIdentifier);
+ c.writeInt(iLinkRemoteIdentifier);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
+ *
+ * @param c input channel buffer
+ * @return object of LinkLocalRemoteIdentifiersTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int iLinkLocalIdentifier = c.readInt();
+ int iLinkRemoteIdentifier = c.readInt();
+ return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
+ .add("LinkLocalIdentifier", iLinkLocalIdentifier).add("LinkRemoteIdentifier", iLinkRemoteIdentifier)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java
new file mode 100644
index 0000000..fb36613
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides the Link Name.
+ */
+public class LinkNameTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7
+ * Link name tlv format.
+ 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=TDB43 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Link Name (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(LinkNameTlv.class);
+
+ public static final short TYPE = 1098; //TODO:NEED TO HANDLE TDB43
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Link-Name
+ * @param hLength length
+ */
+ public LinkNameTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created LinkNameTlv object.
+ *
+ * @param raw Link-Name
+ * @param hLength length
+ * @return object of LinkNameTlv
+ */
+ public static LinkNameTlv of(final byte[] raw, short hLength) {
+ return new LinkNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns value of Link-Name.
+ *
+ * @return raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkNameTlv) {
+ LinkNameTlv other = (LinkNameTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkNameTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of LinkNameTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] linkName = new byte[hLength];
+ c.readBytes(linkName, 0, hLength);
+ return new LinkNameTlv(linkName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
new file mode 100644
index 0000000..f6faa8d
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2015 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;
+
+/**
+ * Provide Link Protection Type.
+ */
+
+public class LinkProtectionTypeTlv implements PcepValueType {
+
+ /* Reference :[RFC5307]/1.2
+ * 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=[TDB38] | Length=2 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |Protection Cap | Reserved |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeTlv.class);
+
+ public static final short TYPE = 20; //TDB38
+ public static final short LENGTH = 2;
+ private final byte protectionCap;
+ private final byte reserved;
+
+ /**
+ * Constructor to initialize protectionCap.
+ *
+ * @param protectionCap Protection Cap
+ */
+ public LinkProtectionTypeTlv(byte protectionCap) {
+ this.protectionCap = protectionCap;
+ this.reserved = 0;
+ }
+
+ /**
+ * Constructor to initialize protectionCap, reserved.
+ *
+ * @param protectionCap Protection Cap
+ * @param reserved Reserved value
+ */
+ public LinkProtectionTypeTlv(byte protectionCap, byte reserved) {
+ this.protectionCap = protectionCap;
+ this.reserved = reserved;
+ }
+
+ /**
+ * Returns Protection Cap.
+ *
+ * @return protectionCap Protection Cap
+ */
+ public byte getProtectionCap() {
+ return protectionCap;
+ }
+
+ @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(protectionCap, reserved);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LinkProtectionTypeTlv) {
+ LinkProtectionTypeTlv other = (LinkProtectionTypeTlv) obj;
+ return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeByte(protectionCap);
+ c.writeByte(reserved);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LinkProtectionTypeTlv.
+ *
+ * @param c input channel buffer
+ * @return object of LinkProtectionTypeTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte protectionCap = c.readByte();
+ byte reserved = c.readByte();
+ return new LinkProtectionTypeTlv(protectionCap, reserved);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
+ .add("ProtectionCap", protectionCap).toString();
+ }
+}
\ No newline at end of file
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTLV.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTLV.java
new file mode 100644
index 0000000..4d3df47
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTLV.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2015 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.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs.
+ */
+public class LocalTENodeDescriptorsTLV implements PcepValueType {
+
+ /* REFERENCE :draft-ietf-idr-ls-distribution-10
+ * 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=[TBD8] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ Note: Length is including header here. Refer Routing Universe TLV.
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(LocalTENodeDescriptorsTLV.class);
+
+ public static final short TYPE = 1637; //TODD:change this TBD8
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // Node Descriptor Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llNodeDescriptorSubTLVs;
+
+ /**
+ * Constructor to initialize llNodeDescriptorSubTLVs.
+ *
+ * @param llNodeDescriptorSubTLVs LinkedList of PcepValueType
+ */
+ public LocalTENodeDescriptorsTLV(LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
+ this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs;
+ }
+
+ /**
+ * Returns a new object of LocalTENodeDescriptorsTLV.
+ *
+ * @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs
+ * @return object of LocalTENodeDescriptorsTLV
+ */
+ public static LocalTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
+ return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
+ }
+
+ /**
+ * Returns Linked List of tlvs.
+ *
+ * @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV
+ */
+ public LinkedList<PcepValueType> getllNodeDescriptorSubTLVs() {
+ return llNodeDescriptorSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llNodeDescriptorSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof LocalTENodeDescriptorsTLV) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ LocalTENodeDescriptorsTLV other = (LocalTENodeDescriptorsTLV) obj;
+ Iterator<PcepValueType> objListIterator = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs
+ .iterator();
+ countObjSubTlv = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs.size();
+ countOtherSubTlv = other.llNodeDescriptorSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv),
+ other.llNodeDescriptorSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(0);
+
+ ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+ if (null == tlv) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, hLength);
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of AutonomousSystemTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length of subtlvs.
+ * @return object of AutonomousSystemTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+
+ switch (hType) {
+
+ case AutonomousSystemTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ case BGPLSidentifierTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new BGPLSidentifierTlv(iValue);
+ break;
+ case OSPFareaIDsubTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new OSPFareaIDsubTlv(iValue);
+ break;
+ case RouterIDSubTlv.TYPE:
+ tlv = RouterIDSubTlv.read(tempCb, length);
+ break;
+
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llNodeDescriptorSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
+ .add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
new file mode 100644
index 0000000..f0cf5b5
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2015 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 MPLS Protocol Mask.
+ */
+public class MPLSProtocolMaskTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.2
+ * 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=TDB39 | Length =1 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |L|R| Reserved |
+ +-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(MPLSProtocolMaskTlv.class);
+
+ public static final short TYPE = 1094; //TDB39
+ public static final short LENGTH = 1;
+ public static final int SET = 1;
+ public static final byte LFLAG_SET = (byte) 0x80;
+ public static final byte RFLAG_SET = 0x40;
+
+ private final byte rawValue;
+ private final boolean bLFlag;
+ private final boolean bRFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue MPLS Protocol Mask Flag Bits
+ */
+ public MPLSProtocolMaskTlv(byte rawValue) {
+ this.rawValue = rawValue;
+ isRawValueSet = true;
+ byte temp = rawValue;
+ if ((temp & LFLAG_SET) == SET) {
+ this.bLFlag = true;
+
+ } else {
+ this.bLFlag = false;
+ }
+ if ((temp & RFLAG_SET) == SET) {
+ this.bRFlag = true;
+ } else {
+ this.bRFlag = false;
+ }
+ }
+
+ /**
+ * constructor to initialize different Flags.
+ *
+ * @param bLFlag L-flag
+ * @param bRFlag R-flag
+ */
+ public MPLSProtocolMaskTlv(boolean bLFlag, boolean bRFlag) {
+ this.bLFlag = bLFlag;
+ this.bRFlag = bRFlag;
+ this.rawValue = 0;
+ isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created MPLSProtocolMaskTlv object.
+ *
+ * @param raw MPLS Protocol Mask Tlv
+ * @return new object of MPLS Protocol Mask Tlv
+ */
+ public static MPLSProtocolMaskTlv of(final byte raw) {
+ return new MPLSProtocolMaskTlv(raw);
+ }
+
+ /**
+ * Returns L-flag.
+ *
+ * @return bLFlag L-flag
+ */
+ public boolean getbLFlag() {
+ return bLFlag;
+ }
+
+ /**
+ * Returns R-flag.
+ *
+ * @return bRFlag R-flag
+ */
+ public boolean getbRFlag() {
+ return bRFlag;
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue raw value
+ */
+ public byte getByte() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bLFlag, bRFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MPLSProtocolMaskTlv) {
+ MPLSProtocolMaskTlv other = (MPLSProtocolMaskTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
+ } else {
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeByte(rawValue);
+ } else {
+ byte temp = 0;
+ if (bLFlag) {
+ temp = (byte) (temp | LFLAG_SET);
+ }
+ if (bRFlag) {
+ temp = (byte) (temp | RFLAG_SET);
+ }
+ c.writeByte(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MPLS Protocol Mask Tlv.
+ *
+ * @param c input channel buffer
+ * @return object of MPLS Protocol Mask Tlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte temp = c.readByte();
+ boolean bLFlag;
+ boolean bRFlag;
+
+ if ((temp & LFLAG_SET) == SET) {
+ bLFlag = true;
+ } else {
+ bLFlag = false;
+ }
+ if ((temp & RFLAG_SET) == SET) {
+ bRFlag = true;
+ } else {
+ bRFlag = false;
+ }
+ return new MPLSProtocolMaskTlv(bLFlag, bRFlag);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java
new file mode 100644
index 0000000..d990c37
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2015 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;
+
+/**
+ * Provide the Maximum Link Bandwidth.
+ */
+public class MaximumLinkBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TDB34] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Maximum Link Bandwidth |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthTlv.class);
+
+ public static final short TYPE = 9; //TDB34
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Maximum-Link-Bandwidth
+ */
+
+ public MaximumLinkBandwidthTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created MaximumLinkBandwidthTlv object.
+ *
+ * @param raw value of Maximum-Link-Bandwidth
+ * @return object of MaximumLinkBandwidthTlv
+ */
+ public static MaximumLinkBandwidthTlv of(final int raw) {
+ return new MaximumLinkBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns value of Maximum Link Bandwidth.
+ *
+ * @return rawValue Maximum Link Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MaximumLinkBandwidthTlv) {
+ MaximumLinkBandwidthTlv other = (MaximumLinkBandwidthTlv) obj;
+ return Objects.equals(rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MaximumLinkBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of MaximumLinkBandwidthTlv
+ */
+ public static MaximumLinkBandwidthTlv read(ChannelBuffer c) {
+ return MaximumLinkBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java
new file mode 100644
index 0000000..2d963bb
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2015 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;
+
+/**
+ * Provide the Maximum Reservable Link Bandwidth.
+ */
+public class MaximumReservableLinkBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.5.
+ * 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=[TDB35] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Maximum Reservable Link Bandwidth |
+ +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthTlv.class);
+
+ public static final short TYPE = 10; // TDB35
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue MaximumReservableLinkBandwidth
+ */
+ public MaximumReservableLinkBandwidthTlv(int rawValue) {
+ log.debug("MaximumReservableLinkBandwidthTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created MaximumReservableLinkBandwidth object.
+ *
+ * @param raw MaximumReservableLinkBandwidth
+ * @return object of MaximumReservableLinkBandwidthTlv
+ */
+ public static MaximumReservableLinkBandwidthTlv of(final int raw) {
+ return new MaximumReservableLinkBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns value of Maximum Reservable Link Bandwidth.
+ * @return rawValue Maximum Reservable Link Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof MaximumReservableLinkBandwidthTlv) {
+ MaximumReservableLinkBandwidthTlv other = (MaximumReservableLinkBandwidthTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of MaximumReservableLinkBandwidthTlv
+ */
+ public static MaximumReservableLinkBandwidthTlv read(ChannelBuffer c) {
+ return MaximumReservableLinkBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java
new file mode 100644
index 0000000..fb4d362
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2015 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;
+
+/**
+ * Provide node Flags bits.
+ */
+public class NodeFlagBitsTlv implements PcepValueType {
+
+ /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.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=[TBD21] | Length=1 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |O|T|E|B| Reserved|
+ +-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(NodeFlagBitsTlv.class);
+
+ public static final short TYPE = 14;
+ public static final short LENGTH = 1;
+ public static final int SET = 1;
+ public static final byte OFLAG_SET = (byte) 0x80;
+ public static final byte TFLAG_SET = 0x40;
+ public static final byte EFLAG_SET = 0x20;
+ public static final byte BFLAG_SET = 0x10;
+
+ private final byte rawValue;
+ private final boolean bOFlag;
+ private final boolean bTFlag;
+ private final boolean bEFlag;
+ private final boolean bBFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Node Flag Bits TLV
+ */
+ public NodeFlagBitsTlv(byte rawValue) {
+ this.rawValue = rawValue;
+ isRawValueSet = true;
+ byte temp = rawValue;
+ this.bOFlag = (temp & OFLAG_SET) == OFLAG_SET ? true : false;
+ this.bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false;
+ this.bEFlag = (temp & EFLAG_SET) == EFLAG_SET ? true : false;
+ this.bBFlag = (temp & BFLAG_SET) == BFLAG_SET ? true : false;
+ }
+
+ /**
+ * constructor to initialize different Flags.
+ *
+ * @param bOFlag O-flag
+ * @param bTFlag T-flag
+ * @param bEFlag E-flag
+ * @param bBFlag B-flag
+ */
+ public NodeFlagBitsTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) {
+ this.bOFlag = bOFlag;
+ this.bTFlag = bTFlag;
+ this.bEFlag = bEFlag;
+ this.bBFlag = bBFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created NodeFlagBitsTlv object.
+ *
+ * @param raw of Node Flag Bits TLV
+ * @return new object of NodeFlagBitsTlv
+ */
+ public static NodeFlagBitsTlv of(final byte raw) {
+ return new NodeFlagBitsTlv(raw);
+ }
+
+ /**
+ * Returns raw value of NodeFlagBitsTlv.
+ *
+ * @return rawValue raw value
+ */
+ public byte getbyte() {
+ return rawValue;
+ }
+
+ /**
+ * Returns O-flag.
+ *
+ * @return bOFlag O-flag
+ */
+ public boolean getOFlag() {
+ return bOFlag;
+ }
+
+ /**
+ * Returns T-flag.
+ *
+ * @return bTFlag T-flag
+ */
+ public boolean getTFlag() {
+ return bTFlag;
+ }
+
+ /**
+ * Returns E-flag.
+ *
+ * @return bEFlag E-flag
+ */
+ public boolean getEFlag() {
+ return bEFlag;
+ }
+
+ /**
+ * Returns B-flag.
+ *
+ * @return bBFlag B-flag
+ */
+ public boolean getBFlag() {
+ return bBFlag;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NodeFlagBitsTlv) {
+ NodeFlagBitsTlv other = (NodeFlagBitsTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag)
+ && Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag);
+ } else {
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeByte(rawValue);
+ } else {
+ byte temp = 0;
+ if (bOFlag) {
+ temp = (byte) (temp | OFLAG_SET);
+ }
+ if (bTFlag) {
+ temp = (byte) (temp | TFLAG_SET);
+ }
+ if (bEFlag) {
+ temp = (byte) (temp | EFLAG_SET);
+ }
+ if (bBFlag) {
+ temp = (byte) (temp | BFLAG_SET);
+ }
+ c.writeByte(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NodeFlagBitsTlv.
+ *
+ * @param c input channel buffer
+ * @return object of NodeFlagBitsTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+
+ return NodeFlagBitsTlv.of(c.readByte());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
+ .add("OFlag", (bOFlag) ? 1 : 0).add("TFlag", (bTFlag) ? 1 : 0).add("EFlag", (bEFlag) ? 1 : 0)
+ .add("BFlag", (bBFlag) ? 1 : 0).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java
new file mode 100644
index 0000000..010d7b0
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provide the name for the node.
+ */
+public class NodeNameTlv implements PcepValueType {
+
+ /* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=[TBD23] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Node Name (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(NodeNameTlv.class);
+
+ public static final short TYPE = 1007; //TODO:check and change TBD23
+ public final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Node Name
+ * @param hLength length
+ */
+ public NodeNameTlv(byte[] rawValue, short hLength) {
+ log.debug("NodeNameTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created NodeNameTlv object.
+ *
+ * @param raw of NodeName
+ * @param hLength length
+ * @return new object of Node Name Tlv
+ */
+ public static NodeNameTlv of(final byte[] raw, short hLength) {
+ return new NodeNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns RawValue for NodeName.
+ *
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NodeNameTlv) {
+ NodeNameTlv other = (NodeNameTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NodeNameTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of Node Name TLV
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iNodeName = new byte[hLength];
+ c.readBytes(iNodeName, 0, hLength);
+ return new NodeNameTlv(iNodeName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java
new file mode 100644
index 0000000..fc2f723
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright 2014 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 area ID for OSPF area.
+ */
+public class OSPFareaIDsubTlv implements PcepValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-10.
+ * 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=[TBD12] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit AS Number) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OSPFareaIDsubTlv.class);
+
+ public static final short TYPE = 600; //TODD:change this TBD12
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue area ID for OSPF area.
+ */
+ public OSPFareaIDsubTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created OSPFareaIDsubTlv object.
+ *
+ * @param raw opaque value of AreaID
+ * @return new object of OSPF area ID sub TLV
+ */
+ public static OSPFareaIDsubTlv of(final int raw) {
+ return new OSPFareaIDsubTlv(raw);
+ }
+
+ /**
+ * Returns RawValue opaque value of AreaID.
+ *
+ * @return rawValue Area ID
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OSPFareaIDsubTlv) {
+ OSPFareaIDsubTlv other = (OSPFareaIDsubTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OSPFAreaIdSubTlv.
+ *
+ * @param c input channel buffer
+ * @return object of OSPFAreaIdSubTlv
+ */
+ public static OSPFareaIDsubTlv read(ChannelBuffer c) {
+ return OSPFareaIDsubTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java
new file mode 100644
index 0000000..2cc5b24
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides Opaque Link Attribute.
+ */
+public class OpaqueLinkAttributeTlv implements PcepValueType {
+
+ /*
+ * TLV format.
+ * Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6
+ 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=TBD42 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Opaque link attributes (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeTlv.class);
+
+ public static final short TYPE = 1097; //TODO:NEED TO HANDLE TDB42
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Opaque Link Attribute
+ * @param hLength length
+ */
+ public OpaqueLinkAttributeTlv(byte[] rawValue, short hLength) {
+ log.debug("OpaqueLinkAttributeTlv");
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created OpaqueLinkAttributeTlv object.
+ *
+ * @param raw of Opaque Link Attribute
+ * @param hLength length
+ * @return new object of OpaqueLinkAttributeTlv
+ */
+ public static OpaqueLinkAttributeTlv of(final byte[] raw, short hLength) {
+ return new OpaqueLinkAttributeTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value of Opaque Link Attribute Tlv.
+ * @return rawValue raw value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpaqueLinkAttributeTlv) {
+ OpaqueLinkAttributeTlv other = (OpaqueLinkAttributeTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OpaqueLinkAttributeTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of Opaque Link Attribute Tlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new OpaqueLinkAttributeTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java
new file mode 100644
index 0000000..d6cc5fe
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides Opaque node attributes.
+ */
+public class OpaqueNodeAttributeTlv implements PcepValueType {
+ /*
+ * Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.5
+ * 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=[TBD22] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Opaque node attributes (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OpaqueNodeAttributeTlv.class);
+
+ public static final short TYPE = 1001;
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue Opaque Node Attribute
+ * @param hLength length
+ */
+ public OpaqueNodeAttributeTlv(byte[] rawValue, short hLength) {
+
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns newly created OpaqueNodeAttributeTlv object.
+ *
+ * @param raw value of Opaque Node Attribute
+ * @param hLength length
+ * @return new object of Opaque Node Attribute Tlv
+ */
+ public static OpaqueNodeAttributeTlv of(final byte[] raw, short hLength) {
+ return new OpaqueNodeAttributeTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value of Opaque Node Attribute Tlv.
+ *
+ * @return rawValue of Opaque Node Attribute
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OpaqueLinkAttributeTlv) {
+ OpaqueNodeAttributeTlv other = (OpaqueNodeAttributeTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of Opaque Node Attribute Tlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of OpaqueNodeAttributeTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new OpaqueNodeAttributeTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
new file mode 100644
index 0000000..6d1ad85
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
@@ -0,0 +1,176 @@
+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 PceccCapabilityTlv.
+ */
+public class PceccCapabilityTlv implements PcepValueType {
+
+ /* PCECC CAPABILITY TLV
+ * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, 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|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
+
+ public static final short TYPE = 32;
+ 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;
+
+ private final boolean bGFlag;
+ private final boolean bLFlag;
+
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue raw value
+ */
+ public PceccCapabilityTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+
+ bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK ? true : false;
+ bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK ? true : false;
+ }
+
+ /**
+ * Constructor to initialize G-flag L-flag.
+ * @param bGFlag G-flag
+ * @param bLFlag L-flag
+ */
+ public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) {
+ this.bGFlag = bGFlag;
+ this.bLFlag = bLFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns newly created PceccCapabilityTlv object.
+ *
+ * @param raw value
+ * @return object of Pcecc Capability Tlv
+ */
+ public static PceccCapabilityTlv of(final int raw) {
+ return new PceccCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns G-flag.
+ * @return bGFlag G-flag
+ */
+ public boolean getGFlag() {
+ return bGFlag;
+ }
+
+ /**
+ * Returns L-flag.
+ * @return bLFlag L-flag
+ */
+ public boolean getLFlag() {
+ return bLFlag;
+ }
+
+ /**
+ * Returns the raw value.
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bLFlag, bGFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PceccCapabilityTlv) {
+ PceccCapabilityTlv other = (PceccCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ int temp = 0;
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ if (bGFlag) {
+ temp = temp | GFLAG_CHECK;
+ }
+ if (bLFlag) {
+ temp = temp | LFLAG_CHECK;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of PceccCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of PceccCapabilityTlv
+ */
+ public static PceccCapabilityTlv read(ChannelBuffer c) {
+ return PceccCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
new file mode 100644
index 0000000..f79cfc4
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
@@ -0,0 +1,119 @@
+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 CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ).
+ */
+public class PcepLabelDbVerTlv implements PcepValueType {
+
+ /* PCEP LABEL DB VERSION TLV format
+
+ Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.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=23 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP State DB Version |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class);
+
+ public static final short TYPE = 34;
+ public static final short LENGTH = 8;
+ private final long rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue of Pcep Label Db Version Tlv
+ */
+ public PcepLabelDbVerTlv(final long rawValue) {
+ log.debug("PcepLabelDbVerTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created PcepLabelDbVerTlv object.
+ *
+ * @param raw LSP State DB Version
+ * @return object of PcepLabelDbVerTlv
+ */
+ public static PcepLabelDbVerTlv of(final long raw) {
+ return new PcepLabelDbVerTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns LSP State DB Version.
+ * @return raw value
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PceccCapabilityTlv) {
+ PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepLabelDbVerTlv.
+ *
+ * @param c input channel buffer
+ * @return object of PcepLabelDbVerTlv
+ */
+ public static PcepLabelDbVerTlv read(ChannelBuffer c) {
+ return PcepLabelDbVerTlv.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTLV.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTLV.java
new file mode 100644
index 0000000..2a12e07
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTLV.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright 2015 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.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Remote TE Node Descriptors TLV.
+ */
+public class RemoteTENodeDescriptorsTLV implements PcepValueType {
+
+ /* Reference :PCEP Extension for Transporting TE Data
+ draft-dhodylee-pce-pcep-te-data-extn-02
+ *
+ 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=[TBD9] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RemoteTENodeDescriptorsTLV.class);
+
+ public static final short TYPE = 1003; //TODD:change this TBD9
+ public static short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // Node Descriptor Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs;
+
+ /**
+ * Constructor to initialize llRemoteTENodeDescriptorSubTLVs.
+ *
+ * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
+ */
+ public RemoteTENodeDescriptorsTLV(LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
+ this.llRemoteTENodeDescriptorSubTLVs = llRemoteTENodeDescriptorSubTLVs;
+ }
+
+ /**
+ * Returns object of Remote TE Node Descriptors TLV.
+ *
+ * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
+ * @return object of RemoteTENodeDescriptorsTLV
+ */
+ public static RemoteTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
+ return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs);
+ }
+
+ /**
+ * Returns Remote TE Node Descriptor Sub TLVs.
+ *
+ * @return llRemoteTENodeDescriptorSubTLVs
+ */
+ public LinkedList<PcepValueType> getllRemoteTENodeDescriptorSubTLVs() {
+ return llRemoteTENodeDescriptorSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llRemoteTENodeDescriptorSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof RemoteTENodeDescriptorsTLV) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ RemoteTENodeDescriptorsTLV other = (RemoteTENodeDescriptorsTLV) obj;
+ Iterator<PcepValueType> objListIterator = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs
+ .iterator();
+ countObjSubTlv = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs.size();
+ countOtherSubTlv = other.llRemoteTENodeDescriptorSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llRemoteTENodeDescriptorSubTLVs.contains(subTlv),
+ other.llRemoteTENodeDescriptorSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ if (null == tlv) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, hLength);
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of Remote TE Node Descriptors TLV.
+ *
+ * @param c input channel buffer
+ * @return object of RemoteTENodeDescriptorsTLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short hLength = tempCb.readShort();
+ switch (hType) {
+
+ case AutonomousSystemTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ case BGPLSidentifierTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new BGPLSidentifierTlv(iValue);
+ break;
+ case OSPFareaIDsubTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new OSPFareaIDsubTlv(iValue);
+ break;
+ case RouterIDSubTlv.TYPE:
+ tlv = RouterIDSubTlv.read(tempCb, hLength);
+ break;
+
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = hLength % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llRemoteTENodeDescriptorSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
+ .add("RemoteTeNodeDescriptorSubTLVs", llRemoteTENodeDescriptorSubTLVs).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java
new file mode 100644
index 0000000..e061d63
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides router id.
+ */
+public class RouterIDSubTlv implements PcepValueType {
+
+ /* reference :I-D.ietf-idr-ls-distribution.
+ * 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=[TBD13] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RouterIDSubTlv.class);
+
+ public static final short TYPE = 1000; //TODD:change this TBD13
+ private final short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue.
+ *
+ * @param rawValue raw value
+ * @param hLength length
+ */
+ public RouterIDSubTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns object of Router ID Sub Tlv.
+ *
+ * @param raw value
+ * @param hLength length
+ * @return object of Router ID Sub Tlv
+ */
+ public static RouterIDSubTlv of(final byte[] raw, short hLength) {
+ return new RouterIDSubTlv(raw, hLength);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue value
+ */
+ public byte[] getValue() {
+ return rawValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RouterIDSubTlv) {
+ RouterIDSubTlv other = (RouterIDSubTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ c.writeBytes(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of RouterIDSubTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of RouterIDSubTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ byte[] iOpaqueValue = new byte[hLength];
+ c.readBytes(iOpaqueValue, 0, hLength);
+ return new RouterIDSubTlv(iOpaqueValue, hLength);
+ }
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (byte b : rawValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTLV.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTLV.java
new file mode 100644
index 0000000..09fcafd
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTLV.java
@@ -0,0 +1,144 @@
+/*
+ * Copyright 2015 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 RoutingUniverseTLV identifiers.
+ */
+public class RoutingUniverseTLV implements PcepValueType {
+
+ /*
+ * Reference : draft-dhodylee-pce-pcep-te-data-extn-02, section 9.2.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=[TBD7] | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Identifier |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ *
+ *
+ * +------------+---------------------+
+ | Identifier | Routing Universe |
+ +------------+---------------------+
+ | 0 | L3 packet topology |
+ | 1 | L1 optical topology |
+ +------------+---------------------+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(RoutingUniverseTLV.class);
+
+ public static final short TYPE = 14; // TODO:need to change TBD7
+ public static final short LENGTH = 8;
+
+ private final long rawValue;
+
+ /**
+ * Constructor to initialize raw value.
+ *
+ * @param rawValue raw value
+ */
+ public RoutingUniverseTLV(long rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns object of RoutingUniverseTLV.
+ *
+ * @param raw value
+ * @return object of RoutingUniverseTLV
+ */
+ public static RoutingUniverseTLV of(final long raw) {
+ return new RoutingUniverseTLV(raw);
+ }
+
+ /**
+ * Returns raw value as Identifier.
+ *
+ * @return rawValue Identifier
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RoutingUniverseTLV) {
+ RoutingUniverseTLV other = (RoutingUniverseTLV) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of RoutingUniverseTLV.
+ *
+ * @param c input channel buffer
+ * @return object of RoutingUniverseTLV
+ */
+ public static RoutingUniverseTLV read(ChannelBuffer c) {
+ return RoutingUniverseTLV.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java
new file mode 100644
index 0000000..b05a01a
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2015 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;
+import com.google.common.base.MoreObjects.ToStringHelper;
+
+/**
+ * Provides SharedRiskLinkGroupTlv.
+ */
+public class SharedRiskLinkGroupTlv implements PcepValueType {
+
+ /*
+ * Reference :[I-D.ietf-idr- Group ls-distribution] /3.3.2.5
+ *
+ * 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 =TDB41 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Shared Risk Link Group Value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // ............ //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Shared Risk Link Group Value |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(SharedRiskLinkGroupTlv.class);
+
+ public static final short TYPE = 1096; //TODO:NEED TO HANDLE TDB41
+
+ private final short hLength;
+
+ private final int[] srlgValue;
+
+ /**
+ * Constructor to initialize SRLG value.
+ *
+ * @param srlgValue Shared Risk Link Group Value
+ * @param hLength length
+ */
+ public SharedRiskLinkGroupTlv(int[] srlgValue, short hLength) {
+ this.srlgValue = srlgValue;
+ if (0 == hLength) {
+ this.hLength = (short) ((srlgValue.length) * 4);
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Returns object of SharedRiskLinkGroupTlv.
+ *
+ * @param raw value
+ * @param hLength length
+ * @return object of SharedRiskLinkGroupTlv
+ */
+ public static SharedRiskLinkGroupTlv of(final int[] raw, short hLength) {
+ return new SharedRiskLinkGroupTlv(raw, hLength);
+ }
+
+ /**
+ * Returns SRLG Value.
+ *
+ * @return srlgValue
+ */
+ public int[] getValue() {
+ return srlgValue;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(srlgValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SharedRiskLinkGroupTlv) {
+ SharedRiskLinkGroupTlv other = (SharedRiskLinkGroupTlv) obj;
+ return Objects.equals(this.srlgValue, other.srlgValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(hLength);
+ for (int b : srlgValue) {
+ c.writeInt(b);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of SharedRiskLinkGroupTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of SharedRiskLinkGroupTlv
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) {
+ int iLength = hLength / 4;
+ int[] iSharedRiskLinkGroup = new int[iLength];
+ for (int i = 0; i < iLength; i++) {
+ iSharedRiskLinkGroup[i] = c.readInt();
+ }
+ return new SharedRiskLinkGroupTlv(iSharedRiskLinkGroup, hLength);
+ }
+
+
+ @Override
+ public String toString() {
+ ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
+
+ toStrHelper.add("Type", TYPE);
+ toStrHelper.add("Length", hLength);
+
+ StringBuffer result = new StringBuffer();
+ for (int b : srlgValue) {
+ result.append(String.format("%02X ", b));
+ }
+ toStrHelper.add("Value", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
new file mode 100644
index 0000000..9677e99
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2015 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 StatefulLspDbVerTlv.
+ */
+public class StatefulLspDbVerTlv implements PcepValueType {
+
+ /* LSP-DB-VERSION TLV format
+ *
+ * Reference : Optimizations of Label Switched Path State Synchronization Procedures
+ for a Stateful PCE draft-ietf-pce-stateful-sync-optimizations-02
+ *
+ *
+
+ 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=23 | Length=8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP State DB Version |
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulLspDbVerTlv.class);
+
+ public static final short TYPE = 23;
+ public static final short LENGTH = 8;
+ private final long rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue value
+ */
+ public StatefulLspDbVerTlv(final long rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns object of StatefulLspDbVerTlv.
+ *
+ * @param raw is LSP State DB Version
+ * @return object of StatefulLspDbVerTlv
+ */
+ public static StatefulLspDbVerTlv of(final long raw) {
+ return new StatefulLspDbVerTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns LSP State DB Version.
+ *
+ * @return rawValue value
+ */
+ public long getLong() {
+ return rawValue;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulLspDbVerTlv) {
+ StatefulLspDbVerTlv other = (StatefulLspDbVerTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeLong(rawValue);
+ return c.writerIndex();
+ }
+
+ /**
+ * Reads the channel buffer and returns object of StatefulLspDbVerTlv.
+ *
+ * @param c input channel buffer
+ * @return object of StatefulLspDbVerTlv
+ */
+ public static StatefulLspDbVerTlv read(ChannelBuffer c) {
+ return StatefulLspDbVerTlv.of(c.readLong());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
new file mode 100644
index 0000000..56fc4de
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
@@ -0,0 +1,262 @@
+/*
+ * Copyright 2015 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 StatefulPceCapabilityTlv.
+ */
+public class StatefulPceCapabilityTlv implements PcepValueType {
+
+ /* STATEFUL-PCE-CAPABILITY TLV format
+ *
+ * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
+
+ 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=16 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |D|T|I|S|U|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulPceCapabilityTlv.class);
+
+ public static final short TYPE = 16;
+ public static final short LENGTH = 4;
+ public static final byte UFLAG_SET = 0x01;
+ public static final byte SFLAG_SET = 0x02;
+ public static final byte IFLAG_SET = 0x04;
+ public static final byte TFLAG_SET = 0x08;
+ public static final byte DFLAG_SET = 0x10;
+ public static final int SET = 1;
+
+ private final int rawValue;
+ private final boolean bDFlag;
+ private final boolean bTFlag;
+ private final boolean bIFlag;
+ private final boolean bSFlag;
+ private final boolean bUFlag;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param rawValue Flags
+ */
+ public StatefulPceCapabilityTlv(int rawValue) {
+ this.rawValue = rawValue;
+ isRawValueSet = true;
+ this.bUFlag = (rawValue & UFLAG_SET) == UFLAG_SET ? true : false;
+ this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET ? true : false;
+ this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET ? true : false;
+ this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET ? true : false;
+ this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET ? true : false;
+ }
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param bDFlag D-flag
+ * @param bTFlag T-flag
+ * @param bIFlag I-flag
+ * @param bSFlag S-flag
+ * @param bUFlag U-flag
+ */
+ public StatefulPceCapabilityTlv(boolean bDFlag, boolean bTFlag, boolean bIFlag, boolean bSFlag, boolean bUFlag) {
+ this.bDFlag = bDFlag;
+ this.bTFlag = bTFlag;
+ this.bIFlag = bIFlag;
+ this.bSFlag = bSFlag;
+ this.bUFlag = bUFlag;
+ this.rawValue = 0;
+ isRawValueSet = false;
+ }
+
+ /**
+ * Returns object of StatefulPceCapabilityTlv.
+ *
+ * @param raw value Flags
+ * @return object of StatefulPceCapabilityTlv
+ */
+ public static StatefulPceCapabilityTlv of(final int raw) {
+ return new StatefulPceCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns D-flag.
+ *
+ * @return bDFlag D-flag
+ */
+ public boolean getDFlag() {
+ return bDFlag;
+ }
+
+ /**
+ * Returns T-flag.
+ *
+ * @return bTFlag T-flag
+ */
+ public boolean getTFlag() {
+ return bTFlag;
+ }
+
+ /**
+ * Returns I-flag.
+ *
+ * @return bIFlag I-flag
+ */
+ public boolean getIFlag() {
+ return bIFlag;
+ }
+
+ /**
+ * Returns S-flag.
+ *
+ * @return bSFlag S-flag
+ */
+ public boolean getSFlag() {
+ return bSFlag;
+ }
+
+ /**
+ * Returns U-flag.
+ *
+ * @return bUFlag U-flag
+ */
+ public boolean getUFlag() {
+ return bUFlag;
+ }
+
+ /**
+ * Returns raw value Flags.
+ *
+ * @return rawValue Flags
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulPceCapabilityTlv) {
+ StatefulPceCapabilityTlv other = (StatefulPceCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bDFlag, other.bDFlag) && Objects.equals(this.bTFlag, other.bTFlag)
+ && Objects.equals(this.bIFlag, other.bIFlag) && Objects.equals(this.bSFlag, other.bSFlag)
+ && Objects.equals(this.bUFlag, other.bUFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ int temp = 0;
+ if (bUFlag) {
+ temp = temp | UFLAG_SET;
+ }
+ if (bSFlag) {
+ temp = temp | SFLAG_SET;
+ }
+ if (bIFlag) {
+ temp = temp | IFLAG_SET;
+ }
+ if (bTFlag) {
+ temp = temp | TFLAG_SET;
+ }
+ if (bDFlag) {
+ temp = temp | DFLAG_SET;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of StatefulPceCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of StatefulPceCapabilityTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int temp = c.readInt();
+ boolean bDFlag;
+ boolean bTFlag;
+ boolean bIFlag;
+ boolean bSFlag;
+ boolean bUFlag;
+
+ bUFlag = (temp & UFLAG_SET) == UFLAG_SET ? true : false;
+ bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false;
+ bIFlag = (temp & IFLAG_SET) == IFLAG_SET ? true : false;
+ bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false;
+ bDFlag = (temp & DFLAG_SET) == DFLAG_SET ? true : false;
+
+ return new StatefulPceCapabilityTlv(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("type", TYPE).add("Length", LENGTH).add("DFlag", bDFlag)
+ .add("TFlag", bTFlag).add("IFlag", bIFlag).add("SFlag", bSFlag).add("UFlag", bUFlag).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java
new file mode 100644
index 0000000..80e043e
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2015 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 TEDefaultMetricTlv.
+ */
+public class TEDefaultMetricTlv implements PcepValueType {
+
+ /*
+ * Reference :| [I-D.ietf-idr- ls-distribution] /3.3.2.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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TDB37 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | TE Default Link Metric |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(TEDefaultMetricTlv.class);
+
+ public static final short TYPE = 13400; //TDB37
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue TE Default Link Metric
+ */
+ public TEDefaultMetricTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created TEDefaultMetricTlv object.
+ *
+ * @param raw raw value
+ * @return object of TEDefaultMetricTlv.
+ */
+ public static TEDefaultMetricTlv of(final int raw) {
+ return new TEDefaultMetricTlv(raw);
+ }
+
+ /**
+ * Returns raw value.
+ *
+ * @return rawValue TE Default Link Metric
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TEDefaultMetricTlv) {
+ TEDefaultMetricTlv other = (TEDefaultMetricTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TEDefaultMetricTlv.
+ *
+ * @param c input channel buffer
+ * @return object of TEDefaultMetricTlv
+ */
+ public static TEDefaultMetricTlv read(ChannelBuffer c) {
+ return TEDefaultMetricTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
new file mode 100644
index 0000000..98113d1
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
@@ -0,0 +1,290 @@
+/*
+ * Copyright 2015 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.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TELinkAttributesTlv.
+ */
+public class TELinkAttributesTlv implements PcepValueType {
+
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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=[TBD27] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Link Attributes Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TELinkAttributesTlv.class);
+
+ public static final short TYPE = 1897; //TODD:change this TBD27
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llLinkAttributesSubTLVs;
+
+ /**
+ * Constructor to initialize Link Attributes Sub TLVs.
+ *
+ * @param llLinkAttributesSubTLVs linked list of PcepValueType
+ */
+ public TELinkAttributesTlv(LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
+ this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs;
+
+ }
+
+ /**
+ * Returns object of TE Link Attributes TLV.
+ *
+ * @param llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
+ * @return object of TELinkAttributesTlv
+ */
+ public static TELinkAttributesTlv of(final LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
+ return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
+ }
+
+ /**
+ * Returns linked list of Link Attribute of Sub TLV.
+ *
+ * @return llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
+ */
+ public LinkedList<PcepValueType> getllLinkAttributesSubTLVs() {
+ return llLinkAttributesSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llLinkAttributesSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TELinkAttributesTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TELinkAttributesTlv other = (TELinkAttributesTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.iterator();
+ countObjSubTlv = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.size();
+ countOtherSubTlv = other.llLinkAttributesSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llLinkAttributesSubTLVs.contains(subTlv),
+ other.llLinkAttributesSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ if (null == tlv) {
+ log.debug("TLV is null from subTlv list");
+ continue;
+ }
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, hLength);
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TE Link Attributes TLV.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of TELinkAttributesTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<PcepValueType>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+ switch (hType) {
+
+ case IPv4TERouterIdOfLocalNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofLocalNodeTlv.TYPE:
+ byte[] ipv6LValue = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6LValue, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6LValue);
+ break;
+ case IPv4TERouterIdOfRemoteNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfRemoteNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofRemoteNodeTlv.TYPE:
+ byte[] ipv6RValue = new byte[IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6RValue, 0, IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofRemoteNodeTlv(ipv6RValue);
+ break;
+ case LinkLocalRemoteIdentifiersTlv.TYPE:
+ tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
+ break;
+ case AdministrativeGroupTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new AdministrativeGroupTlv(iValue);
+ break;
+ case MaximumLinkBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new MaximumLinkBandwidthTlv(iValue);
+ break;
+ case MaximumReservableLinkBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new MaximumReservableLinkBandwidthTlv(iValue);
+ break;
+ case UnreservedBandwidthTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new UnreservedBandwidthTlv(iValue);
+ break;
+ case TEDefaultMetricTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new TEDefaultMetricTlv(iValue);
+ break;
+ case LinkProtectionTypeTlv.TYPE:
+ tlv = LinkProtectionTypeTlv.read(tempCb);
+ break;
+ case MPLSProtocolMaskTlv.TYPE:
+ byte cValue = tempCb.readByte();
+ tlv = new MPLSProtocolMaskTlv(cValue);
+ break;
+ case IGPMetricTlv.TYPE:
+ tlv = IGPMetricTlv.read(tempCb, length);
+ break;
+ case SharedRiskLinkGroupTlv.TYPE:
+ tlv = SharedRiskLinkGroupTlv.read(tempCb, length);
+ break;
+ case OpaqueLinkAttributeTlv.TYPE:
+ tlv = OpaqueLinkAttributeTlv.read(tempCb, length);
+ break;
+ case LinkNameTlv.TYPE:
+ tlv = LinkNameTlv.read(tempCb, length);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+ llLinkAttributesSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+
+ return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
+ .add("LinkAttributesSubTLVs", llLinkAttributesSubTLVs).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTLV.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTLV.java
new file mode 100644
index 0000000..89601be
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTLV.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2015 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.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides TE Link Descriptors TLV.
+ */
+public class TELinkDescriptorsTLV implements PcepValueType {
+
+ /*
+ * Reference: PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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=[TBD14] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Link Descriptor Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TELinkDescriptorsTLV.class);
+
+ public static final short TYPE = 1070; //TODD:change this TBD14
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llLinkDescriptorsSubTLVs;
+
+ /**
+ * Constructor to initialize llLinkDescriptorsSubTLVs.
+ *
+ * @param llLinkDescriptorsSubTLVs of PcepValueType
+ */
+ public TELinkDescriptorsTLV(LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
+ this.llLinkDescriptorsSubTLVs = llLinkDescriptorsSubTLVs;
+ }
+
+ /**
+ * Returns object of TELinkDescriptorsTLV.
+ *
+ * @param llLinkDescriptorsSubTLVs of PcepValueType
+ * @return object of TELinkDescriptorsTLV
+ */
+ public static TELinkDescriptorsTLV of(final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
+ return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs);
+ }
+
+ /**
+ * Returns linked list of Link Attribute of Sub TLV.
+ *
+ * @return llLinkDescriptorsSubTLVs linked list of Link Attribute of Sub TLV
+ */
+ public LinkedList<PcepValueType> getllLinkDescriptorsSubTLVs() {
+ return llLinkDescriptorsSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llLinkDescriptorsSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TELinkDescriptorsTLV) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TELinkDescriptorsTLV other = (TELinkDescriptorsTLV) obj;
+ Iterator<PcepValueType> objListIterator = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.iterator();
+ countObjSubTlv = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.size();
+ countOtherSubTlv = other.llLinkDescriptorsSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llLinkDescriptorsSubTLVs.contains(subTlv),
+ other.llLinkDescriptorsSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, hLength);
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TELinkDescriptorsTLV.
+ *
+ * @param c input channel buffer
+ * @param length length
+ * @return object of TELinkDescriptorsTLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<PcepValueType>();
+
+ ChannelBuffer tempCb = c.readBytes(length - TLV_HEADER_LENGTH);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short hLength = tempCb.readShort();
+ log.debug("sub Tlv Length" + hLength);
+ switch (hType) {
+
+ case LinkLocalRemoteIdentifiersTlv.TYPE:
+ tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
+ break;
+ case IPv4InterfaceAddressTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4InterfaceAddressTlv(iValue);
+ break;
+ case IPv4NeighborAddressTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4NeighborAddressTlv(iValue);
+ break;
+ case IPv6InterfaceAddressTlv.TYPE:
+ byte[] ipv6Value = new byte[IPv6InterfaceAddressTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6Value, 0, IPv6InterfaceAddressTlv.VALUE_LENGTH);
+ tlv = new IPv6InterfaceAddressTlv(ipv6Value);
+ break;
+ case IPv6NeighborAddressTlv.TYPE:
+ byte[] ipv6NeighborAdd = new byte[IPv6NeighborAddressTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6NeighborAdd, 0, IPv6NeighborAddressTlv.VALUE_LENGTH);
+ tlv = new IPv6NeighborAddressTlv(ipv6NeighborAdd);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type:" + hType);
+ }
+
+ // Check for the padding
+ int pad = hLength % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+ llLinkDescriptorsSubTLVs.add(tlv);
+
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
+ .add("LinkDescriptorsSubTLVs", llLinkDescriptorsSubTLVs).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
new file mode 100644
index 0000000..233c260
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2015 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.Iterator;
+import java.util.LinkedList;
+import java.util.ListIterator;
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+public class TENodeAttributesTlv implements PcepValueType {
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ *
+ 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=[TBD20] | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Node Attributes Sub-TLVs (variable) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TENodeAttributesTlv.class);
+
+ public static final short TYPE = 1267; //TODD:change this TBD20
+ public short hLength;
+
+ public static final int TLV_HEADER_LENGTH = 4;
+ // LinkDescriptors Sub-TLVs (variable)
+ private LinkedList<PcepValueType> llNodeAttributesSubTLVs;
+
+ /**
+ * Constructor to initialize llNodeAttributesSubTLVs.
+ *
+ * @param llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
+ */
+ public TENodeAttributesTlv(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
+ this.llNodeAttributesSubTLVs = llNodeAttributesSubTLVs;
+ }
+
+ /**
+ * Returns object of TENodeAttributesTlv.
+ *
+ * @param llNodeAttributesSubTLVs LinkedList of PcepValueType
+ * @return object of TENodeAttributesTlv
+ */
+ public static TENodeAttributesTlv of(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
+ return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
+ }
+
+ /**
+ * Returns Node Attributes Sub-TLVs.
+ *
+ * @return llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
+ */
+ public LinkedList<PcepValueType> getllNodeAttributesSubTLVs() {
+ return llNodeAttributesSubTLVs;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(llNodeAttributesSubTLVs.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ /*
+ * Here we have a list of Tlv so to compare each sub tlv between the object
+ * we have to take a list iterator so one by one we can get each sub tlv object
+ * and can compare them.
+ * it may be possible that the size of 2 lists is not equal so we have to first check
+ * the size, if both are same then we should check for the subtlv objects otherwise
+ * we should return false.
+ */
+ if (obj instanceof TENodeAttributesTlv) {
+ int countObjSubTlv = 0;
+ int countOtherSubTlv = 0;
+ boolean isCommonSubTlv = true;
+ TENodeAttributesTlv other = (TENodeAttributesTlv) obj;
+ Iterator<PcepValueType> objListIterator = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.iterator();
+ countObjSubTlv = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.size();
+ countOtherSubTlv = other.llNodeAttributesSubTLVs.size();
+ if (countObjSubTlv != countOtherSubTlv) {
+ return false;
+ } else {
+ while (objListIterator.hasNext() && isCommonSubTlv) {
+ PcepValueType subTlv = objListIterator.next();
+ isCommonSubTlv = Objects.equals(llNodeAttributesSubTLVs.contains(subTlv),
+ other.llNodeAttributesSubTLVs.contains(subTlv));
+ }
+ return isCommonSubTlv;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int tlvStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+
+ ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+
+ tlv.write(c);
+
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ c.writeByte((byte) 0);
+ }
+ }
+ }
+
+ hLength = (short) (c.writerIndex() - tlvStartIndex);
+ c.setShort(tlvLenIndex, hLength);
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of TENodeAttributesTlv.
+ *
+ * @param c input channel buffer
+ * @param hLength length
+ * @return object of TENodeAttributesTlv
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<PcepValueType>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength - TLV_HEADER_LENGTH);
+
+ while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
+ PcepValueType tlv;
+ short hType = tempCb.readShort();
+ int iValue = 0;
+ short length = tempCb.readShort();
+ switch (hType) {
+
+ case NodeFlagBitsTlv.TYPE:
+ byte cValue = tempCb.readByte();
+ tlv = new NodeFlagBitsTlv(cValue);
+ break;
+ case OpaqueNodeAttributeTlv.TYPE:
+ tlv = OpaqueNodeAttributeTlv.read(tempCb, length);
+ break;
+ case NodeNameTlv.TYPE:
+ tlv = NodeNameTlv.read(tempCb, length);
+ break;
+ case ISISAreaIdentifierTlv.TYPE:
+ tlv = ISISAreaIdentifierTlv.read(tempCb, length);
+ break;
+ case IPv4TERouterIdOfLocalNodeTlv.TYPE:
+ iValue = tempCb.readInt();
+ tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
+ break;
+ case IPv6TERouterIdofLocalNodeTlv.TYPE:
+ byte[] ipv6Value = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
+ tempCb.readBytes(ipv6Value, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
+ tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6Value);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+
+ // Check for the padding
+ int pad = length % 4;
+ if (0 < pad) {
+ pad = 4 - pad;
+ if (pad <= tempCb.readableBytes()) {
+ tempCb.skipBytes(pad);
+ }
+ }
+
+ llNodeAttributesSubTLVs.add(tlv);
+ }
+
+ if (0 < tempCb.readableBytes()) {
+
+ throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
+ }
+ return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
+ .add("NodeAttributesSubTLVs", llNodeAttributesSubTLVs).toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java
new file mode 100644
index 0000000..fa477cf
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java
@@ -0,0 +1,178 @@
+/*
+ * Copyright 2015 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 TED Capability Tlv.
+ */
+public class TedCapabilityTlv implements PcepValueType {
+
+ /*
+ * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
+ * 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=[TBD5] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Flags |R|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(TedCapabilityTlv.class);
+
+ public static final short TYPE = 132; //TODO: need to change this TBD5
+ public static final short LENGTH = 4;
+ public static final int SET = 1;
+ public static final byte RFLAG_CHECK = 0x01;
+
+ private final boolean bRFlag;
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Flags
+ */
+ public TedCapabilityTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+ int temp = rawValue;
+ temp = temp & RFLAG_CHECK;
+ if (temp == SET) {
+ this.bRFlag = true;
+ } else {
+ this.bRFlag = false;
+ }
+
+ }
+
+ /**
+ * Constructor to initialize bRFlag.
+ *
+ * @param bRFlag R-flag
+ */
+ public TedCapabilityTlv(boolean bRFlag) {
+ this.bRFlag = bRFlag;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns R-flag.
+ *
+ * @return bRFlag
+ */
+ public boolean getbRFlag() {
+ return bRFlag;
+ }
+
+ /**
+ * Returns an object of TedCapabilityTlv.
+ *
+ * @param raw value Flags
+ * @return object of TedCapabilityTlv
+ */
+ public static TedCapabilityTlv of(final int raw) {
+ return new TedCapabilityTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ public int getInt() {
+ return rawValue;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ if (isRawValueSet) {
+ return Objects.hash(rawValue);
+ } else {
+ return Objects.hash(bRFlag);
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TedCapabilityTlv) {
+ TedCapabilityTlv other = (TedCapabilityTlv) obj;
+ if (isRawValueSet) {
+ return Objects.equals(this.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bRFlag, other.bRFlag);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ int temp = 0;
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ if (isRawValueSet) {
+ c.writeInt(rawValue);
+ } else {
+ if (bRFlag) {
+ temp = temp | RFLAG_CHECK;
+ }
+ c.writeInt(temp);
+ }
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of TedCapabilityTlv.
+ *
+ * @param c input channel buffer
+ * @return object of TedCapabilityTlv
+ */
+ public static TedCapabilityTlv read(ChannelBuffer c) {
+ return TedCapabilityTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}
diff --git a/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java
new file mode 100644
index 0000000..71006f9
--- /dev/null
+++ b/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2015 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 Unreserved Bandwidth Tlv.
+ */
+public class UnreservedBandwidthTlv implements PcepValueType {
+
+ /* Reference :[RFC5305]/3.6
+ 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=[TDB36] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Unreserved Bandwidth |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(UnreservedBandwidthTlv.class);
+
+ public static final short TYPE = 11; //TDB36
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Unreserved Bandwidth
+ */
+ public UnreservedBandwidthTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created UnreservedBandwidthTlv object.
+ *
+ * @param raw as Unreserved Bandwidth
+ * @return object of UnreservedBandwidthTlv
+ */
+ public static UnreservedBandwidthTlv of(final int raw) {
+ return new UnreservedBandwidthTlv(raw);
+ }
+
+ /**
+ * Returns Unreserved Bandwidth.
+ *
+ * @return rawValue Unreserved Bandwidth
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ @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(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof UnreservedBandwidthTlv) {
+ UnreservedBandwidthTlv other = (UnreservedBandwidthTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads byte stream from channel buffer and returns object of UnreservedBandwidthTlv.
+ *
+ * @param c input channel buffer
+ * @return object of UnreservedBandwidthTlv
+ */
+ public static UnreservedBandwidthTlv read(ChannelBuffer c) {
+ return UnreservedBandwidthTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
+ .toString();
+ }
+}