[Emu][onos-2590] BGP SBI global and peer configuration

Change-Id: I02a60aad06226125a1da9d4e7ada18e07942c0e6
diff --git a/bgp/api/pom.xml b/bgp/api/pom.xml
new file mode 100755
index 0000000..6fa1cc7
--- /dev/null
+++ b/bgp/api/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-bgp</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-bgp-api</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS BGP controller subsystem API</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgpio</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-misc</artifactId>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>2.3</version>
+                <configuration>
+                    <artifactSet>
+                        <excludes>
+                            <exclude>io.netty:netty</exclude>
+                            <exclude>com.google.guava:guava</exclude>
+                            <exclude>org.slf4j:slfj-api</exclude>
+                            <exclude>ch.qos.logback:logback-core</exclude>
+                            <exclude>ch.qos.logback:logback-classic</exclude>
+                            <exclude>com.google.code.findbugs:annotations</exclude>
+                        </excludes>
+                    </artifactSet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.onosproject.bgp.*,org.onosproject.bgpio.*,org.onosproject.bgp.controller
+                        </Export-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java b/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java
new file mode 100755
index 0000000..a8edf5e
--- /dev/null
+++ b/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPCfg.java
@@ -0,0 +1,334 @@
+/*
+ * 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.bgp.controller;
+
+import java.util.TreeMap;
+
+/**
+ * Abstraction of an BGP configuration. Manages the BGP configuration from CLI to the BGP controller.
+ */
+public interface BGPCfg {
+
+    enum State {
+        /**
+         * Signifies that its just created.
+         */
+        INIT,
+
+        /**
+         * Signifies that only IP Address is configured.
+         */
+        IP_CONFIGURED,
+
+        /**
+         * Signifies that only Autonomous System is configured.
+         */
+        AS_CONFIGURED,
+
+        /**
+         * Signifies that both IP and Autonomous System is configured.
+         */
+        IP_AS_CONFIGURED
+    }
+
+    /**
+     * Returns the status of the configuration based on this state certain operations like connection is handled.
+     *
+     * @return
+     *          State of the configuration
+     */
+    State getState();
+
+    /**
+     * To set the current state of the configuration.
+     *
+     * @param state
+     *          Configuration State enum
+     */
+    void setState(State state);
+
+    /**
+     * Get the status of the link state support for this BGP speaker.
+     *
+     * @return
+     *          true if the link state is supported else false
+     */
+    boolean getLsCapability();
+
+    /**
+     * Set the link state support to this BGP speaker.
+     *
+     * @param lscapability
+     *                  true value if link state is supported else false
+     */
+    void setLsCapability(boolean lscapability);
+
+    /**
+     * Get the status of the 32 bit AS support for this BGP speaker.
+     *
+     * @return
+     *          true if the 32 bit AS number is supported else false
+     */
+    boolean getLargeASCapability();
+
+    /**
+     * Set the 32 bit AS support capability to this BGP speaker.
+     *
+     * @param largeAs
+     *          true value if the 32 bit AS is supported else false
+     */
+    void setLargeASCapability(boolean largeAs);
+
+    /**
+     * Set the AS number to which this BGP speaker belongs.
+     *
+     * @param localAs
+     *          16 or 32 bit AS number, length is dependent on the capability
+     */
+    void setAsNumber(int localAs);
+
+    /**
+     * Get the AS number to which this BGP speaker belongs.
+     *
+     * @return
+     *          16 or 32 bit AS number, length is dependent on the capability
+     */
+    int getAsNumber();
+
+    /**
+     * Get the connection retry count number.
+     *
+     * @return
+     *          connection retry count if there is a connection error
+     */
+    int getMaxConnRetryCount();
+
+    /**
+     * Set the connection retry count.
+     *
+     * @param retryCount
+     *          number of times to try to connect if there is any error
+     */
+    void setMaxConnRetryCout(int retryCount);
+
+    /**
+     * Get the connection retry time in seconds.
+     *
+     * @return
+     *          connection retry time in seconds
+     */
+    int getMaxConnRetryTime();
+
+    /**
+     * Set the connection retry time in seconds.
+     *
+     * @param retryTime
+     *          connection retry times in seconds
+     */
+    void setMaxConnRetryTime(int retryTime);
+
+    /**
+     * Set the keep alive timer for the connection.
+     *
+     * @param holdTime
+     *          connection hold timer in seconds
+     */
+    void setHoldTime(short holdTime);
+
+    /**
+     * Returns the connection hold timer in seconds.
+     *
+     * @return
+     *          connection hold timer in seconds
+     */
+    short getHoldTime();
+
+    /**
+     * Returns the maximum number of session supported.
+     *
+     * @return
+     *          maximum number of session supported
+     */
+    int getMaxSession();
+
+    /**
+     * Set the maximum number of sessions to support.
+     *
+     * @param maxsession
+     *          maximum number of session
+     */
+    void setMaxSession(int maxsession);
+
+    /**
+     * Returns the Router ID of this BGP speaker.
+     *
+     * @return
+     *          IP address in string format
+     */
+    String getRouterId();
+
+    /**
+     * Set the Router ID of this BGP speaker.
+     *
+     * @param routerid
+     *          IP address in string format
+     */
+    void setRouterId(String routerid);
+
+    /**
+     * Add the BGP peer IP address and the AS number to which it belongs.
+     *
+     * @param routerid
+     *          IP address in string format
+     * @param remoteAs
+     *          AS number to which it belongs
+     * @return
+     *          true if added successfully else false
+     */
+    boolean addPeer(String routerid, int remoteAs);
+
+    /**
+     * Add the BGP peer IP address and the keep alive time.
+     *
+     * @param routerid
+     *          IP address in string format
+     * @param holdTime
+     *          keep alive time for the connection
+     * @return
+     *          true if added successfully else false
+     */
+    boolean addPeer(String routerid, short holdTime);
+
+    /**
+     * Add the BGP peer IP address, the AS number to which it belongs and keep alive time.
+     *
+     * @param routerid
+     *          IP address in string format
+     * @param remoteAs
+     *          AS number to which it belongs
+     * @param holdTime
+     *          keep alive time for the connection
+     * @return
+     *          true if added successfully else false
+     */
+    boolean addPeer(String routerid, int remoteAs, short holdTime);
+
+    /**
+     * Remove the BGP peer with this IP address.
+     *
+     * @param routerid
+     *          router IP address
+     * @return
+     *          true if removed successfully else false
+     */
+    boolean removePeer(String routerid);
+
+    /**
+     * Connect to BGP peer with this IP address.
+     *
+     * @param routerid
+     *          router IP address
+     * @return
+     *          true of the configuration is found and able to connect else false
+     */
+    boolean connectPeer(String routerid);
+
+    /**
+     * Disconnect this BGP peer with this IP address.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          true if the configuration is found and able to disconnect else false
+     */
+    boolean disconnectPeer(String routerid);
+
+    /**
+     * Returns the peer tree information.
+     *
+     * @return
+     *          return the tree map with IP as key and BGPPeerCfg as object
+     */
+    TreeMap<String, BGPPeerCfg> displayPeers();
+
+    /**
+     * Return the BGP Peer information with this matching IP.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          BGPPeerCfg object
+     */
+    BGPPeerCfg displayPeers(String routerid);
+
+    /**
+     * Check if this BGP peer is configured.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          true if configured exists else false
+     */
+    boolean isPeerConfigured(String routerid);
+
+    /**
+     * Check if this BGP speaker is having connection with the peer.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          true if the connection exists else false
+     */
+    boolean isPeerConnected(String routerid);
+
+    /**
+     * Return the peer tree map.
+     *
+     * @return
+     *          return the tree map with IP as key and BGPPeerCfg as object
+     */
+    TreeMap<String, BGPPeerCfg> getPeerTree();
+
+    /**
+     * Set the current connection state information.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @param state
+     *          state information
+     */
+    void setPeerConnState(String routerid, BGPPeerCfg.State state);
+
+    /**
+     * Check if the peer can be connected or not.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          true if the peer can be connected else false
+     */
+    boolean isPeerConnectable(String routerid);
+
+    /**
+     * Get the current peer connection state information.
+     *
+     * @param routerid
+     *          router IP address in string format
+     * @return
+     *          state information
+     */
+    BGPPeerCfg.State getPeerConnState(String routerid);
+}
diff --git a/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java b/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java
new file mode 100755
index 0000000..87ec031
--- /dev/null
+++ b/bgp/api/src/main/java/org/onosproject/bgp/controller/BGPPeerCfg.java
@@ -0,0 +1,166 @@
+/*
+ * 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.bgp.controller;
+
+/**
+ * BGP Peer configuration information.
+ */
+public interface BGPPeerCfg {
+
+    enum State {
+
+        /**
+         * Signifies that peer connection is idle.
+         */
+        IDLE,
+
+        /**
+         * Signifies that connection is initiated.
+         */
+        CONNECT,
+
+        /**
+         * Signifies that state is active and connection can be established.
+         */
+        ACTIVE,
+
+        /**
+         * Signifies that open is sent and anticipating reply.
+         */
+        OPENSENT,
+
+        /**
+         * Signifies that peer sent the open message as reply.
+         */
+        OPENCONFIRM,
+
+        /**
+         * Signifies that all the negotiation is successful and ready to exchange other messages.
+         */
+        ESTABLISHED,
+
+        /**
+         * Signifies that invalid state.
+         */
+        INVALID
+    }
+
+    /**
+     * Returns the connection State information of the peer.
+     *
+     * @return
+     *          enum state is returned
+     */
+    State getState();
+
+    /**
+     * Set the connection state information of the peer.
+     *
+     * @param state
+     *          enum state
+     */
+    void setState(State state);
+
+    /**
+     * Returns the connection is initiated from us or not.
+     *
+     * @return
+     *          true if the connection is initiated by this peer, false if it has been received.
+     */
+    boolean getSelfInnitConnection();
+
+    /**
+     * Set the connection is initiated from us or not.
+     *
+     * @param selfInit
+     *          true if the connection is initiated by this peer, false if it has been received.
+     */
+    void setSelfInnitConnection(boolean selfInit);
+
+    /**
+     * Returns the AS number to which this peer belongs.
+     *
+     * @return
+     *          AS number
+     */
+    int getAsNumber();
+
+    /**
+     * Set the AS number to which this peer belongs.
+     *
+     * @param asNumber
+     *          AS number
+     */
+    void setAsNumber(int asNumber);
+
+    /**
+     * Get the keep alive timer value configured.
+     *
+     * @return
+     *          keep alive timer value in seconds
+     */
+    short getHoldtime();
+
+    /**
+     * Set the keep alive timer value.
+     *
+     * @param holdTime
+     *          keep alive timer value in seconds
+     */
+    void setHoldtime(short holdTime);
+
+    /**
+     * Return the connection type eBGP or iBGP.
+     *
+     * @return
+     *          true if iBGP, false if it is eBGP
+     */
+    boolean getIsIBgp();
+
+    /**
+     * Set the connection type eBGP or iBGP.
+     *
+     * @param isIBgp
+     *          true if iBGP, false if it is eBGP
+     */
+    void setIsIBgp(boolean isIBgp);
+
+    /**
+     * Return the peer router IP address.
+     *
+     * @return
+     *          IP address in string format
+     */
+    String getPeerRouterId();
+
+    /**
+     * Set the peer router IP address.
+     *
+     * @param peerId
+     *          IP address in string format
+     */
+    void setPeerRouterId(String peerId);
+
+    /**
+     * Set the peer router IP address and AS number.
+     *
+     * @param peerId
+     *          IP address in string format
+     * @param asNumber
+     *          AS number
+     */
+    void setPeerRouterId(String peerId, int asNumber);
+}
diff --git a/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java b/bgp/api/src/main/java/org/onosproject/bgp/controller/package-info.java
new file mode 100755
index 0000000..4dd775b
--- /dev/null
+++ b/bgp/api/src/main/java/org/onosproject/bgp/controller/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.
+ */
+
+/**
+ * BGP controller API.
+ */
+package org.onosproject.bgp.controller;
diff --git a/bgp/bgpio/pom.xml b/bgp/bgpio/pom.xml
new file mode 100755
index 0000000..5d67f18
--- /dev/null
+++ b/bgp/bgpio/pom.xml
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-bgp</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-bgpio</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS BGPio Protocol subsystem</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-osgi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-databind</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.fasterxml.jackson.core</groupId>
+            <artifactId>jackson-annotations</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.console</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/package-info.java
new file mode 100755
index 0000000..78b2807
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/exceptions/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.
+ */
+
+/**
+ * BGP custom exceptions.
+ */
+package org.onosproject.bgpio.exceptions;
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/package-info.java
new file mode 100755
index 0000000..d2a2ccf
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/link_state/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.
+ */
+
+/**
+ * BGP Protocol specific link state details.
+ */
+package org.onosproject.bgpio.protocol.link_state;
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/package-info.java
new file mode 100755
index 0000000..723b31b
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/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.
+ */
+
+/**
+ * BGP Protocol specific components.
+ */
+package org.onosproject.bgpio.protocol;
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/package-info.java
new file mode 100755
index 0000000..fb8c67c
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/ver4/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.
+ */
+
+/**
+ * BGP Protocol specific details of version 4.
+ */
+package org.onosproject.bgpio.protocol.ver4;
\ No newline at end of file
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/package-info.java
new file mode 100755
index 0000000..e2a74db
--- /dev/null
+++ b/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/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/package-info.java
new file mode 100755
index 0000000..1f2ed95
--- /dev/null
+++ b/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;
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/package-info.java
new file mode 100755
index 0000000..3229d89
--- /dev/null
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/util/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 utility functions.
+ */
+package org.onosproject.bgpio.util;
diff --git a/bgp/ctl/pom.xml b/bgp/ctl/pom.xml
new file mode 100755
index 0000000..5cefd73
--- /dev/null
+++ b/bgp/ctl/pom.xml
@@ -0,0 +1,65 @@
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-bgp</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-bgp-ctl</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>ONOS BGP controller subsystem API</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-bgp-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-misc</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPConfig.java b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPConfig.java
new file mode 100755
index 0000000..56877a1
--- /dev/null
+++ b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPConfig.java
@@ -0,0 +1,344 @@
+/*
+ * 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.bgp.controller.impl;
+
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.onlab.packet.Ip4Address;
+import org.onosproject.bgp.controller.BGPCfg;
+import org.onosproject.bgp.controller.BGPPeerCfg;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Provides BGP configuration of this BGP speaker.
+ */
+public class BGPConfig implements BGPCfg {
+
+    protected static final Logger log = LoggerFactory.getLogger(BGPConfig.class);
+
+    private static final short DEFAULT_HOLD_TIMER = 120;
+    private static final short DEFAULT_CONN_RETRY_TIME = 120;
+    private static final short DEFAULT_CONN_RETRY_COUNT = 5;
+
+    private State state = State.INIT;
+    private int localAs;
+    private int maxSession;
+    private boolean lsCapability;
+    private short holdTime;
+    private boolean largeAs = false;
+    private int maxConnRetryTime;
+    private int maxConnRetryCount;
+
+    private Ip4Address routerId = null;
+    private TreeMap<String, BGPPeerCfg> bgpPeerTree = new TreeMap<>();
+
+    /**
+     * Constructor to initialize the values.
+     */
+    public BGPConfig() {
+
+        this.holdTime = DEFAULT_HOLD_TIMER;
+        this.maxConnRetryTime = DEFAULT_CONN_RETRY_TIME;
+        this.maxConnRetryCount = DEFAULT_CONN_RETRY_COUNT;
+    }
+
+    @Override
+    public State getState() {
+        return state;
+    }
+
+    @Override
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public int getAsNumber() {
+        return this.localAs;
+    }
+
+    @Override
+    public void setAsNumber(int localAs) {
+
+        State localState = getState();
+        this.localAs = localAs;
+
+        /* Set configuration state */
+        if (localState == State.IP_CONFIGURED) {
+            setState(State.IP_AS_CONFIGURED);
+        } else {
+            setState(State.AS_CONFIGURED);
+        }
+    }
+
+    @Override
+    public int getMaxSession() {
+        return this.maxSession;
+    }
+
+    @Override
+    public void setMaxSession(int maxSession) {
+        this.maxSession = maxSession;
+    }
+
+    @Override
+    public boolean getLsCapability() {
+        return this.lsCapability;
+    }
+
+    @Override
+    public void setLsCapability(boolean lsCapability) {
+        this.lsCapability = lsCapability;
+    }
+
+    @Override
+    public String getRouterId() {
+        if (this.routerId != null) {
+            return this.routerId.toString();
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public void setRouterId(String routerId) {
+        State localState = getState();
+        this.routerId = Ip4Address.valueOf(routerId);
+
+        /* Set configuration state */
+        if (localState == State.AS_CONFIGURED) {
+            setState(State.IP_AS_CONFIGURED);
+        } else {
+            setState(State.IP_CONFIGURED);
+        }
+    }
+
+    @Override
+    public boolean addPeer(String routerid, int remoteAs) {
+        return addPeer(routerid, remoteAs, DEFAULT_HOLD_TIMER);
+    }
+
+    @Override
+    public boolean addPeer(String routerid, short holdTime) {
+        return addPeer(routerid, this.getAsNumber(), holdTime);
+    }
+
+    @Override
+    public boolean addPeer(String routerid, int remoteAs, short holdTime) {
+        BGPPeerConfig lspeer = new BGPPeerConfig();
+        if (this.bgpPeerTree.get(routerid) == null) {
+
+            lspeer.setPeerRouterId(routerid);
+            lspeer.setAsNumber(remoteAs);
+            lspeer.setHoldtime(holdTime);
+            lspeer.setState(BGPPeerCfg.State.IDLE);
+            lspeer.setSelfInnitConnection(false);
+
+            if (this.getAsNumber() == remoteAs) {
+                lspeer.setIsIBgp(true);
+            } else {
+                lspeer.setIsIBgp(false);
+            }
+
+            this.bgpPeerTree.put(routerid, lspeer);
+            log.debug("added successfully");
+            return true;
+        } else {
+            log.debug("already exists");
+            return false;
+        }
+    }
+
+    @Override
+    public boolean connectPeer(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if (lspeer != null) {
+            lspeer.setSelfInnitConnection(true);
+            // TODO: initiate peer connection
+            return true;
+        }
+
+        return false;
+    }
+
+    @Override
+    public boolean removePeer(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if (lspeer != null) {
+
+            //TODO DISCONNECT PEER
+            disconnectPeer(routerid);
+            lspeer.setSelfInnitConnection(false);
+            lspeer = this.bgpPeerTree.remove(routerid);
+            log.debug("Deleted : " + routerid + " successfully");
+
+            return true;
+        } else {
+            log.debug("Did not find : " + routerid);
+            return false;
+        }
+    }
+
+    @Override
+    public boolean disconnectPeer(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if (lspeer != null) {
+
+            //TODO DISCONNECT PEER
+            lspeer.setState(BGPPeerCfg.State.IDLE);
+            lspeer.setSelfInnitConnection(false);
+            log.debug("Disconnected : " + routerid + " successfully");
+
+            return true;
+        } else {
+            log.debug("Did not find : " + routerid);
+            return false;
+        }
+    }
+
+    @Override
+    public void setPeerConnState(String routerid, BGPPeerCfg.State state) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if (lspeer != null) {
+            lspeer.setState(state);
+            log.debug("Peer : " + routerid + " is not available");
+
+            return;
+        } else {
+            log.debug("Did not find : " + routerid);
+            return;
+        }
+    }
+
+    @Override
+    public BGPPeerCfg.State getPeerConnState(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if (lspeer != null) {
+            return lspeer.getState();
+        } else {
+            return BGPPeerCfg.State.INVALID; //No instance
+        }
+    }
+
+    @Override
+    public boolean isPeerConnectable(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+
+        if ((lspeer != null) && lspeer.getState().equals(BGPPeerCfg.State.IDLE)) {
+            return true;
+        }
+
+        return false;
+    }
+
+    @Override
+    public TreeMap<String, BGPPeerCfg> getPeerTree() {
+        return this.bgpPeerTree;
+    }
+
+    @Override
+    public TreeMap<String, BGPPeerCfg> displayPeers() {
+        if (this.bgpPeerTree.isEmpty()) {
+            log.debug("There are no BGP peers");
+        } else {
+            Set<Entry<String, BGPPeerCfg>> set = this.bgpPeerTree.entrySet();
+            Iterator<Entry<String, BGPPeerCfg>> list = set.iterator();
+            BGPPeerCfg lspeer;
+
+            while (list.hasNext()) {
+                Entry<String, BGPPeerCfg> me = list.next();
+                lspeer = me.getValue();
+                log.debug("Peer neighbor IP :" + me.getKey());
+                log.debug(", AS Number : " + lspeer.getAsNumber());
+                log.debug(", Hold Timer : " + lspeer.getHoldtime());
+                log.debug(", Is iBGP : " + lspeer.getIsIBgp());
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public BGPPeerCfg displayPeers(String routerid) {
+
+        if (this.bgpPeerTree.isEmpty()) {
+            log.debug("There are no BGP peers");
+        } else {
+            return this.bgpPeerTree.get(routerid);
+        }
+        return null;
+    }
+
+    @Override
+    public void setHoldTime(short holdTime) {
+        this.holdTime = holdTime;
+    }
+
+    @Override
+    public short getHoldTime() {
+        return this.holdTime;
+    }
+
+    @Override
+    public boolean getLargeASCapability() {
+        return this.largeAs;
+    }
+
+    @Override
+    public void setLargeASCapability(boolean largeAs) {
+        this.largeAs = largeAs;
+    }
+
+    @Override
+    public boolean isPeerConfigured(String routerid) {
+        BGPPeerCfg lspeer = this.bgpPeerTree.get(routerid);
+        return (lspeer != null) ? true : false;
+    }
+
+    @Override
+    public boolean isPeerConnected(String routerid) {
+        // TODO: is peer connected
+        return true;
+    }
+
+    @Override
+    public int getMaxConnRetryCount() {
+        return this.maxConnRetryCount;
+    }
+
+    @Override
+    public void setMaxConnRetryCout(int retryCount) {
+        this.maxConnRetryCount = retryCount;
+    }
+
+    @Override
+    public int getMaxConnRetryTime() {
+        return this.maxConnRetryTime;
+    }
+
+    @Override
+    public void setMaxConnRetryTime(int retryTime) {
+        this.maxConnRetryTime = retryTime;
+    }
+}
diff --git a/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerConfig.java b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerConfig.java
new file mode 100755
index 0000000..51b95a4
--- /dev/null
+++ b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BGPPeerConfig.java
@@ -0,0 +1,109 @@
+/*
+ * 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.bgp.controller.impl;
+
+import org.onlab.packet.Ip4Address;
+import org.onosproject.bgp.controller.BGPPeerCfg;
+
+/**
+ * BGP Peer configuration information.
+ */
+public class BGPPeerConfig  implements BGPPeerCfg {
+    private int asNumber;
+    private short holdTime;
+    private boolean isIBgp;
+    private Ip4Address peerId = null;
+    private State state;
+    private boolean selfInitiated;
+
+    /**
+     * Constructor to initialize the values.
+     */
+    BGPPeerConfig() {
+        state = State.IDLE;
+        selfInitiated = false;
+    }
+
+    @Override
+    public int getAsNumber() {
+        return this.asNumber;
+    }
+
+    @Override
+    public void setAsNumber(int asNumber) {
+        this.asNumber = asNumber;
+    }
+
+    @Override
+    public short getHoldtime() {
+        return this.holdTime;
+    }
+
+    @Override
+    public void setHoldtime(short holdTime) {
+        this.holdTime = holdTime;
+    }
+
+    @Override
+    public boolean getIsIBgp() {
+        return this.isIBgp;
+    }
+
+    @Override
+    public void setIsIBgp(boolean isIBgp) {
+        this.isIBgp = isIBgp;
+    }
+
+    @Override
+    public String getPeerRouterId() {
+        if (this.peerId != null) {
+            return this.peerId.toString();
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public void setPeerRouterId(String peerId) {
+        this.peerId = Ip4Address.valueOf(peerId);
+    }
+
+    @Override
+    public void setPeerRouterId(String peerId, int asNumber) {
+        this.peerId = Ip4Address.valueOf(peerId);
+        this.asNumber = asNumber;
+    }
+
+    @Override
+    public State getState() {
+        return this.state;
+    }
+
+    @Override
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    @Override
+    public boolean getSelfInnitConnection() {
+        return this.selfInitiated;
+    }
+
+    @Override
+    public void setSelfInnitConnection(boolean selfInit) {
+        this.selfInitiated = selfInit;
+    }
+}
diff --git a/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/package-info.java
new file mode 100755
index 0000000..fd4e950
--- /dev/null
+++ b/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/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 the BGP controller IO subsystem.
+ */
+package org.onosproject.bgp.controller.impl;
diff --git a/bgp/pom.xml b/bgp/pom.xml
new file mode 100755
index 0000000..941168b
--- /dev/null
+++ b/bgp/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos</artifactId>
+        <version>1.4.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>onos-bgp</artifactId>
+    <packaging>pom</packaging>
+
+    <description>ONOS BGP Protocol subsystem</description>
+
+    <modules>
+        <module>api</module>
+        <module>ctl</module>
+        <module>bgpio</module>
+    </modules>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-misc</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onlab-junit</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>