aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types')
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java160
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java138
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java150
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java180
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java181
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java179
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java222
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java179
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java171
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java171
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java246
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java200
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java143
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java190
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java163
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java233
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java135
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java155
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java159
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java164
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java194
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java83
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java105
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java103
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java107
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java99
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java113
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java102
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java131
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java224
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java46
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java160
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java165
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java161
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java156
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java220
-rwxr-xr-xframework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java55
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java250
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java154
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java147
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java167
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java324
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java210
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java142
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java269
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java216
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java159
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java137
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java292
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java251
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java250
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java181
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java136
-rw-r--r--framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java20
71 files changed, 11470 insertions, 0 deletions
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java
new file mode 100644
index 00000000..62ed4e7f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AdministrativeGroupTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java
new file mode 100644
index 00000000..3f213191
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/AutonomousSystemTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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 Autonomous-System-Tlv which contains opaque value (32 Bit AS Number).
+ */
+public class AutonomousSystemTlv implements PcepValueType {
+
+ /* Reference :RFC3209
+ * 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=[TBD10] | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit AS Number) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
+
+ public static final short TYPE = 100; //TODD:change this TBD10
+ public static final short LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize rawValue.
+ *
+ * @param rawValue Autonomous-System-Tlv
+ */
+ public AutonomousSystemTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Returns newly created AutonomousSystemTlv object.
+ *
+ * @param raw value of opaque.
+ * @return object of Autonomous-System-Tlv
+ */
+ public static AutonomousSystemTlv of(final int raw) {
+ return new AutonomousSystemTlv(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 AutonomousSystemTlv) {
+ AutonomousSystemTlv other = (AutonomousSystemTlv) 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 AutonomousSystemTlv.
+ *
+ * @param c input channel buffer
+ * @return object of Autonomous-System-Tlv
+ */
+ public static AutonomousSystemTlv read(ChannelBuffer c) {
+ return AutonomousSystemTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("TYPE", TYPE)
+ .add("Length", LENGTH)
+ .add("value", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java
new file mode 100644
index 00000000..4981649f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/BGPLSidentifierTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
new file mode 100644
index 00000000..40f89f4c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ErrorObjListWithOpen.java
@@ -0,0 +1,160 @@
+/*
+ * 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.LinkedList;
+import java.util.ListIterator;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepErrorObject;
+import org.onosproject.pcepio.protocol.PcepOpenObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide the error object list with open object.
+ */
+public class ErrorObjListWithOpen {
+ //errorObjList is mandatory
+ private LinkedList<PcepErrorObject> llerrorObjList;
+ // openObject is optional
+ private PcepOpenObject openObject;
+ // flag to check if open object is set or not
+ private boolean isOpenObjectSet;
+ protected static final Logger log = LoggerFactory.getLogger(ErrorObjListWithOpen.class);
+
+ /**
+ * Constructor to initialize Error and OPEN object.
+ *
+ * @param errObj ERROR object list
+ * @param openObj OPEN object
+ */
+ public ErrorObjListWithOpen(LinkedList<PcepErrorObject> errObj, PcepOpenObject openObj) {
+ this.llerrorObjList = errObj;
+ this.openObject = openObj;
+ if (openObj != null) {
+ isOpenObjectSet = true;
+ } else {
+ isOpenObjectSet = false;
+ }
+ }
+
+ /**
+ * Constructor to initialize ERROR Object.
+ *
+ * @param errObj ERROR Object list
+ */
+ public ErrorObjListWithOpen(LinkedList<PcepErrorObject> errObj) {
+ this.llerrorObjList = errObj;
+ this.openObject = null;
+ isOpenObjectSet = false;
+ }
+
+ /**
+ * Return list of Error Types.
+ *
+ * @return error types list
+ */
+ public LinkedList<Integer> getErrorType() {
+ LinkedList<Integer> errorType = new LinkedList<>();
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ int error;
+ PcepErrorObject errorObj;
+ while (errObjListIterator.hasNext()) {
+ errorObj = errObjListIterator.next();
+ error = errorObj.getErrorType();
+ errorType.add(error);
+ }
+ }
+ return errorType;
+ }
+
+ /**
+ * Return list of Error Values.
+ *
+ * @return error values list
+ */
+ public LinkedList<Integer> getErrorValue() {
+ LinkedList<Integer> errorValue = new LinkedList<>();
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ int error;
+ PcepErrorObject errorObj;
+ while (errObjListIterator.hasNext()) {
+ errorObj = errObjListIterator.next();
+ error = errorObj.getErrorValue();
+ errorValue.add(error);
+ }
+ }
+ return errorValue;
+ }
+
+ /**
+ * Checks whether ERROR Object list is empty or not.
+ *
+ * @return true if ERROR Object list is empty otherwise false
+ */
+ public boolean isErrorObjListWithOpenPresent() {
+ // ( <error-obj-list> [<Open>]
+ // At least in this case <error-obj-list> should be present.
+ return !this.llerrorObjList.isEmpty();
+ }
+
+ /**
+ * Write Error Object List and Open Object to channel buffer.
+ *
+ * @param cb output channel buffer
+ * @return length of written Error object list with open
+ * @throws PcepParseException when mandatory fields are not set
+ */
+ public int write(ChannelBuffer cb) throws PcepParseException {
+ int iLenStartIndex = cb.writerIndex();
+ boolean bIsErrObjListFound = false;
+
+ //<error-obj-list> is mandatory , if not present throw exception.
+ if (llerrorObjList != null) {
+ ListIterator<PcepErrorObject> errObjListIterator = llerrorObjList.listIterator();
+ while (errObjListIterator.hasNext()) {
+ errObjListIterator.next().write(cb);
+ bIsErrObjListFound = true;
+ }
+ }
+
+ if (!bIsErrObjListFound) {
+ throw new PcepParseException("<error-obj-list> is mandatory.");
+ }
+
+ //Open Object is optional , if present write.
+ if (openObject != null) {
+ openObject.write(cb);
+ }
+
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("ErrorObjList", llerrorObjList)
+ .add("Open", openObject)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
new file mode 100644
index 00000000..212aa3d3
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/GmplsCapabilityTlv.java
@@ -0,0 +1,138 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IGPMetricTlv.java
new file mode 100644
index 00000000..07cfea7f
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IGPMetricTlv) {
+ IGPMetricTlv other = (IGPMetricTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java
new file mode 100644
index 00000000..d1a30157
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4InterfaceAddressTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java
new file mode 100644
index 00000000..0f98777f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4NeighborAddressTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
new file mode 100644
index 00000000..031b5db6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4SubObject.java
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+
+/**
+ * @author b00295750
+ *
+ */
+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 Sub Object.
+ */
+public class IPv4SubObject implements PcepValueType {
+
+ /*Reference : RFC 4874: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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |L| Type | Length | IPv4 address (4 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 address (continued) | Prefix Length | Resvd |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(IPv4SubObject.class);
+
+ public static final byte TYPE = 0x01;
+ public static final byte LENGTH = 8;
+ public static final byte VALUE_LENGTH = 6;
+ public static final byte OBJ_LENGTH = 8;
+ public static final byte LBIT = 0;
+ public static final int SHIFT_LBIT_POSITION = 7;
+ private int ipAddress;
+ private byte prefixLen;
+ private byte resvd;
+
+ /**
+ * Constructor to initialize ipv4 address.
+ *
+ * @param ipAddr ipv4 address
+ */
+ public IPv4SubObject(int ipAddr) {
+ this.ipAddress = ipAddr;
+ }
+
+ /**
+ * constructor to initialize ipAddress, prefixLen and resvd.
+ *
+ * @param ipAddress ipv4 address
+ * @param prefixLen prefix length
+ * @param resvd reserved flags value
+ */
+ public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) {
+ this.ipAddress = ipAddress;
+ this.prefixLen = prefixLen;
+ this.resvd = resvd;
+ }
+
+ /**
+ * Returns a new instance of IPv4SubObject.
+ *
+ * @param ipAddress ipv4 address
+ * @param prefixLen prefix length
+ * @param resvd reserved flags value
+ * @return object of IPv4SubObject
+ */
+ public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) {
+ return new IPv4SubObject(ipAddress, prefixLen, resvd);
+ }
+
+ /**
+ * Returns prefixLen of IPv4 IP address.
+ *
+ * @return byte value of rawValue
+ */
+ public byte getPrefixLen() {
+ return prefixLen;
+ }
+
+ /**
+ * Returns value of IPv4 IP address.
+ *
+ * @return int value of ipv4 address
+ */
+ public int getIpAddress() {
+ return ipAddress;
+ }
+
+ @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(ipAddress, prefixLen, resvd);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv4SubObject) {
+ IPv4SubObject other = (IPv4SubObject) obj;
+ return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen)
+ && Objects.equals(this.resvd, other.resvd);
+ }
+ return false;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPv4SubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of IPv4SubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int ipAddess = c.readInt();
+ byte prefixLen = c.readByte();
+ byte resvd = c.readByte();
+ return new IPv4SubObject(ipAddess, prefixLen, resvd);
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ byte bValue = LBIT;
+ bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
+ bValue = (byte) (bValue | TYPE);
+ c.writeByte(bValue);
+ c.writeByte(OBJ_LENGTH);
+ c.writeInt(ipAddress);
+ c.writeByte(prefixLen);
+ c.writeByte(resvd);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("IPv4Address", ipAddress)
+ .add("PrefixLength", prefixLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java
new file mode 100644
index 00000000..2abf4cdc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfLocalNodeTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java
new file mode 100644
index 00000000..21e09890
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv4TERouterIdOfRemoteNodeTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6InterfaceAddressTlv.java
new file mode 100644
index 00000000..62a5588d
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6InterfaceAddressTlv) {
+ IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6NeighborAddressTlv.java
new file mode 100644
index 00000000..fb9b98ac
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6NeighborAddressTlv) {
+ IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java
new file mode 100644
index 00000000..b3164f26
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6SubObject.java
@@ -0,0 +1,222 @@
+/*
+ * 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.Arrays;
+
+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 Sub Object.
+ */
+public class IPv6SubObject implements PcepValueType {
+
+ /* reference :RFC 4874.
+ Subobject : IPv6 address
+
+ 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 | Length | IPv6 address (16 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv6 address (continued) | Prefix Length | Flags |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Type
+
+ 0x02 IPv6 address
+
+ Length
+
+ The Length contains the total length of the subobject in bytes,
+ including the Type and Length fields. The Length is always 20.
+
+ IPv6 address
+
+ A 128-bit unicast host address.
+
+ Prefix length
+
+ 128
+
+ Flags
+
+ 0x01 Local protection available
+
+ Indicates that the link downstream of this node is
+ protected via a local repair mechanism. This flag can
+ only be set if the Local protection flag was set in the
+ SESSION_ATTRIBUTE object of the corresponding Path
+ message.
+
+ 0x02 Local protection in use
+
+ Indicates that a local repair mechanism is in use to
+ maintain this tunnel (usually in the face of an outage
+ of the link it was previously routed over).
+ */
+ protected static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class);
+
+ public static final short TYPE = 0x02;
+ 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 IPv6SubObject NONE = new IPv6SubObject(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 IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL);
+ public static final IPv6SubObject FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * constructor to initialize rawValue with ipv6 address.
+ *
+ * @param rawValue ipv6 address
+ */
+ public IPv6SubObject(byte[] rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * To create instance of IPv6SubObject.
+ *
+ * @param raw byte array of ipv6 address
+ * @return object of IPv6SubObject
+ */
+ public static IPv6SubObject 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 IPv6SubObject(raw);
+ }
+
+ /**
+ * Returns value of IPv6 Sub Object.
+ *
+ * @return byte array of ipv6 address
+ */
+ 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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6SubObject) {
+ IPv6SubObject other = (IPv6SubObject) obj;
+ return Arrays.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 IPv6SubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of IPv6SubObject
+ */
+ public static IPv6SubObject read20Bytes(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return IPv6SubObject.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofLocalNodeTlv.java
new file mode 100644
index 00000000..f10d5e31
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofLocalNodeTlv) {
+ IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/IPv6TERouterIdofRemoteNodeTlv.java
new file mode 100644
index 00000000..bf1d475e
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) {
+ IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/ISISAreaIdentifierTlv.java
new file mode 100644
index 00000000..648dbb66
--- /dev/null
+++ b/framework/src/onos/protocols/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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.java
new file mode 100644
index 00000000..5b1c2438
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LabelSubObject.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;
+
+/**
+ * LabelSubObject: Provides a LabelSubObject.
+ */
+public class LabelSubObject implements PcepValueType {
+
+ /* Reference : RFC 3209
+ * LABEL Sub Object
+ *
+ 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 | Length | Flags | C-Type |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Contents of Label Object |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(LabelSubObject.class);
+
+ public static final short TYPE = 0x03;
+ public static final short LENGTH = 8;
+ private final byte flags;
+ private final byte cType;
+ private final int contents;
+
+ /**
+ * constructor to initialize parameters for LabelSubObject.
+ *
+ * @param flags flags
+ * @param cType C-Type
+ * @param contents Contents of label object
+ */
+ public LabelSubObject(byte flags, byte cType, int contents) {
+ this.flags = flags;
+ this.cType = cType;
+ this.contents = contents;
+ }
+
+ /**
+ * Return an object of LabelSubObject.
+ *
+ * @param flags flags
+ * @param cType C-type
+ * @param contents contents of label objects
+ * @return object of LabelSubObject
+ */
+ public static LabelSubObject of(byte flags, byte cType, int contents) {
+ return new LabelSubObject(flags, cType, contents);
+ }
+
+ /**
+ * Returns Flags.
+ *
+ * @return flags
+ */
+ public byte getFlags() {
+ return flags;
+ }
+
+ /**
+ * Returns cType.
+ *
+ * @return cType
+ */
+ public byte getCtype() {
+ return cType;
+ }
+
+ /**
+ * Returns contents.
+ *
+ * @return contents
+ */
+ public int getContents() {
+ return contents;
+ }
+
+ @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(flags, cType, contents);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof LabelSubObject) {
+ LabelSubObject other = (LabelSubObject) obj;
+ return Objects.equals(this.flags, other.flags) && Objects.equals(this.cType, other.cType)
+ && Objects.equals(this.contents, other.contents);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeByte(flags);
+ c.writeByte(cType);
+ c.writeByte(contents);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of LabelSubObject.
+ *
+ * @param c type of channel buffer
+ * @return object of LabelSubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ byte flags = c.readByte();
+ byte cType = c.readByte();
+ int contents = c.readInt();
+ return new LabelSubObject(flags, cType, contents);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("type", TYPE)
+ .add("Length", LENGTH)
+ .add("flags", flags)
+ .add("C-type", cType)
+ .add("contents", contents)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.java
new file mode 100644
index 00000000..5fa0a4c6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkLocalRemoteIdentifiersTlv.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;
+
+/**
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkNameTlv.java
new file mode 100644
index 00000000..aa0f11a7
--- /dev/null
+++ b/framework/src/onos/protocols/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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
new file mode 100644
index 00000000..a802d577
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LinkProtectionTypeTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.java
new file mode 100644
index 00000000..b31dac2c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/LocalTENodeDescriptorsTlv.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 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 (tlv == null) {
+ 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 - TLV_HEADER_LENGTH));
+ 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<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
new file mode 100644
index 00000000..fc0f8771
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MPLSProtocolMaskTlv.java
@@ -0,0 +1,200 @@
+/*
+ * 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 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;
+ this.isRawValueSet = true;
+ this.bLFlag = (rawValue & LFLAG_SET) == LFLAG_SET;
+ this.bRFlag = (rawValue & RFLAG_SET) == RFLAG_SET;
+ }
+
+ /**
+ * 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.rawValue, other.rawValue);
+ } else {
+ return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
+ }
+ }
+ 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;
+
+ bLFlag = (temp & LFLAG_SET) == LFLAG_SET;
+ bRFlag = (temp & RFLAG_SET) == RFLAG_SET;
+
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java
new file mode 100644
index 00000000..db1acf09
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumLinkBandwidthTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java
new file mode 100644
index 00000000..01d08cae
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/MaximumReservableLinkBandwidthTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java
new file mode 100644
index 00000000..6f193384
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv4addressTlv.java
@@ -0,0 +1,143 @@
+/*
+ * 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;
+
+/**
+ * NexthopIPv6addressTlv provides Ipv4 address of next hop.
+ */
+public class NexthopIPv4addressTlv implements PcepValueType {
+
+ /*
+ Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01
+
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 8 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | nexthop IPv4 address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-IPV4-ADDRESS TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class);
+
+ public static final short TYPE = 2; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 8;
+ public static final short VALUE_LENGTH = 4;
+
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize next hop IPv4 address.
+ *
+ * @param rawValue next hop IPv4 address
+ */
+ public NexthopIPv4addressTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Return next hop IPv4 address tlv.
+ *
+ * @param raw of next hop IPv4 address
+ * @return object of NexthopIPv4addressTlv
+ */
+ public static NexthopIPv4addressTlv of(final int raw) {
+ return new NexthopIPv4addressTlv(raw);
+ }
+
+ /**
+ * Returns next hop IPv4 address.
+ *
+ * @return next hop IPv4 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 NexthopIPv4addressTlv) {
+ NexthopIPv4addressTlv other = (NexthopIPv4addressTlv) obj;
+ return Objects.equals(this.rawValue, other.rawValue);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(rawValue);
+ return c.writerIndex() - iStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NexthopIPv4addressTlv.
+ *
+ * @param c type of channel buffer
+ * @return object of NexthopIPv4addressTlv
+ */
+ public static NexthopIPv4addressTlv read(ChannelBuffer c) {
+ return NexthopIPv4addressTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Ipv4Address ", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
new file mode 100644
index 00000000..45bf7ac5
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopIPv6addressTlv.java
@@ -0,0 +1,190 @@
+/*
+ * 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;
+
+/**
+ * NexthopIPv6addressTlv provides Ipv6 address of next hop.
+ */
+public class NexthopIPv6addressTlv implements PcepValueType {
+
+ /*
+ Reference: draft-zhao-pce-pcep-extension-for-pce-controller-01.
+
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 20 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // nexthop IPv6 address (16 bytes) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-IPV6-ADDRESS TLV:
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopIPv6addressTlv.class);
+
+ public static final short TYPE = 100; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 20;
+ public static final short VALUE_LENGTH = 16;
+
+ 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 NexthopIPv6addressTlv NONE = new NexthopIPv6addressTlv(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 NexthopIPv6addressTlv NO_MASK = new NexthopIPv6addressTlv(NO_MASK_VAL);
+ public static final NexthopIPv6addressTlv FULL_MASK = NONE;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize IP address for next hop IPv6 address tlv.
+ *
+ * @param rawValue value of Next hop ipAddress
+ */
+ public NexthopIPv6addressTlv(byte[] rawValue) {
+ log.debug("NexthopIPv6addressTlv");
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Creates next hop IPv6 address tlv.
+ *
+ * @param raw value of Next hop ipAddress
+ * @return object of NexthopIPv6addressTlv
+ */
+ //logic to be checked
+ public static NexthopIPv6addressTlv of(final byte[] raw) {
+ //check NONE_VAL
+ boolean bFoundNONE = true;
+ //value starts from 3rd byte.
+ for (int i = 5; 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 = 5; i < 20; ++i) {
+ if (0xFF != raw[i]) {
+ bFoundNoMask = false;
+ }
+ }
+ if (bFoundNoMask) {
+ return NO_MASK;
+ }
+ return new NexthopIPv6addressTlv(raw);
+ }
+
+ /**
+ * Returns next hop IPv6 address.
+ *
+ * @return next hop IPv6 address
+ */
+ 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 NexthopIPv6addressTlv) {
+ NexthopIPv6addressTlv other = (NexthopIPv6addressTlv) obj;
+ return Objects.equals(this.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 NexthopIPv6addressTlv.
+ *
+ * @param c type of channel buffer
+ * @return object of NexthopIPv6addressTlv
+ */
+ public static NexthopIPv6addressTlv read(ChannelBuffer c) {
+ byte[] yTemp = new byte[20];
+ c.readBytes(yTemp, 0, 20);
+ return NexthopIPv6addressTlv.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("IpAddress", result);
+
+ return toStrHelper.toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
new file mode 100644
index 00000000..fb4ceeff
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NexthopUnnumberedIPv4IDTlv.java
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+/**
+ * NexthopUnnumberedIPv4IDTlv provides the next node's ID and Interface ID.
+ */
+public class NexthopUnnumberedIPv4IDTlv implements PcepValueType {
+
+ /*
+ Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01.
+
+ 0 1 2 3
+ 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Type=TBD | Length = 12 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Node-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Interface ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NEXTHOP-UNNUMBERED-IPV4-ID TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(NexthopUnnumberedIPv4IDTlv.class);
+
+ public static final short TYPE = 1; //to be defined
+ //Length is header + value
+ public static final short LENGTH = 12;
+
+ private final int nodeID;
+ private final int interfaceID;
+
+ /**
+ * constructor to initialize nodeID and interfaceID.
+ *
+ * @param nodeID node ID
+ * @param interfaceID interface ID
+ */
+ public NexthopUnnumberedIPv4IDTlv(int nodeID, int interfaceID) {
+ this.nodeID = nodeID;
+ this.interfaceID = interfaceID;
+ }
+
+ /**
+ * Returns new object of NexthopUnnumberedIPv4IDTlv.
+ *
+ * @param nodeID node ID
+ * @param interfaceID interface ID
+ * @return NexthopUnnumberedIPv4IDTlv
+ */
+ public static NexthopUnnumberedIPv4IDTlv of(int nodeID, int interfaceID) {
+ return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
+ }
+
+ /**
+ * Returns Node Id.
+ *
+ * @return node ID
+ */
+ public int getNodeID() {
+ return nodeID;
+ }
+
+ /**
+ * Returns Interface Id.
+ *
+ * @return interface ID
+ */
+ public int getInterfaceID() {
+ return interfaceID;
+ }
+
+ @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(nodeID, interfaceID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof NexthopUnnumberedIPv4IDTlv) {
+ NexthopUnnumberedIPv4IDTlv other = (NexthopUnnumberedIPv4IDTlv) obj;
+ return Objects.equals(this.nodeID, other.nodeID) && Objects.equals(this.interfaceID, other.interfaceID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ c.writeInt(nodeID);
+ c.writeInt(interfaceID);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv.
+ *
+ * @param cb type of channel buffer
+ * @return object of NexthopUnnumberedIPv4IDTlv
+ */
+ public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) {
+ int nodeID = cb.readInt();
+ int interfaceID = cb.readInt();
+ return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("NodeId", nodeID)
+ .add("InterfaceId", interfaceID)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java
new file mode 100644
index 00000000..019daa14
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeFlagBitsTlv.java
@@ -0,0 +1,233 @@
+/*
+ * 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;
+ this.bOFlag = (rawValue & OFLAG_SET) == OFLAG_SET;
+ this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
+ this.bEFlag = (rawValue & EFLAG_SET) == EFLAG_SET;
+ this.bBFlag = (rawValue & BFLAG_SET) == BFLAG_SET;
+ }
+
+ /**
+ * 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.rawValue, other.rawValue);
+ } else {
+ 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);
+ }
+ }
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/NodeNameTlv.java
new file mode 100644
index 00000000..e535a358
--- /dev/null
+++ b/framework/src/onos/protocols/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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.java
new file mode 100644
index 00000000..2233ab0d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OSPFareaIDsubTlv.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 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueLinkAttributeTlv.java
new file mode 100644
index 00000000..1af332eb
--- /dev/null
+++ b/framework/src/onos/protocols/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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/OpaqueNodeAttributeTlv.java
new file mode 100644
index 00000000..26e8c8bf
--- /dev/null
+++ b/framework/src/onos/protocols/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 OpaqueNodeAttributeTlv) {
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
new file mode 100644
index 00000000..86ad042a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathKeySubObject.java
@@ -0,0 +1,159 @@
+/*
+ * 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;
+
+/**
+ * Path Key SubObject: When a PCC needs to expand a path-key in order to expand a CPS, it
+ * issues a Path Computation Request (PCReq) to the PCE identified in
+ * the PKS in the RSVP-TE ERO that it is processing. The PCC supplies
+ * the PKS to be expanded in a PATH-KEY SubObject in the PCReq message.
+ */
+public class PathKeySubObject implements PcepValueType {
+
+ /*
+ Pathkey subobject(RFC 5520):
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |L| Type | Length | Path-Key |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | PCE ID (4 bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class);
+
+ public static final byte TYPE = 0x40;
+ public static final byte LENGTH = 8;
+ private final short pathKey;
+ private final int pceID;
+
+ /**
+ * Constructor for Path Key sub Object which initializes pathKey and pceId.
+ *
+ * @param pathKey path key provided by PCC
+ * @param pceID ID for the PCE
+ */
+ public PathKeySubObject(short pathKey, int pceID) {
+ this.pathKey = pathKey;
+ this.pceID = pceID;
+ }
+
+ /**
+ * Creates Path Key sub Object which initializes pathKey and pceId.
+ *
+ * @param pathKey path key provided by PCC
+ * @param pceID PCE id
+ * @return new object of type path key sub object
+ */
+ public static PathKeySubObject of(short pathKey, int pceID) {
+ return new PathKeySubObject(pathKey, pceID);
+ }
+
+ /**
+ * Returns Path Key.
+ *
+ * @return pathKey
+ */
+ public short getPathKey() {
+ return pathKey;
+ }
+
+ /**
+ * Returns pceID.
+ *
+ * @return pceID
+ */
+ public int getPceId() {
+ return pceID;
+ }
+
+ @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(pathKey, pceID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PathKeySubObject) {
+ PathKeySubObject other = (PathKeySubObject) obj;
+ return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ c.writeShort(pathKey);
+ c.writeInt(pceID);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns new path key sub objects.
+ *
+ * @param c of type channel buffer
+ * @return object of type path key sub object
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ Short pathKey = c.readShort();
+ int pceID = c.readInt();
+ return new PathKeySubObject(pathKey, pceID);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("PathKey", pathKey)
+ .add("PceID", pceID)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
new file mode 100644
index 00000000..3e8f9676
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PathSetupTypeTlv.java
@@ -0,0 +1,164 @@
+/*
+ * 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 PcepSetup type tlv.
+ */
+public class PathSetupTypeTlv implements PcepValueType {
+
+ /*
+ Reference : draft-sivabalan-pce-lsp-setup-type-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 | Length |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Reserved | PST |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure 1: PATH-SETUP-TYPE TLV
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
+
+ public static final short TYPE = 0; //TODO : need to reassign the value as per RFC
+ public static final short LENGTH = 4;
+
+ private final byte pst;
+ private final int rawValue;
+ private final boolean isRawValueSet;
+
+ /**
+ * Constructor to initialize parameters for path setup type tlv.
+ *
+ * @param rawValue parameter for path setup type tlv
+ */
+ public PathSetupTypeTlv(final int rawValue) {
+ this.rawValue = rawValue;
+ this.isRawValueSet = true;
+ this.pst = (byte) rawValue;
+ }
+
+ /**
+ * Constructor to initialize pst.
+ *
+ * @param pst PST
+ */
+ public PathSetupTypeTlv(byte pst) {
+ this.pst = pst;
+ this.rawValue = 0;
+ this.isRawValueSet = false;
+ }
+
+ /**
+ * Returns Object of path setup type tlv.
+ *
+ * @param raw parameter for path setup type tlv
+ * @return object of PathSetupTypeTlv
+ */
+ public static PathSetupTypeTlv of(final int raw) {
+ return new PathSetupTypeTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns parameters for path setup type tlv.
+ *
+ * @return parameters for path setup type tlv
+ */
+ public int getInt() {
+ return rawValue;
+ }
+
+ /**
+ * Returns the pst value.
+ *
+ * @return pst value
+ */
+ public byte getPst() {
+ return pst;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(pst);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PathSetupTypeTlv) {
+ PathSetupTypeTlv other = (PathSetupTypeTlv) obj;
+ return Objects.equals(this.pst, other.pst);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(pst);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Returns the object of type PathSetupTypeTlv.
+ *
+ * @param c is type Channel buffer
+ * @return object of PathSetupTypeTlv
+ */
+ public static PathSetupTypeTlv read(ChannelBuffer c) {
+ return PathSetupTypeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("PST", pst)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
new file mode 100644
index 00000000..b8ae1e87
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PceccCapabilityTlv.java
@@ -0,0 +1,194 @@
+/*
+ * 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 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;
+ bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK;
+ }
+
+ /**
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
new file mode 100644
index 00000000..83a62103
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepErrorDetailInfo.java
@@ -0,0 +1,83 @@
+/*
+ * 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;
+
+/**
+ * Provide the PCEP Error Info Details.
+ */
+public final class PcepErrorDetailInfo {
+
+ private PcepErrorDetailInfo() {
+ }
+
+ // Error Types
+ /**
+ Error- Meaning Reference:RFC 5440
+ Type
+ 1 PCEP session establishment failure
+ Error-value=1: reception of an invalid Open message or a non Open message.
+ Error-value=2: no Open message received before the expiration of the OpenWait timer
+ Error-value=3: unacceptable and non-negotiable session characteristics
+ Error-value=4: unacceptable but negotiable session characteristics
+ Error-value=5: reception of a second Open message with still unacceptable session characteristics
+ Error-value=6: reception of a PCErr message proposing unacceptable session characteristics
+ Error-value=7: No Keepalive or PCErr message received before the expiration of the KeepWait timer
+ Error-value=8: PCEP version not supported
+ 2 Capability not supported
+ 3 Unknown Object
+ Error-value=1: Unrecognized object class
+ Error-value=2: Unrecognized object Type
+ 4 Not supported object
+ Error-value=1: Not supported object class
+ Error-value=2: Not supported object Type
+ 5 Policy violation
+ Error-value=1: C bit of the METRIC object set (request rejected)
+ Error-value=2: O bit of the RP object cleared (request rejected)
+ 6 Mandatory Object missing
+ Error-value=1: RP object missing
+ Error-value=2: RRO missing for a re-optimization request (R bit of the RP object set)
+ Error-value=3: END-POINTS object missing
+ 7 Synchronized path computation request missing
+ 8 Unknown request reference
+ 9 Attempt to establish a second PCEP session
+ 10 Reception of an invalid object
+ Error-value=1: reception of an object with P flag not set although the P flag must be
+ set according to this specification.
+ */
+ public static final byte ERROR_TYPE_1 = 1;
+ public static final byte ERROR_TYPE_2 = 2;
+ public static final byte ERROR_TYPE_3 = 3;
+ public static final byte ERROR_TYPE_4 = 4;
+ public static final byte ERROR_TYPE_5 = 5;
+ public static final byte ERROR_TYPE_6 = 6;
+ public static final byte ERROR_TYPE_7 = 7;
+ public static final byte ERROR_TYPE_8 = 8;
+ public static final byte ERROR_TYPE_9 = 9;
+ public static final byte ERROR_TYPE_10 = 10;
+
+ // Error Values
+ public static final byte ERROR_VALUE_1 = 1;
+ public static final byte ERROR_VALUE_2 = 2;
+ public static final byte ERROR_VALUE_3 = 3;
+ public static final byte ERROR_VALUE_4 = 4;
+ public static final byte ERROR_VALUE_5 = 5;
+ public static final byte ERROR_VALUE_6 = 6;
+ public static final byte ERROR_VALUE_7 = 7;
+ public static final byte ERROR_VALUE_8 = 8;
+ public static final byte ERROR_VALUE_9 = 9;
+ public static final byte ERROR_VALUE_10 = 10;
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
new file mode 100644
index 00000000..97eedcfd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDbVerTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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 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 PcepLabelDbVerTlv) {
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
new file mode 100644
index 00000000..e2ad069c
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelDownload.java
@@ -0,0 +1,105 @@
+/*
+ * 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.LinkedList;
+
+import org.onosproject.pcepio.protocol.PcepLabelObject;
+import org.onosproject.pcepio.protocol.PcepLspObject;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Label.
+ * REference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
+ */
+public class PcepLabelDownload {
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelDownload.class);
+
+ //PCEP SPR Object
+ private PcepSrpObject srpObject;
+ //PCEP LSP Object
+ private PcepLspObject lspObject;
+ //LinkList of Labels
+ private LinkedList<PcepLabelObject> llLabelList;
+
+ /**
+ * Returns SRP Object.
+ *
+ * @return PCEP SRP Object
+ */
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ /**
+ * Sets the Pcep SRP Object.
+ *
+ * @param srpobj PCEP SRP Object
+ */
+ public void setSrpObject(PcepSrpObject srpobj) {
+ this.srpObject = srpobj;
+ }
+
+ /**
+ * Returns LSP Object.
+ *
+ * @return PCEP LSP Object
+ */
+ public PcepLspObject getLspObject() {
+ return lspObject;
+ }
+
+ /**
+ * Sets the Pcep LSP Object.
+ *
+ * @param lspObject PCEP LSP Object
+ */
+ public void setLspObject(PcepLspObject lspObject) {
+ this.lspObject = lspObject;
+ }
+
+ /**
+ * Returns a list of labels.
+ *
+ * @return llLabelList list of pcep label objects
+ */
+ public LinkedList<PcepLabelObject> getLabelList() {
+ return llLabelList;
+ }
+
+ /**
+ * set the llLabelList list of type PcepLableObject.
+ *
+ * @param llLabelList list of pcep label objects
+ */
+ public void setLabelList(LinkedList<PcepLabelObject> llLabelList) {
+ this.llLabelList = llLabelList;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SrpObject", srpObject)
+ .add("LspObject", lspObject)
+ .add("LabelObjectList", llLabelList)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
new file mode 100644
index 00000000..2d3a953f
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepLabelMap.java
@@ -0,0 +1,103 @@
+/*
+ * 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 org.onosproject.pcepio.protocol.PcepFecObject;
+import org.onosproject.pcepio.protocol.PcepLabelObject;
+import org.onosproject.pcepio.protocol.PcepSrpObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provide PCEP Label Map.
+ * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
+ */
+public class PcepLabelMap {
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepLabelMap.class);
+ //PCEP SRP Object
+ private PcepSrpObject srpObject;
+ //PCEP Label Object
+ private PcepLabelObject labelObject;
+ //PCEP FEC Object
+ private PcepFecObject fecObject;
+
+ /**
+ * Sets Fec Object.
+ *
+ * @param fecObject PCEP fec object
+ */
+ public void setFECObject(PcepFecObject fecObject) {
+ this.fecObject = fecObject;
+ }
+
+ /**
+ * Returns the PcepFecObject.
+ *
+ * @return PCEP fec object
+ */
+ public PcepFecObject getFECObject() {
+ return this.fecObject;
+ }
+
+ /**
+ * Returns SRP Object.
+ *
+ * @return PCEP SRP Object
+ */
+ public PcepSrpObject getSrpObject() {
+ return srpObject;
+ }
+
+ /**
+ * Sets the PCEP Srp Object.
+ *
+ * @param srpObject PCEP SRP Object
+ */
+ public void setSrpObject(PcepSrpObject srpObject) {
+ this.srpObject = srpObject;
+ }
+
+ /**
+ * Returns labelObject.
+ *
+ * @return PCEP label object
+ */
+ public PcepLabelObject getLabelObject() {
+ return labelObject;
+ }
+
+ /**
+ * Sets the Pcep labelObject.
+ *
+ * @param labelObject PCEP label object
+ */
+ public void setLabelObject(PcepLabelObject labelObject) {
+ this.labelObject = labelObject;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SrpObject", srpObject)
+ .add("LabelObject", labelObject)
+ .add("FecObject", fecObject)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
new file mode 100644
index 00000000..1ed0ab14
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4Adjacency.java
@@ -0,0 +1,107 @@
+/*
+ * 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.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv4 Adjacency.
+ */
+public class PcepNaiIpv4Adjacency implements PcepNai {
+
+ public static final byte ST_TYPE = 0x03;
+ private final int localIpv4Addr;
+ private final int remoteIpv4Addr;
+
+ /**
+ * Constructor to initialize variables.
+ *
+ * @param localIpv4 local ipv4 address
+ * @param remoteIpv4 remote ipv4 address
+ */
+ public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) {
+ this.localIpv4Addr = localIpv4;
+ this.remoteIpv4Addr = remoteIpv4;
+ }
+
+ /**
+ * Returns Object of Pcep nai Ipv4 Adjacency.
+ *
+ * @param localIpv4Addr local ipv4 address
+ * @param remoteIpv4Addr remote ipv4 address
+ * @return Object of Pcep nai Ipv4 Adjacency
+ */
+ public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) {
+ return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(localIpv4Addr);
+ bb.writeInt(remoteIpv4Addr);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1.
+ *
+ * @param cb of channel buffer
+ * @return object of PcepNAIIpv4Adjacency
+ */
+ public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) {
+ int localIpv4 = cb.readInt();
+ int remoteIpv4 = cb.readInt();
+ return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIpv4Addr, remoteIpv4Addr);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv4Adjacency) {
+ PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj;
+ return Objects.equals(this.localIpv4Addr, other.localIpv4Addr)
+ && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("localIPv4Address", localIpv4Addr)
+ .add("remoteIPv4Address", remoteIpv4Addr)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
new file mode 100644
index 00000000..1d4ce5d4
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv4NodeId.java
@@ -0,0 +1,99 @@
+/*
+ * 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.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv4 Node Id.
+ */
+public class PcepNaiIpv4NodeId implements PcepNai {
+
+ public static final byte ST_TYPE = 0x01;
+
+ private final int ipv4NodeId;
+
+ /**
+ * Constructor to initialize ipv4NodeId.
+ *
+ * @param value ipv4 node id
+ */
+ public PcepNaiIpv4NodeId(int value) {
+ this.ipv4NodeId = value;
+ }
+
+ /**
+ * Returns an object of PcepNaiIpv4NodeId.
+ *
+ * @param value ipv4 node id
+ * @return object of PcepNaiIpv4NodeId
+ */
+ public static PcepNaiIpv4NodeId of(int value) {
+ return new PcepNaiIpv4NodeId(value);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(ipv4NodeId);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1.
+ *
+ * @param bb of channel buffer.
+ * @return object of PcepNAIIpv4NodeIdVer1
+ */
+ public static PcepNaiIpv4NodeId read(ChannelBuffer bb) {
+ return new PcepNaiIpv4NodeId(bb.readInt());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv4NodeId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv4NodeId) {
+ PcepNaiIpv4NodeId other = (PcepNaiIpv4NodeId) obj;
+ return Objects.equals(this.ipv4NodeId, other.ipv4NodeId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv4NodeId", ipv4NodeId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
new file mode 100644
index 00000000..3a177d99
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6Adjacency.java
@@ -0,0 +1,113 @@
+/*
+ * 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.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv6 Adjacency.
+ */
+public class PcepNaiIpv6Adjacency implements PcepNai {
+
+ public static final byte ST_TYPE = 0x04;
+ public static final byte IPV6_LEN = 0x10;
+
+ private final byte[] localIpv6Addr;
+ private final byte[] remoteIpv6Addr;
+
+ /**
+ * Constructor to initialize local ipv6 and remote ipv6.
+ *
+ * @param localIpv6 local ipv6 address
+ * @param remoteIpv6 remote ipv6 address
+ */
+ public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) {
+ this.localIpv6Addr = localIpv6;
+ this.remoteIpv6Addr = remoteIpv6;
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeBytes(localIpv6Addr);
+ bb.writeBytes(remoteIpv6Addr);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1.
+ *
+ * @param bb of type channel buffer
+ * @return object of PcepNAIIpv6AdjacencyVer1
+ */
+ public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) {
+ byte[] localIpv6 = new byte[IPV6_LEN];
+ bb.readBytes(localIpv6, 0, IPV6_LEN);
+ byte[] remoteIpv6 = new byte[IPV6_LEN];
+ bb.readBytes(remoteIpv6, 0, IPV6_LEN);
+ return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localIpv6Addr, remoteIpv6Addr);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv6Adjacency) {
+ PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj;
+ return Objects.equals(this.localIpv6Addr, other.localIpv6Addr)
+ && Objects.equals(this.remoteIpv6Addr, other.remoteIpv6Addr);
+ }
+ return false;
+ }
+
+ /**
+ * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address.
+ *
+ * @param localIpv6Addr local ipv6 address
+ * @param remoteIpv6Addr remote ipv6 address
+ * @return object of PcepNaiIpv6Adjacency
+ */
+
+ public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) {
+ return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("localIPV6Address", localIpv6Addr)
+ .add("remoteIPV6Address", remoteIpv6Addr)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
new file mode 100644
index 00000000..3b7d52fd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiIpv6NodeId.java
@@ -0,0 +1,102 @@
+/*
+ * 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.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Ipv6 Node Id.
+ */
+public class PcepNaiIpv6NodeId implements PcepNai {
+
+ public static final byte ST_TYPE = 0x02;
+ public static final byte IPV6_LEN = 0x10;
+
+ private final byte[] ipv6NodeId;
+
+ /**
+ * Constructor to initialize ipv6NodeId.
+ *
+ * @param value ipv6 node id
+ */
+ public PcepNaiIpv6NodeId(byte[] value) {
+ this.ipv6NodeId = value;
+ }
+
+ /**
+ * Return object of Pcep Nai Ipv6 Node ID.
+ *
+ * @param ipv6NodeId Ipv6 node ID.
+ * @return object of Pcep Nai Ipv6 Node ID.
+ */
+ public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) {
+ return new PcepNaiIpv6NodeId(ipv6NodeId);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeBytes(ipv6NodeId);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId.
+ *
+ * @param cb of type channel buffer.
+ * @return object of PcepNAIIpv6NodeId
+ */
+ public static PcepNaiIpv6NodeId read(ChannelBuffer cb) {
+ byte[] ipv6NodeId = new byte[IPV6_LEN];
+ cb.readBytes(ipv6NodeId, 0, IPV6_LEN);
+ return new PcepNaiIpv6NodeId(ipv6NodeId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv6NodeId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiIpv6NodeId) {
+ PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj;
+ return Objects.equals(this.ipv6NodeId, other.ipv6NodeId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPV6NodeID", ipv6NodeId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
new file mode 100644
index 00000000..4e8926cf
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepNaiUnnumberedAdjacencyIpv4.java
@@ -0,0 +1,131 @@
+/*
+ * 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.PcepNai;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Nai Unnumbered Adjacency Ipv4.
+ */
+public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai {
+ /**
+ * draft-ietf-pce-segment-routing-03 section 5.3.2.
+ */
+ public static final byte ST_TYPE = 0x05;
+
+ private final int localNodeId;
+ private final int localInterfaceId;
+ private final int remoteNodeId;
+ private final int remoteInterfaceId;
+
+ /**
+ * Constructor to initialize all the member variables.
+ *
+ * @param localNodeId local node id
+ * @param localInterfaceId local interface id
+ * @param remoteNodeId remote node id
+ * @param remoteInterfaceId remote interface id
+ */
+ public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId,
+ int remoteInterfaceId) {
+ this.localNodeId = localNodeId;
+ this.localInterfaceId = localInterfaceId;
+ this.remoteNodeId = remoteNodeId;
+ this.remoteInterfaceId = remoteInterfaceId;
+ }
+
+ /**
+ * Returns PCEP Nai Unnumbered Adjacency Ipv4 object.
+ *
+ * @param localNodeId local node id
+ * @param localInterfaceId local interface if
+ * @param remoteNodeId remote node id
+ * @param remoteInterfaceId remote interface id
+ * @return PCEP Nai Unnumbered Adjacency Ipv4 object
+ */
+ public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId,
+ int remoteInterfaceId) {
+ return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public byte getType() {
+ return ST_TYPE;
+ }
+
+ @Override
+ public int write(ChannelBuffer bb) {
+ int iLenStartIndex = bb.writerIndex();
+ bb.writeInt(localNodeId);
+ bb.writeInt(localInterfaceId);
+ bb.writeInt(remoteNodeId);
+ bb.writeInt(remoteInterfaceId);
+ return bb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4.
+ *
+ * @param bb of type channel buffer
+ * @return object of PcepNAIUnnumberedAdjacencyIpv4
+ */
+ public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) {
+ int localNodeId;
+ int localInterfaceId;
+ int remoteNodeId;
+ int remoteInterfaceId;
+ localNodeId = bb.readInt();
+ localInterfaceId = bb.readInt();
+ remoteNodeId = bb.readInt();
+ remoteInterfaceId = bb.readInt();
+ return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) {
+ PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj;
+ return Objects.equals(this.localNodeId, other.localNodeId)
+ && Objects.equals(this.localInterfaceId, other.localInterfaceId)
+ && Objects.equals(this.remoteNodeId, other.remoteNodeId)
+ && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("localNodeId", localNodeId)
+ .add("localInterfaceId", localInterfaceId)
+ .add("remoteNodeId", remoteNodeId)
+ .add("remoteInterfaceId", remoteInterfaceId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
new file mode 100644
index 00000000..a4af6746
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepObjectHeader.java
@@ -0,0 +1,224 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PCEP Object Header which is common for all the objects.
+ * Reference : RFC 5440.
+ */
+
+public class PcepObjectHeader {
+
+ /*
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Object-Class | OT |Res|P|I| Object Length (bytes) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // (Object body) //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ PCEP Common Object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepObjectHeader.class);
+
+ public static final boolean REQ_OBJ_MUST_PROCESS = true;
+ public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
+ public static final boolean RSP_OBJ_IGNORED = true;
+ public static final boolean RSP_OBJ_PROCESSED = false;
+ public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
+ public static final byte PFLAG_SET = 0x02;
+ public static final byte IFLAG_SET = 0x01;
+ public static final int SET = 1;
+ private byte objClass;
+ private byte objType;
+ private boolean bPFlag;
+ private boolean bIFlag;
+ private short objLen;
+
+ /**
+ * Constructor to initialize all the variables in object header.
+ *
+ * @param objClass PCEP Object class
+ * @param objType PCEP Object type
+ * @param bPFlag P flag
+ * @param bIFlag I flag
+ * @param objLen PCEP object length
+ */
+
+ public PcepObjectHeader(byte objClass, byte objType, boolean bPFlag, boolean bIFlag, short objLen) {
+ this.objClass = objClass;
+ this.objType = objType;
+ this.bPFlag = bPFlag;
+ this.bIFlag = bIFlag;
+ this.objLen = objLen;
+ }
+
+ /**
+ * Sets the Object class.
+ *
+ * @param value object class
+ */
+ public void setObjClass(byte value) {
+ this.objClass = value;
+ }
+
+ /**
+ * Sets the Object TYPE.
+ *
+ * @param value object type
+ */
+ public void setObjType(byte value) {
+ this.objType = value;
+ }
+
+ /**
+ * Sets the Object P flag.
+ *
+ * @param value p flag
+ */
+ public void setPFlag(boolean value) {
+ this.bPFlag = value;
+ }
+
+ /**
+ * Sets the Object I flag.
+ *
+ * @param value I flag
+ */
+ public void setIFlag(boolean value) {
+ this.bIFlag = value;
+ }
+
+ /**
+ * Sets the Object Length.
+ *
+ * @param value object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object's P flag.
+ *
+ * @return bPFlag P flag
+ */
+ public boolean getPFlag() {
+ return this.bPFlag;
+ }
+
+ /**
+ * Returns Object's i flag.
+ *
+ * @return bIFlag I flag
+ */
+ public boolean getIFlag() {
+ return this.bIFlag;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen object length
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object class.
+ *
+ * @return objClass object class
+ */
+ public byte getObjClass() {
+ return this.objClass;
+ }
+
+ /**
+ * Returns Object Type.
+ *
+ * @return objType object type
+ */
+ public byte getObjType() {
+ return this.objType;
+ }
+
+ /**
+ * Writes Byte stream of PCEP object header to channel buffer.
+ *
+ * @param cb output channel buffer
+ * @return objLenIndex object length index in channel buffer
+ */
+ public int write(ChannelBuffer cb) {
+
+ cb.writeByte(this.objClass);
+ byte temp = (byte) (this.objType << OBJECT_TYPE_SHIFT_VALUE);
+ if (this.bPFlag) {
+ temp = (byte) (temp | PFLAG_SET);
+ }
+ if (this.bIFlag) {
+ temp = (byte) (temp | IFLAG_SET);
+ }
+ cb.writeByte(temp);
+ int objLenIndex = cb.writerIndex();
+ cb.writeShort((short) 0);
+ return objLenIndex;
+ }
+
+ /**
+ * Read from channel buffer and Returns PCEP Objects header.
+ *
+ * @param cb of type channel buffer
+ * @return PCEP Object header
+ */
+ public static PcepObjectHeader read(ChannelBuffer cb) {
+
+ byte objClass;
+ byte objType;
+ boolean bPFlag;
+ boolean bIFlag;
+ short objLen;
+ objClass = cb.readByte();
+ byte temp = cb.readByte();
+ bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
+ bPFlag = (temp & PFLAG_SET) == PFLAG_SET;
+ objType = (byte) (temp >> OBJECT_TYPE_SHIFT_VALUE);
+ objLen = cb.readShort();
+ return new PcepObjectHeader(objClass, objType, bPFlag, bIFlag, objLen);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClass", objClass)
+ .add("ObjectType", objType)
+ .add("ObjectLength", objLen)
+ .add("PFlag", (bPFlag) ? 1 : 0)
+ .add("IFlag", (bIFlag) ? 1 : 0)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java
new file mode 100644
index 00000000..8d3c67a7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpErrorSpec.java
@@ -0,0 +1,46 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ * Abstraction of an entity which provides PCPE RSVP error spec.
+ */
+public interface PcepRsvpErrorSpec extends PcepValueType {
+
+ /**
+ * To write the object information to channelBuffer.
+ *
+ * @param cb of type channel buffer
+ */
+ @Override
+ int write(ChannelBuffer cb);
+
+ /**
+ * Returns class number.
+ *
+ * @return class number
+ */
+ byte getClassNum();
+
+ /**
+ * Returns class type.
+ *
+ * @return class type
+ */
+ byte getClassType();
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
new file mode 100644
index 00000000..326b66b7
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv4ErrorSpec.java
@@ -0,0 +1,160 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp Ipv4 Error Spec.
+ */
+public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ RSVP error spec object header.
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
+ +-------------+-------------+-------------+-------------+
+ | IPv4 Error Node Address (4 bytes) |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+ */
+
+ PcepRsvpSpecObjHeader objHeader;
+ public static final byte CLASS_NUM = 0x06;
+ public static final byte CLASS_TYPE = 0x01;
+ public static final byte CLASS_LENGTH = 0x0c;
+ private int ipv4Addr;
+ private byte flags;
+ private byte errCode;
+ private short errValue;
+
+ /**
+ * Constructor to initialize obj header, ipv4 addr, flags, err code and err value.
+ *
+ * @param objHeader rsvp ipv4 error spec object header
+ * @param ipv4Addr ipv4 address
+ * @param flags flags value
+ * @param errCode error code value
+ * @param errValue error value
+ */
+ public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode,
+ short errValue) {
+ this.objHeader = objHeader;
+ this.ipv4Addr = ipv4Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ /**
+ * Constructor to initialize ipv4 address, flags, err code and err value.
+ *
+ * @param ipv4Addr ipv4 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) {
+ this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
+ this.ipv4Addr = ipv4Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeInt(ipv4Addr);
+ cb.writeByte(flags);
+ cb.writeByte(errCode);
+ cb.writeShort(errValue);
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
+ *
+ * @param cb channel buffer
+ * @return PCEP rsvp IPv4 error spec object
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
+ PcepRsvpSpecObjHeader objHeader;
+ int ipv4Addr;
+ byte flags;
+ byte errCode;
+ short errValue;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+ ipv4Addr = cb.readInt();
+ flags = cb.readByte();
+ errCode = cb.readByte();
+ errValue = cb.readShort();
+ return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return CLASS_LENGTH;
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv4Address", ipv4Addr)
+ .add("flags", flags)
+ .add("errorCode", errCode)
+ .add("errorValue", errValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
new file mode 100644
index 00000000..4da1ec6d
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpIpv6ErrorSpec.java
@@ -0,0 +1,165 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp Ipv6 Error Spec.
+ */
+public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
+ +-------------+-------------+-------------+-------------+
+ | |
+ + +
+ | |
+ + IPv6 Error Node Address (16 bytes) +
+ | |
+ + +
+ | |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+ */
+
+ PcepRsvpSpecObjHeader objHeader;
+ public static final byte CLASS_NUM = 0x06;
+ public static final byte CLASS_TYPE = 0x02;
+ public static final byte CLASS_LENGTH = 0x18;
+ public static final byte IPV6_LEN = 0x10;
+
+ private byte[] ipv6Addr;
+ private byte flags;
+ private byte errCode;
+ private short errValue;
+
+ /**
+ * Constructor to initialize obj header, ipv6 addr, flags, err code and err value.
+ *
+ * @param objHeader rsvp ipv6 error spec object header
+ * @param ipv6Addr ipv6 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode,
+ short errValue) {
+ this.objHeader = objHeader;
+ this.ipv6Addr = ipv6Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ /**
+ * Constructor to initialize ipv6 addr, flags, err code and err value.
+ *
+ * @param ipv6Addr ipv6 address
+ * @param flags flags value
+ * @param errCode error code
+ * @param errValue error value
+ */
+ public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) {
+ this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
+ this.ipv6Addr = ipv6Addr;
+ this.flags = flags;
+ this.errCode = errCode;
+ this.errValue = errValue;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeBytes(ipv6Addr);
+ cb.writeByte(flags);
+ cb.writeByte(errCode);
+ cb.writeShort(errValue);
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Returns PCEP rsvp IPv6 error spce object.
+ *
+ * @param cb channel buffer
+ * @return PCEP rsvp IPv6 error spce object
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
+ PcepRsvpSpecObjHeader objHeader;
+ byte[] ipv6Addr = new byte[IPV6_LEN];
+ byte flags;
+ byte errCode;
+ short errValue;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+ cb.readBytes(ipv6Addr, 0, IPV6_LEN);
+ flags = cb.readByte();
+ errCode = cb.readByte();
+ errValue = cb.readShort();
+ return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return CLASS_LENGTH;
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("IPv6Address", ipv6Addr)
+ .add("flags", flags)
+ .add("errorCode", errCode)
+ .add("errorValue", errValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
new file mode 100644
index 00000000..bddcb898
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpObjectHeader.java
@@ -0,0 +1,161 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PcepRsvpObjectHeader.
+ */
+public class PcepRsvpObjectHeader {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ ERROR_SPEC object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepRsvpObjectHeader.class);
+
+ public static final boolean REQ_OBJ_MUST_PROCESS = true;
+ public static final boolean REQ_OBJ_OPTIONAL_PROCESS = false;
+ public static final boolean RSP_OBJ_IGNORED = true;
+ public static final boolean RSP_OBJ_PROCESSED = false;
+ public static final int OBJECT_TYPE_SHIFT_VALUE = 4;
+ private byte objClassNum;
+ private byte objClassType;
+ private short objLen;
+
+ /**
+ * Constructor to initialize class num, length and type.
+ *
+ * @param objClassNum object class number
+ * @param objClassType object class type
+ * @param objLen object length
+ */
+ public PcepRsvpObjectHeader(byte objClassNum, byte objClassType, short objLen) {
+ this.objClassNum = objClassNum;
+ this.objClassType = objClassType;
+ this.objLen = objLen;
+ }
+
+ /**
+ * Sets the Class-Num.
+ *
+ * @param value object class number
+ */
+ public void setObjClassNum(byte value) {
+ this.objClassNum = value;
+ }
+
+ /**
+ * Sets the Class type.
+ *
+ * @param value object class type
+ */
+ public void setObjClassType(byte value) {
+ this.objClassType = value;
+ }
+
+ /**
+ * Sets the Class Length.
+ *
+ * @param value object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object num.
+ *
+ * @return objClassNum
+ */
+ public byte getObjClassNum() {
+ return this.objClassNum;
+ }
+
+ /**
+ * Returns Object type.
+ *
+ * @return objClassType
+ */
+ public byte getObjClassType() {
+ return this.objClassType;
+ }
+
+ /**
+ * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return object length index in channel buffer
+ */
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeShort((short) 0);
+ cb.writeByte(this.objClassNum);
+ cb.writeByte(this.objClassType);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the PcepRsvpObjectHeader.
+ *
+ * @param cb input channel buffer
+ * @return PcepRsvpObjectHeader
+ */
+ public static PcepRsvpObjectHeader read(ChannelBuffer cb) {
+ log.debug("read ");
+ byte objClassNum;
+ byte objClassType;
+ short objLen;
+ objLen = cb.readShort();
+ objClassNum = cb.readByte();
+ objClassType = cb.readByte();
+
+ return new PcepRsvpObjectHeader(objClassNum, objClassType, objLen);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClassNum", objClassNum)
+ .add("ObjectCType", objClassType)
+ .add("ObjectLength", objLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
new file mode 100644
index 00000000..132ff862
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpSpecObjHeader.java
@@ -0,0 +1,156 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides PcepRsvpObjectHeader.
+ */
+public class PcepRsvpSpecObjHeader {
+
+ /*
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ ERROR_SPEC object Header
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(PcepRsvpSpecObjHeader.class);
+
+ private short objLen;
+ private byte objClassNum;
+ private byte objClassType;
+
+ /**
+ * Constructor to initialize length, class num and type.
+ *
+ * @param objLen object length
+ * @param objClassNum pcep rsvp error spec object class num
+ * @param objClassType pcep rsvp error spec object class type
+ */
+ public PcepRsvpSpecObjHeader(short objLen, byte objClassNum, byte objClassType) {
+ this.objLen = objLen;
+ this.objClassNum = objClassNum;
+ this.objClassType = objClassType;
+ }
+
+ /**
+ * Sets the Class num.
+ *
+ * @param value pcep rsvp error spec object class num
+ */
+ public void setObjClassNum(byte value) {
+ this.objClassNum = value;
+ }
+
+ /**
+ * Sets the Class type.
+ *
+ * @param value pcep rsvp error spec object class type
+ */
+ public void setObjClassType(byte value) {
+ this.objClassType = value;
+ }
+
+ /**
+ * Sets the Class Length.
+ *
+ * @param value pcep rsvp error spec object length
+ */
+ public void setObjLen(short value) {
+ this.objLen = value;
+ }
+
+ /**
+ * Returns Object Length.
+ *
+ * @return objLen pcep rsvp error spec object length
+ */
+ public short getObjLen() {
+ return this.objLen;
+ }
+
+ /**
+ * Returns Object num.
+ *
+ * @return objClassNum pcep rsvp error spec object class num
+ */
+ public byte getObjClassNum() {
+ return this.objClassNum;
+ }
+
+ /**
+ * Returns Object type.
+ *
+ * @return objClassType pcep rsvp error spec object class type
+ */
+ public byte getObjClassType() {
+ return this.objClassType;
+ }
+
+ /**
+ * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
+ *
+ * @param cb of type channel buffer
+ * @return object length index
+ */
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = cb.writerIndex();
+ objLen = 0;
+ cb.writeShort(objLen);
+ cb.writeByte(objClassNum);
+ cb.writeByte(objClassType);
+ return objLenIndex;
+ }
+
+ /**
+ * Reads the PcepRsvpObjectHeader.
+ *
+ * @param cb of type channel buffer
+ * @return PcepRsvpObjectHeader
+ */
+ public static PcepRsvpSpecObjHeader read(ChannelBuffer cb) {
+ byte objClassNum;
+ byte objClassType;
+ short objLen;
+ objLen = cb.readShort();
+ objClassNum = cb.readByte();
+ objClassType = cb.readByte();
+
+ return new PcepRsvpSpecObjHeader(objLen, objClassNum, objClassType);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("ObjectClassNum: ", objClassNum)
+ .add("ObjectCType: ", objClassType)
+ .add("ObjectLength: ", objLen)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java
new file mode 100644
index 00000000..4a9357de
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepRsvpUserErrorSpec.java
@@ -0,0 +1,220 @@
+/*
+ * 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.LinkedList;
+import java.util.ListIterator;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Pcep Rsvp User Error Spec.
+ */
+public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec {
+
+ /*
+ RSVP error spec object header.
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : USER_ERROR_SPEC @ RFC5284.
+ USER_ERROR_SPEC object: Class = 194, C-Type = 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
+ +---------------+---------------+---------------+---------------+
+ | Enterprise Number |
+ +---------------+---------------+---------------+---------------+
+ | Sub Org | Err Desc Len | User Error Value |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ Error Description ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ User-Defined Subobjects ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ */
+
+ public static final byte CLASS_NUM = (byte) 0xc2;
+ public static final byte CLASS_TYPE = 0x01;
+
+ private PcepRsvpSpecObjHeader objHeader;
+ private int enterpriseNum;
+ private byte subOrg;
+ private byte errDescLen;
+ private short userErrorValue;
+ private byte[] errDesc;
+ private LinkedList<PcepValueType> llRsvpUserSpecSubObj;
+
+ /**
+ * Default constructor.
+ *
+ * @param objHeader pcep rsvp spec object header
+ * @param enterpriseNum enterprise number
+ * @param subOrg organization identifier value
+ * @param errDescLen error description length
+ * @param userErrorValue user error value
+ * @param errDesc error description
+ * @param llRsvpUserSpecSubObj list of subobjects
+ */
+ public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen,
+ short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) {
+ this.objHeader = objHeader;
+ this.enterpriseNum = enterpriseNum;
+ this.subOrg = subOrg;
+ this.errDescLen = errDescLen;
+ this.userErrorValue = userErrorValue;
+ this.errDesc = errDesc;
+ this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int objLenIndex = objHeader.write(cb);
+ cb.writeInt(enterpriseNum);
+ cb.writeByte(subOrg);
+ cb.writeByte(errDescLen);
+ cb.writeShort(userErrorValue);
+ cb.writeBytes(errDesc);
+
+ if (llRsvpUserSpecSubObj != null) {
+
+ ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator();
+
+ while (listIterator.hasNext()) {
+ PcepValueType tlv = listIterator.next();
+ if (tlv == null) {
+ continue;
+ }
+ tlv.write(cb);
+ // need to take care of padding
+ int pad = tlv.getLength() % 4;
+ if (0 != pad) {
+ pad = 4 - pad;
+ for (int i = 0; i < pad; ++i) {
+ cb.writeByte((byte) 0);
+ }
+ }
+ }
+ }
+ short objLen = (short) (cb.writerIndex() - objLenIndex);
+ cb.setShort(objLenIndex, objLen);
+ return objLen;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of PcepRsvpErrorSpec.
+ *
+ * @param cb of type channel buffer
+ * @return object of PcepRsvpErrorSpec
+ * @throws PcepParseException when expected object is not received
+ */
+ public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
+ PcepRsvpSpecObjHeader objHeader;
+ int enterpriseNum;
+ byte subOrg;
+ byte errDescLen;
+ short userErrorValue;
+ byte[] errDesc;
+ LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
+
+ objHeader = PcepRsvpSpecObjHeader.read(cb);
+
+ if (objHeader.getObjClassNum() != CLASS_NUM || objHeader.getObjClassType() != CLASS_TYPE) {
+ throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
+ }
+ enterpriseNum = cb.readInt();
+ subOrg = cb.readByte();
+ errDescLen = cb.readByte();
+ userErrorValue = cb.readShort();
+ errDesc = new byte[errDescLen];
+ cb.readBytes(errDesc, 0, errDescLen);
+
+ llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
+
+ return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
+ llRsvpUserSpecSubObj);
+ }
+
+ private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
+ LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<>();
+ while (0 < cb.readableBytes()) {
+ PcepValueType tlv = null;
+ short hType = cb.readShort();
+ int iValue = 0;
+ //short hLength = cb.readShort();
+ switch (hType) {
+ case AutonomousSystemTlv.TYPE:
+ iValue = cb.readInt();
+ tlv = new AutonomousSystemTlv(iValue);
+ break;
+ default:
+ throw new PcepParseException("Unsupported Sub TLV type :" + hType);
+ }
+ llRsvpUserSpecSubObj.add(tlv);
+ }
+ return llRsvpUserSpecSubObj;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return StatefulRsvpErrorSpecTlv.TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return objHeader.getObjLen();
+ }
+
+ @Override
+ public byte getClassNum() {
+ return CLASS_NUM;
+ }
+
+ @Override
+ public byte getClassType() {
+ return CLASS_TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("enterpriseNumber", enterpriseNum)
+ .add("subOrganization", subOrg)
+ .add("errDescLength", errDescLen)
+ .add("userErrorValue", userErrorValue)
+ .add("errDesc", errDesc)
+ .add("RsvpUserSpecSubObject", llRsvpUserSpecSubObj)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
new file mode 100755
index 00000000..c960e7ac
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/PcepValueType.java
@@ -0,0 +1,55 @@
+/*
+ * 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 org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.pcepio.protocol.PcepVersion;
+
+/**
+ * Abstraction which Provides the PCEP Values of Type, Length ,Version.
+ */
+public interface PcepValueType {
+
+ /**
+ * Returns the Version Of PCEP Message.
+ *
+ * @return Version of PcepVersion Type.
+ */
+ PcepVersion getVersion();
+
+ /**
+ * Returns the Type of PCEP Message.
+ *
+ * @return value of type
+ */
+ short getType();
+
+ /**
+ * Returns the Length of PCEP Message.
+ *
+ * @return value of Length
+ */
+ short getLength();
+
+ /**
+ * Writes the byte Stream of PCEP Message to channel buffer.
+ *
+ * @param bb of type channel buffer
+ * @return length of bytes written to channel buffer
+ */
+ int write(ChannelBuffer bb);
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java
new file mode 100644
index 00000000..aceb7ea0
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RemoteTENodeDescriptorsTlv.java
@@ -0,0 +1,250 @@
+/*
+ * 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 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 (tlv == null) {
+ 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 - TLV_HEADER_LENGTH));
+
+ return c.writerIndex() - tlvStartIndex;
+ }
+
+ /**
+ * Reads channel buffer and returns object of Remote TE Node Descriptors TLV.
+ *
+ * @param c input channel buffer
+ * @param length length of buffer
+ * @return object of RemoteTENodeDescriptorsTLV
+ * @throws PcepParseException if mandatory fields are missing
+ */
+ public static PcepValueType read(ChannelBuffer c , short length) throws PcepParseException {
+
+ // Node Descriptor Sub-TLVs (variable)
+ LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<>();
+
+ ChannelBuffer tempCb = c.readBytes(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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RouterIDSubTlv.java
new file mode 100644
index 00000000..228d8533
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(rawValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof RouterIDSubTlv) {
+ RouterIDSubTlv other = (RouterIDSubTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
new file mode 100644
index 00000000..924a3a32
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/RoutingUniverseTlv.java
@@ -0,0 +1,147 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SharedRiskLinkGroupTlv.java
new file mode 100644
index 00000000..e855a526
--- /dev/null
+++ b/framework/src/onos/protocols/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.Arrays;
+
+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 Arrays.hashCode(srlgValue);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SharedRiskLinkGroupTlv) {
+ SharedRiskLinkGroupTlv other = (SharedRiskLinkGroupTlv) obj;
+ return Arrays.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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
new file mode 100644
index 00000000..3cbb82c8
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SrEroSubObject.java
@@ -0,0 +1,324 @@
+/*
+ * 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.PcepNai;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides SrEroSubObject.
+ */
+public class SrEroSubObject implements PcepValueType {
+ /*
+ SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ |L| Type | Length | ST | Flags |F|S|C|M|
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | SID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // NAI (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+
+ NAI
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Local IPv4 address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Remote IPv4 address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for IPv4 Adjacency
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Local IPv6 address (16 bytes) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // Remote IPv6 address (16 bytes) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for IPv6 adjacency
+
+ 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Local Node-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Local Interface ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Remote Node-ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Remote Interface ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ NAI for Unnumbered adjacency with IPv4 Node IDs
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
+
+ public static final short TYPE = 0x60; //TODO : type to be defined
+ public static final short LENGTH = 12;
+ public static final short VALUE_LENGTH = 10;
+ public static final int SET = 1;
+ public static final byte MFLAG_SET = 0x01;
+ public static final byte CFLAG_SET = 0x02;
+ public static final byte SFLAG_SET = 0x04;
+ public static final byte FFLAG_SET = 0x08;
+ public static final byte SHIFT_ST = 12;
+
+ private final boolean bFFlag;
+ private final boolean bSFlag;
+ private final boolean bCFlag;
+ private final boolean bMFlag;
+ private final byte st;
+
+ private final int sID;
+ private final PcepNai nai;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param st SID type
+ * @param bFFlag F flag
+ * @param bSFlag S flag
+ * @param bCFlag C flag
+ * @param bMFlag M flag
+ * @param sID segment identifier value
+ * @param nai NAI associated with SID
+ */
+ public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ PcepNai nai) {
+ this.st = st;
+ this.bFFlag = bFFlag;
+ this.bSFlag = bSFlag;
+ this.bCFlag = bCFlag;
+ this.bMFlag = bMFlag;
+ this.sID = sID;
+ this.nai = nai;
+ }
+
+ /**
+ * Creates object of SrEroSubObject.
+ *
+ * @param st SID type
+ * @param bFFlag F flag
+ * @param bSFlag S flag
+ * @param bCFlag C flag
+ * @param bMFlag M flag
+ * @param sID segment identifier value
+ * @param nai NAI associated with SID
+ * @return object of SrEroSubObject
+ */
+ public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
+ PcepNai nai) {
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ /**
+ * Returns SID type.
+ * @return st sid type
+ */
+ public byte getSt() {
+ return st;
+ }
+
+ /**
+ * Returns bFFlag.
+ * @return bFFlag
+ */
+ public boolean getFFlag() {
+ return bFFlag;
+ }
+
+ /**
+ * Returns bSFlag.
+ * @return bSFlag
+ */
+ public boolean getSFlag() {
+ return bSFlag;
+ }
+
+ /**
+ * Returns bCFlag.
+ * @return bCFlag
+ */
+ public boolean getCFlag() {
+ return bCFlag;
+ }
+
+ /**
+ * Returns bMFlag.
+ * @return bMFlag
+ */
+ public boolean getMFlag() {
+ return bMFlag;
+ }
+
+ /**
+ * Returns sID.
+ * @return sID
+ */
+ public int getSID() {
+ return sID;
+ }
+
+ /**
+ * Returns nai.
+ * @return nai
+ */
+ public PcepNai getNai() {
+ return nai;
+ }
+
+ @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(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SrEroSubObject) {
+ SrEroSubObject other = (SrEroSubObject) obj;
+ return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag)
+ && Objects.equals(this.bSFlag, other.bSFlag) && Objects.equals(this.bCFlag, other.bCFlag)
+ && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sID, other.sID)
+ && Objects.equals(this.nai, other.nai);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+
+ short temp = 0;
+ if (bMFlag) {
+ temp = (short) (temp | MFLAG_SET);
+ }
+ if (bCFlag) {
+ temp = (short) (temp | CFLAG_SET);
+ }
+ if (bSFlag) {
+ temp = (short) (temp | SFLAG_SET);
+ }
+ if (bFFlag) {
+ temp = (short) (temp | FFLAG_SET);
+ }
+ short tempST = (short) (st << SHIFT_ST);
+ temp = (short) (temp | tempST);
+ c.writeShort(temp);
+ c.writeInt(sID);
+ nai.write(c);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of SrEroSubObject.
+ * @param c of type channel buffer
+ * @return object of SrEroSubObject
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ short temp = c.readShort();
+ boolean bMFlag;
+ boolean bCFlag;
+ boolean bSFlag;
+ boolean bFFlag;
+ byte st;
+ PcepNai nai = null;
+
+ bMFlag = (temp & MFLAG_SET) == MFLAG_SET;
+ bCFlag = (temp & CFLAG_SET) == CFLAG_SET;
+ bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
+ bFFlag = (temp & FFLAG_SET) == FFLAG_SET;
+
+ st = (byte) (temp >> SHIFT_ST);
+
+ int sID = c.readInt();
+ switch (st) {
+ case 0x01:
+ nai = PcepNaiIpv4NodeId.read(c);
+ break;
+ case 0x02:
+ nai = PcepNaiIpv6NodeId.read(c);
+ break;
+ case 0x03:
+ nai = PcepNaiIpv4Adjacency.read(c);
+ break;
+ case 0x04:
+ nai = PcepNaiIpv6Adjacency.read(c);
+ break;
+ case 0x05:
+ nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
+ break;
+ default:
+ nai = null;
+ break;
+ }
+
+ return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("st", st)
+ .add("bFflag", bFFlag)
+ .add("bSFlag", bSFlag)
+ .add("bCFlag", bCFlag)
+ .add("bMFlag", bMFlag)
+ .add("sID", sID)
+ .add("nAI", nai)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
new file mode 100644
index 00000000..020d31d9
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulIPv4LspIdentidiersTlv.java
@@ -0,0 +1,210 @@
+/*
+ * 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 StatefulIPv4LspIdentidiersTlv.
+ */
+public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
+
+ /* IPV4-LSP-IDENTIFIERS 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=18 | Length=16 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Tunnel Sender Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP ID | Tunnel ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Extended Tunnel ID |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | IPv4 Tunnel Endpoint Address |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
+
+ public static final short TYPE = 18;
+ public static final short LENGTH = 16;
+ public static final int VALUE_LENGTH = 16;
+ private final int ipv4IngressAddress;
+ private final short lspId;
+ private final short tunnelId;
+ private final int extendedTunnelId;
+ private final int ipv4EgressAddress;
+
+ /**
+ * Constructor to initialize member variables.
+ *
+ * @param ipv4IngressAddress ingress ipv4 address
+ * @param lspId lsp id
+ * @param tunnelId tunnel id
+ * @param extendedTunnelId extended tunnel id
+ * @param ipv4EgressAddress egress ipv4 address
+ */
+ public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
+ int ipv4EgressAddress) {
+
+ this.ipv4IngressAddress = ipv4IngressAddress;
+ this.lspId = lspId;
+ this.tunnelId = tunnelId;
+ this.extendedTunnelId = extendedTunnelId;
+ this.ipv4EgressAddress = ipv4EgressAddress;
+ }
+
+ /**
+ * Creates object of StatefulIPv4LspIdentidiersTlv.
+ *
+ * @param ipv4IngressAddress ingress ipv4 address
+ * @param lspId lsp id
+ * @param tunnelId tunnel id
+ * @param extendedTunnelId extended tunnel id
+ * @param ipv4EgressAddress egress ipv4 address
+ * @return object of StatefulIPv4LspIdentidiersTlv
+ */
+ public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
+ int extendedTunnelId, int ipv4EgressAddress) {
+ return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ ipv4EgressAddress);
+ }
+
+ /**
+ * Returns tunnel id.
+ *
+ * @return tunnelId
+ */
+ public short getTunnelId() {
+ return this.tunnelId;
+ }
+
+ /**
+ * Returns extendedTunnelId.
+ *
+ * @return extendedTunnelId
+ */
+ public int getextendedTunnelId() {
+ return this.extendedTunnelId;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns ipv4IngressAddress.
+ *
+ * @return ipv4IngressAddress
+ */
+ public int getIpv4IngressAddress() {
+ return ipv4IngressAddress;
+ }
+
+ /**
+ * Returns ipv4EgressAddress.
+ *
+ * @return ipv4EgressAddress
+ */
+ public int getIpv4EgressAddress() {
+ return ipv4EgressAddress;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return LENGTH;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
+ StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
+ return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
+ && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
+ && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
+ && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(ipv4IngressAddress);
+ c.writeShort(lspId);
+ c.writeShort(tunnelId);
+ c.writeInt(extendedTunnelId);
+ c.writeInt(ipv4EgressAddress);
+
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv.
+ *
+ * @param c of type channel buffer
+ * @return object of StatefulIPv4LspIdentidiersTlv
+ */
+ public static PcepValueType read(ChannelBuffer c) {
+ int ipv4IngressAddress = c.readInt();
+ short lspId = c.readShort();
+ short tunnelId = c.readShort();
+ int extendedTunnelId = c.readInt();
+ int ipv4EgressAddress = c.readInt();
+ return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
+ ipv4EgressAddress);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type:", TYPE)
+ .add("Length:", LENGTH)
+ .add("Ipv4IngressAddress:", ipv4IngressAddress)
+ .add("LspId:", lspId).add("TunnelId:", tunnelId)
+ .add("ExtendedTunnelId:", extendedTunnelId)
+ .add("Ipv4EgressAddress:", ipv4EgressAddress).toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
new file mode 100644
index 00000000..a667dccd
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspDbVerTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
new file mode 100644
index 00000000..5d323f6a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulLspErrorCodeTlv.java
@@ -0,0 +1,142 @@
+/*
+ * 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 StatefulLspErrorCodeTlv.
+ */
+public class StatefulLspErrorCodeTlv implements PcepValueType {
+
+ /* LSP-ERROR-CODE 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=20 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | LSP Error Code |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class);
+
+ public static final short TYPE = 20;
+ public static final short LENGTH = 4;
+ private final int rawValue;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue lsp error code value
+ */
+ public StatefulLspErrorCodeTlv(int rawValue) {
+ this.rawValue = rawValue;
+ }
+
+ /**
+ * Creates object of StatefulLspErrorCodeTlv.
+ *
+ * @param raw lsp error code value
+ * @return object of StatefulLspErrorCodeTlv
+ */
+ public static StatefulLspErrorCodeTlv of(int raw) {
+ return new StatefulLspErrorCodeTlv(raw);
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ /**
+ * Returns lsp error code value.
+ *
+ * @return lsp error code value
+ */
+ public int getInt() {
+ 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 StatefulLspErrorCodeTlv) {
+ StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) 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 StatefulLspErrorCodeTlv.
+ *
+ * @param c of type channel buffer
+ * @return object of StatefulLspErrorCodeTlv
+ */
+ public static StatefulLspErrorCodeTlv read(ChannelBuffer c) {
+ return StatefulLspErrorCodeTlv.of(c.readInt());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", rawValue)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
new file mode 100644
index 00000000..84f40e12
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulPceCapabilityTlv.java
@@ -0,0 +1,269 @@
+/*
+ * 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;
+ this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET;
+ this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET;
+ this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET;
+ this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET;
+ }
+
+ /**
+ * 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;
+ bSFlag = (temp & SFLAG_SET) == SFLAG_SET;
+ bIFlag = (temp & IFLAG_SET) == IFLAG_SET;
+ bTFlag = (temp & TFLAG_SET) == TFLAG_SET;
+ bDFlag = (temp & DFLAG_SET) == DFLAG_SET;
+
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
new file mode 100644
index 00000000..9e1a074a
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/StatefulRsvpErrorSpecTlv.java
@@ -0,0 +1,216 @@
+/*
+ * 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.exceptions.PcepParseException;
+import org.onosproject.pcepio.protocol.PcepVersion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides StatefulRsvpErrorSpecTlv.
+ */
+public class StatefulRsvpErrorSpecTlv implements PcepValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class);
+
+ /* RSVP-ERROR-SPEC 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=21 | Length (variable) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ + RSVP ERROR_SPEC or USER_ERROR_SPEC Object +
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ 0 1 2 3
+ +-------------+-------------+-------------+-------------+
+ | Length (bytes) | Class-Num | C-Type |
+ +-------------+-------------+-------------+-------------+
+ | |
+ // (Object contents) //
+ | |
+ +-------------+-------------+-------------+-------------+
+
+ Ref : ERROR_SPEC @ RFC2205
+
+ IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
+ +-------------+-------------+-------------+-------------+
+ | IPv4 Error Node Address (4 bytes) |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+
+ IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
+ +-------------+-------------+-------------+-------------+
+ | |
+ + +
+ | |
+ + IPv6 Error Node Address (16 bytes) +
+ | |
+ + +
+ | |
+ +-------------+-------------+-------------+-------------+
+ | Flags | Error Code | Error Value |
+ +-------------+-------------+-------------+-------------+
+
+
+ Ref : USER_ERROR_SPEC @ RFC5284
+ USER_ERROR_SPEC object: Class = 194, C-Type = 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
+ +---------------+---------------+---------------+---------------+
+ | Enterprise Number |
+ +---------------+---------------+---------------+---------------+
+ | Sub Org | Err Desc Len | User Error Value |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ Error Description ~
+ | |
+ +---------------+---------------+---------------+---------------+
+ | |
+ ~ User-Defined Subobjects ~
+ | |
+ +---------------+---------------+---------------+---------------+
+
+ */
+
+ public static final short TYPE = 21;
+ public static final int OBJECT_HEADER_LENGTH = 4;
+ private short hLength;
+
+ private final PcepRsvpErrorSpec rsvpErrSpecObj;
+ private final boolean isErrSpceObjSet;
+
+ /**
+ * Constructor to initialize errSpecObj.
+ *
+ * @param rsvpErrSpecObj Rsvp error spec object
+ */
+ public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) {
+ this.rsvpErrSpecObj = rsvpErrSpecObj;
+ this.isErrSpceObjSet = true;
+ }
+
+ /**
+ * Returns PcepRsvpErrorSpecObject.
+ *
+ * @return rsvpErrSpecObj
+ */
+ public PcepRsvpErrorSpec getPcepRsvpErrorSpec() {
+ return this.rsvpErrSpecObj;
+ }
+
+ @Override
+ public PcepVersion getVersion() {
+ return PcepVersion.PCEP_1;
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public short getLength() {
+ return hLength;
+ }
+
+ /**
+ * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv.
+ *
+ * @param cb of type channel buffer
+ * @return object of StatefulRsvpErrorSpecTlv
+ * @throws PcepParseException while parsing this tlv from channel buffer
+ */
+ public static PcepValueType read(ChannelBuffer cb) throws PcepParseException {
+
+ PcepRsvpErrorSpec rsvpErrSpecObj = null;
+ PcepRsvpSpecObjHeader rsvpErrSpecObjHeader;
+
+ cb.markReaderIndex();
+ rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb);
+ cb.resetReaderIndex();
+
+ if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb);
+ } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb);
+ } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
+ && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
+ rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
+ }
+ return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(rsvpErrSpecObj.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof StatefulRsvpErrorSpecTlv) {
+ StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj;
+ return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ int tlvLenIndex = c.writerIndex();
+ hLength = 0;
+ c.writeShort(hLength);
+ if (isErrSpceObjSet) {
+ rsvpErrSpecObj.write(c);
+ }
+ hLength = (short) (c.writerIndex() - iStartIndex);
+ c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH));
+
+ return c.writerIndex() - iStartIndex;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("Type", TYPE)
+ .add("Length", hLength)
+ .add("RSVPErrorSpecObject", rsvpErrSpecObj)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
new file mode 100644
index 00000000..27cf56a6
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/SymbolicPathNameTlv.java
@@ -0,0 +1,159 @@
+/*
+ * 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 SymbolicPathNameTlv.
+ */
+public class SymbolicPathNameTlv implements PcepValueType {
+
+ /*
+ * SYMBOLIC-PATH-NAME 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=17 | Length (variable) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ // Symbolic Path Name //
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+ protected static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class);
+
+ public static final short TYPE = 17;
+ private short hLength;
+
+ private final byte[] rawValue;
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Symbolic path name
+ */
+ public SymbolicPathNameTlv(byte[] rawValue) {
+ this.rawValue = rawValue;
+ this.hLength = (short) rawValue.length;
+ }
+
+ /**
+ * Constructor to initialize raw Value.
+ *
+ * @param rawValue Symbolic path name
+ * @param hLength length of Symbolic path name
+ */
+ public SymbolicPathNameTlv(byte[] rawValue, short hLength) {
+ this.rawValue = rawValue;
+ if (0 == hLength) {
+ this.hLength = (short) rawValue.length;
+ } else {
+ this.hLength = hLength;
+ }
+ }
+
+ /**
+ * Creates an object of SymbolicPathNameTlv.
+ *
+ * @param raw Symbolic path name
+ * @param hLength length of Symbolic path name
+ * @return object of SymbolicPathNameTlv
+ */
+ public static SymbolicPathNameTlv of(final byte[] raw, short hLength) {
+ return new SymbolicPathNameTlv(raw, hLength);
+ }
+
+ /**
+ * Returns Symbolic path name.
+ *
+ * @return Symbolic path name byte array
+ */
+ 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 SymbolicPathNameTlv) {
+ SymbolicPathNameTlv other = (SymbolicPathNameTlv) 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 SymbolicPathNameTlv.
+ *
+ * @param c of type channel buffer
+ * @param hLength length of bytes to read
+ * @return object of SymbolicPathNameTlv
+ */
+ public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) {
+ byte[] symbolicPathName = new byte[hLength];
+ c.readBytes(symbolicPathName, 0, hLength);
+ return new SymbolicPathNameTlv(symbolicPathName, hLength);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("SymbolicPathName ", rawValue)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java
new file mode 100644
index 00000000..4429d223
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TEDefaultMetricTlv.java
@@ -0,0 +1,137 @@
+/*
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
new file mode 100644
index 00000000..b3b71aef
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkAttributesTlv.java
@@ -0,0 +1,292 @@
+/*
+ * 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 (tlv == null) {
+ 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 - TLV_HEADER_LENGTH));
+
+ 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<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java
new file mode 100644
index 00000000..b974cf82
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TELinkDescriptorsTlv.java
@@ -0,0 +1,251 @@
+/*
+ * 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 - TLV_HEADER_LENGTH));
+
+ 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<>();
+
+ ChannelBuffer tempCb = c.readBytes(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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
new file mode 100644
index 00000000..f18b75b2
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TENodeAttributesTlv.java
@@ -0,0 +1,250 @@
+/*
+ * 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 Node Attributes Tlv.
+ */
+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 - TLV_HEADER_LENGTH));
+
+ 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<>();
+
+ ChannelBuffer tempCb = c.readBytes(hLength);
+
+ 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.java
new file mode 100644
index 00000000..189dcadc
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/TedCapabilityTlv.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;
+
+/**
+ * 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/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java
new file mode 100644
index 00000000..d44bf824
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/UnreservedBandwidthTlv.java
@@ -0,0 +1,136 @@
+/*
+ * 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();
+ }
+}
diff --git a/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java
new file mode 100644
index 00000000..12744de1
--- /dev/null
+++ b/framework/src/onos/protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/types/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of Tlvs and Pcep common objects.
+ */
+package org.onosproject.pcepio.types;