Probe all interfaces that contains given IP

Change-Id: I150471a2031c214d5f08c76b974e7449e930b453
diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java b/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
index d85fb97..a3a3069 100644
--- a/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
+++ b/core/net/src/main/java/org/onosproject/net/host/impl/HostMonitor.java
@@ -25,7 +25,6 @@
 import org.onlab.packet.VlanId;
 import org.onlab.packet.ndp.NeighborSolicitation;
 import org.onlab.util.Timer;
-import org.onosproject.incubator.net.intf.Interface;
 import org.onosproject.incubator.net.intf.InterfaceService;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.Host;
@@ -33,7 +32,6 @@
 import org.onosproject.net.flow.DefaultTrafficTreatment;
 import org.onosproject.net.flow.TrafficTreatment;
 import org.onosproject.net.host.HostProvider;
-import org.onosproject.net.host.InterfaceIpAddress;
 import org.onosproject.net.packet.DefaultOutboundPacket;
 import org.onosproject.net.packet.OutboundPacket;
 import org.onosproject.net.packet.PacketService;
@@ -187,34 +185,30 @@
      * @param targetIp IP address to send the request for
      */
     private void sendRequest(IpAddress targetIp) {
-        Interface intf = interfaceService.getMatchingInterface(targetIp);
-
-        if (intf == null) {
-            return;
-        }
-
-        if (!edgePortService.isEdgePoint(intf.connectPoint())) {
-            log.warn("Aborting attempt to send probe out non-edge port: {}", intf);
-            return;
-        }
-
-        for (InterfaceIpAddress ia : intf.ipAddressesList()) {
-            if (ia.subnetAddress().contains(targetIp)) {
-                log.info("Sending probe for target:{} out of intf:{} vlan:{}",
-                         targetIp, intf.connectPoint(), intf.vlan());
-                sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
-                        intf.mac(), intf.vlan());
-                // account for use-cases where tagged-vlan config is used
-                if (!intf.vlanTagged().isEmpty()) {
-                    intf.vlanTagged().forEach(tag -> {
-                        log.info("Sending probe for target:{} out of intf:{} vlan:{}",
-                             targetIp, intf.connectPoint(), tag);
-                        sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
-                                  intf.mac(), tag);
-                    });
-                }
+        interfaceService.getMatchingInterfaces(targetIp).forEach(intf -> {
+            if (!edgePortService.isEdgePoint(intf.connectPoint())) {
+                log.warn("Aborting attempt to send probe out non-edge port: {}", intf);
+                return;
             }
-        }
+
+            intf.ipAddressesList().stream()
+                    .filter(ia -> ia.subnetAddress().contains(targetIp))
+                    .forEach(ia -> {
+                        log.info("Sending probe for target:{} out of intf:{} vlan:{}",
+                                targetIp, intf.connectPoint(), intf.vlan());
+                        sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
+                                intf.mac(), intf.vlan());
+                        // account for use-cases where tagged-vlan config is used
+                        if (!intf.vlanTagged().isEmpty()) {
+                            intf.vlanTagged().forEach(tag -> {
+                                log.info("Sending probe for target:{} out of intf:{} vlan:{}",
+                                        targetIp, intf.connectPoint(), tag);
+                                sendProbe(intf.connectPoint(), targetIp, ia.ipAddress(),
+                                        intf.mac(), tag);
+                            });
+                        }
+                    });
+        });
     }
 
     public void sendProbe(ConnectPoint connectPoint,
diff --git a/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java b/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
index 21bec18..80e6858 100644
--- a/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
+++ b/core/net/src/test/java/org/onosproject/net/host/impl/HostMonitorTest.java
@@ -163,9 +163,9 @@
         replay(hostManager);
 
         InterfaceService interfaceService = createMock(InterfaceService.class);
-        expect(interfaceService.getMatchingInterface(TARGET_IPV4_ADDR))
-                .andReturn(new Interface(Interface.NO_INTERFACE_NAME,
-                        cp, Collections.singletonList(IA1), sourceMac, VlanId.NONE))
+        expect(interfaceService.getMatchingInterfaces(TARGET_IPV4_ADDR))
+                .andReturn(Collections.singleton(new Interface(Interface.NO_INTERFACE_NAME,
+                        cp, Collections.singletonList(IA1), sourceMac, VlanId.NONE)))
                 .anyTimes();
         replay(interfaceService);
 
@@ -232,9 +232,9 @@
         replay(hostManager);
 
         InterfaceService interfaceService = createMock(InterfaceService.class);
-        expect(interfaceService.getMatchingInterface(TARGET_IPV6_ADDR))
-                .andReturn(new Interface(Interface.NO_INTERFACE_NAME, cp,
-                        Collections.singletonList(IA2), sourceMac2, VlanId.NONE))
+        expect(interfaceService.getMatchingInterfaces(TARGET_IPV6_ADDR))
+                .andReturn(Collections.singleton(new Interface(Interface.NO_INTERFACE_NAME, cp,
+                        Collections.singletonList(IA2), sourceMac2, VlanId.NONE)))
                 .anyTimes();
         replay(interfaceService);
 
@@ -303,9 +303,9 @@
         replay(hostManager);
 
         InterfaceService interfaceService = createMock(InterfaceService.class);
-        expect(interfaceService.getMatchingInterface(TARGET_IPV4_ADDR))
-                .andReturn(new Interface(Interface.NO_INTERFACE_NAME, cp,
-                        Collections.singletonList(IA1), sourceMac, VlanId.vlanId(vlan)))
+        expect(interfaceService.getMatchingInterfaces(TARGET_IPV4_ADDR))
+                .andReturn(Collections.singleton(new Interface(Interface.NO_INTERFACE_NAME, cp,
+                        Collections.singletonList(IA1), sourceMac, VlanId.vlanId(vlan))))
                 .anyTimes();
         replay(interfaceService);
 
@@ -373,9 +373,9 @@
         replay(hostManager);
 
         InterfaceService interfaceService = createMock(InterfaceService.class);
-        expect(interfaceService.getMatchingInterface(TARGET_IPV6_ADDR))
-                .andReturn(new Interface(Interface.NO_INTERFACE_NAME, cp,
-                        Collections.singletonList(IA2), sourceMac2, VlanId.vlanId(vlan)))
+        expect(interfaceService.getMatchingInterfaces(TARGET_IPV6_ADDR))
+                .andReturn(Collections.singleton(new Interface(Interface.NO_INTERFACE_NAME, cp,
+                        Collections.singletonList(IA2), sourceMac2, VlanId.vlanId(vlan))))
                 .anyTimes();
         replay(interfaceService);