ONOS-2740,ONOS-2741,from ONOS-3032 - to ONOS 3071 , OSPF Protocol Implementation

Change-Id: Ie8cccca4aaf2641ab1e332ed367ddfc9b725a35c
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java
new file mode 100755
index 0000000..ae75a95
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/Configuration.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 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.ospf.controller.area;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.ospf.controller.OspfProcess;
+
+import java.util.List;
+
+/**
+ * Representation of an OSPF configuration data.
+ */
+public class Configuration {
+    private List<OspfProcess> processes;
+    private String method;
+
+    /**
+     * Gets the configured processes.
+     *
+     * @return list of configured processes.
+     */
+    public List<OspfProcess> getProcesses() {
+        return processes;
+    }
+
+    /**
+     * Sets the configured processes.
+     *
+     * @param processes configured processes
+     */
+    public void setProcesses(List<OspfProcess> processes) {
+        this.processes = processes;
+    }
+
+    /**
+     * Gets whether to update, add or delete configuration.
+     *
+     * @return update, add or delete configuration
+     */
+    public String getMethod() {
+        return method;
+    }
+
+    /**
+     * Sets whether to update, add or delete configuration.
+     *
+     * @param method configuration method.
+     */
+    public void setMethod(String method) {
+        this.method = method;
+    }
+
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("method", method)
+                .add("processes", processes)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java
new file mode 100755
index 0000000..a5c99b2
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfAreaAddressRangeImpl.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2016 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.ospf.controller.area;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfAreaAddressRange;
+
+/**
+ * Representation of an area address ranges.
+ * Address ranges are used in order to aggregate routing information at area boundaries.
+ * Each address range is specified by an [address,mask] pair and a status indication of
+ * either advertise or do not advertise
+ */
+public class OspfAreaAddressRangeImpl implements OspfAreaAddressRange {
+
+    public Ip4Address ipAddress;
+    public String mask;
+    public boolean advertise;
+
+    /**
+     * Gets the IP address.
+     *
+     * @return IP address
+     */
+    public Ip4Address ipAddress() {
+        return ipAddress;
+    }
+
+    /**
+     * Sets the IP address.
+     *
+     * @param ipAddress IP address
+     */
+    public void setIpAddress(Ip4Address ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /**
+     * Gets the network mask.
+     *
+     * @return network  mask
+     */
+    public String mask() {
+        return mask;
+    }
+
+    /**
+     * Sets the network mask.
+     *
+     * @param mask network mask value
+     */
+    public void setMask(String mask) {
+        this.mask = mask;
+    }
+
+    /**
+     * Gets the advertise value.
+     *
+     * @return advertise value
+     */
+    public boolean isAdvertise() {
+        return advertise;
+    }
+
+    /**
+     * Sets the advertise value.
+     *
+     * @param advertise advertise value
+     */
+    public void setAdvertise(boolean advertise) {
+        this.advertise = advertise;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof OspfAreaAddressRangeImpl)) {
+            return false;
+        }
+        OspfAreaAddressRangeImpl otherAreaAddressRange = (OspfAreaAddressRangeImpl) other;
+        return Objects.equal(ipAddress, otherAreaAddressRange.ipAddress) &&
+                Objects.equal(mask, otherAreaAddressRange.mask) &&
+                Objects.equal(advertise, otherAreaAddressRange.advertise);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(ipAddress, mask, advertise);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("ipAddress", ipAddress)
+                .add("mask", mask)
+                .add("advertise", advertise)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
new file mode 100755
index 0000000..4c19161
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfInterfaceImpl.java
@@ -0,0 +1,520 @@
+/*
+ * Copyright 2016 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.ospf.controller.area;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onlab.packet.Ip4Address;
+import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfNbr;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+import org.onosproject.ospf.protocol.lsa.OpaqueLsaHeader;
+import org.onosproject.ospf.protocol.util.OspfInterfaceState;
+import org.onosproject.ospf.protocol.util.OspfParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Representation of an OSPF interface.
+ */
+public class OspfInterfaceImpl implements OspfInterface {
+    private static final Logger log = LoggerFactory.getLogger(OspfInterfaceImpl.class);
+    private Ip4Address ipAddress;
+    private Ip4Address ipNetworkMask;
+    private int areaId;
+    private int helloIntervalTime;
+    private int routerDeadIntervalTime;
+    private int transmitDelay;
+    private int routerPriority;
+    private int systemInterfaceType;
+    private int interfaceType;
+    private int interfaceCost;
+    private String authType;
+    private String authKey;
+    private int pollInterval;
+    private int mtu;
+    private int reTransmitInterval;
+    private Ip4Address dr;
+    private Ip4Address bdr;
+    private OspfInterfaceState state;
+    private List<LsaHeader> linkStateHeaders = new ArrayList<>();
+    private HashMap<String, OspfNbr> listOfNeighbors = new HashMap<>();
+    private HashMap<String, LsaHeader> listOfNeighborMap = new HashMap<>();
+
+    /**
+     * Gets the interface state.
+     *
+     * @return interfaceState state of the interface
+     */
+    public OspfInterfaceState state() {
+        return state;
+    }
+
+    /**
+     * Sets the interface state.
+     *
+     * @param ospfInterfaceState interface state enum instance
+     */
+    public void setState(OspfInterfaceState ospfInterfaceState) {
+        this.state = ospfInterfaceState;
+    }
+
+    /**
+     * Gets link state headers.
+     *
+     * @return get the list of lsa headers
+     */
+    public List<LsaHeader> linkStateHeaders() {
+        Set<String> key = listOfNeighborMap.keySet();
+        for (String keys : key) {
+            LsaHeader lsaHeader = listOfNeighborMap.get(keys);
+            linkStateHeaders.add(lsaHeader);
+        }
+        return linkStateHeaders;
+    }
+
+    /**
+     * Gets IP network mask.
+     *
+     * @return network mask
+     */
+    public Ip4Address ipNetworkMask() {
+        return ipNetworkMask;
+    }
+
+    /**
+     * Sets IP network mask.
+     *
+     * @param ipNetworkMask network mask
+     */
+    @Override
+    public void setIpNetworkMask(Ip4Address ipNetworkMask) {
+        this.ipNetworkMask = ipNetworkMask;
+    }
+
+    /**
+     * Adds neighboring router to list.
+     *
+     * @param ospfNbr ospfNbr instance
+     */
+    public void addNeighbouringRouter(OspfNbr ospfNbr) {
+        listOfNeighbors.put(ospfNbr.neighborId().toString(), ospfNbr);
+    }
+
+    /**
+     * Gets the neighbour details from listOfNeighbors map.
+     *
+     * @param neighborId neighbors id
+     * @return ospfNbr neighbor instance
+     */
+    public OspfNbr neighbouringRouter(String neighborId) {
+        return listOfNeighbors.get(neighborId);
+    }
+
+
+    /**
+     * Adds LSAHeader to map.
+     *
+     * @param lsaHeader LSA header instance
+     */
+    public void addLsaHeaderForDelayAck(LsaHeader lsaHeader) {
+        String key = lsaHeader.lsType() + "-" + lsaHeader.linkStateId() + "-" +
+                lsaHeader.advertisingRouter();
+        if (lsaHeader.lsType() == OspfParameters.LINK_LOCAL_OPAQUE_LSA ||
+                lsaHeader.lsType() == OspfParameters.AREA_LOCAL_OPAQUE_LSA ||
+                lsaHeader.lsType() == OspfParameters.AS_OPAQUE_LSA) {
+            OpaqueLsaHeader header = (OpaqueLsaHeader) lsaHeader;
+            key = lsaHeader.lsType() + "-" + header.opaqueType() + header.opaqueId()
+                    + "-" + lsaHeader.advertisingRouter();
+        }
+
+        log.debug("Adding LSA key {} for delayed Ack", key);
+        listOfNeighborMap.put(key, lsaHeader);
+    }
+
+    /**
+     * Removes LSA header from map.
+     *
+     * @param lsaKey key used to store LSA in map
+     */
+    public void removeLsaFromNeighborMap(String lsaKey) {
+        listOfNeighborMap.remove(lsaKey);
+    }
+
+    /**
+     * Checks neighbor is in the list or not.
+     *
+     * @param neighborId neighbors id
+     * @return true if neighbor in list else false
+     */
+    public boolean isNeighborInList(String neighborId) {
+        return listOfNeighbors.containsKey(neighborId);
+    }
+
+    /**
+     * Gets the list of neighbors.
+     *
+     * @return listOfNeighbors as key value pair
+     */
+    public HashMap<String, OspfNbr> listOfNeighbors() {
+        return listOfNeighbors;
+    }
+
+    /**
+     * Sets the list of neighbors.
+     *
+     * @param listOfNeighbors as key value pair
+     */
+    public void setListOfNeighbors(HashMap<String, OspfNbr> listOfNeighbors) {
+        this.listOfNeighbors = listOfNeighbors;
+    }
+
+    /**
+     * Gets the IP address.
+     *
+     * @return IP address
+     */
+    public Ip4Address ipAddress() {
+        return ipAddress;
+    }
+
+    /**
+     * Sets the interface IP address.
+     *
+     * @param ipAddress interface IP address
+     */
+    public void setIpAddress(Ip4Address ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /**
+     * Gets router priority.
+     *
+     * @return routerPriority value
+     */
+    public int routerPriority() {
+        return routerPriority;
+    }
+
+    /**
+     * Sets router priority.
+     *
+     * @param routerPriority value
+     */
+    public void setRouterPriority(int routerPriority) {
+        this.routerPriority = routerPriority;
+    }
+
+    /**
+     * Gets the area id this interface belongs.
+     *
+     * @return area id this interface belongs
+     */
+    public int areaId() {
+        return areaId;
+    }
+
+
+    /**
+     * Sets the area id this interface belongs.
+     *
+     * @param areaId the area id this interface belongs
+     */
+    public void setAreaId(int areaId) {
+        this.areaId = areaId;
+    }
+
+    /**
+     * Gets hello interval time.
+     *
+     * @return hello interval time
+     */
+    public int helloIntervalTime() {
+        return helloIntervalTime;
+    }
+
+    /**
+     * Sets hello interval time.
+     *
+     * @param helloIntervalTime an integer interval time
+     */
+    public void setHelloIntervalTime(int helloIntervalTime) {
+        this.helloIntervalTime = helloIntervalTime;
+    }
+
+    /**
+     * Gets router dead interval time.
+     *
+     * @return router dead interval time
+     */
+    public int routerDeadIntervalTime() {
+        return routerDeadIntervalTime;
+    }
+
+    /**
+     * Sets router dead interval time.
+     *
+     * @param routerDeadIntervalTime router dead interval time
+     */
+    public void setRouterDeadIntervalTime(int routerDeadIntervalTime) {
+        this.routerDeadIntervalTime = routerDeadIntervalTime;
+    }
+
+    /**
+     * Gets interface type.
+     *
+     * @return interfaceType an integer represents interface type
+     */
+    public int interfaceType() {
+        return interfaceType;
+    }
+
+    /**
+     * Sets interface type.
+     *
+     * @param interfaceType interface type
+     */
+    public void setInterfaceType(int interfaceType) {
+        this.interfaceType = interfaceType;
+    }
+
+    /**
+     * Gets interface cost.
+     *
+     * @return interface cost
+     */
+    public int interfaceCost() {
+        return interfaceCost;
+    }
+
+    /**
+     * Sets interface cost.
+     *
+     * @param interfaceCost interface cost
+     */
+    public void setInterfaceCost(int interfaceCost) {
+        this.interfaceCost = interfaceCost;
+    }
+
+    /**
+     * Gets authentication type.
+     *
+     * @return authType represents authentication type
+     */
+    public String authType() {
+        return authType;
+    }
+
+    /**
+     * Sets authentication type.
+     *
+     * @param authType authType represents authentication type
+     */
+    public void setAuthType(String authType) {
+        this.authType = authType;
+    }
+
+    /**
+     * Gets authentication key.
+     *
+     * @return authKey represents authentication key
+     */
+    public String authKey() {
+        return authKey;
+    }
+
+    /**
+     * Sets authentication key.
+     *
+     * @param authKey represents authentication key
+     */
+    public void setAuthKey(String authKey) {
+        this.authKey = authKey;
+    }
+
+    /**
+     * Gets poll interval.
+     *
+     * @return pollInterval an integer represents poll interval
+     */
+    public int pollInterval() {
+        return pollInterval;
+    }
+
+    /**
+     * Sets poll interval.
+     *
+     * @param pollInterval an integer represents poll interval
+     */
+    public void setPollInterval(int pollInterval) {
+        this.pollInterval = pollInterval;
+    }
+
+    /**
+     * Gets max transfer unit.
+     *
+     * @return mtu an integer represents max transfer unit
+     */
+    public int mtu() {
+        return mtu;
+    }
+
+    /**
+     * Sets max transfer unit.
+     *
+     * @param mtu max transfer unit
+     */
+    public void setMtu(int mtu) {
+        this.mtu = mtu;
+    }
+
+    /**
+     * Gets retransmit interval.
+     *
+     * @return retransmit interval
+     */
+    public int reTransmitInterval() {
+        return reTransmitInterval;
+    }
+
+    /**
+     * Sets retransmit interval.
+     *
+     * @param reTransmitInterval retransmit interval
+     */
+    public void setReTransmitInterval(int reTransmitInterval) {
+        this.reTransmitInterval = reTransmitInterval;
+    }
+
+    /**
+     * Gets designated routers IP address.
+     *
+     * @return dr designated routers IP address
+     */
+    public Ip4Address dr() {
+        return dr;
+    }
+
+    /**
+     * Sets designated routers IP address.
+     *
+     * @param dr designated routers IP address
+     */
+    public void setDr(Ip4Address dr) {
+        this.dr = dr;
+    }
+
+    /**
+     * Gets backup designated routers IP address.
+     *
+     * @return bdr backup designated routers IP address
+     */
+    public Ip4Address bdr() {
+        return bdr;
+    }
+
+    /**
+     * Sets backup designated routers IP address.
+     *
+     * @param bdr backup designated routers IP address
+     */
+    public void setBdr(Ip4Address bdr) {
+        this.bdr = bdr;
+    }
+
+    /**
+     * Get transmission delay.
+     *
+     * @return transmission delay
+     */
+    public int transmitDelay() {
+        return transmitDelay;
+    }
+
+    /**
+     * Sets transmission delay.
+     *
+     * @param transmitDelay transmission delay
+     */
+    public void setTransmitDelay(int transmitDelay) {
+        this.transmitDelay = transmitDelay;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        OspfInterfaceImpl that = (OspfInterfaceImpl) o;
+        return Objects.equal(areaId, that.areaId) &&
+                Objects.equal(helloIntervalTime, that.helloIntervalTime) &&
+                Objects.equal(routerDeadIntervalTime, that.routerDeadIntervalTime) &&
+                Objects.equal(transmitDelay, that.transmitDelay) &&
+                Objects.equal(routerPriority, that.routerPriority) &&
+                Objects.equal(systemInterfaceType, that.systemInterfaceType) &&
+                Objects.equal(interfaceType, that.interfaceType) &&
+                Objects.equal(interfaceCost, that.interfaceCost) &&
+                Objects.equal(pollInterval, that.pollInterval) &&
+                Objects.equal(mtu, that.mtu) &&
+                Objects.equal(reTransmitInterval, that.reTransmitInterval) &&
+                Objects.equal(ipAddress, that.ipAddress) &&
+                Objects.equal(ipNetworkMask, that.ipNetworkMask) &&
+                Objects.equal(listOfNeighbors, that.listOfNeighbors) &&
+                Objects.equal(authType, that.authType) &&
+                Objects.equal(authKey, that.authKey) &&
+                Objects.equal(dr, that.dr) &&
+                Objects.equal(bdr, that.bdr);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(ipAddress, ipNetworkMask, areaId, helloIntervalTime,
+                                routerDeadIntervalTime, transmitDelay, routerPriority, listOfNeighbors,
+                                systemInterfaceType, interfaceType, interfaceCost, authType, authKey,
+                                pollInterval, mtu, reTransmitInterval, dr, bdr);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("ipAddress", ipAddress)
+                .add("routerPriority", routerPriority)
+                .add("areaID", areaId)
+                .add("helloIntervalTime", helloIntervalTime)
+                .add("routerDeadIntervalTime", routerDeadIntervalTime)
+                .add("interfaceType", interfaceType)
+                .add("interfaceCost", interfaceCost)
+                .add("authType", authType)
+                .add("authKey", authKey)
+                .add("pollInterval", pollInterval)
+                .add("mtu", mtu)
+                .add("reTransmitInterval", reTransmitInterval)
+                .add("dr", dr)
+                .add("bdr", bdr)
+                .add("transmitDelay", transmitDelay)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java
new file mode 100755
index 0000000..facbdb3
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/OspfProcessImpl.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 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.ospf.controller.area;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import org.onosproject.ospf.controller.OspfArea;
+import org.onosproject.ospf.controller.OspfProcess;
+
+import java.util.List;
+
+/**
+ * Representation of the configuration data for OSPF Process, which will be configured using rest URI.
+ */
+public class OspfProcessImpl implements OspfProcess {
+
+    private String processId;
+    private List<OspfArea> areas;
+
+    /**
+     * Gets the list of areas belonging to this process.
+     *
+     * @return list of areas belonging to this process
+     */
+    public List<OspfArea> areas() {
+        return areas;
+    }
+
+    /**
+     * Sets the list of areas belonging to this process.
+     *
+     * @param areas list of areas belonging to this process
+     */
+    @JsonProperty("areas")
+    public void setAreas(List<OspfArea> areas) {
+        this.areas = areas;
+    }
+
+    /**
+     * Gets the process id.
+     *
+     * @return process id
+     */
+    public String processId() {
+        return processId;
+    }
+
+    /**
+     * Sets the process id.
+     *
+     * @param processId the process id
+     */
+    @JsonProperty("processId")
+    public void setProcessId(String processId) {
+        this.processId = processId;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("areas", areas)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java
new file mode 100755
index 0000000..a06d2f8
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/area/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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 OSPF controller.
+ */
+package org.onosproject.ospf.controller.area;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
new file mode 100755
index 0000000..5f86936
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/Controller.java
@@ -0,0 +1,774 @@
+/*
+ * Copyright 2016 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.ospf.controller.impl;
+
+import org.jboss.netty.bootstrap.ServerBootstrap;
+import org.jboss.netty.channel.AdaptiveReceiveBufferSizePredictor;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.FixedReceiveBufferSizePredictorFactory;
+import org.jboss.netty.channel.group.ChannelGroup;
+import org.jboss.netty.channel.group.DefaultChannelGroup;
+import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.onosproject.net.driver.DriverService;
+import org.onosproject.ospf.controller.OspfAgent;
+import org.onosproject.ospf.controller.OspfArea;
+import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfLinkTed;
+import org.onosproject.ospf.controller.OspfProcess;
+import org.onosproject.ospf.controller.OspfRouter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+
+/**
+ * Representation of the main controller class. Handles all setup and network listeners.
+ */
+public class Controller {
+
+    protected static final Logger log = LoggerFactory.getLogger(Controller.class);
+    protected static final int BUFFER_SIZE = 4 * 1024 * 1024;
+    private static final String PROCESS = "process";
+    private static final String AREA = "area";
+    private static final String INTERFACE = "interface";
+
+    protected int ospfPort = 7000;
+    protected int workerThreads = 16;
+    protected long systemStartTime;
+    private DriverService driverService;
+    private OspfAgent agent;
+    private List<ChannelGroup> cgList = new ArrayList();
+    private List<NioServerSocketChannelFactory> execFactoryLst = new ArrayList<>();
+    private List<OspfProcess> processes;
+
+    /**
+     * Gets all configured processes.
+     *
+     * @return all configured processes
+     */
+    public List<OspfProcess> getAllConfiguredProcesses() {
+        return processes;
+    }
+
+    /**
+     * Adds device details.
+     *
+     * @param ospfRouter OSPF router instance
+     */
+    public void addDeviceDetails(OspfRouter ospfRouter) {
+        agent.addConnectedRouter(ospfRouter);
+    }
+
+    /**
+     * Removes device details.
+     *
+     * @param ospfRouter OSPF router instance
+     */
+    public void removeDeviceDetails(OspfRouter ospfRouter) {
+        agent.removeConnectedRouter(ospfRouter);
+    }
+
+    /**
+     * Adds link details.
+     *
+     * @param ospfRouter  OSPF router instance
+     * @param ospfLinkTed OSPF link ted instance
+     */
+    public void addLinkDetails(OspfRouter ospfRouter, OspfLinkTed ospfLinkTed) {
+        agent.addLink(ospfRouter, ospfLinkTed);
+    }
+
+    /**
+     * Removes link details.
+     *
+     * @param ospfRouter OSPF router instance
+     */
+    public void removeLinkDetails(OspfRouter ospfRouter) {
+        agent.deleteLink(ospfRouter);
+    }
+
+    /**
+     * Creates a server bootstrap.
+     *
+     * @return ServerBootstrap bootstrap instance
+     */
+    private ServerBootstrap createServerBootStrap() {
+
+        Executor bossPool = Executors.newCachedThreadPool();
+        Executor workerPool = Executors.newCachedThreadPool();
+        NioServerSocketChannelFactory executerFactory;
+
+        if (workerThreads == 0) {
+            executerFactory = new NioServerSocketChannelFactory(bossPool, workerPool);
+            execFactoryLst.add(executerFactory);
+        } else {
+            executerFactory = new NioServerSocketChannelFactory(bossPool, workerPool, workerThreads);
+            execFactoryLst.add(executerFactory);
+        }
+
+        return new ServerBootstrap(executerFactory);
+    }
+
+
+    /**
+     * Initializes internal data structures.
+     */
+    public void init() {
+        this.systemStartTime = System.currentTimeMillis();
+    }
+
+    /**
+     * Starts the controller.
+     *
+     * @param ag            OSPF agent instance
+     * @param driverService driver service instance
+     */
+    public void start(OspfAgent ag, DriverService driverService) {
+        log.info("Starting OSPF Controller...!!!");
+        this.agent = ag;
+        this.driverService = driverService;
+        this.init();
+    }
+
+    /**
+     * Stops the Controller.
+     */
+    public void stop() {
+        log.info("Stopping OSPF Controller...!!!");
+
+        for (ChannelGroup cg : cgList) {
+            cg.close();
+        }
+
+        for (NioServerSocketChannelFactory execFactory : execFactoryLst) {
+            execFactory.shutdown();
+        }
+
+        processes.clear();
+    }
+
+    /**
+     * Deletes configured interface from the area.
+     *
+     * @param processId         process id
+     * @param areaId            area id
+     * @param interfaceToDelete interface to delete
+     * @return true if operation success else false
+     */
+    public boolean deleteInterfaceFromArea(String processId, String areaId, String interfaceToDelete) {
+        Iterator<OspfProcess> processItr = processes.iterator();
+
+        while (processItr.hasNext()) {
+            OspfProcess process = processItr.next();
+            if (processId.equalsIgnoreCase(process.processId())) {
+                Iterator<OspfArea> areaItr = process.areas().iterator();
+                while (areaItr.hasNext()) {
+                    OspfArea area = areaItr.next();
+                    Iterator<OspfInterface> ospfIntrItr = area.getInterfacesLst().iterator();
+                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
+                        while (ospfIntrItr.hasNext()) {
+                            OspfInterface ospfIntr = ospfIntrItr.next();
+                            if (interfaceToDelete.equalsIgnoreCase(ospfIntr.ipAddress().toString())) {
+                                ospfIntrItr.remove();
+                                log.debug("Interface With Id {} is removed from Area {}",
+                                          ospfIntr.ipAddress(), ospfIntr.areaId());
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        return false;
+    }
+
+    /*
+    * Checks area with area id exists in process.
+    *
+    * @param processId process id
+    * @param areaId area id
+    * @return true if exist else false
+    */
+    public boolean checkArea(String processId, String areaId) {
+        for (OspfProcess process : processes) {
+            if (processId.equalsIgnoreCase(process.processId())) {
+                for (OspfArea area : process.areas()) {
+                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /*
+    * Checks process with process id exists or not.
+    *
+    * @param processId process id
+    * @return true if exist else false
+    */
+    public boolean checkProcess(String processId) {
+        log.debug("CheckProcess,Process Id ={} processes={}", processId, processes);
+        for (OspfProcess process : processes) {
+            if (processId.equalsIgnoreCase(process.processId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /*
+    * Checks interface exists in given area.
+    *
+    * @param processId process id
+    * @param areaId area id
+    * @param ipAddress interface
+    * @return true if exist else false
+    */
+    public boolean checkInterface(String processId, String areaId, String interfaceIp) {
+        for (OspfProcess process : processes) {
+            if (processId.equalsIgnoreCase(process.processId())) {
+                for (OspfArea area : process.areas()) {
+                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
+                        for (OspfInterface ospfInterface : area.getInterfacesLst()) {
+                            if (ospfInterface.ipAddress().toString().equalsIgnoreCase(interfaceIp)) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Create processes first time when no process exist.
+     * Create server bootstraps for all the interfaces in the processes.
+     *
+     * @param ospfProcesses list of OSPF processes to create
+     */
+    private void createProcessWhenNoProcessesExists(List<OspfProcess> ospfProcesses) {
+        Set<String> interfaceIpList = new HashSet<>();
+        Set<String> areaIdList = new HashSet<>();
+        if (processes != null) {
+            if (processes.size() == 0) {
+
+                processes.addAll(ospfProcesses);
+                for (OspfProcess process : ospfProcesses) {
+                    for (OspfArea area : process.areas()) {
+                        areaIdList.add(area.areaId().toString());
+                        for (OspfInterface intrfc : area.getInterfacesLst()) {
+                            interfaceIpList.add(intrfc.ipAddress().toString());
+                        }
+                    }
+                }
+                createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
+            }
+        } else {
+            processes = new ArrayList<>();
+            processes.addAll(ospfProcesses);
+
+            for (OspfProcess process : ospfProcesses) {
+                for (OspfArea area : process.areas()) {
+                    areaIdList.add(area.areaId().toString());
+                    for (OspfInterface intrfc : area.getInterfacesLst()) {
+                        interfaceIpList.add(intrfc.ipAddress().toString());
+                    }
+                }
+            }
+            createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
+        }
+    }
+
+    /**
+     * Creates processes when already process exist.
+     * It can be modifying existing process or adding a new process.
+     *
+     * @param ospfProcesses list of processes
+     */
+    private void createProcessWhenProcessesExists(List<OspfProcess> ospfProcesses) {
+        if (ospfProcesses != null) {
+            for (OspfProcess process : ospfProcesses) {
+                if (!checkProcess(process.processId())) {
+                    createNewProcess(process.processId(), process);
+                } else {
+                    List<OspfArea> areas = process.areas();
+                    for (OspfArea area : areas) {
+                        if (!checkArea(process.processId(), area.areaId().toString())) {
+                            createAreaInProcess(process.processId(),
+                                                area.areaId().toString(), area);
+                        } else {
+                            updateAreaInProcess(process.processId(), area.areaId().toString(), area);
+                            for (OspfInterface interfc : area.getInterfacesLst()) {
+                                if (!checkInterface(process.processId(),
+                                                    area.areaId().toString(), interfc.ipAddress().toString())) {
+                                    createInterfaceInAreaInProcess(process.processId(),
+                                                                   area.areaId().toString(), interfc);
+                                } else {
+                                    updateInterfaceParameters(process.processId(),
+                                                              area.areaId().toString(),
+                                                              interfc.ipAddress().toString(), interfc);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Updates the area information in already started OSPF processes.
+     *
+     * @param processId     process id
+     * @param areaId        area id
+     * @param areaFrmConfig area to update
+     */
+    public void updateAreaInProcess(String processId, String areaId, OspfArea areaFrmConfig) {
+        if (processes != null) {
+            Iterator<OspfProcess> processItr = processes.iterator();
+            while (processItr.hasNext()) {
+                OspfProcess process = processItr.next();
+                if (processId.equalsIgnoreCase(process.processId())) {
+                    Iterator<OspfArea> area = process.areas().iterator();
+                    while (area.hasNext()) {
+                        OspfArea ospfArea = area.next();
+                        if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
+                            ospfArea.setAddressRanges(areaFrmConfig.addressRanges());
+                            ospfArea.setRouterId(areaFrmConfig.routerId());
+                            ospfArea.setTransitCapability(areaFrmConfig.isTransitCapability());
+                            ospfArea.setExternalRoutingCapability(areaFrmConfig.isExternalRoutingCapability());
+                            ospfArea.setStubCost(areaFrmConfig.stubCost());
+                            ospfArea.setOptions(areaFrmConfig.options());
+                            ospfArea.setIsOpaqueEnabled(areaFrmConfig.isOpaqueEnabled());
+                            log.debug("updateAreaInProcess::Process Id::{}::Ospf Area with Id::{}::is " +
+                                              "updated", processId, areaId);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Updates the processes configuration.
+     *
+     * @param ospfProcesses list of OSPF processes
+     */
+    public void updateConfig(List<OspfProcess> ospfProcesses) {
+        log.info("Controller::UpdateConfig called");
+        if (processes != null) {
+            if (processes.size() == 0) {
+                createProcessWhenNoProcessesExists(ospfProcesses);
+            } else {
+                createProcessWhenProcessesExists(ospfProcesses);
+            }
+        } else {
+            createProcessWhenNoProcessesExists(ospfProcesses);
+        }
+    }
+
+    /**
+     * Deletes configuration.
+     *
+     * @param ospfProcesses OSPF processes
+     * @param attribute     attribute to delete
+     */
+    public void deleteConfig(List<OspfProcess> ospfProcesses, String attribute) {
+        log.info("Controller::UpdateConfig called");
+        if (processes != null) {
+            if (processes.size() == 0) {
+                log.debug("DeleteConfig:: No process exists");
+            } else {
+                deleteProcessWhenExists(ospfProcesses, attribute);
+            }
+        } else {
+            log.debug("DeleteConfig:: No process exists");
+        }
+    }
+
+    /**
+     * Creates a new process.
+     *
+     * @param processId process id
+     * @param process   OSPF process instance
+     */
+    private void createNewProcess(String processId, OspfProcess process) {
+        Set<String> interfaceIpList = new HashSet<>();
+        Set<String> areaIdList = new HashSet<>();
+
+        processes.add(process);
+        for (OspfArea area : process.areas()) {
+            areaIdList.add(area.areaId().toString());
+            for (OspfInterface interfc : area.getInterfacesLst()) {
+                interfaceIpList.add(interfc.ipAddress().toString());
+            }
+        }
+        log.debug("createNewProcess::List of areas in process::{} areas::{}", processId, areaIdList);
+
+        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
+
+        log.debug("createNewProcess:: all processes::{}", processes);
+    }
+
+    /**
+     * Creates a new area information in the process.
+     *
+     * @param processId process id
+     * @param areaId    area id
+     * @param area      OSPF area instance
+     */
+    private void createAreaInProcess(String processId, String areaId, OspfArea area) {
+        Set<String> interfaceIpList = new HashSet<>();
+        Set<String> areaIdList = new HashSet<>();
+
+        Iterator<OspfProcess> processItr = processes.iterator();
+        while (processItr.hasNext()) {
+            OspfProcess process = processItr.next();
+            List<OspfArea> areasInProcess = process.areas();
+            if (processId.equalsIgnoreCase(process.processId())) {
+                areasInProcess.add(area);
+
+                for (OspfInterface intrfc : area.getInterfacesLst()) {
+                    interfaceIpList.add(intrfc.ipAddress().toString());
+                }
+                areaIdList.add(area.areaId().toString());
+                log.debug("createAreaInProcess::List of areas in process Id::{} " +
+                                  "AreaId ::{} update process::{}",
+                          processId, areaId, process);
+            }
+        }
+        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
+        log.debug("createAreaInProcess:: all processes::{}", processes);
+    }
+
+    /**
+     * Creates an interface in the given area and process.
+     *
+     * @param processId     process id
+     * @param areaId        area id
+     * @param ospfInterface OSPF interface instance
+     */
+    private void createInterfaceInAreaInProcess(String processId,
+                                                String areaId, OspfInterface ospfInterface) {
+        Set<String> interfaceIpList = new HashSet<>();
+        Set<String> areaIdList = new HashSet<>();
+
+        Iterator<OspfProcess> processItr = processes.iterator();
+        while (processItr.hasNext()) {
+            OspfProcess process = processItr.next();
+            List<OspfArea> areasInProcess = process.areas();
+            if (processId.equalsIgnoreCase(process.processId())) {
+                Iterator<OspfArea> areaItr = areasInProcess.iterator();
+                while (areaItr.hasNext()) {
+                    OspfArea area = areaItr.next();
+                    if (areaId.equalsIgnoreCase(area.areaId().toString())) {
+                        area.getInterfacesLst().add(ospfInterface);
+                        interfaceIpList.add(ospfInterface.ipAddress().toString());
+
+                        log.debug("createInterfaceInAreaInProcess::Interface " +
+                                          "updated in process Id::{} AreaId ::{} Interface List{}",
+                                  processId, areaId, area.getInterfacesLst());
+
+                    }
+                }
+            }
+        }
+        createBootStrapForCreatedInterface(interfaceIpList, areaIdList);
+        log.debug("createInterfaceInAreaInProcess:: all processes::{}", processes);
+    }
+
+    /**
+     * Updates interface parameters.
+     *
+     * @param processId     process id
+     * @param areaId        area id
+     * @param interfaceId   interface id
+     * @param ospfInterface OSPF interface instance
+     */
+    private void updateInterfaceParameters(String processId, String areaId, String interfaceId,
+                                           OspfInterface ospfInterface) {
+        Iterator<OspfProcess> processItr = processes.iterator();
+        while (processItr.hasNext()) {
+            OspfProcess process = processItr.next();
+            if (processId.equalsIgnoreCase(process.processId())) {
+                Iterator<OspfArea> areItr = process.areas().iterator();
+                while (areItr.hasNext()) {
+                    OspfArea area = (OspfArea) areItr.next();
+                    if (area.areaId().toString().equalsIgnoreCase(areaId)) {
+                        Iterator<OspfInterface> intfcList = area.getInterfacesLst().iterator();
+                        while (intfcList.hasNext()) {
+                            OspfInterface intrfcObj = intfcList.next();
+                            if (interfaceId.equalsIgnoreCase(intrfcObj.ipAddress().toString())) {
+                                intrfcObj.setPollInterval(ospfInterface.pollInterval());
+                                intrfcObj.setTransmitDelay(ospfInterface.transmitDelay());
+                                intrfcObj.setBdr(ospfInterface.bdr());
+                                intrfcObj.setDr(ospfInterface.dr());
+                                intrfcObj.setAuthKey(ospfInterface.authKey());
+                                intrfcObj.setAuthType(ospfInterface.authType());
+                                intrfcObj.setHelloIntervalTime(ospfInterface.helloIntervalTime());
+                                intrfcObj.setReTransmitInterval(ospfInterface.reTransmitInterval());
+                                intrfcObj.setMtu(ospfInterface.mtu());
+                                intrfcObj.setInterfaceCost(ospfInterface.interfaceCost());
+                                intrfcObj.setInterfaceType(ospfInterface.interfaceType());
+                                intrfcObj.setRouterDeadIntervalTime(ospfInterface.routerDeadIntervalTime());
+                                intrfcObj.setRouterPriority(ospfInterface.routerPriority());
+                                intrfcObj.setIpNetworkMask(ospfInterface.ipNetworkMask());
+                                log.debug("updateInterfaceParameters::Interface updated in " +
+                                                  "process Id::{} AreaId ::{} Interface Id:{} " +
+                                                  "Updated Interface List: {}", processId, areaId,
+                                          interfaceId, intfcList);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        log.debug("updateInterfaceParameters:: all processes::{}", processes);
+    }
+
+    /**
+     * Creates server bootstrap for interface.
+     *
+     * @param interfaceIPs set of interfaces
+     * @param areaIds      set of area id's
+     */
+    private void createBootStrapForCreatedInterface(Set<String> interfaceIPs, Set<String> areaIds) {
+
+        log.debug("createBootStrapForCreatedInterface:: List of new Interfaces::{}, " +
+                          "List of new areas::{}", interfaceIPs, areaIds);
+        List<String> networkInterfaces = new ArrayList();
+        //get the connected interfaces
+        Enumeration<NetworkInterface> nets = null;
+        try {
+            nets = NetworkInterface.getNetworkInterfaces();
+            // Check NetworkInterfaces and add the IP's
+            for (NetworkInterface netInt : Collections.list(nets)) {
+                // if the interface is up & not loopback
+                if (!netInt.isUp() && !netInt.isLoopback()) {
+                    continue;
+                }
+                //get all the InetAddresses
+                Enumeration<InetAddress> inetAddresses = netInt.getInetAddresses();
+                for (InetAddress inetAddress : Collections.list(inetAddresses)) {
+                    String ipAddress = inetAddress.getHostAddress();
+                    networkInterfaces.add(ipAddress);
+                }
+            }
+            //Search for the address in all configured areas interfaces
+            for (OspfProcess process : processes) {
+                for (OspfArea area : process.areas()) {
+                    for (OspfInterface ospfIf : area.getInterfacesLst()) {
+                        String ipFromConfig = ospfIf.ipAddress().toString();
+                        if (interfaceIPs.contains(ipFromConfig)) {
+                            log.debug("Ip address::{} for area {} is newly created" + ipFromConfig);
+                            if (networkInterfaces.contains(ipFromConfig)) {
+                                log.debug("Both Config and Interface have ipAddress {} for area {}",
+                                          ipFromConfig, area.areaId());
+                                // if same IP address create
+                                try {
+                                    log.debug("Creating ServerBootstrap for {} @ {}", ipFromConfig, ospfPort);
+
+                                    final ServerBootstrap bootstrap = createServerBootStrap();
+
+                                    bootstrap.setOption("receiveBufferSize", Controller.BUFFER_SIZE);
+                                    bootstrap.setOption("receiveBufferSizePredictorFactory",
+                                                        new FixedReceiveBufferSizePredictorFactory(
+                                                                Controller.BUFFER_SIZE));
+                                    bootstrap.setOption("reuseAddress", true);
+                                    bootstrap.setOption("tcpNoDelay", true);
+                                    bootstrap.setOption("keepAlive", true);
+
+                                    bootstrap.setOption("child.receiveBufferSize", Controller.BUFFER_SIZE);
+                                    bootstrap.setOption("child.receiveBufferSizePredictorFactory",
+                                                        new FixedReceiveBufferSizePredictorFactory(
+                                                                Controller.BUFFER_SIZE));
+                                    bootstrap.setOption("child.reuseAddress", true);
+                                    bootstrap.setOption("child.tcpNoDelay", true);
+                                    bootstrap.setOption("child.keepAlive", true);
+                                    bootstrap.setOption("receiveBufferSizePredictorFactory",
+                                                        new FixedReceiveBufferSizePredictorFactory(
+                                                                Controller.BUFFER_SIZE));
+                                    bootstrap.setOption("receiveBufferSizePredictor",
+                                                        new AdaptiveReceiveBufferSizePredictor(64, 1024, 65536));
+
+                                    ChannelPipelineFactory pfact = new OspfPipelineFactory(this, area, ospfIf);
+                                    bootstrap.setPipelineFactory(pfact);
+                                    InetSocketAddress sa = new InetSocketAddress(InetAddress.getByName(ipFromConfig),
+                                                                                 ospfPort);
+
+                                    ChannelGroup cg = new DefaultChannelGroup();
+                                    cg.add(bootstrap.bind(sa));
+                                    cgList.add(cg);
+
+                                    log.debug("Listening for connections on {}", sa);
+
+                                } catch (Exception e) {
+                                    throw new RuntimeException(e);
+                                }
+                            }
+                        } else {
+                            log.debug("Ip address::{} for area {} is not newly created" + ipFromConfig);
+                        }
+                    }
+                    if (areaIds.contains(area.areaId().toString())) {
+                        area.initializeDb();
+                    }
+                }
+            }
+
+        } catch (SocketException e) {
+            log.error("Error occured due to SocketException::Class::{},Line::{},Method::{}",
+                      e.getStackTrace()[0].getFileName(), e.getStackTrace()[0].getLineNumber(),
+                      e.getStackTrace()[0].getMethodName());
+        }
+    }
+
+    /**
+     * Deletes given process.
+     *
+     * @param ospfProcesses list of OSPF process instance.
+     * @param attribute     attribute to delete
+     */
+    public void deleteProcessWhenExists(List<OspfProcess> ospfProcesses, String attribute) {
+        if (ospfProcesses != null) {
+            for (OspfProcess process : ospfProcesses) {
+                if (checkProcess(process.processId())) {
+                    if (PROCESS.equalsIgnoreCase(attribute)) {
+                        deleteProcess(process.processId(), process);
+                    } else {
+                        List<OspfArea> areas = process.areas();
+                        for (OspfArea area : areas) {
+                            if (checkArea(process.processId(), area.areaId().toString())) {
+                                if (AREA.equalsIgnoreCase(attribute)) {
+                                    deleteAreaFromProcess(process.processId(),
+                                                          area.areaId().toString(), area);
+                                } else {
+                                    for (OspfInterface interfc : area.getInterfacesLst()) {
+                                        if (checkInterface(process.processId(),
+                                                           area.areaId().toString(),
+                                                           interfc.ipAddress().toString())) {
+                                            if (INTERFACE.equalsIgnoreCase(attribute)) {
+                                                deleteInterfaceFromAreaProcess(process.processId(),
+                                                                               area.areaId().toString(),
+                                                                               interfc);
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Deletes given process.
+     *
+     * @param processId process id
+     * @param process   OSPF process instance
+     */
+    private void deleteProcess(String processId, OspfProcess process) {
+        if (processes != null) {
+            Iterator<OspfProcess> itrProcess = processes.iterator();
+            while (itrProcess.hasNext()) {
+                OspfProcess ospfPrs = itrProcess.next();
+                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
+                    itrProcess.remove();
+                }
+            }
+        }
+    }
+
+    /**
+     * Deletes area from process.
+     *
+     * @param processId process id
+     * @param areaId    area id
+     * @param area      OSPF area instance
+     */
+    private void deleteAreaFromProcess(String processId, String areaId, OspfArea area) {
+        if (processes != null) {
+            Iterator<OspfProcess> itrProcess = processes.iterator();
+            while (itrProcess.hasNext()) {
+                OspfProcess ospfPrs = itrProcess.next();
+                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
+                    if (ospfPrs.areas() != null) {
+                        Iterator<OspfArea> itrArea = ospfPrs.areas().iterator();
+                        while (itrArea.hasNext()) {
+                            OspfArea ospfArea = itrArea.next();
+                            if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
+                                itrArea.remove();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Deletes interface from area.
+     *
+     * @param processId         process id
+     * @param areaId            area id
+     * @param interfaceToDelete interface to delete
+     */
+    private void deleteInterfaceFromAreaProcess(String processId, String areaId, OspfInterface interfaceToDelete) {
+        if (processes != null) {
+            Iterator<OspfProcess> itrProcess = processes.iterator();
+            while (itrProcess.hasNext()) {
+                OspfProcess ospfPrs = itrProcess.next();
+                if (processId.equalsIgnoreCase(ospfPrs.processId())) {
+                    if (ospfPrs.areas() != null) {
+                        Iterator<OspfArea> itrArea = ospfPrs.areas().iterator();
+                        while (itrArea.hasNext()) {
+                            OspfArea ospfArea = itrArea.next();
+                            if (areaId.equalsIgnoreCase(ospfArea.areaId().toString())) {
+                                if (ospfArea.getInterfacesLst() != null) {
+                                    Iterator<OspfInterface> intrfcList = ospfArea.getInterfacesLst().iterator();
+                                    while (intrfcList.hasNext()) {
+                                        OspfInterface ospfItrfc = intrfcList.next();
+                                        if (interfaceToDelete.ipAddress().equals(ospfItrfc.ipAddress())) {
+                                            intrfcList.remove();
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java
new file mode 100755
index 0000000..9eb10c7
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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 OSPF controller.
+ */
+package org.onosproject.ospf.controller.impl;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java
new file mode 100755
index 0000000..36e147e
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaBinImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016 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.ospf.controller.lsdb;
+
+import com.google.common.base.MoreObjects;
+import org.onosproject.ospf.controller.LsaBin;
+import org.onosproject.ospf.controller.LsaWrapper;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Represents a bin, where an LSA is stored for Aging.
+ * A bin is identified by a bin number and can have one or more LSAs
+ * store in a particular bin location.
+ */
+public class LsaBinImpl implements LsaBin {
+
+    private int binNumber;
+    private Map<String, LsaWrapper> listOfLsa = new ConcurrentHashMap<>();
+
+    /**
+     * Creates an instance of LSA bin.
+     *
+     * @param binNumber unique number of this bin
+     */
+    public LsaBinImpl(int binNumber) {
+        this.binNumber = binNumber;
+    }
+
+    /**
+     * Adds the LSA to this bin with the given key.
+     *
+     * @param lsaKey     key of the LSA
+     * @param lsaWrapper wrapper instance to store
+     */
+    public void addOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
+        if (!listOfLsa.containsKey(lsaKey)) {
+            listOfLsa.put(lsaKey, lsaWrapper);
+            lsaWrapper.setBinNumber(this.binNumber);
+        }
+    }
+
+    /**
+     * Gets the LSA from the bin.
+     *
+     * @param lsaKey key to search the LSA
+     * @return LSA Wrapper instance
+     */
+    public LsaWrapper ospfLsa(String lsaKey) {
+
+        return listOfLsa.get(lsaKey);
+    }
+
+    /**
+     * Removes LSA from the bin.
+     *
+     * @param lsaKey     key to search LSA
+     * @param lsaWrapper wrapper object to remove
+     */
+    public void removeOspfLsa(String lsaKey, LsaWrapper lsaWrapper) {
+        if (listOfLsa.containsKey(lsaKey)) {
+            listOfLsa.remove(lsaKey);
+        }
+    }
+
+    /**
+     * Gets the list of LSAs in this bin as key value pair.
+     *
+     * @return list of LSAs in this bin as key value pair
+     */
+    public Map<String, LsaWrapper> listOfLsa() {
+        return listOfLsa;
+    }
+
+    /**
+     * Gets the bin number.
+     *
+     * @return the bin number
+     */
+    public int binNumber() {
+        return binNumber;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("binNumber", binNumber)
+                .add("listOfLsa", listOfLsa)
+                .toString();
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
new file mode 100755
index 0000000..18c50e6
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/LsaWrapperImpl.java
@@ -0,0 +1,452 @@
+/*
+ * Copyright 2016 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.ospf.controller.lsdb;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Objects;
+import org.onosproject.ospf.controller.LsaWrapper;
+import org.onosproject.ospf.controller.LsdbAge;
+import org.onosproject.ospf.controller.OspfInterface;
+import org.onosproject.ospf.controller.OspfLsa;
+import org.onosproject.ospf.controller.OspfLsaType;
+import org.onosproject.ospf.protocol.lsa.LsaHeader;
+import org.onosproject.ospf.protocol.util.OspfParameters;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Wrapper object to store LSA and associated metadata information.
+ */
+public class LsaWrapperImpl implements LsaWrapper {
+    private static final Logger log = LoggerFactory.getLogger(LsaWrapperImpl.class);
+    private LsaHeader lsaHeader;
+    private int lsaAgeReceived;
+    private int ageCounterWhenReceived;
+    private boolean isSelfOriginated;
+    private OspfLsaType lsaType;
+    private OspfLsa ospfLsa;
+    private int noReTransmissionLists;
+    private boolean inAnAgeBin;
+    private boolean changedSinceLastFlood;
+    private boolean isSequenceRollOver;
+    private boolean sentReplyForOlderLsa;
+    private boolean checkAge; // Queued for check sum verification
+    private boolean isAging;
+    private String lsaProcessing; //for LSAQueueConsumer processing
+    private int binNumber = -1;
+    private OspfInterface ospfInterface;
+    private LsdbAge lsdbAge;
+
+    /**
+     * Gets the LSA type.
+     *
+     * @return LSA type
+     */
+    public OspfLsaType lsaType() {
+        return lsaType;
+    }
+
+    /**
+     * Sets the LSA type.
+     *
+     * @param lsaType LSA type
+     */
+    public void setLsaType(OspfLsaType lsaType) {
+        this.lsaType = lsaType;
+    }
+
+    /**
+     * Gets if self originated or not.
+     *
+     * @return true if self originated else false
+     */
+    public boolean isSelfOriginated() {
+        return isSelfOriginated;
+    }
+
+    /**
+     * Sets if self originated or not.
+     *
+     * @param isSelfOriginated true if self originated else false
+     */
+    public void setIsSelfOriginated(boolean isSelfOriginated) {
+        this.isSelfOriginated = isSelfOriginated;
+    }
+
+    /**
+     * Adds the LSA in the wrapper.
+     *
+     * @param lsaType LSA type
+     * @param ospfLsa LSA instance
+     */
+    public void addLsa(OspfLsaType lsaType, OspfLsa ospfLsa) {
+        this.lsaType = lsaType;
+        this.lsaHeader = (LsaHeader) ospfLsa.lsaHeader();
+        this.ospfLsa = ospfLsa;
+    }
+
+    /**
+     * Age of LSA when received.
+     *
+     * @return Age of LSA when received
+     */
+    public int lsaAgeReceived() {
+        return lsaAgeReceived;
+    }
+
+    /**
+     * Sets the Age of LSA when received.
+     *
+     * @param lsaAgeReceived Age of LSA when received
+     */
+    public void setLsaAgeReceived(int lsaAgeReceived) {
+        this.lsaAgeReceived = lsaAgeReceived;
+    }
+
+    /**
+     * Gets the LSA header.
+     *
+     * @return LSA header instance
+     */
+    public LsaHeader lsaHeader() {
+        lsaHeader.setAge(currentAge());
+        return lsaHeader;
+    }
+
+    /**
+     * Sets LSA header.
+     *
+     * @param lsaHeader LSA header
+     */
+    public void setLsaHeader(LsaHeader lsaHeader) {
+        this.lsaHeader = lsaHeader;
+    }
+
+    /**
+     * Gets the LSA.
+     *
+     * @return LSA instance
+     */
+    public OspfLsa ospfLsa() {
+        LsaHeader lsaHeader = (LsaHeader) ospfLsa;
+        lsaHeader.setAge(currentAge());
+
+        return lsaHeader;
+    }
+
+    /**
+     * Sets the LSA.
+     *
+     * @param ospfLsa LSA instance
+     */
+    public void setOspfLsa(OspfLsa ospfLsa) {
+        this.ospfLsa = ospfLsa;
+    }
+
+    /**
+     * Gets number of LSAs in retransmission list.
+     *
+     * @return number of LSAs in retransmission list
+     */
+    public int noReTransmissionLists() {
+        return noReTransmissionLists;
+    }
+
+    /**
+     * Sets number of LSAs in retransmission list.
+     *
+     * @param noReTransmissionLists number of LSAs in retransmission list
+     */
+    public void setNoReTransmissionLists(int noReTransmissionLists) {
+        this.noReTransmissionLists = noReTransmissionLists;
+    }
+
+    /**
+     * whether LSA in age bin or not.
+     *
+     * @return true if LSA in age bin else false
+     */
+    public boolean isInAnAgeBin() {
+        return inAnAgeBin;
+    }
+
+    /**
+     * Sets whether LSA in age bin or not.
+     *
+     * @param inAnAgeBin whether LSA in age bin or not
+     */
+    public void setInAnAgeBin(boolean inAnAgeBin) {
+        this.inAnAgeBin = inAnAgeBin;
+    }
+
+    /**
+     * Gets if LSA is changed since last flood.
+     *
+     * @return true if LSA is changed since last flood else false
+     */
+    public boolean isChangedSinceLastFlood() {
+        return changedSinceLastFlood;
+    }
+
+    /**
+     * Sets if LSA is changed since last flood.
+     *
+     * @param changedSinceLastFlood true if LSA is changed since last flood else false
+     */
+    public void setChangedSinceLastFlood(boolean changedSinceLastFlood) {
+        this.changedSinceLastFlood = changedSinceLastFlood;
+    }
+
+    /**
+     * Gets if sequence number rolled over.
+     *
+     * @return true if sequence rolled over else false.
+     */
+    public boolean isSequenceRollOver() {
+        return isSequenceRollOver;
+    }
+
+    /**
+     * Sets if sequence number rolled over.
+     *
+     * @param isSequenceRollOver true if sequence rolled over else false
+     */
+    public void setIsSequenceRollOver(boolean isSequenceRollOver) {
+        this.isSequenceRollOver = isSequenceRollOver;
+    }
+
+    /**
+     * Gets is sent reply for older LSA.
+     *
+     * @return true if sent reply for old LSA else false
+     */
+    public boolean isSentReplyForOlderLsa() {
+        return sentReplyForOlderLsa;
+    }
+
+    /**
+     * Sets is sent reply for older lsa.
+     *
+     * @param sentReplyForOlderLsa true if sent reply for older lsa else false
+     */
+    public void setSentReplyForOlderLsa(boolean sentReplyForOlderLsa) {
+        this.sentReplyForOlderLsa = sentReplyForOlderLsa;
+    }
+
+    /**
+     * Gets check age flag.
+     *
+     * @return true check age flag is set else false
+     */
+    public boolean isCheckAge() {
+        return checkAge;
+    }
+
+    /**
+     * Sets check age flag.
+     *
+     * @param checkAge check age flag.
+     */
+    public void setCheckAge(boolean checkAge) {
+        this.checkAge = checkAge;
+    }
+
+    /**
+     * Gets value of aging flag.
+     *
+     * @return is aging flag
+     */
+    public boolean isAging() {
+        return isAging;
+    }
+
+    /**
+     * Sets aging flag.
+     *
+     * @param isAging is aging flag
+     */
+    public void setIsAging(boolean isAging) {
+        this.isAging = isAging;
+    }
+
+    /**
+     * Gets the LSDB age.
+     *
+     * @return LSDB age
+     */
+    public LsdbAge getLsdbAge() {
+        return lsdbAge;
+    }
+
+    /**
+     * Sets the LSDB age.
+     *
+     * @param lsdbAge LSDB age
+     */
+    public void setLsdbAge(LsdbAge lsdbAge) {
+        this.lsdbAge = lsdbAge;
+    }
+
+    /**
+     * Gets the current LSA Age.
+     *
+     * @return LSA age
+     */
+    public int currentAge() {
+
+        int currentAge = 0;
+        //ls age received
+        if (lsdbAge.getAgeCounter() >= ageCounterWhenReceived) {
+            currentAge = lsaAgeReceived + (lsdbAge.getAgeCounter() - ageCounterWhenReceived);
+        } else {
+            currentAge = lsaAgeReceived + ((OspfParameters.MAXAGE + lsdbAge.getAgeCounter())
+                    - ageCounterWhenReceived);
+        }
+
+        if (currentAge >= OspfParameters.MAXAGE) {
+            return OspfParameters.MAXAGE;
+        }
+
+        return currentAge;
+    }
+
+    /**
+     * Gets the age counter when received.
+     *
+     * @return the age counter when received
+     */
+    public int ageCounterWhenReceived() {
+        return ageCounterWhenReceived;
+    }
+
+    /**
+     * Sets the age counter when received.
+     *
+     * @param ageCounterWhenReceived the age counter when received
+     */
+    public void setAgeCounterWhenReceived(int ageCounterWhenReceived) {
+        this.ageCounterWhenReceived = ageCounterWhenReceived;
+    }
+
+    /**
+     * Gets the LSA process command.
+     *
+     * @return LSA process command
+     */
+    public String lsaProcessing() {
+        return lsaProcessing;
+    }
+
+    /**
+     * Sets the LSA process command.
+     *
+     * @param lsaProcessing LSA process command
+     */
+    public void setLsaProcessing(String lsaProcessing) {
+        this.lsaProcessing = lsaProcessing;
+    }
+
+    /**
+     * Gets bin number.
+     *
+     * @return bin number
+     */
+    public int binNumber() {
+        return binNumber;
+    }
+
+    /**
+     * Sets bin number.
+     *
+     * @param binNumber bin number
+     */
+    public void setBinNumber(int binNumber) {
+        this.binNumber = binNumber;
+    }
+
+
+    /**
+     * Get the OSPF interface.
+     *
+     * @return the OSPF interface.
+     */
+    public OspfInterface ospfInterface() {
+        return ospfInterface;
+    }
+
+    /**
+     * Sets the OSPF interface.
+     *
+     * @param ospfInterface OSPF interface instance
+     */
+    @Override
+    public void setOspfInterface(OspfInterface ospfInterface) {
+        this.ospfInterface = ospfInterface;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("lsaAgeReceived", lsaAgeReceived)
+                .add("ageCounterWhenReceived", ageCounterWhenReceived)
+                .add("isSelfOriginated", isSelfOriginated)
+                .add("lsaHeader", lsaHeader)
+                .add("lsaType", lsaType)
+                .add("ospflsa", ospfLsa)
+                .add("noReTransmissionLists", noReTransmissionLists)
+                .add("inAnAgeBin", inAnAgeBin)
+                .add("changedSinceLasFlood", changedSinceLastFlood)
+                .add("isSequenceRollOver", isSequenceRollOver)
+                .add("sentReplyForOlderLSA", sentReplyForOlderLsa)
+                .add("checkAge", checkAge)
+                .add("isAging", isAging)
+                .add("lsaProcessing", lsaProcessing)
+                .toString();
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        LsaWrapperImpl that = (LsaWrapperImpl) o;
+        return Objects.equal(lsaAgeReceived, that.lsaAgeReceived) &&
+                Objects.equal(ageCounterWhenReceived, that.ageCounterWhenReceived) &&
+                Objects.equal(isSelfOriginated, that.isSelfOriginated) &&
+                Objects.equal(lsaHeader, that.lsaHeader) &&
+                Objects.equal(ospfLsa, that.ospfLsa) &&
+                Objects.equal(noReTransmissionLists, that.noReTransmissionLists) &&
+                Objects.equal(inAnAgeBin, that.inAnAgeBin) &&
+                Objects.equal(changedSinceLastFlood, that.changedSinceLastFlood) &&
+                Objects.equal(isSequenceRollOver, that.isSequenceRollOver) &&
+                Objects.equal(sentReplyForOlderLsa, that.sentReplyForOlderLsa) &&
+                Objects.equal(checkAge, that.checkAge) &&
+                Objects.equal(isAging, that.isAging) &&
+                Objects.equal(lsaProcessing, that.lsaProcessing);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hashCode(lsaAgeReceived, lsaAgeReceived, ageCounterWhenReceived, isSelfOriginated,
+                                lsaHeader, lsaType, ospfLsa, noReTransmissionLists, inAnAgeBin,
+                                changedSinceLastFlood, isSequenceRollOver, sentReplyForOlderLsa,
+                                checkAge, isAging, lsaProcessing);
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java
new file mode 100755
index 0000000..3ca39c3
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/lsdb/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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 OSPF Link state database and Ageing.
+ */
+package org.onosproject.ospf.controller.lsdb;
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java
new file mode 100755
index 0000000..b1087d4
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfEligibleRouter.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2016 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.ospf.controller.util;
+
+import org.onlab.packet.Ip4Address;
+
+/**
+ * Represents a router who is eligible for DR election.
+ */
+public class OspfEligibleRouter {
+
+    private Ip4Address ipAddress;
+    private Ip4Address routerId;
+    private int routerPriority;
+    private boolean isDr;
+    private boolean isBdr;
+
+    /**
+     * Creates an instance.
+     * Initialize IP address of eligible router.
+     */
+    public OspfEligibleRouter() {
+        ipAddress = Ip4Address.valueOf("0.0.0.0");
+    }
+
+    /**
+     * Gets the value of IP address.
+     *
+     * @return IP address
+     */
+    public Ip4Address getIpAddress() {
+        return ipAddress;
+    }
+
+    /**
+     * Sets the value of IP address.
+     *
+     * @param ipAddress IP address
+     */
+    public void setIpAddress(Ip4Address ipAddress) {
+        this.ipAddress = ipAddress;
+    }
+
+    /**
+     * Gets the value of router id.
+     *
+     * @return router id.
+     */
+    public Ip4Address getRouterId() {
+        return routerId;
+    }
+
+    /**
+     * Sets the value of router id.
+     *
+     * @param routerId router id
+     */
+    public void setRouterId(Ip4Address routerId) {
+        this.routerId = routerId;
+    }
+
+    /**
+     * Gets the value of router priority.
+     *
+     * @return router priority.
+     */
+    public int getRouterPriority() {
+        return routerPriority;
+    }
+
+    /**
+     * Sets the value of router priority.
+     *
+     * @param routerPriority router priority
+     */
+    public void setRouterPriority(int routerPriority) {
+        this.routerPriority = routerPriority;
+    }
+
+    /**
+     * Gets whether the router is DR.
+     *
+     * @return boolean true if router is DR else return false.
+     */
+    public boolean isDr() {
+        return isDr;
+    }
+
+    /**
+     * Sets the router is DR or not.
+     *
+     * @param isDr router is DR or not
+     */
+    public void setIsDr(boolean isDr) {
+        this.isDr = isDr;
+    }
+
+    /**
+     * Gets whether the router is BDR or not.
+     *
+     * @return boolean true if router is Bdr else return false.
+     */
+    public boolean isBdr() {
+        return isBdr;
+    }
+
+    /**
+     * Sets the router is BDR or not.
+     *
+     * @param isBdr the router is BDR or not
+     */
+    public void setIsBdr(boolean isBdr) {
+        this.isBdr = isBdr;
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java
new file mode 100755
index 0000000..e34ea43
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfInterfaceType.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016 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.ospf.controller.util;
+
+/**
+ * Enum represents OSPF interface types.
+ */
+public enum OspfInterfaceType {
+
+    POINT_TO_POINT(1),
+    BROADCAST(2),
+    VIRTUAL(3);
+
+    private int value;
+
+    /**
+     * Creates an instance.
+     *
+     * @param value value represents interface type
+     */
+    OspfInterfaceType(int value) {
+        this.value = value;
+    }
+
+    /**
+     * Gets value represents interface type.
+     *
+     * @return value represents interface type
+     */
+    public int value() {
+        return value;
+    }
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java
new file mode 100755
index 0000000..aa6270a
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/OspfLinkType.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2016 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.ospf.controller.util;
+
+/**
+ * Enum represents OSPF link type.
+ */
+public enum OspfLinkType {
+
+    /**
+     * Indicates a point-to-point connection to another router.
+     */
+    POINT_TO_POINT,
+
+    /**
+     * Indicates a connection to a transit network.
+     */
+    TO_TRANSIT_NET,
+
+    /**
+     * Indicates a connection to a stub network.
+     */
+    TO_STUB_NET,
+
+    /**
+     * Indicates a Virtual link to another area border router.
+     */
+    VIRTUAL_LINK;
+}
\ No newline at end of file
diff --git a/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java
new file mode 100755
index 0000000..b36992f
--- /dev/null
+++ b/protocols/ospf/ctl/src/main/java/org/onosproject/ospf/controller/util/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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 OSPF utilities.
+ */
+package org.onosproject.ospf.controller.util;
\ No newline at end of file