Renamed routing packages to foo & foo.impl pattern.

Plus added some package-info.java files.

Change-Id: I0b68a7f4cea7a5f089b37b1a1c016d1c3b7a8702
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java b/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java
new file mode 100644
index 0000000..f5d95f2
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/BgpService.java
@@ -0,0 +1,34 @@
+/*
+ * 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.routing;
+
+/**
+ * Provides a way of interacting with the BGP protocol component.
+ */
+public interface BgpService {
+
+    /**
+     * Starts the BGP service.
+     *
+     * @param routeListener listener to send route updates to
+     */
+    void start(RouteListener routeListener);
+
+    /**
+     * Stops the BGP service.
+     */
+    void stop();
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
new file mode 100644
index 0000000..e2e2049
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/FibEntry.java
@@ -0,0 +1,100 @@
+/*
+ * 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.routing;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+
+import java.util.Objects;
+
+/**
+ * An entry in the Forwarding Information Base (FIB).
+ */
+public class FibEntry {
+
+    private final IpPrefix prefix;
+    private final IpAddress nextHopIp;
+    private final MacAddress nextHopMac;
+
+    /**
+     * Creates a new FIB entry.
+     *
+     * @param prefix IP prefix of the FIB entry
+     * @param nextHopIp IP address of the next hop
+     * @param nextHopMac MAC address of the next hop
+     */
+    public FibEntry(IpPrefix prefix, IpAddress nextHopIp, MacAddress nextHopMac) {
+        this.prefix = prefix;
+        this.nextHopIp = nextHopIp;
+        this.nextHopMac = nextHopMac;
+    }
+
+    /**
+     * Returns the IP prefix of the FIB entry.
+     *
+     * @return the IP prefix
+     */
+    public IpPrefix prefix() {
+        return prefix;
+    }
+
+    /**
+     * Returns the IP address of the next hop.
+     *
+     * @return the IP address
+     */
+    public IpAddress nextHopIp() {
+        return nextHopIp;
+    }
+
+    /**
+     * Returns the MAC address of the next hop.
+     *
+     * @return the MAC address
+     */
+    public MacAddress nextHopMac() {
+        return nextHopMac;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof FibEntry)) {
+            return false;
+        }
+
+        FibEntry that = (FibEntry) o;
+
+        return Objects.equals(this.prefix, that.prefix) &&
+                Objects.equals(this.nextHopIp, that.nextHopIp) &&
+                Objects.equals(this.nextHopMac, that.nextHopMac);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(prefix, nextHopIp, nextHopMac);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("prefix", prefix)
+                .add("nextHopIp", nextHopIp)
+                .add("nextHopMac", nextHopMac)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
new file mode 100644
index 0000000..0c8e627
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/FibListener.java
@@ -0,0 +1,35 @@
+/*
+ * 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.routing;
+
+import java.util.Collection;
+
+/**
+ * A component that is able to process Forwarding Information Base (FIB) updates.
+ */
+public interface FibListener {
+
+    /**
+     * Signals the FIB component of changes to the FIB.
+     *
+     * @param updates FIB updates of the UDPATE type
+     * @param withdraws FIB updates of the WITHDRAW type
+     */
+    // TODO this interface should use only one collection when we have the new
+    // intent key API
+    void update(Collection<FibUpdate> updates, Collection<FibUpdate> withdraws);
+
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java b/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
new file mode 100644
index 0000000..dacb159
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/FibUpdate.java
@@ -0,0 +1,98 @@
+/*
+ * 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.routing;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+/**
+ * Represents a change to the Forwarding Information Base (FIB).
+ */
+public class FibUpdate {
+
+    /**
+     * Specifies the type of the FIB update.
+     */
+    public enum Type {
+        /**
+         * The update contains a new or updated FIB entry for a prefix.
+         */
+        UPDATE,
+
+        /**
+         * The update signals that a prefix should be removed from the FIB.
+         */
+        DELETE
+    }
+
+    private final Type type;
+    private final FibEntry entry;
+
+    /**
+     * Creates a new FIB update.
+     *
+     * @param type type of the update
+     * @param entry FIB entry describing the update
+     */
+    public FibUpdate(Type type, FibEntry entry) {
+        this.type = type;
+        this.entry = entry;
+    }
+
+    /**
+     * Returns the type of the update.
+     *
+     * @return update type
+     */
+    public Type type() {
+        return type;
+    }
+
+    /**
+     * Returns the FIB entry which contains update information.
+     *
+     * @return the FIB entry
+     */
+    public FibEntry entry() {
+        return entry;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (!(o instanceof FibUpdate)) {
+            return false;
+        }
+
+        FibUpdate that = (FibUpdate) o;
+
+        return Objects.equals(this.type, that.type) &&
+                Objects.equals(this.entry, that.entry);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(type, entry);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("type", type)
+                .add("entry", entry)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java b/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
new file mode 100644
index 0000000..358f707
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/RouteEntry.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2014 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.routing;
+
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a route entry for an IP prefix.
+ */
+public class RouteEntry {
+    private final IpPrefix prefix;              // The IP prefix
+    private final IpAddress nextHop;            // Next-hop IP address
+
+    /**
+     * Class constructor.
+     *
+     * @param prefix the IP prefix of the route
+     * @param nextHop the next hop IP address for the route
+     */
+    public RouteEntry(IpPrefix prefix, IpAddress nextHop) {
+        this.prefix = checkNotNull(prefix);
+        this.nextHop = checkNotNull(nextHop);
+    }
+
+    /**
+     * Returns the IP version of the route.
+     *
+     * @return the IP version of the route
+     */
+    public IpAddress.Version version() {
+        return nextHop.version();
+    }
+
+    /**
+     * Returns the IP prefix of the route.
+     *
+     * @return the IP prefix of the route
+     */
+    public IpPrefix prefix() {
+        return prefix;
+    }
+
+    /**
+     * Returns the next hop IP address for the route.
+     *
+     * @return the next hop IP address for the route
+     */
+    public IpAddress nextHop() {
+        return nextHop;
+    }
+
+    /**
+     * Creates the binary string representation of an IP prefix.
+     * The prefix can be either IPv4 or IPv6.
+     * The string length is equal to the prefix length.
+     *
+     * @param ipPrefix the IP prefix to use
+     * @return the binary string representation
+     */
+    public static String createBinaryString(IpPrefix ipPrefix) {
+        if (ipPrefix.prefixLength() == 0) {
+            return "";
+        }
+
+        byte[] octets = ipPrefix.address().toOctets();
+        StringBuilder result = new StringBuilder(ipPrefix.prefixLength());
+        for (int i = 0; i < ipPrefix.prefixLength(); i++) {
+            int byteOffset = i / Byte.SIZE;
+            int bitOffset = i % Byte.SIZE;
+            int mask = 1 << (Byte.SIZE - 1 - bitOffset);
+            byte value = octets[byteOffset];
+            boolean isSet = ((value & mask) != 0);
+            result.append(isSet ? "1" : "0");
+        }
+        return result.toString();
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+
+        //
+        // NOTE: Subclasses are considered as change of identity, hence
+        // equals() will return false if the class type doesn't match.
+        //
+        if (other == null || getClass() != other.getClass()) {
+            return false;
+        }
+
+        RouteEntry otherRoute = (RouteEntry) other;
+        return Objects.equals(this.prefix, otherRoute.prefix) &&
+            Objects.equals(this.nextHop, otherRoute.nextHop);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(prefix, nextHop);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+            .add("prefix", prefix)
+            .add("nextHop", nextHop)
+            .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java b/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
new file mode 100644
index 0000000..46ed545
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/RouteListener.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2014 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.routing;
+
+import java.util.Collection;
+
+/**
+ * An interface to receive route updates from route providers.
+ */
+public interface RouteListener {
+    /**
+     * Receives a route update from a route provider.
+     *
+     * @param routeUpdates the collection with updated route information
+     */
+    public void update(Collection<RouteUpdate> routeUpdates);
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java b/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
new file mode 100644
index 0000000..a5a8e83
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/RouteUpdate.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2014 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.routing;
+
+import com.google.common.base.MoreObjects;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Represents a change in routing information.
+ */
+public class RouteUpdate {
+    private final Type type;                    // The route update type
+    private final RouteEntry routeEntry;        // The updated route entry
+
+    /**
+     * Specifies the type of a route update.
+     * <p>
+     * Route updates can either provide updated information for a route, or
+     * withdraw a previously updated route.
+     * </p>
+     */
+    public enum Type {
+        /**
+         * The update contains updated route information for a route.
+         */
+        UPDATE,
+        /**
+         * The update withdraws the route, meaning any previous information is
+         * no longer valid.
+         */
+        DELETE
+    }
+
+    /**
+     * Class constructor.
+     *
+     * @param type the type of the route update
+     * @param routeEntry the route entry with the update
+     */
+    public RouteUpdate(Type type, RouteEntry routeEntry) {
+        this.type = type;
+        this.routeEntry = checkNotNull(routeEntry);
+    }
+
+    /**
+     * Returns the type of the route update.
+     *
+     * @return the type of the update
+     */
+    public Type type() {
+        return type;
+    }
+
+    /**
+     * Returns the route entry the route update is for.
+     *
+     * @return the route entry the route update is for
+     */
+    public RouteEntry routeEntry() {
+        return routeEntry;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+
+        if (!(other instanceof RouteUpdate)) {
+            return false;
+        }
+
+        RouteUpdate otherUpdate = (RouteUpdate) other;
+
+        return Objects.equals(this.type, otherUpdate.type) &&
+            Objects.equals(this.routeEntry, otherUpdate.routeEntry);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(type, routeEntry);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+            .add("type", type)
+            .add("routeEntry", routeEntry)
+            .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java b/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
new file mode 100644
index 0000000..fdd4f2c
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/RoutingService.java
@@ -0,0 +1,50 @@
+/*
+ * 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.routing;
+
+import java.util.Collection;
+
+/**
+ * Provides a way of interacting with the RIB management component.
+ */
+public interface RoutingService {
+
+    /**
+     * Starts the routing service.
+     *
+     * @param listener listener to send FIB updates to
+     */
+    public void start(FibListener listener);
+
+    /**
+     * Stops the routing service.
+     */
+    public void stop();
+
+    /**
+     * Gets all IPv4 routes known to SDN-IP.
+     *
+     * @return the SDN-IP IPv4 routes
+     */
+    public Collection<RouteEntry> getRoutes4();
+
+    /**
+     * Gets all IPv6 routes known to SDN-IP.
+     *
+     * @return the SDN-IP IPv6 routes
+     */
+    public Collection<RouteEntry> getRoutes6();
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java
new file mode 100644
index 0000000..3693ca2
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpPeer.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2014 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.routing.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.NetTools;
+import org.onosproject.net.PortNumber;
+
+import java.util.Objects;
+
+/**
+ * Configuration details for a BGP peer.
+ */
+public class BgpPeer {
+    private final ConnectPoint connectPoint;
+    private final IpAddress ipAddress;
+
+    /**
+     * Creates a new BgpPeer.
+     *
+     * @param dpid the DPID of the switch the peer is attached at, as a String
+     * @param port the port the peer is attached at
+     * @param ipAddress the IP address of the peer as a String
+     */
+    public BgpPeer(@JsonProperty("attachmentDpid") String dpid,
+                   @JsonProperty("attachmentPort") long port,
+                   @JsonProperty("ipAddress") String ipAddress) {
+        this.connectPoint = new ConnectPoint(
+                DeviceId.deviceId(NetTools.dpidToUri(dpid)),
+                PortNumber.portNumber(port));
+        this.ipAddress = IpAddress.valueOf(ipAddress);
+    }
+
+    /**
+     * Gets the connection point of the peer.
+     *
+     * @return the connection point
+     */
+    public ConnectPoint connectPoint() {
+        return connectPoint;
+    }
+
+    /**
+     * Gets the IP address of the peer.
+     *
+     * @return the IP address
+     */
+    public IpAddress ipAddress() {
+        return ipAddress;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(connectPoint, ipAddress);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+
+        if (!(obj instanceof BgpPeer)) {
+            return false;
+        }
+
+        BgpPeer that = (BgpPeer) obj;
+        return Objects.equals(this.connectPoint, that.connectPoint)
+                && Objects.equals(this.ipAddress, that.ipAddress);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("connectPoint", connectPoint)
+                .add("ipAddress", ipAddress)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java
new file mode 100644
index 0000000..b17c74a
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/BgpSpeaker.java
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2014 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.routing.config;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.NetTools;
+import org.onosproject.net.PortNumber;
+
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Represents a BGP daemon in SDN network.
+ * <p>
+ * Each BGP speaker has a attachment point, which includes a switch DPID and a
+ * switch port. Each BGP speaker has one MAC address and several IP addresses,
+ * which are used to peer with BGP peers outside the SDN network. For each
+ * peer outside the SDN network, we configure a different IP address to BGP
+ * speaker inside the SDN network.
+ * </p>
+ * <p>
+ * Each BGP speaker has a name, which is a unique identifying String that is
+ * used to reference this speaker in the configuration.
+ * </p>
+ */
+public class BgpSpeaker {
+    private final String name;
+    private final ConnectPoint connectPoint;
+    private final MacAddress macAddress;
+    private List<InterfaceAddress> interfaceAddresses;
+
+    /**
+     * Class constructor used by the JSON library to create an object.
+     *
+     * @param name the name of the BGP speaker inside SDN network
+     * @param attachmentDpid the DPID where the BGP speaker is attached to
+     * @param attachmentPort the port where the BGP speaker is attached to
+     * @param macAddress the MAC address of the BGP speaker
+     */
+    @JsonCreator
+    public BgpSpeaker(@JsonProperty("name") String name,
+            @JsonProperty("attachmentDpid") String attachmentDpid,
+            @JsonProperty("attachmentPort") long attachmentPort,
+            @JsonProperty("macAddress") String macAddress) {
+
+        this.name = name;
+        this.macAddress = MacAddress.valueOf(macAddress);
+        this.connectPoint = new ConnectPoint(
+                DeviceId.deviceId(NetTools.dpidToUri(attachmentDpid)),
+                PortNumber.portNumber(attachmentPort));
+    }
+
+    /**
+     * Sets the addresses we configured for the BGP speaker on all virtual
+     * {@link Interface}s.
+     *
+     * @param interfaceAddresses a list of IP addresses of the BGP speaker
+     * configured on all virtual interfaces
+     */
+    @JsonProperty("interfaceAddresses")
+    public void setInterfaceAddresses(
+            List<InterfaceAddress> interfaceAddresses) {
+        this.interfaceAddresses = interfaceAddresses;
+    }
+
+    /**
+     * Gets the BGP speaker name.
+     *
+     * @return the BGP speaker name
+     */
+    public String name() {
+        return name;
+    }
+
+    /**
+     * Gets the connect point where the BGP speaker is attached.
+     *
+     * @return the connect point
+     */
+    public ConnectPoint connectPoint() {
+        return connectPoint;
+    }
+
+    /**
+     * Gets the MAC address of the BGP speaker.
+     *
+     * @return the MAC address
+     */
+    public MacAddress macAddress() {
+        return macAddress;
+    }
+
+    /**
+     * Gets all IP addresses configured on all {@link Interface}s of the
+     * BGP speaker.
+     *
+     * @return a list of IP addresses of the BGP speaker configured on all
+     * virtual interfaces
+     */
+    public List<InterfaceAddress> interfaceAddresses() {
+        return interfaceAddresses;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof BgpSpeaker)) {
+            return false;
+        }
+
+        BgpSpeaker otherBgpSpeaker = (BgpSpeaker) other;
+
+        return  name.equals(otherBgpSpeaker.name) &&
+                connectPoint.equals(
+                        otherBgpSpeaker.connectPoint) &&
+                macAddress.equals(otherBgpSpeaker.macAddress) &&
+                interfaceAddresses.equals(otherBgpSpeaker.interfaceAddresses);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(name, connectPoint, macAddress,
+                interfaceAddresses);
+
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("speakerName", name)
+                .add("connectPoint", connectPoint)
+                .add("macAddress", macAddress)
+                .add("interfaceAddresses", interfaceAddresses)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
new file mode 100644
index 0000000..ac9e34b
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2014 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.routing.config;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.Sets;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.host.InterfaceIpAddress;
+import org.onosproject.net.host.PortAddresses;
+
+import java.util.Objects;
+import java.util.Set;
+
+/**
+ * An Interface is a set of addresses that are logically mapped to a switch
+ * port in the network.
+ */
+public class Interface {
+    private final ConnectPoint connectPoint;
+    private final Set<InterfaceIpAddress> ipAddresses;
+    private final MacAddress macAddress;
+    private final VlanId vlan;
+
+    /**
+     * Creates an Interface based on a connection point, a set of interface
+     * IP addresses, and a MAC address.
+     *
+     * @param connectPoint the connect point this interface is mapped to
+     * @param ipAddresses the IP addresses for the interface
+     * @param macAddress the MAC address of the interface
+     * @param vlan VLAN identifier
+     */
+    public Interface(ConnectPoint connectPoint,
+                     Set<InterfaceIpAddress> ipAddresses,
+                     MacAddress macAddress, VlanId vlan) {
+        this.connectPoint = connectPoint;
+        this.ipAddresses = Sets.newHashSet(ipAddresses);
+        this.macAddress = macAddress;
+        this.vlan = vlan;
+    }
+
+    /**
+     * Creates an Interface based on a PortAddresses object.
+     *
+     * @param portAddresses the PortAddresses object to turn into an Interface
+     */
+    public Interface(PortAddresses portAddresses) {
+        connectPoint = portAddresses.connectPoint();
+        ipAddresses = Sets.newHashSet(portAddresses.ipAddresses());
+        macAddress = portAddresses.mac();
+        vlan = portAddresses.vlan();
+    }
+
+    /**
+     * Retrieves the connection point that this interface maps to.
+     *
+     * @return the connection point
+     */
+    public ConnectPoint connectPoint() {
+        return connectPoint;
+    }
+
+    /**
+     * Retrieves the set of IP addresses that are assigned to the interface.
+     *
+     * @return the set of interface IP addresses
+     */
+    public Set<InterfaceIpAddress> ipAddresses() {
+        return ipAddresses;
+    }
+
+    /**
+     * Retrieves the MAC address that is assigned to the interface.
+     *
+     * @return the MAC address
+     */
+    public MacAddress mac() {
+        return macAddress;
+    }
+
+    /**
+     * Retrieves the VLAN ID that is assigned to the interface.
+     *
+     * @return the VLAN ID
+     */
+    public VlanId vlan() {
+        return vlan;
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (!(other instanceof Interface)) {
+            return false;
+        }
+
+        Interface otherInterface = (Interface) other;
+
+        return  connectPoint.equals(otherInterface.connectPoint) &&
+                ipAddresses.equals(otherInterface.ipAddresses) &&
+                macAddress.equals(otherInterface.macAddress) &&
+                vlan.equals(otherInterface.vlan);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(connectPoint, ipAddresses, macAddress, vlan);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("connectPoint", connectPoint)
+                .add("ipAddresses", ipAddresses)
+                .add("macAddress", macAddress)
+                .add("vlan", vlan)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java
new file mode 100644
index 0000000..4bf6e02
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/InterfaceAddress.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2014 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.routing.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.NetTools;
+import org.onosproject.net.PortNumber;
+
+import java.util.Objects;
+
+/**
+ * Represents an address of a {@link BgpSpeaker} configured on an
+ * {@link Interface}.
+ * <p>
+ * Each InterfaceAddress includes the interface name and an IP address.
+ * </p>
+ */
+public class InterfaceAddress {
+    private final ConnectPoint connectPoint;
+    private final IpAddress ipAddress;
+
+    /**
+     * Creates an InterfaceAddress object.
+     *
+     * @param dpid the DPID of the interface as a String
+     * @param port the port of the interface
+     * @param ipAddress the IP address of a {@link BgpSpeaker} configured on
+     * the interface
+     */
+    public InterfaceAddress(@JsonProperty("interfaceDpid") String dpid,
+                            @JsonProperty("interfacePort") int port,
+                            @JsonProperty("ipAddress") String ipAddress) {
+        this.connectPoint = new ConnectPoint(
+                DeviceId.deviceId(NetTools.dpidToUri(dpid)),
+                PortNumber.portNumber(port));
+        this.ipAddress = IpAddress.valueOf(ipAddress);
+    }
+
+    /**
+     * Gets the connection point of the peer.
+     *
+     * @return the connection point
+     */
+    public ConnectPoint connectPoint() {
+        return connectPoint;
+    }
+
+    /**
+     * Gets the IP address of a BGP speaker configured on an {@link Interface}.
+     *
+     * @return the IP address
+     */
+    public IpAddress ipAddress() {
+        return ipAddress;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(connectPoint, ipAddress);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        }
+
+        if (!(obj instanceof InterfaceAddress)) {
+            return false;
+        }
+
+        InterfaceAddress that = (InterfaceAddress) obj;
+        return Objects.equals(this.connectPoint, that.connectPoint)
+                && Objects.equals(this.ipAddress, that.ipAddress);
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("connectPoint", connectPoint)
+                .add("ipAddress", ipAddress)
+                .toString();
+    }
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
new file mode 100644
index 0000000..113daa7
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/RoutingConfigurationService.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2014 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.routing.config;
+
+import org.onlab.packet.IpAddress;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Provides information about the routing configuration.
+ */
+public interface RoutingConfigurationService {
+
+    /**
+     * Gets the list of BGP speakers inside the SDN network.
+     *
+     * @return the map of BGP speaker names to BGP speaker objects
+     */
+    public Map<String, BgpSpeaker> getBgpSpeakers();
+
+    /**
+     * Gets the list of configured BGP peers.
+     *
+     * @return the map from peer IP address to BgpPeer object
+     */
+    public Map<IpAddress, BgpPeer> getBgpPeers();
+
+    /**
+     * Retrieves the entire set of interfaces in the network.
+     *
+     * @return the set of interfaces
+     */
+    Set<Interface> getInterfaces();
+
+    /**
+     * Retrieves the interface associated with the given connect point.
+     *
+     * @param connectPoint the connect point to retrieve interface information
+     * for
+     * @return the interface
+     */
+    Interface getInterface(ConnectPoint connectPoint);
+
+    /**
+     * Retrieves the interface that matches the given IP address. Matching
+     * means that the IP address is in one of the interface's assigned subnets.
+     *
+     * @param ipAddress IP address to match
+     * @return the matching interface
+     */
+    Interface getMatchingInterface(IpAddress ipAddress);
+
+}
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java b/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java
new file mode 100644
index 0000000..d033daa
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/config/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 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.
+ */
+
+/**
+ * Routing configuration interfaces.
+ */
+package org.onosproject.routing.config;
diff --git a/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java b/apps/routing-api/src/main/java/org/onosproject/routing/package-info.java
new file mode 100644
index 0000000..66e590b
--- /dev/null
+++ b/apps/routing-api/src/main/java/org/onosproject/routing/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.
+ */
+
+/**
+ * API for routing libraries.
+ */
+package org.onosproject.routing;