Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
diff --git a/apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java b/apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
index cb60405..7958f99 100644
--- a/apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
+++ b/apps/mobility/src/main/java/org/onlab/onos/mobility/HostMobility.java
@@ -28,7 +28,7 @@
 
 
 /**
- * Sample reactive forwarding application.
+ * Sample mobility application. Cleans up flowmods when a host moves.
  */
 @Component(immediate = true)
 public class HostMobility {
@@ -82,6 +82,10 @@
 
         }
 
+        /**
+         * For a given host, remove any flow rule which references it's addresses.
+         * @param host the host to clean up for
+         */
         private void cleanup(Host host) {
             Iterable<Device> devices = deviceService.getDevices();
             List<FlowRule> flowRules = Lists.newLinkedList();
@@ -102,7 +106,6 @@
                         EthCriterion eth = (EthCriterion) c;
                         if (eth.mac().equals(mac)) {
                             flowRules.add(rule);
-                            break;
                         }
                     }
                 }
diff --git a/providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java b/providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
index d124f2a..4f5bb81 100644
--- a/providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
+++ b/providers/openflow/host/src/main/java/org/onlab/onos/provider/of/host/impl/OpenFlowHostProvider.java
@@ -31,6 +31,7 @@
 import org.onlab.onos.openflow.controller.PacketListener;
 import org.onlab.packet.ARP;
 import org.onlab.packet.Ethernet;
+import org.onlab.packet.IPv4;
 import org.onlab.packet.IpPrefix;
 import org.onlab.packet.VlanId;
 import org.slf4j.Logger;
@@ -92,29 +93,37 @@
         public void handlePacket(OpenFlowPacketContext pktCtx) {
             Ethernet eth = pktCtx.parsed();
 
+            VlanId vlan = VlanId.vlanId(eth.getVlanID());
+            ConnectPoint heardOn = new ConnectPoint(deviceId(Dpid.uri(pktCtx.dpid())),
+                    portNumber(pktCtx.inPort()));
+
+         // If this is not an edge port, bail out.
+            Topology topology = topologyService.currentTopology();
+            if (topologyService.isInfrastructure(topology, heardOn)) {
+                return;
+            }
+
+            HostLocation hloc = new HostLocation(deviceId(Dpid.uri(pktCtx.dpid())),
+                    portNumber(pktCtx.inPort()),
+                    System.currentTimeMillis());
+            HostId hid = HostId.hostId(eth.getSourceMAC(), vlan);
             // Potentially a new or moved host
             if (eth.getEtherType() == Ethernet.TYPE_ARP) {
-                VlanId vlan = VlanId.vlanId(eth.getVlanID());
-                ConnectPoint heardOn = new ConnectPoint(deviceId(Dpid.uri(pktCtx.dpid())),
-                        portNumber(pktCtx.inPort()));
 
-                // If this is not an edge port, bail out.
-                Topology topology = topologyService.currentTopology();
-                if (topologyService.isInfrastructure(topology, heardOn)) {
-                    return;
-                }
 
-                HostLocation hloc = new HostLocation(deviceId(Dpid.uri(pktCtx.dpid())),
-                        portNumber(pktCtx.inPort()),
-                        System.currentTimeMillis());
-
-                HostId hid = HostId.hostId(eth.getSourceMAC(), vlan);
                 ARP arp = (ARP) eth.getPayload();
                 Set<IpPrefix> ips = newHashSet(IpPrefix.valueOf(arp.getSenderProtocolAddress()));
                 HostDescription hdescr =
                         new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ips);
                 providerService.hostDetected(hid, hdescr);
 
+            } else if (eth.getEtherType() == Ethernet.TYPE_IPV4) {
+                IPv4 ip = (IPv4) eth.getPayload();
+                Set<IpPrefix> ips = newHashSet(IpPrefix.valueOf(ip.getSourceAddress()));
+                HostDescription hdescr =
+                        new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ips);
+                providerService.hostDetected(hid, hdescr);
+
             }
 
             // TODO: Use DHCP packets as well later...