Thomas Vachuska

Merge remote-tracking branch 'origin/master'

Showing 29 changed files with 109 additions and 121 deletions
......@@ -520,8 +520,7 @@ public class Router implements RouteListener {
// See if we know the MAC address of the next hop
MacAddress nextHopMacAddress = null;
Set<Host> hosts = hostService.getHostsByIp(
routeEntry.nextHop().toPrefix());
Set<Host> hosts = hostService.getHostsByIp(routeEntry.nextHop());
if (!hosts.isEmpty()) {
// TODO how to handle if multiple hosts are returned?
nextHopMacAddress = hosts.iterator().next().mac();
......@@ -773,8 +772,8 @@ public class Router implements RouteListener {
if (event.type() == HostEvent.Type.HOST_ADDED ||
event.type() == HostEvent.Type.HOST_UPDATED) {
Host host = event.subject();
for (IpPrefix ip : host.ipAddresses()) {
updateMac(ip.toIpAddress(), host.mac());
for (IpAddress ip : host.ipAddresses()) {
updateMac(ip, host.mac());
}
}
}
......
......@@ -197,27 +197,27 @@ public class RouterTest {
hostService.addListener(anyObject(HostListener.class));
expectLastCall().anyTimes();
IpPrefix host1Address = IpPrefix.valueOf("192.168.10.1/32");
IpAddress host1Address = IpAddress.valueOf("192.168.10.1");
Host host1 = new DefaultHost(ProviderId.NONE, HostId.NONE,
MacAddress.valueOf("00:00:00:00:00:01"), VlanId.NONE,
new HostLocation(SW1_ETH1, 1),
Sets.newHashSet(host1Address));
Sets.newHashSet(host1Address));
expect(hostService.getHostsByIp(host1Address))
.andReturn(Sets.newHashSet(host1)).anyTimes();
hostService.startMonitoringIp(host1Address.toIpAddress());
hostService.startMonitoringIp(host1Address);
expectLastCall().anyTimes();
IpPrefix host2Address = IpPrefix.valueOf("192.168.20.1/32");
IpAddress host2Address = IpAddress.valueOf("192.168.20.1");
Host host2 = new DefaultHost(ProviderId.NONE, HostId.NONE,
MacAddress.valueOf("00:00:00:00:00:02"), VlanId.NONE,
new HostLocation(SW2_ETH1, 1),
Sets.newHashSet(host2Address));
Sets.newHashSet(host2Address));
expect(hostService.getHostsByIp(host2Address))
.andReturn(Sets.newHashSet(host2)).anyTimes();
hostService.startMonitoringIp(host2Address.toIpAddress());
hostService.startMonitoringIp(host2Address);
expectLastCall().anyTimes();
......
......@@ -184,7 +184,7 @@ public class RouterTestWithAsyncArp {
// Set up test expectation
reset(hostService);
expect(hostService.getHostsByIp(anyObject(IpPrefix.class))).andReturn(
expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn(
new HashSet<Host>()).anyTimes();
hostService.startMonitoringIp(IpAddress.valueOf("192.168.10.1"));
replay(hostService);
......@@ -203,7 +203,7 @@ public class RouterTestWithAsyncArp {
new HostLocation(
SW1_ETH1.deviceId(),
SW1_ETH1.port(), 1),
Sets.newHashSet(IpPrefix.valueOf("192.168.10.1/32")));
Sets.newHashSet(IpAddress.valueOf("192.168.10.1")));
internalHostListener.event(
new HostEvent(HostEvent.Type.HOST_ADDED, host));
......@@ -266,7 +266,7 @@ public class RouterTestWithAsyncArp {
// Set up test expectation
reset(hostService);
expect(hostService.getHostsByIp(anyObject(IpPrefix.class))).andReturn(
expect(hostService.getHostsByIp(anyObject(IpAddress.class))).andReturn(
new HashSet<Host>()).anyTimes();
hostService.startMonitoringIp(IpAddress.valueOf("192.168.20.1"));
replay(hostService);
......@@ -286,7 +286,7 @@ public class RouterTestWithAsyncArp {
new HostLocation(
SW2_ETH1.deviceId(),
SW2_ETH1.port(), 1),
Sets.newHashSet(IpPrefix.valueOf("192.168.20.1/32")));
Sets.newHashSet(IpAddress.valueOf("192.168.20.1")));
internalHostListener.event(
new HostEvent(HostEvent.Type.HOST_ADDED, host));
......
......@@ -34,7 +34,7 @@ import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyGraph;
import org.onlab.onos.net.topology.TopologyService;
import org.onlab.onos.net.topology.TopologyVertex;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.rest.BaseResource;
import javax.ws.rs.GET;
......@@ -92,8 +92,8 @@ public class TopologyResource extends BaseResource {
// Merge the exterior and interior vertexes and inject host links as
// the exterior edges.
for (Host host : hostService.getHosts()) {
Set<IpPrefix> ipAddresses = host.ipAddresses();
IpPrefix ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
Set<IpAddress> ipAddresses = host.ipAddresses();
IpAddress ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
String label = ipAddress != null ? ipAddress.toString() : host.mac().toString();
vertexesNode.add(json(mapper, host.id(), 3, label, true));
edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1))));
......
......@@ -27,7 +27,7 @@ import org.onlab.onos.cli.AbstractShellCommand;
import org.onlab.onos.cli.Comparators;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.host.HostService;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import java.util.Collections;
import java.util.List;
......@@ -71,7 +71,7 @@ public class HostsListCommand extends AbstractShellCommand {
ObjectNode loc = LinksListCommand.json(mapper, host.location())
.put("time", host.location().time());
ArrayNode ips = mapper.createArrayNode();
for (IpPrefix ip : host.ipAddresses()) {
for (IpAddress ip : host.ipAddresses()) {
ips.add(ip.toString());
}
ObjectNode result = mapper.createObjectNode()
......
package org.onlab.onos.net;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -20,8 +20,7 @@ public class DefaultHost extends AbstractElement implements Host {
private final MacAddress mac;
private final VlanId vlan;
private final HostLocation location;
// FIXME: should be IpAddress
private final Set<IpPrefix> ips;
private final Set<IpAddress> ips;
/**
* Creates an end-station host using the supplied information.
......@@ -35,13 +34,13 @@ public class DefaultHost extends AbstractElement implements Host {
* @param annotations optional key/value annotations
*/
public DefaultHost(ProviderId providerId, HostId id, MacAddress mac,
VlanId vlan, HostLocation location, Set<IpPrefix> ips,
VlanId vlan, HostLocation location, Set<IpAddress> ips,
Annotations... annotations) {
super(providerId, id, annotations);
this.mac = mac;
this.vlan = vlan;
this.location = location;
this.ips = new HashSet<IpPrefix>(ips);
this.ips = new HashSet<>(ips);
}
@Override
......@@ -55,7 +54,7 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public Set<IpPrefix> ipAddresses() {
public Set<IpAddress> ipAddresses() {
return Collections.unmodifiableSet(ips);
}
......
package org.onlab.onos.net;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -38,8 +38,7 @@ public interface Host extends Element {
*
* @return set of IP addresses; empty if no IP address is bound
*/
// FIXME: Switch to IpAddress
Set<IpPrefix> ipAddresses();
Set<IpAddress> ipAddresses();
/**
* Returns the most recent host location where the host attaches to the
......
......@@ -6,7 +6,7 @@ import java.util.Set;
import org.onlab.onos.net.AbstractDescription;
import org.onlab.onos.net.HostLocation;
import org.onlab.onos.net.SparseAnnotations;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -23,7 +23,7 @@ public class DefaultHostDescription extends AbstractDescription
private final MacAddress mac;
private final VlanId vlan;
private final HostLocation location;
private final Set<IpPrefix> ip;
private final Set<IpAddress> ip;
/**
* Creates a host description using the supplied information.
......@@ -36,7 +36,8 @@ public class DefaultHostDescription extends AbstractDescription
public DefaultHostDescription(MacAddress mac, VlanId vlan,
HostLocation location,
SparseAnnotations... annotations) {
this(mac, vlan, location, Collections.<IpPrefix>emptySet(), annotations);
this(mac, vlan, location, Collections.<IpAddress>emptySet(),
annotations);
}
/**
......@@ -49,7 +50,7 @@ public class DefaultHostDescription extends AbstractDescription
* @param annotations optional key/value annotations map
*/
public DefaultHostDescription(MacAddress mac, VlanId vlan,
HostLocation location, IpPrefix ip,
HostLocation location, IpAddress ip,
SparseAnnotations... annotations) {
this(mac, vlan, location, ImmutableSet.of(ip), annotations);
}
......@@ -64,7 +65,7 @@ public class DefaultHostDescription extends AbstractDescription
* @param annotations optional key/value annotations map
*/
public DefaultHostDescription(MacAddress mac, VlanId vlan,
HostLocation location, Set<IpPrefix> ip,
HostLocation location, Set<IpAddress> ip,
SparseAnnotations... annotations) {
super(annotations);
this.mac = mac;
......@@ -89,7 +90,7 @@ public class DefaultHostDescription extends AbstractDescription
}
@Override
public Set<IpPrefix> ipAddress() {
public Set<IpAddress> ipAddress() {
return ip;
}
......
......@@ -4,7 +4,7 @@ import java.util.Set;
import org.onlab.onos.net.Description;
import org.onlab.onos.net.HostLocation;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -39,7 +39,5 @@ public interface HostDescription extends Description {
*
* @return host IP address
*/
// FIXME: Switch to IpAddress
Set<IpPrefix> ipAddress();
Set<IpAddress> ipAddress();
}
......
......@@ -7,7 +7,6 @@ import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.HostId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -60,7 +59,7 @@ public interface HostService {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set<Host> getHostsByIp(IpPrefix ip);
Set<Host> getHostsByIp(IpAddress ip);
// TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
......
......@@ -6,7 +6,7 @@ import org.onlab.onos.net.Host;
import org.onlab.onos.net.HostId;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.Store;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -82,8 +82,7 @@ public interface HostStore extends Store<HostEvent, HostStoreDelegate> {
* @param ip ip address
* @return set of hosts with the given IP
*/
// FIXME: Switch to IpAddress
Set<Host> getHosts(IpPrefix ip);
Set<Host> getHosts(IpAddress ip);
/**
* Returns the set of hosts whose location falls on the given connection point.
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.net.proxyarp;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.packet.PacketContext;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
/**
* Service for processing arp requests on behalf of applications.
......@@ -17,7 +17,7 @@ public interface ProxyArpService {
* @param addr a ip address
* @return true if know, false otherwise
*/
boolean known(IpPrefix addr);
boolean known(IpAddress addr);
/**
* Sends a reply for a given request. If the host is not known then the arp
......
......@@ -2,7 +2,7 @@ package org.onlab.onos.net;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.ChassisId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import java.util.ArrayList;
import java.util.HashSet;
......@@ -45,7 +45,7 @@ public final class NetTestTools {
public static Host host(String id, String did) {
return new DefaultHost(PID, hid(id), valueOf(1234), vlanId((short) 2),
new HostLocation(did(did), portNumber(1), 321),
new HashSet<IpPrefix>());
new HashSet<IpAddress>());
}
// Short-hand for creating a connection point.
......
......@@ -5,7 +5,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
import java.util.Set;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -24,9 +24,9 @@ public abstract class TestDeviceParams {
protected static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02");
protected static final VlanId VLAN1 = VlanId.vlanId((short) 11);
protected static final VlanId VLAN2 = VlanId.vlanId((short) 22);
protected static final IpPrefix IP1 = IpPrefix.valueOf("10.0.0.1");
protected static final IpPrefix IP2 = IpPrefix.valueOf("10.0.0.2");
protected static final IpPrefix IP3 = IpPrefix.valueOf("10.0.0.3");
protected static final IpAddress IP1 = IpAddress.valueOf("10.0.0.1");
protected static final IpAddress IP2 = IpAddress.valueOf("10.0.0.2");
protected static final IpAddress IP3 = IpAddress.valueOf("10.0.0.3");
protected static final PortNumber P1 = PortNumber.portNumber(100);
protected static final PortNumber P2 = PortNumber.portNumber(200);
......@@ -34,7 +34,7 @@ public abstract class TestDeviceParams {
protected static final HostId HID2 = HostId.hostId(MAC2, VLAN2);
protected static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L);
protected static final HostLocation LOC2 = new HostLocation(DID2, P2, 123L);
protected static final Set<IpPrefix> IPSET1 = Sets.newHashSet(IP1, IP2);
protected static final Set<IpPrefix> IPSET2 = Sets.newHashSet(IP1, IP3);
protected static final Set<IpAddress> IPSET1 = Sets.newHashSet(IP1, IP2);
protected static final Set<IpAddress> IPSET2 = Sets.newHashSet(IP1, IP3);
}
......
......@@ -4,7 +4,7 @@ import org.junit.Test;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.HostLocation;
import org.onlab.onos.net.PortNumber;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -20,7 +20,7 @@ public class DefaultHostDecriptionTest {
private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
private static final VlanId VLAN = VlanId.vlanId((short) 10);
private static final IpPrefix IP = IpPrefix.valueOf("10.0.0.1");
private static final IpAddress IP = IpAddress.valueOf("10.0.0.1");
private static final HostLocation LOC = new HostLocation(
DeviceId.deviceId("of:foo"),
......
......@@ -11,7 +11,7 @@ import org.onlab.onos.net.HostId;
import org.onlab.onos.net.HostLocation;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -27,9 +27,9 @@ public class HostEventTest extends AbstractEventTest {
PortNumber.portNumber(100),
123L
);
Set<IpPrefix> ipset = Sets.newHashSet(
IpPrefix.valueOf("10.0.0.1"),
IpPrefix.valueOf("10.0.0.2")
Set<IpAddress> ipset = Sets.newHashSet(
IpAddress.valueOf("10.0.0.1"),
IpAddress.valueOf("10.0.0.2")
);
HostId hid = HostId.hostId(mac, vlan);
......
......@@ -7,7 +7,6 @@ import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.HostId;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -41,7 +40,7 @@ public class HostServiceAdapter implements HostService {
}
@Override
public Set<Host> getHostsByIp(IpPrefix ip) {
public Set<Host> getHostsByIp(IpAddress ip) {
return null;
}
......
......@@ -33,7 +33,6 @@ import org.onlab.onos.net.packet.PacketService;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
......@@ -121,7 +120,7 @@ public class HostManager
}
@Override
public Set<Host> getHostsByIp(IpPrefix ip) {
public Set<Host> getHostsByIp(IpAddress ip) {
checkNotNull(ip, "IP address cannot be null");
return store.getHosts(ip);
}
......
......@@ -129,10 +129,7 @@ public class HostMonitor implements TimerTask {
@Override
public void run(Timeout timeout) throws Exception {
for (IpAddress ip : monitoredAddresses) {
// TODO have to convert right now because the HostService API uses IpPrefix
IpPrefix prefix = IpPrefix.valueOf(ip.toOctets());
Set<Host> hosts = hostManager.getHostsByIp(prefix);
Set<Host> hosts = hostManager.getHostsByIp(ip);
if (hosts.isEmpty()) {
sendArpRequest(ip);
......
......@@ -99,7 +99,7 @@ public class ProxyArpManager implements ProxyArpService {
}
@Override
public boolean known(IpPrefix addr) {
public boolean known(IpAddress addr) {
checkNotNull(addr, MAC_ADDR_NULL);
Set<Host> hosts = hostService.getHostsByIp(addr);
return !hosts.isEmpty();
......@@ -150,7 +150,7 @@ public class ProxyArpManager implements ProxyArpService {
// Continue with normal proxy ARP case
VlanId vlan = VlanId.vlanId(eth.getVlanID());
Set<Host> hosts = hostService.getHostsByIp(IpPrefix.valueOf(arp
Set<Host> hosts = hostService.getHostsByIp(IpAddress.valueOf(arp
.getTargetProtocolAddress()));
Host dst = null;
......@@ -170,8 +170,7 @@ public class ProxyArpManager implements ProxyArpService {
}
// TODO find the correct IP address
IpAddress ipAddress =
dst.ipAddresses().iterator().next().toIpAddress();
IpAddress ipAddress = dst.ipAddresses().iterator().next();
Ethernet arpReply = buildArpReply(ipAddress, dst.mac(), eth);
// TODO: check send status with host service.
sendTo(arpReply, src.location());
......
......@@ -58,8 +58,8 @@ public class HostManagerTest {
private static final HostId HID1 = HostId.hostId(MAC1, VLAN1);
private static final HostId HID2 = HostId.hostId(MAC2, VLAN1);
private static final IpPrefix IP1 = IpPrefix.valueOf("10.0.0.1");
private static final IpPrefix IP2 = IpPrefix.valueOf("10.0.0.2");
private static final IpAddress IP1 = IpAddress.valueOf("10.0.0.1");
private static final IpAddress IP2 = IpAddress.valueOf("10.0.0.2");
private static final DeviceId DID1 = DeviceId.deviceId("of:001");
private static final DeviceId DID2 = DeviceId.deviceId("of:002");
......@@ -115,7 +115,7 @@ public class HostManagerTest {
}
private void detect(HostId hid, MacAddress mac, VlanId vlan,
HostLocation loc, IpPrefix ip) {
HostLocation loc, IpAddress ip) {
HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ip);
providerService.hostDetected(hid, descr);
assertNotNull("host should be found", mgr.getHost(hid));
......
......@@ -46,9 +46,8 @@ import com.google.common.collect.Multimap;
public class HostMonitorTest {
private IpAddress targetIpAddress = IpAddress.valueOf("10.0.0.1");
private IpPrefix targetIpPrefix = IpPrefix.valueOf(targetIpAddress.toOctets());
private static final IpAddress TARGET_IP_ADDR =
IpAddress.valueOf("10.0.0.1");
private static final IpAddress SOURCE_ADDR =
IpAddress.valueOf("10.0.0.99");
private static final InterfaceIpAddress IA1 =
......@@ -71,7 +70,7 @@ public class HostMonitorTest {
replay(host);
HostManager hostManager = createMock(HostManager.class);
expect(hostManager.getHostsByIp(targetIpPrefix))
expect(hostManager.getHostsByIp(TARGET_IP_ADDR))
.andReturn(Collections.singleton(host));
replay(hostManager);
......@@ -84,7 +83,7 @@ public class HostMonitorTest {
hostMonitor = new HostMonitor(null, null, hostManager);
hostMonitor.registerHostProvider(hostProvider);
hostMonitor.addMonitoringFor(targetIpAddress);
hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
hostMonitor.run(null);
......@@ -115,7 +114,7 @@ public class HostMonitorTest {
PortAddresses pa =
new PortAddresses(cp, Collections.singleton(IA1), sourceMac);
expect(hostManager.getHostsByIp(targetIpPrefix))
expect(hostManager.getHostsByIp(TARGET_IP_ADDR))
.andReturn(Collections.<Host>emptySet()).anyTimes();
expect(hostManager.getAddressBindingsForPort(cp))
.andReturn(pa).anyTimes();
......@@ -127,7 +126,7 @@ public class HostMonitorTest {
// Run the test
hostMonitor = new HostMonitor(deviceService, packetService, hostManager);
hostMonitor.addMonitoringFor(targetIpAddress);
hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
hostMonitor.run(null);
......@@ -150,7 +149,8 @@ public class HostMonitorTest {
assertTrue(Arrays.equals(arp.getSenderProtocolAddress(),
SOURCE_ADDR.toOctets()));
assertTrue(Arrays.equals(arp.getSenderHardwareAddress(), sourceMac.toBytes()));
assertTrue(Arrays.equals(arp.getTargetProtocolAddress(), targetIpPrefix.toOctets()));
assertTrue(Arrays.equals(arp.getTargetProtocolAddress(),
TARGET_IP_ADDR.toOctets()));
}
class TestPacketService implements PacketService {
......
......@@ -59,8 +59,8 @@ public class ProxyArpManagerTest {
private static final int NUM_ADDRESS_PORTS = NUM_DEVICES / 2;
private static final int NUM_FLOOD_PORTS = 3;
private static final IpPrefix IP1 = IpPrefix.valueOf("192.168.1.1/24");
private static final IpPrefix IP2 = IpPrefix.valueOf("192.168.1.2/24");
private static final IpAddress IP1 = IpAddress.valueOf("192.168.1.1");
private static final IpAddress IP2 = IpAddress.valueOf("192.168.1.2");
private static final ProviderId PID = new ProviderId("of", "foo");
......@@ -214,7 +214,7 @@ public class ProxyArpManagerTest {
}
/**
* Tests {@link ProxyArpManager#known(IpPrefix)} in the case where the
* Tests {@link ProxyArpManager#known(IpAddress)} in the case where the
* IP address is not known.
* Verifies the method returns false.
*/
......@@ -227,7 +227,7 @@ public class ProxyArpManagerTest {
}
/**
* Tests {@link ProxyArpManager#known(IpPrefix)} in the case where the
* Tests {@link ProxyArpManager#known(IpAddress)} in the case where the
* IP address is known.
* Verifies the method returns true.
*/
......@@ -256,8 +256,8 @@ public class ProxyArpManagerTest {
Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
Collections.singleton(IP2));
expect(hostService.getHostsByIp(IpPrefix.valueOf(IP1.toOctets())))
.andReturn(Collections.singleton(replyer));
expect(hostService.getHostsByIp(IP1))
.andReturn(Collections.singleton(replyer));
expect(hostService.getHost(HID2)).andReturn(requestor);
replay(hostService);
......@@ -281,7 +281,7 @@ public class ProxyArpManagerTest {
Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
Collections.singleton(IP2));
expect(hostService.getHostsByIp(IpPrefix.valueOf(IP1.toOctets())))
expect(hostService.getHostsByIp(IP1))
.andReturn(Collections.<Host>emptySet());
expect(hostService.getHost(HID2)).andReturn(requestor);
......@@ -308,7 +308,7 @@ public class ProxyArpManagerTest {
Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, getLocation(5),
Collections.singleton(IP2));
expect(hostService.getHostsByIp(IpPrefix.valueOf(IP1.toOctets())))
expect(hostService.getHostsByIp(IP1))
.andReturn(Collections.singleton(replyer));
expect(hostService.getHost(HID2)).andReturn(requestor);
......@@ -323,9 +323,9 @@ public class ProxyArpManagerTest {
@Test
public void testReplyToRequestForUs() {
IpPrefix theirIp = IpPrefix.valueOf("10.0.1.254/24");
IpPrefix ourFirstIp = IpPrefix.valueOf("10.0.1.1/24");
IpPrefix ourSecondIp = IpPrefix.valueOf("10.0.2.1/24");
IpAddress theirIp = IpAddress.valueOf("10.0.1.254");
IpAddress ourFirstIp = IpAddress.valueOf("10.0.1.1");
IpAddress ourSecondIp = IpAddress.valueOf("10.0.2.1");
MacAddress ourMac = MacAddress.valueOf(1L);
Host requestor = new DefaultHost(PID, HID2, MAC2, VLAN1, LOC1,
......@@ -357,11 +357,11 @@ public class ProxyArpManagerTest {
public void testReplyExternalPortBadRequest() {
replay(hostService); // no further host service expectations
IpPrefix theirIp = IpPrefix.valueOf("10.0.1.254/24");
IpAddress theirIp = IpAddress.valueOf("10.0.1.254");
// Request for a valid external IP address but coming in the wrong port
Ethernet arpRequest = buildArp(ARP.OP_REQUEST, MAC1, null, theirIp,
IpPrefix.valueOf("10.0.3.1"));
IpAddress.valueOf("10.0.3.1"));
proxyArp.reply(arpRequest, LOC1);
assertEquals(0, packetService.packets.size());
......@@ -376,9 +376,9 @@ public class ProxyArpManagerTest {
public void testReplyToRequestFromUs() {
replay(hostService); // no further host service expectations
IpPrefix ourIp = IpPrefix.valueOf("10.0.1.1/24");
IpAddress ourIp = IpAddress.valueOf("10.0.1.1");
MacAddress ourMac = MacAddress.valueOf(1L);
IpPrefix theirIp = IpPrefix.valueOf("10.0.1.100/24");
IpAddress theirIp = IpAddress.valueOf("10.0.1.100");
// This is a request from something inside our network (like a BGP
// daemon) to an external host.
......@@ -501,7 +501,7 @@ public class ProxyArpManagerTest {
* @return the ARP packet
*/
private Ethernet buildArp(short opcode, MacAddress srcMac, MacAddress dstMac,
IpPrefix srcIp, IpPrefix dstIp) {
IpAddress srcIp, IpAddress dstIp) {
Ethernet eth = new Ethernet();
if (dstMac == null) {
......
......@@ -42,7 +42,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject;
import org.onlab.onos.store.impl.Timestamped;
import org.onlab.onos.store.serializers.DistributedStoreSerializers;
import org.onlab.onos.store.serializers.KryoSerializer;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onlab.util.KryoNamespace;
......@@ -221,7 +221,7 @@ public class GossipHostStore
return null;
}
Set<IpPrefix> addresses = new HashSet<>(host.ipAddresses());
Set<IpAddress> addresses = new HashSet<>(host.ipAddresses());
addresses.addAll(descr.ipAddress());
StoredHost updated = new StoredHost(providerId, host.id(),
host.mac(), host.vlan(),
......@@ -300,7 +300,7 @@ public class GossipHostStore
}
@Override
public Set<Host> getHosts(IpPrefix ip) {
public Set<Host> getHosts(IpAddress ip) {
Set<Host> ipset = new HashSet<>();
for (Host h : hosts.values()) {
if (h.ipAddresses().contains(ip)) {
......@@ -418,7 +418,7 @@ public class GossipHostStore
*/
public StoredHost(ProviderId providerId, HostId id,
MacAddress mac, VlanId vlan, Timestamped<HostLocation> location,
Set<IpPrefix> ips, Annotations... annotations) {
Set<IpAddress> ips, Annotations... annotations) {
super(providerId, id, mac, vlan, location.value(), ips, annotations);
this.location = location;
}
......
......@@ -23,7 +23,7 @@ import org.onlab.onos.net.host.InterfaceIpAddress;
import org.onlab.onos.net.host.PortAddresses;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.store.AbstractStore;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
......@@ -106,7 +106,7 @@ public class SimpleHostStore
return null;
}
Set<IpPrefix> addresses = new HashSet<>(host.ipAddresses());
Set<IpAddress> addresses = new HashSet<>(host.ipAddresses());
addresses.addAll(descr.ipAddress());
StoredHost updated = new StoredHost(providerId, host.id(),
host.mac(), host.vlan(),
......@@ -170,7 +170,7 @@ public class SimpleHostStore
}
@Override
public Set<Host> getHosts(IpPrefix ip) {
public Set<Host> getHosts(IpAddress ip) {
Set<Host> ipset = new HashSet<>();
for (Host h : hosts.values()) {
if (h.ipAddresses().contains(ip)) {
......@@ -288,7 +288,7 @@ public class SimpleHostStore
*/
public StoredHost(ProviderId providerId, HostId id,
MacAddress mac, VlanId vlan, HostLocation location,
Set<IpPrefix> ips, Annotations... annotations) {
Set<IpAddress> ips, Annotations... annotations) {
super(providerId, id, mac, vlan, location, ips, annotations);
this.location = location;
}
......
......@@ -43,7 +43,7 @@ import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyService;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
......@@ -122,8 +122,8 @@ public class HostLocationProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if (eth.getEtherType() == Ethernet.TYPE_ARP) {
ARP arp = (ARP) eth.getPayload();
IpPrefix ip = IpPrefix.valueOf(arp.getSenderProtocolAddress(),
IpPrefix.MAX_INET_MASK);
IpAddress ip =
IpAddress.valueOf(arp.getSenderProtocolAddress());
HostDescription hdescr =
new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip);
providerService.hostDetected(hid, hdescr);
......
......@@ -47,7 +47,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.IpAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
......@@ -128,16 +128,16 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if (eth.getEtherType() == Ethernet.TYPE_ARP) {
ARP arp = (ARP) eth.getPayload();
IpPrefix ip = IpPrefix.valueOf(arp.getSenderProtocolAddress(),
IpPrefix.MAX_INET_MASK);
IpAddress ip =
IpAddress.valueOf(arp.getSenderProtocolAddress());
HostDescription hdescr =
new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip);
providerService.hostDetected(hid, hdescr);
} else if (ipLearn && eth.getEtherType() == Ethernet.TYPE_IPV4) {
IPv4 pip = (IPv4) eth.getPayload();
IpPrefix ip = IpPrefix.valueOf(pip.getSourceAddress(),
IpPrefix.MAX_INET_MASK);
IpAddress ip =
IpAddress.valueOf(pip.getSourceAddress());
HostDescription hdescr =
new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ip);
providerService.hostDetected(hid, hdescr);
......
......@@ -43,7 +43,7 @@ import org.onlab.onos.net.link.LinkProviderRegistry;
import org.onlab.onos.net.link.LinkProviderService;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.ChassisId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -179,7 +179,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
HostId hostId = HostId.hostId(mac, vlanId);
SparseAnnotations annotations = annotations(node.get("annotations"));
HostLocation location = new HostLocation(connectPoint(get(node, "location")), 0);
IpPrefix ip = IpPrefix.valueOf(get(node, "ip"));
IpAddress ip = IpAddress.valueOf(get(node, "ip"));
DefaultHostDescription desc =
new DefaultHostDescription(mac, vlanId, location, ip, annotations);
......
......@@ -33,7 +33,7 @@ import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyGraph;
import org.onlab.onos.net.topology.TopologyService;
import org.onlab.onos.net.topology.TopologyVertex;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.rest.BaseResource;
......@@ -102,8 +102,8 @@ public class TopologyResource extends BaseResource {
private ArrayNode getHosts(ObjectMapper mapper, HostService hostService) {
ArrayNode hosts = mapper.createArrayNode();
for (Host host : hostService.getHosts()) {
Set<IpPrefix> ipAddresses = host.ipAddresses();
IpPrefix ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
Set<IpAddress> ipAddresses = host.ipAddresses();
IpAddress ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
String label = ipAddress != null ? ipAddress.toString() : host.mac().toString();
hosts.add(json(mapper, host));
}
......@@ -160,8 +160,8 @@ public class TopologyResource extends BaseResource {
return json;
}
private String ip(Set<IpPrefix> ipPrefixes) {
Iterator<IpPrefix> it = ipPrefixes.iterator();
private String ip(Set<IpAddress> ipAddresses) {
Iterator<IpAddress> it = ipAddresses.iterator();
return it.hasNext() ? it.next().toString() : "unknown";
}
......