aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types')
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java126
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java126
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java57
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java161
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java127
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java39
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java156
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java117
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java133
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java118
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java125
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java163
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java177
-rw-r--r--framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java127
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java20
-rwxr-xr-xframework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java20
16 files changed, 1792 insertions, 0 deletions
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
new file mode 100644
index 00000000..52bae466
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AreaIDTlv.java
@@ -0,0 +1,126 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides AreaID Tlv which contains opaque value (32 Bit Area-ID).
+ */
+public class AreaIDTlv implements BGPValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-11
+ * 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= 514 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit Area-ID) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AreaIDTlv.class);
+
+ public static final short TYPE = 514;
+ public static final short LENGTH = 4;
+
+ private final int areaID;
+
+ /**
+ * Constructor to initialize areaID.
+ *
+ * @param areaID of BGP AreaID Tlv
+ */
+ public AreaIDTlv(int areaID) {
+ this.areaID = areaID;
+ }
+
+ /**
+ * Returns object of this class with specified areaID.
+ *
+ * @param areaID opaque value of area id
+ * @return object of AreaIDTlv
+ */
+ public static AreaIDTlv of(final int areaID) {
+ return new AreaIDTlv(areaID);
+ }
+
+ /**
+ * Returns opaque value of area id.
+ *
+ * @return opaque value of area id
+ */
+ public int getAreaID() {
+ return areaID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(areaID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof AreaIDTlv) {
+ AreaIDTlv other = (AreaIDTlv) obj;
+ return Objects.equals(areaID, other.areaID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(areaID);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of AreaIDTlv.
+ *
+ * @param cb ChannelBuffer
+ * @return object of AreaIDTlv
+ */
+ public static AreaIDTlv read(ChannelBuffer cb) {
+ return AreaIDTlv.of(cb.readInt());
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", areaID)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
new file mode 100644
index 00000000..5d8a9193
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/AutonomousSystemTlv.java
@@ -0,0 +1,126 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+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 BGPValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-11
+ * 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= 512 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit AS Number) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
+
+ public static final short TYPE = 512;
+ public static final short LENGTH = 4;
+
+ private final int asNum;
+
+ /**
+ * Constructor to initialize asNum.
+ *
+ * @param asNum 32 Bit AS Number
+ */
+ public AutonomousSystemTlv(int asNum) {
+ this.asNum = asNum;
+ }
+
+ /**
+ * Returns object of this class with specified asNum.
+ *
+ * @param asNum 32 Bit AS Number
+ * @return object of AutonomousSystemTlv
+ */
+ public static AutonomousSystemTlv of(final int asNum) {
+ return new AutonomousSystemTlv(asNum);
+ }
+
+ /**
+ * Returns opaque value of AS Number.
+ *
+ * @return opaque value of AS Number
+ */
+ public int getAsNum() {
+ return asNum;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(asNum);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof AutonomousSystemTlv) {
+ AutonomousSystemTlv other = (AutonomousSystemTlv) obj;
+ return Objects.equals(asNum, other.asNum);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(asNum);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of AutonomousSystemTlv.
+ *
+ * @param c ChannelBuffer
+ * @return object of AutonomousSystemTlv
+ */
+ public static AutonomousSystemTlv read(ChannelBuffer c) {
+ return AutonomousSystemTlv.of(c.readInt());
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("asNum", asNum)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java
new file mode 100644
index 00000000..f643ae00
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPErrorType.java
@@ -0,0 +1,57 @@
+/*
+ * 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.bgpio.types;
+
+/**
+ * BgpErrorType class defines all errorCodes and error Subcodes required for Notification message.
+ */
+public final class BGPErrorType {
+ private BGPErrorType() {
+ }
+
+ //Error Codes
+ public static final byte MESSAGE_HEADER_ERROR = 1;
+ public static final byte OPEN_MESSAGE_ERROR = 2;
+ public static final byte UPDATE_MESSAGE_ERROR = 3;
+ public static final byte HOLD_TIMER_EXPIRED = 4;
+ public static final byte FINITE_STATE_MACHINE_ERROR = 4;
+ public static final byte CEASE = 5;
+
+ //Message Header Error subcodes
+ public static final byte CONNECTION_NOT_SYNCHRONIZED = 1;
+ public static final byte BAD_MESSAGE_LENGTH = 2;
+ public static final byte BAD_MESSAGE_TYPE = 3;
+
+ //OPEN Message Error subcodes
+ public static final byte UNSUPPORTED_VERSION_NUMBER = 1;
+ public static final byte BAD_PEER_AS = 2;
+ public static final byte BAD_BGP_IDENTIFIER = 3;
+ public static final byte UNSUPPORTED_OPTIONAL_PARAMETER = 4;
+ public static final byte UNACCEPTABLE_HOLD_TIME = 5;
+
+ //UPDATE Message Error subcodes
+ public static final byte MALFORMED_ATTRIBUTE_LIST = 1;
+ public static final byte UNRECOGNIZED_WELLKNOWN_ATTRIBUTE = 2;
+ public static final byte MISSING_WELLKNOWN_ATTRIBUTE = 3;
+ public static final byte ATTRIBUTE_FLAGS_ERROR = 4;
+ public static final byte ATTRIBUTE_LENGTH_ERROR = 5;
+ public static final byte INVALID_ORIGIN_ATTRIBUTE = 6;
+ public static final byte INVALID_NEXTHOP_ATTRIBUTE = 8;
+ public static final byte OPTIONAL_ATTRIBUTE_ERROR = 9;
+ public static final byte INVALID_NETWORK_FIELD = 10;
+ public static final byte MALFORMED_ASPATH = 11;
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.java
new file mode 100755
index 00000000..6acda0d6
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPHeader.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.bgpio.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides BGP Message Header which is common for all the Messages.
+ */
+
+public class BGPHeader {
+
+ /* 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
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | |
+ + +
+ | |
+ + +
+ | Marker |
+ + +
+ | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Length | Type |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPHeader.class);
+
+ public static final int MARKER_LENGTH = 16;
+ public static final short DEFAULT_HEADER_LENGTH = 19;
+
+ private byte[] marker;
+ private byte type;
+ private short length;
+
+ /**
+ * Reset fields.
+ */
+ public BGPHeader() {
+ this.marker = null;
+ this.length = 0;
+ this.type = 0;
+ }
+
+ /**
+ * Constructors to initialize parameters.
+ *
+ * @param marker field in BGP header
+ * @param length message length
+ * @param type message type
+ */
+ public BGPHeader(byte[] marker, short length, byte type) {
+ this.marker = marker;
+ this.length = length;
+ this.type = type;
+ }
+
+ /**
+ * Sets marker field.
+ *
+ * @param value marker field
+ */
+ public void setMarker(byte[] value) {
+ this.marker = value;
+ }
+
+ /**
+ * Sets message type.
+ *
+ * @param value message type
+ */
+ public void setType(byte value) {
+ this.type = value;
+ }
+
+ /**
+ * Sets message length.
+ *
+ * @param value message length
+ */
+ public void setLength(short value) {
+ this.length = value;
+ }
+
+ /**
+ * Returns message length.
+ *
+ * @return message length
+ */
+ public short getLength() {
+ return this.length;
+ }
+
+ /**
+ * Returns message marker.
+ *
+ * @return message marker
+ */
+ public byte[] getMarker() {
+ return this.marker;
+ }
+
+ /**
+ * Returns message type.
+ *
+ * @return message type
+ */
+ public byte getType() {
+ return this.type;
+ }
+
+ /**
+ * Writes Byte stream of BGP header to channel buffer.
+ *
+ * @param cb ChannelBuffer
+ * @return length index of message header
+ */
+ public int write(ChannelBuffer cb) {
+
+ cb.writeBytes(getMarker(), 0, MARKER_LENGTH);
+
+ int headerLenIndex = cb.writerIndex();
+ cb.writeShort((short) 0);
+ cb.writeByte(type);
+
+ return headerLenIndex;
+ }
+
+ /**
+ * Read from channel buffer and Returns BGP header.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BGPHeader
+ */
+ public static BGPHeader read(ChannelBuffer cb) {
+
+ byte[] marker = new byte[MARKER_LENGTH];
+ byte type;
+ short length;
+ cb.readBytes(marker, 0, MARKER_LENGTH);
+ length = cb.readShort();
+ type = cb.readByte();
+ return new BGPHeader(marker, length, type);
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java
new file mode 100644
index 00000000..f723d2ca
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPLSIdentifierTlv.java
@@ -0,0 +1,127 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides BGPLSIdentifier Tlv which contains opaque value (32 Bit BGPLS-Identifier).
+ */
+public class BGPLSIdentifierTlv implements BGPValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-11
+ * 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= 513 | Length=4 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | opaque value (32 Bit BGPLS-Identifier) |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(BGPLSIdentifierTlv.class);
+
+ public static final short TYPE = 513;
+ public static final short LENGTH = 4;
+
+ private final int bgpLSIdentifier;
+
+ /**
+ * Constructor to initialize bgpLSIdentifier.
+ *
+ * @param bgpLSIdentifier BgpLS-Identifier
+ */
+ public BGPLSIdentifierTlv(int bgpLSIdentifier) {
+ this.bgpLSIdentifier = bgpLSIdentifier;
+ }
+
+ /**
+ * Returns object of this class with specified rbgpLSIdentifier.
+ *
+ * @param bgpLSIdentifier BgpLS-Identifier
+ * @return BgpLS-Identifier
+ */
+ public static BGPLSIdentifierTlv of(final int bgpLSIdentifier) {
+ return new BGPLSIdentifierTlv(bgpLSIdentifier);
+ }
+
+ /**
+ * Returns opaque value of BgpLS-Identifier.
+ *
+ * @return opaque value of BgpLS-Identifier
+ */
+ public int getBgpLSIdentifier() {
+ return bgpLSIdentifier;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bgpLSIdentifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BGPLSIdentifierTlv) {
+ BGPLSIdentifierTlv other = (BGPLSIdentifierTlv) obj;
+ return Objects.equals(bgpLSIdentifier, other.bgpLSIdentifier);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(bgpLSIdentifier);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and parses BGPLS Identifier TLV.
+ *
+ * @param cb ChannelBuffer
+ * @return object of BGPLSIdentifierTlv
+ */
+ public static BGPLSIdentifierTlv read(ChannelBuffer cb) {
+ return BGPLSIdentifierTlv.of(cb.readInt());
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", bgpLSIdentifier)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java
new file mode 100755
index 00000000..54a8b43c
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BGPValueType.java
@@ -0,0 +1,39 @@
+/*
+ * 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.bgpio.types;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+
+/**
+ * Abstraction which Provides the BGP of TLV format.
+ */
+public interface BGPValueType {
+ /**
+ * Returns the Type of BGP Message.
+ *
+ * @return short value of type
+ */
+ short getType();
+
+ /**
+ * Writes the byte Stream of BGP Message to channel buffer.
+ *
+ * @param cb channel buffer
+ * @return length written to channel buffer
+ */
+ int write(ChannelBuffer cb);
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.java
new file mode 100644
index 00000000..85fb748b
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IPReachabilityInformationTlv.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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.IpPrefix;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides IP Reachability InformationTlv Tlv which contains IP Prefix.
+ */
+public class IPReachabilityInformationTlv implements BGPValueType {
+
+ /*
+ * Reference :draft-ietf-idr-ls-distribution-11
+
+ 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 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Prefix Length | IP Prefix (variable) //
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ Figure 14: IP Reachability Information TLV Format
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(IPReachabilityInformationTlv.class);
+
+ public static final short TYPE = 265;
+ public static final int ONE_BYTE_LEN = 8;
+ private byte prefixLen;
+ private byte[] ipPrefix;
+ public short length;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param prefixLen length of IP Prefix
+ * @param ipPrefix IP Prefix
+ * @param length length of value field
+ */
+ public IPReachabilityInformationTlv(byte prefixLen, byte[] ipPrefix, short length) {
+ this.ipPrefix = ipPrefix;
+ this.prefixLen = prefixLen;
+ this.length = length;
+ }
+
+ /**
+ * Returns IP Prefix.
+ *
+ * @return IP Prefix
+ */
+ public IpPrefix getPrefixValue() {
+ IpPrefix prefix = Validation.bytesToPrefix(ipPrefix, prefixLen);
+ return prefix;
+ }
+
+ /**
+ * Returns IP Prefix length.
+ *
+ * @return IP Prefix length
+ */
+ public byte getPrefixLen() {
+ return this.prefixLen;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ipPrefix, prefixLen);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof IPReachabilityInformationTlv) {
+ IPReachabilityInformationTlv other = (IPReachabilityInformationTlv) obj;
+ return Objects.equals(prefixLen, other.prefixLen) && Objects.equals(ipPrefix, other.ipPrefix);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ int iLenStartIndex = cb.writerIndex();
+ cb.writeShort(TYPE);
+ cb.writeShort(length);
+ cb.writeByte(prefixLen);
+ cb.writeBytes(ipPrefix);
+ return cb.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IPReachabilityInformationTlv.
+ *
+ * @param cb ChannelBuffer
+ * @param length of value field
+ * @return object of IPReachabilityInformationTlv
+ */
+ public static IPReachabilityInformationTlv read(ChannelBuffer cb, short length) {
+ byte preficLen = cb.readByte();
+ byte[] prefix;
+ if (preficLen == 0) {
+ prefix = new byte[] {0};
+ } else {
+ int len = preficLen / ONE_BYTE_LEN;
+ int reminder = preficLen % ONE_BYTE_LEN;
+ if (reminder > 0) {
+ len = len + 1;
+ }
+ prefix = new byte[len];
+ cb.readBytes(prefix, 0, len);
+ }
+ return IPReachabilityInformationTlv.of(preficLen, prefix, length);
+ }
+
+ public static IPReachabilityInformationTlv of(final byte preficLen, final byte[] prefix, final short length) {
+ return new IPReachabilityInformationTlv(preficLen, prefix, length);
+ }
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", length)
+ .add("Prefixlength", getPrefixLen())
+ .add("Prefixvalue", getPrefixValue())
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
new file mode 100644
index 00000000..d5f3e7f3
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsNonPseudonode.java
@@ -0,0 +1,117 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.protocol.IGPRouterID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides Implementation of IsIsNonPseudonode Tlv.
+ */
+public class IsIsNonPseudonode implements IGPRouterID, BGPValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IsIsNonPseudonode.class);
+
+ public static final short TYPE = 515;
+ public static final short LENGTH = 6;
+
+ private final byte[] isoNodeID;
+
+ /**
+ * Constructor to initialize isoNodeID.
+ *
+ * @param isoNodeID ISO system-ID
+ */
+ public IsIsNonPseudonode(byte[] isoNodeID) {
+ this.isoNodeID = isoNodeID;
+ }
+
+ /**
+ * Returns object of this class with specified isoNodeID.
+ *
+ * @param isoNodeID ISO system-ID
+ * @return object of IsIsNonPseudonode
+ */
+ public static IsIsNonPseudonode of(final byte[] isoNodeID) {
+ return new IsIsNonPseudonode(isoNodeID);
+ }
+
+ /**
+ * Returns ISO NodeID.
+ *
+ * @return ISO NodeID
+ */
+ public byte[] getISONodeID() {
+ return isoNodeID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(isoNodeID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IsIsNonPseudonode) {
+ IsIsNonPseudonode other = (IsIsNonPseudonode) obj;
+ return Objects.equals(isoNodeID, other.isoNodeID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(isoNodeID);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IsIsNonPseudonode.
+ *
+ * @param cb ChannelBuffer
+ * @return object of IsIsNonPseudonode
+ */
+ public static IsIsNonPseudonode read(ChannelBuffer cb) {
+ byte[] isoNodeID = new byte[LENGTH];
+ cb.readBytes(isoNodeID, 0, LENGTH);
+ return IsIsNonPseudonode.of(isoNodeID);
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("ISONodeID", isoNodeID)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
new file mode 100644
index 00000000..5c742d0f
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/IsIsPseudonode.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.protocol.IGPRouterID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides implementation of IsIsPseudonode Tlv.
+ */
+public class IsIsPseudonode implements IGPRouterID, BGPValueType {
+ protected static final Logger log = LoggerFactory.getLogger(IsIsPseudonode.class);
+
+ public static final short TYPE = 515;
+ public static final short LENGTH = 7;
+
+ private final byte[] isoNodeID;
+ private byte psnIdentifier;
+
+ /**
+ * Constructor to initialize isoNodeID.
+ *
+ * @param isoNodeID ISO system-ID
+ * @param psnIdentifier PSN identifier
+ */
+ public IsIsPseudonode(byte[] isoNodeID, byte psnIdentifier) {
+ this.isoNodeID = isoNodeID;
+ this.psnIdentifier = psnIdentifier;
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param isoNodeID ISO system-ID
+ * @param psnIdentifier PSN identifier
+ * @return object of IsIsPseudonode
+ */
+ public static IsIsPseudonode of(final byte[] isoNodeID, final byte psnIdentifier) {
+ return new IsIsPseudonode(isoNodeID, psnIdentifier);
+ }
+
+ /**
+ * Returns ISO NodeID.
+ *
+ * @return ISO NodeID
+ */
+ public byte[] getISONodeID() {
+ return isoNodeID;
+ }
+
+ /**
+ * Returns PSN Identifier.
+ *
+ * @return PSN Identifier
+ */
+ public byte getPSNIdentifier() {
+ return this.psnIdentifier;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(isoNodeID, psnIdentifier);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof IsIsPseudonode) {
+ IsIsPseudonode other = (IsIsPseudonode) obj;
+ return Objects.equals(isoNodeID, other.isoNodeID) && Objects.equals(psnIdentifier, other.psnIdentifier);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeBytes(isoNodeID);
+ c.writeByte(psnIdentifier);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of IsIsPseudonode.
+ *
+ * @param cb ChannelBuffer
+ * @return object of IsIsPseudonode
+ */
+ public static IsIsPseudonode read(ChannelBuffer cb) {
+ byte[] isoNodeID = new byte[LENGTH - 1];
+ cb.readBytes(isoNodeID, 0, LENGTH - 1);
+ byte psnIdentifier = cb.readByte();
+ return IsIsPseudonode.of(isoNodeID, psnIdentifier);
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("isoNodeID", isoNodeID)
+ .add("psnIdentifier", psnIdentifier)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
new file mode 100644
index 00000000..6d8282b7
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFNonPseudonode.java
@@ -0,0 +1,118 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.protocol.IGPRouterID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides implementation of OSPFNonPseudonode Tlv.
+ */
+public class OSPFNonPseudonode implements IGPRouterID, BGPValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(OSPFNonPseudonode.class);
+
+ public static final short TYPE = 515;
+ public static final short LENGTH = 4;
+
+ private final int routerID;
+
+ /**
+ * Constructor to initialize routerID.
+ *
+ * @param routerID routerID
+ */
+ public OSPFNonPseudonode(int routerID) {
+ this.routerID = routerID;
+ }
+
+ /**
+ * Returns object of this class with specified routerID.
+ *
+ * @param routerID routerID
+ * @return object of OSPFNonPseudonode
+ */
+ public static OSPFNonPseudonode of(final int routerID) {
+ return new OSPFNonPseudonode(routerID);
+ }
+
+ /**
+ * Returns RouterID.
+ *
+ * @return RouterID
+ */
+ public int getrouterID() {
+ return this.routerID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routerID);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof OSPFNonPseudonode) {
+ OSPFNonPseudonode other = (OSPFNonPseudonode) obj;
+ return Objects.equals(routerID, other.routerID);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(routerID);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OSPFNonPseudonode.
+ *
+ * @param cb ChannelBuffer
+ * @return object of OSPFNonPseudonode
+ */
+ public static OSPFNonPseudonode read(ChannelBuffer cb) {
+ return OSPFNonPseudonode.of(cb.readInt());
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("RouterID", routerID)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
new file mode 100644
index 00000000..82a39bd1
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFPseudonode.java
@@ -0,0 +1,125 @@
+/*
+ * 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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.bgpio.protocol.IGPRouterID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides implementation of OSPFPseudonode Tlv.
+ */
+public class OSPFPseudonode implements IGPRouterID, BGPValueType {
+
+ protected static final Logger log = LoggerFactory.getLogger(OSPFPseudonode.class);
+
+ public static final short TYPE = 515;
+ public static final short LENGTH = 8;
+
+ private final int routerID;
+ private final Ip4Address drInterface;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param routerID routerID
+ * @param drInterface IPv4 address of the DR's interface
+ */
+ public OSPFPseudonode(int routerID, Ip4Address drInterface) {
+ this.routerID = routerID;
+ this.drInterface = drInterface;
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param routerID routerID
+ * @param drInterface IPv4 address of the DR's interface
+ * @return object of OSPFPseudonode
+ */
+ public static OSPFPseudonode of(final int routerID, final Ip4Address drInterface) {
+ return new OSPFPseudonode(routerID, drInterface);
+ }
+
+ /**
+ * Returns RouterID.
+ *
+ * @return RouterID
+ */
+ public int getrouterID() {
+ return this.routerID;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routerID, drInterface);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OSPFPseudonode) {
+ OSPFPseudonode other = (OSPFPseudonode) obj;
+ return Objects.equals(routerID, other.routerID) && Objects.equals(drInterface, other.drInterface);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeInt(routerID);
+ c.writeInt(drInterface.toInt());
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads the channel buffer and returns object of OSPFPseudonode.
+ *
+ * @param cb ChannelBuffer
+ * @return object of OSPFPseudonode
+ */
+ public static OSPFPseudonode read(ChannelBuffer cb) {
+ int routerID = cb.readInt();
+ Ip4Address drInterface = Ip4Address.valueOf(cb.readInt());
+ return OSPFPseudonode.of(routerID, drInterface);
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("RouterID", routerID)
+ .add("DRInterface", drInterface)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.java
new file mode 100644
index 00000000..20fffbfa
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/OSPFRouteTypeTlv.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.bgpio.types;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Provides OSPF Route Type Tlv which contains route type.
+ */
+public class OSPFRouteTypeTlv implements BGPValueType {
+
+ /* Reference :draft-ietf-idr-ls-distribution-11
+ 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 |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Route Type |
+ +-+-+-+-+-+-+-+-+
+
+ Figure : OSPF Route Type TLV Format
+ */
+
+ protected static final Logger log = LoggerFactory.getLogger(OSPFRouteTypeTlv.class);
+
+ public static final short TYPE = 264;
+ public static final short LENGTH = 1;
+ public static final int INTRA_AREA_TYPE = 1;
+ public static final short INTER_AREA_TYPE = 2;
+ public static final short EXTERNAL_TYPE_1 = 3;
+ public static final short EXTERNAL_TYPE_2 = 4;
+ public static final short NSSA_TYPE_1 = 5;
+ public static final short NSSA_TYPE_2 = 6;
+ private final byte routeType;
+
+ /**
+ * Enum for Route Type.
+ */
+ public enum ROUTETYPE {
+ Intra_Area(1), Inter_Area(2), External_1(3), External_2(4), NSSA_1(5), NSSA_2(6);
+ int value;
+ ROUTETYPE(int val) {
+ value = val;
+ }
+ public byte getType() {
+ return (byte) value;
+ }
+ }
+
+ /**
+ * Constructor to initialize routeType.
+ *
+ * @param routeType Route type
+ */
+ public OSPFRouteTypeTlv(byte routeType) {
+ this.routeType = routeType;
+ }
+
+ /**
+ * Returns object of this class with specified routeType.
+ *
+ * @param routeType Route type
+ * @return object of OSPFRouteTypeTlv
+ */
+ public static OSPFRouteTypeTlv of(final byte routeType) {
+ return new OSPFRouteTypeTlv(routeType);
+ }
+
+ /**
+ * Returns RouteType.
+ *
+ * @return RouteType
+ * @throws BGPParseException if routeType is not matched
+ */
+ public ROUTETYPE getValue() throws BGPParseException {
+ switch (routeType) {
+ case INTRA_AREA_TYPE:
+ return ROUTETYPE.Intra_Area;
+ case INTER_AREA_TYPE:
+ return ROUTETYPE.Inter_Area;
+ case EXTERNAL_TYPE_1:
+ return ROUTETYPE.External_1;
+ case EXTERNAL_TYPE_2:
+ return ROUTETYPE.External_2;
+ case NSSA_TYPE_1:
+ return ROUTETYPE.NSSA_1;
+ case NSSA_TYPE_2:
+ return ROUTETYPE.NSSA_2;
+ default:
+ throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(routeType);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof OSPFRouteTypeTlv) {
+ OSPFRouteTypeTlv other = (OSPFRouteTypeTlv) obj;
+ return Objects.equals(routeType, other.routeType);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer c) {
+ int iLenStartIndex = c.writerIndex();
+ c.writeShort(TYPE);
+ c.writeShort(LENGTH);
+ c.writeByte(routeType);
+ return c.writerIndex() - iLenStartIndex;
+ }
+
+ /**
+ * Reads from ChannelBuffer and parses OSPFRouteTypeTlv.
+ *
+ * @param cb channelBuffer
+ * @return object of OSPFRouteTypeTlv
+ */
+ public static OSPFRouteTypeTlv read(ChannelBuffer cb) {
+ return OSPFRouteTypeTlv.of(cb.readByte());
+ }
+
+ @Override
+ public short getType() {
+ return TYPE;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("Type", TYPE)
+ .add("Length", LENGTH)
+ .add("Value", routeType)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
new file mode 100755
index 00000000..ba02f6d1
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeFlagBitTlv.java
@@ -0,0 +1,177 @@
+/*
+ * 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.bgpio.types.attr;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implements BGP attribute node flag.
+ */
+public class BgpAttrNodeFlagBitTlv implements BGPValueType {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(BgpAttrNodeFlagBitTlv.class);
+
+ public static final int ATTRNODE_FLAGBIT = 1024;
+
+ /* Node flag bit TLV */
+ private boolean bOverloadBit;
+ private boolean bAttachedBit;
+ private boolean bExternalBit;
+ private boolean bABRBit;
+
+ public static final int BIT_SET = 1;
+ public static final int FIRST_BIT = 0x80;
+ public static final int SECOND_BIT = 0x40;
+ public static final int THIRD_BIT = 0x20;
+ public static final int FOURTH_BIT = 0x01;
+
+ /**
+ * Constructor to initialize parameters.
+ *
+ * @param bOverloadBit Overload bit
+ * @param bAttachedBit Attached bit
+ * @param bExternalBit External bit
+ * @param bABRBit ABR Bit
+ */
+ BgpAttrNodeFlagBitTlv(boolean bOverloadBit, boolean bAttachedBit,
+ boolean bExternalBit, boolean bABRBit) {
+ this.bOverloadBit = bOverloadBit;
+ this.bAttachedBit = bAttachedBit;
+ this.bExternalBit = bExternalBit;
+ this.bABRBit = bABRBit;
+ }
+
+ /**
+ * Reads the Node Flag Bits.
+ *
+ * @param cb ChannelBuffer
+ * @return attribute node flag bit tlv
+ * @throws BGPParseException while parsing BgpAttrNodeFlagBitTlv
+ */
+ public static BgpAttrNodeFlagBitTlv read(ChannelBuffer cb)
+ throws BGPParseException {
+ boolean bOverloadBit = false;
+ boolean bAttachedBit = false;
+ boolean bExternalBit = false;
+ boolean bABRBit = false;
+
+ short lsAttrLength = cb.readShort();
+
+ if (lsAttrLength != 1) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ lsAttrLength);
+ }
+
+ byte nodeFlagBits = cb.readByte();
+
+ bOverloadBit = ((nodeFlagBits & (byte) FIRST_BIT) == FIRST_BIT);
+ bAttachedBit = ((nodeFlagBits & (byte) SECOND_BIT) == SECOND_BIT);
+ bExternalBit = ((nodeFlagBits & (byte) THIRD_BIT) == THIRD_BIT);
+ bABRBit = ((nodeFlagBits & (byte) FOURTH_BIT) == FOURTH_BIT);
+
+ return new BgpAttrNodeFlagBitTlv(bOverloadBit, bAttachedBit,
+ bExternalBit, bABRBit);
+ }
+
+ /**
+ * Returns Overload Bit.
+ *
+ * @return Overload Bit
+ */
+ boolean getOverLoadBit() {
+ return bOverloadBit;
+ }
+
+ /**
+ * Returns Attached Bit.
+ *
+ * @return Attached Bit
+ */
+ boolean getAttachedBit() {
+ return bAttachedBit;
+ }
+
+ /**
+ * Returns External Bit.
+ *
+ * @return External Bit
+ */
+ boolean getExternalBit() {
+ return bExternalBit;
+ }
+
+ /**
+ * Returns ABR Bit.
+ *
+ * @return ABR Bit
+ */
+ boolean getABRBit() {
+ return bABRBit;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_FLAGBIT;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO will be implementing it later
+ return 0;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bOverloadBit, bAttachedBit, bExternalBit, bABRBit);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrNodeFlagBitTlv) {
+ BgpAttrNodeFlagBitTlv other = (BgpAttrNodeFlagBitTlv) obj;
+ return Objects.equals(bOverloadBit, other.bOverloadBit)
+ && Objects.equals(bAttachedBit, other.bAttachedBit)
+ && Objects.equals(bExternalBit, other.bExternalBit)
+ && Objects.equals(bABRBit, other.bABRBit);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("bOverloadBit", bOverloadBit)
+ .add("bAttachedBit", bAttachedBit)
+ .add("bExternalBit", bExternalBit).add("bABRBit", bABRBit)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
new file mode 100644
index 00000000..194d6dac
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeMultiTopologyId.java
@@ -0,0 +1,127 @@
+/*
+ * 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.bgpio.types.attr;
+
+import java.util.Objects;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.util.Validation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * BGP Multi-Topology ID of the LS attribute.
+ */
+public class BgpAttrNodeMultiTopologyId implements BGPValueType {
+
+ private static final Logger log = LoggerFactory
+ .getLogger(BgpAttrNodeMultiTopologyId.class);
+
+ public static final int ATTRNODE_MULTITOPOLOGY = 263;
+
+ /* Opaque Node Attribute */
+ private short[] multiTopologyId;
+
+ /**
+ * Constructor to initialize the Node attribute multi-topology ID.
+ *
+ * @param multiTopologyId multi-topology ID
+ */
+ BgpAttrNodeMultiTopologyId(short[] multiTopologyId) {
+ this.multiTopologyId = multiTopologyId;
+ }
+
+ /**
+ * Reads the Multi-topology ID of Node attribute.
+ *
+ * @param cb ChannelBuffer
+ * @return Constructor of BgpAttrNodeMultiTopologyId
+ * @throws BGPParseException while parsing BgpAttrNodeMultiTopologyId
+ */
+ public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb)
+ throws BGPParseException {
+
+ log.debug("BgpAttrNodeMultiTopologyId");
+ short lsAttrLength = cb.readShort();
+ int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs
+
+ if (cb.readableBytes() < lsAttrLength) {
+ Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR,
+ BGPErrorType.ATTRIBUTE_LENGTH_ERROR,
+ cb.readableBytes());
+ }
+
+ short[] multiTopologyId;
+ multiTopologyId = new short[len];
+ for (int i = 0; i < len; i++) {
+ multiTopologyId[i] = cb.readShort();
+ }
+
+ return new BgpAttrNodeMultiTopologyId(multiTopologyId);
+ }
+
+ /**
+ * to get the multi-topology ID.
+ *
+ * @return multitopology ID
+ */
+ short[] getAttrMultiTopologyId() {
+ return multiTopologyId;
+ }
+
+ @Override
+ public short getType() {
+ return ATTRNODE_MULTITOPOLOGY;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(multiTopologyId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj instanceof BgpAttrNodeMultiTopologyId) {
+ BgpAttrNodeMultiTopologyId other = (BgpAttrNodeMultiTopologyId) obj;
+ return Objects.equals(multiTopologyId, other.multiTopologyId);
+ }
+ return false;
+ }
+
+ @Override
+ public int write(ChannelBuffer cb) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("multiTopologyId", multiTopologyId)
+ .toString();
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java
new file mode 100755
index 00000000..e2a74dbc
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/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 BGP Link state attribute Tlvs.
+ */
+package org.onosproject.bgpio.types.attr;
diff --git a/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java
new file mode 100755
index 00000000..1f2ed95e
--- /dev/null
+++ b/framework/src/onos/bgp/bgpio/src/main/java/org/onosproject/bgpio/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, Attributes and Descriptors.
+ */
+package org.onosproject.bgpio.types;