ONOS-1521 : Supports Leaf-Spine topology (tested with 4 x 4 )
- Supports ECMPNotSupportedInTransitRouter option
- Adds Leaf-Spine config file
- Removes the temporary NetworkConfigHanlder class
- Removes the grouphandler dependency
- Removes the grouphandler app
Change-Id: I8c70e81bfb4062e251b25c0fa23ef2c92419a75c
diff --git a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
index 0dfb3fd..d0721e9 100644
--- a/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
+++ b/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
@@ -313,4 +313,31 @@
         log.debug("Cannot find a router for {}", gatewayIpAddress);
         return null;
     }
+
+
+    /**
+     * Checks if the host is in the subnet defined in the router with the
+     * device ID given.
+     *
+     * @param deviceId device identification of the router
+     * @param hostIp   host IP address to check
+     * @return true if the host is within the subnet of the router,
+     * false if no subnet is defined under the router or if the host is not
+     * within the subnet defined in the router
+     */
+    public boolean inSameSubnet(DeviceId deviceId, Ip4Address hostIp) {
+
+        List<Ip4Prefix> subnets = getSubnets(deviceId);
+        if (subnets == null) {
+            return false;
+        }
+
+        for (Ip4Prefix subnet: subnets) {
+            if (subnet.contains(hostIp)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }