Carry location of next hop in ResolvedRoute

Change-Id: I64ca6ecc5cfcffc3ed19621053b0ee266c4093ea
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/NextHopData.java b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/NextHopData.java
new file mode 100644
index 0000000..2f05200
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/NextHopData.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2016-present 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.incubator.net.routing;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Host;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Stores next hop information.
+ */
+public class NextHopData {
+
+    private final MacAddress mac;
+    private final ConnectPoint location;
+
+    /**
+     * Creates a new instance.
+     *
+     * @param mac MAC address
+     * @param location Connect point
+     */
+    public NextHopData(MacAddress mac, ConnectPoint location) {
+        this.mac = mac;
+        this.location = location;
+    }
+
+    /**
+     * Returns the MAC address.
+     *
+     * @return MAC address
+     */
+    public MacAddress mac() {
+        return mac;
+    }
+
+    /**
+     * Returns the location.
+     *
+     * @return Connect point
+     */
+    public ConnectPoint location() {
+        return location;
+    }
+
+    /**
+     * Creates a new instance from a host.
+     *
+     * @param host Host information
+     * @return NextHopData instance
+     */
+    public static NextHopData fromHost(Host host) {
+        return new NextHopData(host.mac(), host.location());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(mac, location);
+    }
+
+    @Override
+    public boolean equals(Object other) {
+        if (this == other) {
+            return true;
+        }
+
+        if (!(other instanceof NextHopData)) {
+            return false;
+        }
+
+        NextHopData that = (NextHopData) other;
+
+        return Objects.equals(this.mac, that.mac) &&
+                Objects.equals(this.location, that.location);
+    }
+
+    @Override
+    public String toString() {
+        return toStringHelper(this)
+                .add("mac", mac)
+                .add("location", location)
+                .toString();
+    }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/ResolvedRoute.java b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/ResolvedRoute.java
index 68f2feb..d6cb4b4 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/ResolvedRoute.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/ResolvedRoute.java
@@ -19,6 +19,7 @@
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.MacAddress;
+import org.onosproject.net.ConnectPoint;
 
 import java.util.Objects;
 
@@ -32,17 +33,20 @@
     private final IpPrefix prefix;
     private final IpAddress nextHop;
     private final MacAddress nextHopMac;
+    private final ConnectPoint location;
 
     /**
      * Creates a new resolved route.
      *
      * @param route input route
      * @param nextHopMac next hop MAC address
+     * @param location connect point where the next hop connects to
      */
-    public ResolvedRoute(Route route, MacAddress nextHopMac) {
+    public ResolvedRoute(Route route, MacAddress nextHopMac, ConnectPoint location) {
         this.prefix = route.prefix();
         this.nextHop = route.nextHop();
         this.nextHopMac = nextHopMac;
+        this.location = location;
     }
 
     /**
@@ -51,11 +55,14 @@
      * @param prefix route prefix
      * @param nextHop route next hop IP address
      * @param nextHopMac next hop MAC address
+     * @param location connect point where the next hop connects to
      */
-    public ResolvedRoute(IpPrefix prefix, IpAddress nextHop, MacAddress nextHopMac) {
+    public ResolvedRoute(IpPrefix prefix, IpAddress nextHop, MacAddress nextHopMac,
+                         ConnectPoint location) {
         this.prefix = prefix;
         this.nextHop = nextHop;
         this.nextHopMac = nextHopMac;
+        this.location = location;
     }
 
     /**
@@ -85,9 +92,18 @@
         return nextHopMac;
     }
 
+    /**
+     * Returns the next hop location.
+     *
+     * @return connect point where the next hop attaches to
+     */
+    public ConnectPoint location() {
+        return location;
+    }
+
     @Override
     public int hashCode() {
-        return Objects.hash(prefix, nextHop, nextHopMac);
+        return Objects.hash(prefix, nextHop, nextHopMac, location);
     }
 
     @Override
@@ -104,7 +120,8 @@
 
         return Objects.equals(this.prefix, that.prefix) &&
                 Objects.equals(this.nextHop, that.nextHop) &&
-                Objects.equals(this.nextHopMac, that.nextHopMac);
+                Objects.equals(this.nextHopMac, that.nextHopMac) &&
+                Objects.equals(this.location, that.location);
     }
 
     @Override
@@ -113,6 +130,7 @@
                 .add("prefix", prefix)
                 .add("nextHop", nextHop)
                 .add("nextHopMac", nextHopMac)
+                .add("location", location)
                 .toString();
     }
 }
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/RouteStore.java b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/RouteStore.java
index 9b75099..9eac65c 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/routing/RouteStore.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/routing/RouteStore.java
@@ -17,7 +17,6 @@
 package org.onosproject.incubator.net.routing;
 
 import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
 import org.onosproject.store.Store;
 
 import java.util.Collection;
@@ -78,30 +77,30 @@
      * Updates a next hop IP and MAC in the store.
      *
      * @param ip IP address
-     * @param mac MAC address
+     * @param nextHopData Information of the next hop
      */
-    void updateNextHop(IpAddress ip, MacAddress mac);
+    void updateNextHop(IpAddress ip, NextHopData nextHopData);
 
     /**
      * Removes a next hop IP and MAC from the store.
      *
      * @param ip IP address
-     * @param mac MAC address
+     * @param nextHopData Information of the next hop
      */
-    void removeNextHop(IpAddress ip, MacAddress mac);
+    void removeNextHop(IpAddress ip, NextHopData nextHopData);
 
     /**
      * Returns the MAC address of the given next hop.
      *
      * @param ip next hop IP
-     * @return MAC address
+     * @return Information of the next hop
      */
-    MacAddress getNextHop(IpAddress ip);
+    NextHopData getNextHop(IpAddress ip);
 
     /**
      * Returns all next hops in the route store.
      *
      * @return next hops
      */
-    Map<IpAddress, MacAddress> getNextHops();
+    Map<IpAddress, NextHopData> getNextHops();
 }