Jonathan Hart

Fix for creating IpPrefixes with wrong prefix length

1 package org.onlab.onos.provider.host.impl; 1 package org.onlab.onos.provider.host.impl;
2 2
3 +import static org.slf4j.LoggerFactory.getLogger;
4 +
3 import org.apache.felix.scr.annotations.Activate; 5 import org.apache.felix.scr.annotations.Activate;
4 import org.apache.felix.scr.annotations.Component; 6 import org.apache.felix.scr.annotations.Component;
5 import org.apache.felix.scr.annotations.Deactivate; 7 import org.apache.felix.scr.annotations.Deactivate;
...@@ -21,16 +23,12 @@ import org.onlab.onos.net.provider.AbstractProvider; ...@@ -21,16 +23,12 @@ import org.onlab.onos.net.provider.AbstractProvider;
21 import org.onlab.onos.net.provider.ProviderId; 23 import org.onlab.onos.net.provider.ProviderId;
22 import org.onlab.onos.net.topology.Topology; 24 import org.onlab.onos.net.topology.Topology;
23 import org.onlab.onos.net.topology.TopologyService; 25 import org.onlab.onos.net.topology.TopologyService;
24 -
25 import org.onlab.packet.ARP; 26 import org.onlab.packet.ARP;
26 import org.onlab.packet.Ethernet; 27 import org.onlab.packet.Ethernet;
27 -
28 import org.onlab.packet.IpPrefix; 28 import org.onlab.packet.IpPrefix;
29 import org.onlab.packet.VlanId; 29 import org.onlab.packet.VlanId;
30 import org.slf4j.Logger; 30 import org.slf4j.Logger;
31 31
32 -import static org.slf4j.LoggerFactory.getLogger;
33 -
34 /** 32 /**
35 * Provider which uses an OpenFlow controller to detect network 33 * Provider which uses an OpenFlow controller to detect network
36 * end-station hosts. 34 * end-station hosts.
...@@ -106,7 +104,8 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid ...@@ -106,7 +104,8 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
106 // Potentially a new or moved host 104 // Potentially a new or moved host
107 if (eth.getEtherType() == Ethernet.TYPE_ARP) { 105 if (eth.getEtherType() == Ethernet.TYPE_ARP) {
108 ARP arp = (ARP) eth.getPayload(); 106 ARP arp = (ARP) eth.getPayload();
109 - IpPrefix ip = IpPrefix.valueOf(arp.getSenderProtocolAddress()); 107 + IpPrefix ip = IpPrefix.valueOf(arp.getSenderProtocolAddress(),
108 + IpPrefix.MAX_INET_MASK);
110 HostDescription hdescr = 109 HostDescription hdescr =
111 new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip); 110 new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip);
112 providerService.hostDetected(hid, hdescr); 111 providerService.hostDetected(hid, hdescr);
......