Replaced IpPrefix and IpAddress in the following methods
and cleanup related code:
- Host.ipAddresses()
- DefaultHost.ipAddresses()
- HostDescription.ipAddress()
- DefaultHostDescription.ipAddress()
- HostService.getHostsByIp()
- HostManager.getHostsByIp()
- HostStore.getHosts()
- GossipHostStore.getHosts()
- SimpleHostStore.getHosts()
- ProxyArpService.known()
- ProxyArpManager.known()
As a result of the above cleanup, the "hosts" CLI command outputs
the IP addresses as "1.2.3.4" instead of "1.2.3.4/32".
Also, the following REST calls might be affected as well with
the above format replacement:
- REST POST: config/topology
- REST GET: topology/graph
diff --git a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java
index c20da19..67e6cc4 100644
--- a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostManagerTest.java
@@ -58,8 +58,8 @@
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 @@
}
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));
diff --git a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
index 4b9d214..df211fb 100644
--- a/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/host/impl/HostMonitorTest.java
@@ -46,9 +46,8 @@
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 @@
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 @@
hostMonitor = new HostMonitor(null, null, hostManager);
hostMonitor.registerHostProvider(hostProvider);
- hostMonitor.addMonitoringFor(targetIpAddress);
+ hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
hostMonitor.run(null);
@@ -115,7 +114,7 @@
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 @@
// Run the test
hostMonitor = new HostMonitor(deviceService, packetService, hostManager);
- hostMonitor.addMonitoringFor(targetIpAddress);
+ hostMonitor.addMonitoringFor(TARGET_IP_ADDR);
hostMonitor.run(null);
@@ -150,7 +149,8 @@
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 {
diff --git a/core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java b/core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java
index 76bf021..60fdb69 100644
--- a/core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java
+++ b/core/net/src/test/java/org/onlab/onos/net/proxyarp/impl/ProxyArpManagerTest.java
@@ -59,8 +59,8 @@
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 @@
}
/**
- * 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 @@
}
/**
- * 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 @@
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 @@
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 @@
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 @@
@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 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 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 @@
* @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) {