[Emu] [ONOS-2603] Implement BGP Update Protocol Message and parse all Link State atrributes of
 Node and Prefix

Change-Id: I1859ad92a1fc5ba0035865576fd062cf8f1ed64e
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java
new file mode 100644
index 0000000..572e2ae
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPLSNlri.java
@@ -0,0 +1,54 @@
+/*
+ * 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.protocol;
+
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSNlriVer4.PROTOCOLTYPE;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+
+/**
+ * Abstraction of an entity providing BGP-LS NLRI.
+ */
+public interface BGPLSNlri {
+    /**
+     * Returns NlriType of BGP-LS NLRI.
+     *
+     * @return NlriType of BGP-LS NLRI
+     */
+    NlriType getNlriType();
+
+    /**
+     * Returns Identifier in Nlri.
+     *
+     * @return Identifier in Nlri
+     */
+    long getIdentifier();
+
+    /**
+     * Returns Protocol Id in Nlri.
+     *
+     * @return Protocol Id in Nlri
+     * @throws BGPParseException while getting protocol ID
+     */
+    PROTOCOLTYPE getProtocolId() throws BGPParseException;
+
+    /**
+     * Returns Route distinguisher in Nlri.
+     *
+     * @return Route distinguisher in Nlri
+     */
+    RouteDistinguisher getRouteDistinguisher();
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java
new file mode 100644
index 0000000..fd5b805
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPNodeLSNlri.java
@@ -0,0 +1,30 @@
+/*
+ * 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.protocol;
+
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSIdentifier;
+
+/**
+ * Abstraction of an entity providing BGP-LS Node NLRI.
+ */
+public interface BGPNodeLSNlri extends BGPLSNlri {
+    /**
+     * Returns local node descriptors.
+     *
+     * @return local node descriptors
+     */
+    BGPNodeLSIdentifier getLocalNodeDescriptors();
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java
new file mode 100644
index 0000000..7e849f4
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/BGPPrefixLSNlri.java
@@ -0,0 +1,40 @@
+/*
+ * 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.protocol;
+
+import java.util.LinkedList;
+
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.protocol.link_state.NodeDescriptors;
+
+/**
+ * Abstraction of an entity providing BGP-LS Prefix NLRI.
+ */
+public interface BGPPrefixLSNlri extends BGPLSNlri {
+    /**
+     * Returns local node descriptors.
+     *
+     * @return local node descriptors
+     */
+    NodeDescriptors getLocalNodeDescriptors();
+
+    /**
+     * Returns list of Prefix descriptor.
+     *
+     * @return list of Prefix descriptor
+     */
+    LinkedList<BGPValueType> getPrefixdescriptor();
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
new file mode 100644
index 0000000..535ba71
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/NlriType.java
@@ -0,0 +1,45 @@
+/*
+ * 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.protocol;
+
+/**
+ * Enum to Provide the Different BGP-LS NLRI types.
+ */
+public enum NlriType {
+
+    NODE(1), LINK(2), PREFIX_IPV4(3), PREFIX_IPV6(4);
+
+    int value;
+
+    /**
+     * Assign value with the value as the LINK-STATE NLRI type.
+     *
+     * @param value LINK-STATE NLRI type
+     */
+    NlriType(int value) {
+        this.value = value;
+    }
+
+    /**
+     * Returns value as LINK-STATE NLRI type.
+     *
+     * @return value LINK-STATE NLRI type
+     */
+    public byte getType() {
+        return (byte) value;
+    }
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.java
new file mode 100644
index 0000000..cd2422a
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSIdentifier.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.bgpio.protocol.link_state;
+
+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.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Node Identifier which includes local node descriptor/remote node descriptors.
+ */
+public class BGPNodeLSIdentifier {
+
+    protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSIdentifier.class);
+    private NodeDescriptors nodeDescriptors;
+
+    /**
+     * Resets fields.
+     */
+    public BGPNodeLSIdentifier() {
+        this.nodeDescriptors = null;
+    }
+
+    /**
+     * Constructor to initialize fields.
+     *
+     * @param nodeDescriptors local/remote node descriptor
+     */
+    public BGPNodeLSIdentifier(NodeDescriptors nodeDescriptors) {
+        this.nodeDescriptors = nodeDescriptors;
+    }
+
+    /**
+     * Parse local node descriptors.
+     *
+     * @param cb ChannelBuffer
+     * @param protocolId protocol identifier
+     * @return object of this BGPNodeLSIdentifier
+     * @throws BGPParseException while parsing local node descriptors
+     */
+    public static BGPNodeLSIdentifier parseLocalNodeDescriptors(ChannelBuffer cb, byte protocolId)
+            throws BGPParseException {
+        ChannelBuffer tempBuf = cb;
+        short type = cb.readShort();
+        short length = cb.readShort();
+        if (cb.readableBytes() < length) {
+            throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.OPTIONAL_ATTRIBUTE_ERROR,
+                                        tempBuf.readBytes(cb.readableBytes() + Constants.TYPE_AND_LEN));
+        }
+        NodeDescriptors nodeDescriptors = new NodeDescriptors();
+        ChannelBuffer tempCb = cb.readBytes(length);
+
+        if (type == NodeDescriptors.LOCAL_NODE_DES_TYPE) {
+            nodeDescriptors = NodeDescriptors.read(tempCb, length, type, protocolId);
+        } else {
+            throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, BGPErrorType.MALFORMED_ATTRIBUTE_LIST, null);
+        }
+        return new BGPNodeLSIdentifier(nodeDescriptors);
+    }
+
+    /**
+     * Returns node descriptors.
+     *
+     * @return node descriptors
+     */
+    public NodeDescriptors getNodedescriptors() {
+        return this.nodeDescriptors;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof BGPNodeLSIdentifier) {
+            BGPNodeLSIdentifier other = (BGPNodeLSIdentifier) obj;
+            return Objects.equals(nodeDescriptors, other.nodeDescriptors);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(nodeDescriptors);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("NodeDescriptors", nodeDescriptors)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java
new file mode 100644
index 0000000..04780d8
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPNodeLSNlriVer4.java
@@ -0,0 +1,212 @@
+/*
+ * 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.protocol.link_state;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPNodeLSNlri;
+import org.onosproject.bgpio.protocol.NlriType;
+import org.onosproject.bgpio.types.BGPErrorType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Node LS NLRI.
+ */
+public class BGPNodeLSNlriVer4 implements BGPNodeLSNlri {
+
+    /*
+     *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
+         +-+-+-+-+-+-+-+-+
+         |  Protocol-ID  |
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+         |                           Identifier                          |
+         |                            (64 bits)                          |
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+         //                Local Node Descriptors (variable)            //
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+                          Figure : The Node NLRI format
+     */
+
+    protected static final Logger log = LoggerFactory.getLogger(BGPNodeLSNlriVer4.class);
+
+    public static final int NODE_NLRITYPE = 1;
+    public static final int IDENTIFIER_LENGTH = 16;
+    private long identifier;
+    private byte protocolId;
+    private BGPNodeLSIdentifier localNodeDescriptors;
+    private RouteDistinguisher routeDistinguisher;
+    private boolean isVpn;
+
+    /**
+     * Enum to provide PROTOCOLTYPE.
+     */
+    public enum PROTOCOLTYPE {
+        ISIS_LevelOne(1), ISIS_LevelTwo(2), OSPFv2(3), Direct(4), Static_Configuration(5), OSPFv3(6);
+        int value;
+
+        /**
+         * Assign val with the value as the protocol type.
+         *
+         * @param val protocol type
+         */
+        PROTOCOLTYPE(int val) {
+            value = val;
+        }
+
+        /**
+         * Returns value of protocol type.
+         *
+         * @return protocol type
+         */
+        public byte getType() {
+            return (byte) value;
+        }
+    }
+
+    /**
+     * Reset fields.
+     */
+    public BGPNodeLSNlriVer4() {
+        this.identifier = 0;
+        this.protocolId = 0;
+        this.localNodeDescriptors = null;
+        this.routeDistinguisher = null;
+        this.isVpn = false;
+    }
+
+    /**
+     * Constructors to initialize its parameters.
+     *
+     * @param identifier of LinkState Nlri
+     * @param protocolId of LinkState Nlri
+     * @param localNodeDescriptors local node descriptors
+     * @param isVpn true if VPN info is present
+     * @param routeDistinguisher unique for each VPN
+     */
+    BGPNodeLSNlriVer4(long identifier, byte protocolId, BGPNodeLSIdentifier localNodeDescriptors, boolean isVpn,
+                      RouteDistinguisher routeDistinguisher) {
+        this.identifier = identifier;
+        this.protocolId = protocolId;
+        this.localNodeDescriptors = localNodeDescriptors;
+        this.routeDistinguisher = routeDistinguisher;
+        this.isVpn = isVpn;
+    }
+
+    /**
+     * Reads from channelBuffer and parses Node LS Nlri.
+     *
+     * @param cb ChannelBuffer
+     * @param afi Address Family Identifier
+     * @param safi Subsequent Address Family Identifier
+     * @return object of this class
+     * @throws BGPParseException while parsing node descriptors
+     */
+    public static BGPNodeLSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+        boolean isVpn = false;
+        RouteDistinguisher routeDistinguisher = null;
+        if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
+            routeDistinguisher = new RouteDistinguisher();
+            routeDistinguisher = RouteDistinguisher.read(cb);
+            isVpn = true;
+        } else {
+            isVpn = false;
+        }
+        byte protocolId = cb.readByte();
+        long identifier = cb.readLong();
+
+        // Parse Local Node Descriptors
+        BGPNodeLSIdentifier localNodeDescriptors = new BGPNodeLSIdentifier();
+        localNodeDescriptors = BGPNodeLSIdentifier.parseLocalNodeDescriptors(cb, protocolId);
+        return new BGPNodeLSNlriVer4(identifier, protocolId, localNodeDescriptors, isVpn, routeDistinguisher);
+    }
+
+    @Override
+    public NlriType getNlriType() {
+        return NlriType.NODE;
+    }
+
+    @Override
+    public BGPNodeLSIdentifier getLocalNodeDescriptors() {
+        return this.localNodeDescriptors;
+    }
+
+    /**
+     * Returns whether VPN is present or not.
+     *
+     * @return whether VPN is present or not
+     */
+    public boolean isVpnPresent() {
+        return this.isVpn;
+    }
+
+    @Override
+    public RouteDistinguisher getRouteDistinguisher() {
+        return this.routeDistinguisher;
+    }
+
+    @Override
+    public long getIdentifier() {
+        return this.identifier;
+    }
+
+    /**
+     * Set the node LS identifier.
+     *
+     * @param localNodeDescriptors node LS identifier to set
+     */
+    public void setNodeLSIdentifier(BGPNodeLSIdentifier localNodeDescriptors) {
+        this.localNodeDescriptors = localNodeDescriptors;
+    }
+
+    @Override
+    public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+        switch (protocolId) {
+        case Constants.ISIS_LEVELONE:
+            return PROTOCOLTYPE.ISIS_LevelOne;
+        case Constants.ISIS_LEVELTWO:
+            return PROTOCOLTYPE.ISIS_LevelTwo;
+        case Constants.OSPFV2:
+            return PROTOCOLTYPE.OSPFv2;
+        case Constants.DIRECT:
+            return PROTOCOLTYPE.Direct;
+        case Constants.STATIC_CONFIGURATION:
+            return PROTOCOLTYPE.Static_Configuration;
+        case Constants.OSPFV3:
+            return PROTOCOLTYPE.OSPFv3;
+        default:
+            throw new BGPParseException(BGPErrorType.UPDATE_MESSAGE_ERROR, (byte) 0, null);
+        }
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("protocolId", protocolId)
+                .add("identifier", identifier)
+                .add("RouteDistinguisher ", routeDistinguisher)
+                .add("localNodeDescriptors", localNodeDescriptors)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java
new file mode 100644
index 0000000..0f18c75
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/BGPPrefixIPv4LSNlriVer4.java
@@ -0,0 +1,205 @@
+/*
+ * 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.protocol.link_state;
+
+import java.util.LinkedList;
+
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.onosproject.bgpio.exceptions.BGPParseException;
+import org.onosproject.bgpio.protocol.BGPPrefixLSNlri;
+import org.onosproject.bgpio.protocol.NlriType;
+import org.onosproject.bgpio.protocol.link_state.BGPNodeLSNlriVer4.PROTOCOLTYPE;
+import org.onosproject.bgpio.types.BGPValueType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import org.onosproject.bgpio.util.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Implementation of Prefix IPV4 LS NLRI.
+ */
+public class BGPPrefixIPv4LSNlriVer4 implements BGPPrefixLSNlri {
+
+    /*
+     * 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
+         +-+-+-+-+-+-+-+-+
+         |  Protocol-ID  |
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+         |                           Identifier                          |
+         |                            (64 bits)                          |
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+         //              Local Node Descriptor (variable)               //
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+         //                Prefix Descriptors (variable)                //
+         +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+                Figure : The IPv4/IPv6 Topology Prefix NLRI format
+     */
+
+    protected static final Logger log = LoggerFactory.getLogger(BGPPrefixIPv4LSNlriVer4.class);
+
+    public static final int PREFIX_IPV4_NLRITYPE = 3;
+    public static final int IDENTIFIER_LENGTH = 16;
+    private long identifier;
+    private byte protocolId;
+    private RouteDistinguisher routeDistinguisher;
+    private boolean isVpn;
+    private BGPPrefixLSIdentifier bgpPrefixLSIdentifier;
+
+    /**
+     * Resets parameters.
+     */
+    public BGPPrefixIPv4LSNlriVer4() {
+        this.identifier = 0;
+        this.protocolId = 0;
+        this.bgpPrefixLSIdentifier = null;
+        this.routeDistinguisher = null;
+        this.isVpn = false;
+    }
+
+    /**
+     * Constructor to initialize parameters for BGP PrefixLSNlri.
+     *
+     * @param identifier field in BGP PrefixLSNlri
+     * @param protocolId protocol Id
+     * @param bgpPrefixLSIdentifier prefix LS Identifier
+     * @param routeDistinguisher RouteDistinguisher
+     * @param isVpn vpn availability in message
+     */
+    public BGPPrefixIPv4LSNlriVer4(long identifier, byte protocolId, BGPPrefixLSIdentifier bgpPrefixLSIdentifier,
+                                   RouteDistinguisher routeDistinguisher, boolean isVpn) {
+        this.identifier = identifier;
+        this.protocolId = protocolId;
+        this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
+        this.routeDistinguisher = routeDistinguisher;
+        this.isVpn = isVpn;
+    }
+
+    /**
+     * Reads from channelBuffer and parses Prefix LS Nlri.
+     *
+     * @param cb ChannelBuffer
+     * @param afi Address family identifier
+     * @param safi Subsequent address family identifier
+     * @return object of BGPPrefixIPv4LSNlriVer4
+     * @throws BGPParseException while parsing Prefix LS Nlri
+     */
+    public static BGPPrefixIPv4LSNlriVer4 read(ChannelBuffer cb, short afi, byte safi) throws BGPParseException {
+
+        boolean isVpn = false;
+        RouteDistinguisher routeDistinguisher = null;
+        if ((afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
+            routeDistinguisher = new RouteDistinguisher();
+            routeDistinguisher = RouteDistinguisher.read(cb);
+            isVpn = true;
+        } else {
+            isVpn = false;
+        }
+        byte protocolId = cb.readByte();
+        long identifier = cb.readLong();
+
+        BGPPrefixLSIdentifier bgpPrefixLSIdentifier = new BGPPrefixLSIdentifier();
+        bgpPrefixLSIdentifier = BGPPrefixLSIdentifier.parsePrefixIdendifier(cb, protocolId);
+        return new BGPPrefixIPv4LSNlriVer4(identifier, protocolId, bgpPrefixLSIdentifier, routeDistinguisher, isVpn);
+    }
+
+    @Override
+    public NlriType getNlriType() {
+        return NlriType.PREFIX_IPV4;
+    }
+
+    @Override
+    public NodeDescriptors getLocalNodeDescriptors() {
+        return this.bgpPrefixLSIdentifier.getLocalNodeDescriptors();
+    }
+
+    @Override
+    public long getIdentifier() {
+        return this.identifier;
+    }
+
+    /**
+     * Set the prefix LS identifier.
+     *
+     * @param bgpPrefixLSIdentifier prefix identifier to set
+     */
+    public void setPrefixLSIdentifier(BGPPrefixLSIdentifier bgpPrefixLSIdentifier) {
+        this.bgpPrefixLSIdentifier = bgpPrefixLSIdentifier;
+    }
+
+    @Override
+    public PROTOCOLTYPE getProtocolId() throws BGPParseException {
+        switch (protocolId) {
+        case Constants.ISIS_LEVELONE:
+            return PROTOCOLTYPE.ISIS_LevelOne;
+        case Constants.ISIS_LEVELTWO:
+            return PROTOCOLTYPE.ISIS_LevelTwo;
+        case Constants.OSPFV2:
+            return PROTOCOLTYPE.OSPFv2;
+        case Constants.DIRECT:
+            return PROTOCOLTYPE.Direct;
+        case Constants.STATIC_CONFIGURATION:
+            return PROTOCOLTYPE.Static_Configuration;
+        case Constants.OSPFV3:
+            return PROTOCOLTYPE.OSPFv3;
+        default:
+            throw new BGPParseException("protocol id not valid");
+        }
+    }
+
+    /**
+     * Returns whether VPN is present or not.
+     *
+     * @return whether VPN is present or not
+     */
+    public boolean isVpnPresent() {
+        return this.isVpn;
+    }
+
+    /**
+     * Returns Prefix Identifier.
+     *
+     * @return Prefix Identifier
+     */
+    public BGPPrefixLSIdentifier getPrefixIdentifier() {
+        return this.bgpPrefixLSIdentifier;
+    }
+
+    @Override
+    public RouteDistinguisher getRouteDistinguisher() {
+        return this.routeDistinguisher;
+    }
+
+    @Override
+    public LinkedList<BGPValueType> getPrefixdescriptor() {
+        return this.bgpPrefixLSIdentifier.getPrefixdescriptor();
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("protocolId", protocolId)
+                .add("identifier", identifier)
+                .add("RouteDistinguisher ", routeDistinguisher)
+                .add("bgpPrefixLSIdentifier", bgpPrefixLSIdentifier)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
new file mode 100644
index 0000000..d026709
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/RouteDistinguisher.java
@@ -0,0 +1,62 @@
+/*
+ * 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;
+
+/**
+ * Implementation of RouteDistinguisher.
+ */
+public class RouteDistinguisher {
+
+    private long routeDistinguisher;
+
+    /**
+     * Resets fields.
+     */
+    public RouteDistinguisher() {
+        this.routeDistinguisher = 0;
+    }
+
+    /**
+     * Constructor to initialize parameters.
+     *
+     * @param routeDistinguisher route distinguisher
+     */
+    public RouteDistinguisher(long routeDistinguisher) {
+        this.routeDistinguisher = routeDistinguisher;
+    }
+
+    /**
+     * Reads route distinguisher from channelBuffer.
+     *
+     * @param cb channelBuffer
+     * @return object of RouteDistinguisher
+     */
+    public static RouteDistinguisher read(ChannelBuffer cb) {
+        return new RouteDistinguisher(cb.readLong());
+    }
+
+    /**
+     * Returns route distinguisher.
+     *
+     * @return route distinguisher
+     */
+    public long getRouteDistinguisher() {
+        return this.routeDistinguisher;
+    }
+}
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
new file mode 100644
index 0000000..9649bf1
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/Constants.java
@@ -0,0 +1,37 @@
+/*
+ * 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.util;
+
+/**
+ * Provides Constants usage for BGP.
+ */
+public final class Constants {
+    private Constants() {
+    }
+
+    public static final short TYPE_AND_LEN = 4;
+    public static final short TYPE_AND_LEN_AS_SHORT = 4;
+    public static final short TYPE_AND_LEN_AS_BYTE = 3;
+    public static final int ISIS_LEVELONE = 1;
+    public static final int ISIS_LEVELTWO = 2;
+    public static final int OSPFV2 = 3;
+    public static final int DIRECT = 4;
+    public static final int STATIC_CONFIGURATION = 5;
+    public static final int OSPFV3 = 6;
+    public static final short AFI_VALUE = 16388;
+    public static final byte VPN_SAFI_VALUE = (byte) 0x80;
+    public static final byte SAFI_VALUE = 71;
+}
\ No newline at end of file