Ayaka Koshibe

renamed IpAddress to IpPrefix

Change-Id: I35990622e5b1c29ab6f6a0a0227088cd5d6c7294
Showing 24 changed files with 128 additions and 128 deletions
...@@ -16,7 +16,7 @@ import org.onlab.onos.net.topology.Topology; ...@@ -16,7 +16,7 @@ import org.onlab.onos.net.topology.Topology;
16 import org.onlab.onos.net.topology.TopologyGraph; 16 import org.onlab.onos.net.topology.TopologyGraph;
17 import org.onlab.onos.net.topology.TopologyService; 17 import org.onlab.onos.net.topology.TopologyService;
18 import org.onlab.onos.net.topology.TopologyVertex; 18 import org.onlab.onos.net.topology.TopologyVertex;
19 -import org.onlab.packet.IpAddress; 19 +import org.onlab.packet.IpPrefix;
20 import org.onlab.rest.BaseResource; 20 import org.onlab.rest.BaseResource;
21 21
22 import javax.ws.rs.GET; 22 import javax.ws.rs.GET;
...@@ -74,8 +74,8 @@ public class TopologyResource extends BaseResource { ...@@ -74,8 +74,8 @@ public class TopologyResource extends BaseResource {
74 // Merge the exterior and interior vertexes and inject host links as 74 // Merge the exterior and interior vertexes and inject host links as
75 // the exterior edges. 75 // the exterior edges.
76 for (Host host : hostService.getHosts()) { 76 for (Host host : hostService.getHosts()) {
77 - Set<IpAddress> ipAddresses = host.ipAddresses(); 77 + Set<IpPrefix> ipAddresses = host.ipAddresses();
78 - IpAddress ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next(); 78 + IpPrefix ipAddress = ipAddresses.isEmpty() ? null : ipAddresses.iterator().next();
79 String label = ipAddress != null ? ipAddress.toString() : host.mac().toString(); 79 String label = ipAddress != null ? ipAddress.toString() : host.mac().toString();
80 vertexesNode.add(json(mapper, host.id(), 3, label, true)); 80 vertexesNode.add(json(mapper, host.id(), 3, label, true));
81 edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1)))); 81 edgesNode.add(json(mapper, 1, host.location(), new ConnectPoint(host.id(), portNumber(-1))));
......
1 package org.onlab.onos.cluster; 1 package org.onlab.onos.cluster;
2 2
3 -import org.onlab.packet.IpAddress; 3 +import org.onlab.packet.IpPrefix;
4 4
5 /** 5 /**
6 * Represents a controller instance as a member in a cluster. 6 * Represents a controller instance as a member in a cluster.
...@@ -33,6 +33,6 @@ public interface ControllerInstance { ...@@ -33,6 +33,6 @@ public interface ControllerInstance {
33 * 33 *
34 * @return IP address 34 * @return IP address
35 */ 35 */
36 - IpAddress ip(); 36 + IpPrefix ip();
37 37
38 } 38 }
......
...@@ -8,7 +8,7 @@ import java.util.Objects; ...@@ -8,7 +8,7 @@ import java.util.Objects;
8 import java.util.Set; 8 import java.util.Set;
9 9
10 import org.onlab.onos.net.provider.ProviderId; 10 import org.onlab.onos.net.provider.ProviderId;
11 -import org.onlab.packet.IpAddress; 11 +import org.onlab.packet.IpPrefix;
12 import org.onlab.packet.MacAddress; 12 import org.onlab.packet.MacAddress;
13 import org.onlab.packet.VlanId; 13 import org.onlab.packet.VlanId;
14 14
...@@ -20,15 +20,15 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -20,15 +20,15 @@ public class DefaultHost extends AbstractElement implements Host {
20 private final MacAddress mac; 20 private final MacAddress mac;
21 private final VlanId vlan; 21 private final VlanId vlan;
22 private final HostLocation location; 22 private final HostLocation location;
23 - private final Set<IpAddress> ips; 23 + private final Set<IpPrefix> ips;
24 24
25 public DefaultHost(ProviderId providerId, HostId id, MacAddress mac, 25 public DefaultHost(ProviderId providerId, HostId id, MacAddress mac,
26 - VlanId vlan, HostLocation loc, Set<IpAddress> ips) { 26 + VlanId vlan, HostLocation loc, Set<IpPrefix> ips) {
27 super(providerId, id); 27 super(providerId, id);
28 this.mac = mac; 28 this.mac = mac;
29 this.vlan = vlan; 29 this.vlan = vlan;
30 this.location = loc; 30 this.location = loc;
31 - this.ips = new HashSet<IpAddress>(ips); 31 + this.ips = new HashSet<IpPrefix>(ips);
32 } 32 }
33 33
34 @Override 34 @Override
...@@ -42,7 +42,7 @@ public class DefaultHost extends AbstractElement implements Host { ...@@ -42,7 +42,7 @@ public class DefaultHost extends AbstractElement implements Host {
42 } 42 }
43 43
44 @Override 44 @Override
45 - public Set<IpAddress> ipAddresses() { 45 + public Set<IpPrefix> ipAddresses() {
46 return Collections.unmodifiableSet(ips); 46 return Collections.unmodifiableSet(ips);
47 } 47 }
48 48
......
1 package org.onlab.onos.net; 1 package org.onlab.onos.net;
2 2
3 -import org.onlab.packet.IpAddress; 3 +import org.onlab.packet.IpPrefix;
4 import org.onlab.packet.MacAddress; 4 import org.onlab.packet.MacAddress;
5 import org.onlab.packet.VlanId; 5 import org.onlab.packet.VlanId;
6 6
...@@ -38,7 +38,7 @@ public interface Host extends Element { ...@@ -38,7 +38,7 @@ public interface Host extends Element {
38 * 38 *
39 * @return set of IP addresses; empty if no IP address is bound 39 * @return set of IP addresses; empty if no IP address is bound
40 */ 40 */
41 - Set<IpAddress> ipAddresses(); 41 + Set<IpPrefix> ipAddresses();
42 42
43 /** 43 /**
44 * Returns the most recent host location where the host attaches to the 44 * Returns the most recent host location where the host attaches to the
......
...@@ -2,7 +2,7 @@ package org.onlab.onos.net.flow.criteria; ...@@ -2,7 +2,7 @@ package org.onlab.onos.net.flow.criteria;
2 2
3 import org.onlab.onos.net.PortNumber; 3 import org.onlab.onos.net.PortNumber;
4 import org.onlab.onos.net.flow.criteria.Criterion.Type; 4 import org.onlab.onos.net.flow.criteria.Criterion.Type;
5 -import org.onlab.packet.IpAddress; 5 +import org.onlab.packet.IpPrefix;
6 import org.onlab.packet.MacAddress; 6 import org.onlab.packet.MacAddress;
7 import org.onlab.packet.VlanId; 7 import org.onlab.packet.VlanId;
8 8
...@@ -95,7 +95,7 @@ public final class Criteria { ...@@ -95,7 +95,7 @@ public final class Criteria {
95 * @param ip ip src value 95 * @param ip ip src value
96 * @return match criterion 96 * @return match criterion
97 */ 97 */
98 - public static Criterion matchIPSrc(IpAddress ip) { 98 + public static Criterion matchIPSrc(IpPrefix ip) {
99 return new IPCriterion(ip, Type.IPV4_SRC); 99 return new IPCriterion(ip, Type.IPV4_SRC);
100 } 100 }
101 101
...@@ -105,7 +105,7 @@ public final class Criteria { ...@@ -105,7 +105,7 @@ public final class Criteria {
105 * @param ip ip src value 105 * @param ip ip src value
106 * @return match criterion 106 * @return match criterion
107 */ 107 */
108 - public static Criterion matchIPDst(IpAddress ip) { 108 + public static Criterion matchIPDst(IpPrefix ip) {
109 return new IPCriterion(ip, Type.IPV4_DST); 109 return new IPCriterion(ip, Type.IPV4_DST);
110 } 110 }
111 111
...@@ -173,10 +173,10 @@ public final class Criteria { ...@@ -173,10 +173,10 @@ public final class Criteria {
173 173
174 public static final class IPCriterion implements Criterion { 174 public static final class IPCriterion implements Criterion {
175 175
176 - private final IpAddress ip; 176 + private final IpPrefix ip;
177 private final Type type; 177 private final Type type;
178 178
179 - public IPCriterion(IpAddress ip, Type type) { 179 + public IPCriterion(IpPrefix ip, Type type) {
180 this.ip = ip; 180 this.ip = ip;
181 this.type = type; 181 this.type = type;
182 } 182 }
...@@ -186,7 +186,7 @@ public final class Criteria { ...@@ -186,7 +186,7 @@ public final class Criteria {
186 return this.type; 186 return this.type;
187 } 187 }
188 188
189 - public IpAddress ip() { 189 + public IpPrefix ip() {
190 return this.ip; 190 return this.ip;
191 } 191 }
192 192
......
...@@ -7,7 +7,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType; ...@@ -7,7 +7,7 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.L2SubType;
7 import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction; 7 import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherInstruction;
8 import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType; 8 import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType;
9 import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction; 9 import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
10 -import org.onlab.packet.IpAddress; 10 +import org.onlab.packet.IpPrefix;
11 import org.onlab.packet.MacAddress; 11 import org.onlab.packet.MacAddress;
12 import org.onlab.packet.VlanId; 12 import org.onlab.packet.VlanId;
13 13
...@@ -85,7 +85,7 @@ public final class Instructions { ...@@ -85,7 +85,7 @@ public final class Instructions {
85 * @param addr the ip address to modify to. 85 * @param addr the ip address to modify to.
86 * @return a L3 modification 86 * @return a L3 modification
87 */ 87 */
88 - public static L3ModificationInstruction modL3Src(IpAddress addr) { 88 + public static L3ModificationInstruction modL3Src(IpPrefix addr) {
89 checkNotNull(addr, "Src l3 address cannot be null"); 89 checkNotNull(addr, "Src l3 address cannot be null");
90 return new ModIPInstruction(L3SubType.L3_SRC, addr); 90 return new ModIPInstruction(L3SubType.L3_SRC, addr);
91 } 91 }
...@@ -95,7 +95,7 @@ public final class Instructions { ...@@ -95,7 +95,7 @@ public final class Instructions {
95 * @param addr the ip address to modify to. 95 * @param addr the ip address to modify to.
96 * @return a L3 modification 96 * @return a L3 modification
97 */ 97 */
98 - public static L3ModificationInstruction modL3Dst(IpAddress addr) { 98 + public static L3ModificationInstruction modL3Dst(IpPrefix addr) {
99 checkNotNull(addr, "Dst l3 address cannot be null"); 99 checkNotNull(addr, "Dst l3 address cannot be null");
100 return new ModIPInstruction(L3SubType.L3_DST, addr); 100 return new ModIPInstruction(L3SubType.L3_DST, addr);
101 } 101 }
......
1 package org.onlab.onos.net.flow.instructions; 1 package org.onlab.onos.net.flow.instructions;
2 2
3 -import org.onlab.packet.IpAddress; 3 +import org.onlab.packet.IpPrefix;
4 4
5 /** 5 /**
6 * Abstraction of a single traffic treatment step. 6 * Abstraction of a single traffic treatment step.
...@@ -41,9 +41,9 @@ public abstract class L3ModificationInstruction implements Instruction { ...@@ -41,9 +41,9 @@ public abstract class L3ModificationInstruction implements Instruction {
41 public static final class ModIPInstruction extends L3ModificationInstruction { 41 public static final class ModIPInstruction extends L3ModificationInstruction {
42 42
43 private final L3SubType subtype; 43 private final L3SubType subtype;
44 - private final IpAddress ip; 44 + private final IpPrefix ip;
45 45
46 - public ModIPInstruction(L3SubType subType, IpAddress addr) { 46 + public ModIPInstruction(L3SubType subType, IpPrefix addr) {
47 47
48 this.subtype = subType; 48 this.subtype = subType;
49 this.ip = addr; 49 this.ip = addr;
...@@ -54,7 +54,7 @@ public abstract class L3ModificationInstruction implements Instruction { ...@@ -54,7 +54,7 @@ public abstract class L3ModificationInstruction implements Instruction {
54 return this.subtype; 54 return this.subtype;
55 } 55 }
56 56
57 - public IpAddress ip() { 57 + public IpPrefix ip() {
58 return this.ip; 58 return this.ip;
59 } 59 }
60 60
......
...@@ -6,7 +6,7 @@ import java.util.HashSet; ...@@ -6,7 +6,7 @@ import java.util.HashSet;
6 import java.util.Set; 6 import java.util.Set;
7 7
8 import org.onlab.onos.net.HostLocation; 8 import org.onlab.onos.net.HostLocation;
9 -import org.onlab.packet.IpAddress; 9 +import org.onlab.packet.IpPrefix;
10 import org.onlab.packet.MacAddress; 10 import org.onlab.packet.MacAddress;
11 import org.onlab.packet.VlanId; 11 import org.onlab.packet.VlanId;
12 12
...@@ -17,22 +17,22 @@ public class DefaultHostDescription implements HostDescription { ...@@ -17,22 +17,22 @@ public class DefaultHostDescription implements HostDescription {
17 private final MacAddress mac; 17 private final MacAddress mac;
18 private final VlanId vlan; 18 private final VlanId vlan;
19 private final HostLocation location; 19 private final HostLocation location;
20 - private final Set<IpAddress> ips; 20 + private final Set<IpPrefix> ips;
21 21
22 public DefaultHostDescription(MacAddress mac, VlanId vlan, 22 public DefaultHostDescription(MacAddress mac, VlanId vlan,
23 HostLocation loc) { 23 HostLocation loc) {
24 this.mac = mac; 24 this.mac = mac;
25 this.vlan = vlan; 25 this.vlan = vlan;
26 this.location = loc; 26 this.location = loc;
27 - this.ips = new HashSet<IpAddress>(); 27 + this.ips = new HashSet<IpPrefix>();
28 } 28 }
29 29
30 public DefaultHostDescription(MacAddress mac, VlanId vlan, 30 public DefaultHostDescription(MacAddress mac, VlanId vlan,
31 - HostLocation loc, Set<IpAddress> ips) { 31 + HostLocation loc, Set<IpPrefix> ips) {
32 this.mac = mac; 32 this.mac = mac;
33 this.vlan = vlan; 33 this.vlan = vlan;
34 this.location = loc; 34 this.location = loc;
35 - this.ips = new HashSet<IpAddress>(ips); 35 + this.ips = new HashSet<IpPrefix>(ips);
36 } 36 }
37 37
38 @Override 38 @Override
...@@ -51,7 +51,7 @@ public class DefaultHostDescription implements HostDescription { ...@@ -51,7 +51,7 @@ public class DefaultHostDescription implements HostDescription {
51 } 51 }
52 52
53 @Override 53 @Override
54 - public Set<IpAddress> ipAddresses() { 54 + public Set<IpPrefix> ipAddresses() {
55 return ImmutableSet.copyOf(ips); 55 return ImmutableSet.copyOf(ips);
56 } 56 }
57 57
......
...@@ -4,7 +4,7 @@ import java.util.Set; ...@@ -4,7 +4,7 @@ import java.util.Set;
4 4
5 import org.onlab.onos.net.Description; 5 import org.onlab.onos.net.Description;
6 import org.onlab.onos.net.HostLocation; 6 import org.onlab.onos.net.HostLocation;
7 -import org.onlab.packet.IpAddress; 7 +import org.onlab.packet.IpPrefix;
8 import org.onlab.packet.MacAddress; 8 import org.onlab.packet.MacAddress;
9 import org.onlab.packet.VlanId; 9 import org.onlab.packet.VlanId;
10 10
...@@ -39,6 +39,6 @@ public interface HostDescription extends Description { ...@@ -39,6 +39,6 @@ public interface HostDescription extends Description {
39 * 39 *
40 * @return a set of IP addresses. 40 * @return a set of IP addresses.
41 */ 41 */
42 - Set<IpAddress> ipAddresses(); 42 + Set<IpPrefix> ipAddresses();
43 43
44 } 44 }
......
...@@ -4,7 +4,7 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -4,7 +4,7 @@ import org.onlab.onos.net.ConnectPoint;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.Host; 5 import org.onlab.onos.net.Host;
6 import org.onlab.onos.net.HostId; 6 import org.onlab.onos.net.HostId;
7 -import org.onlab.packet.IpAddress; 7 +import org.onlab.packet.IpPrefix;
8 import org.onlab.packet.MacAddress; 8 import org.onlab.packet.MacAddress;
9 import org.onlab.packet.VlanId; 9 import org.onlab.packet.VlanId;
10 10
...@@ -59,7 +59,7 @@ public interface HostService { ...@@ -59,7 +59,7 @@ public interface HostService {
59 * @param ip ip address 59 * @param ip ip address
60 * @return set of hosts with the given IP 60 * @return set of hosts with the given IP
61 */ 61 */
62 - Set<Host> getHostsByIp(IpAddress ip); 62 + Set<Host> getHostsByIp(IpPrefix ip);
63 63
64 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan); 64 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
65 65
......
...@@ -5,7 +5,7 @@ import org.onlab.onos.net.DeviceId; ...@@ -5,7 +5,7 @@ import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.Host; 5 import org.onlab.onos.net.Host;
6 import org.onlab.onos.net.HostId; 6 import org.onlab.onos.net.HostId;
7 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 -import org.onlab.packet.IpAddress; 8 +import org.onlab.packet.IpPrefix;
9 import org.onlab.packet.MacAddress; 9 import org.onlab.packet.MacAddress;
10 import org.onlab.packet.VlanId; 10 import org.onlab.packet.VlanId;
11 11
...@@ -81,7 +81,7 @@ public interface HostStore { ...@@ -81,7 +81,7 @@ public interface HostStore {
81 * @param ip ip address 81 * @param ip ip address
82 * @return set of hosts with the given IP 82 * @return set of hosts with the given IP
83 */ 83 */
84 - Set<Host> getHosts(IpAddress ip); 84 + Set<Host> getHosts(IpPrefix ip);
85 85
86 /** 86 /**
87 * Returns the set of hosts whose location falls on the given connection point. 87 * Returns the set of hosts whose location falls on the given connection point.
......
...@@ -5,7 +5,7 @@ import static org.onlab.onos.net.DeviceId.deviceId; ...@@ -5,7 +5,7 @@ import static org.onlab.onos.net.DeviceId.deviceId;
5 import java.util.Set; 5 import java.util.Set;
6 6
7 import org.onlab.onos.net.provider.ProviderId; 7 import org.onlab.onos.net.provider.ProviderId;
8 -import org.onlab.packet.IpAddress; 8 +import org.onlab.packet.IpPrefix;
9 import org.onlab.packet.MacAddress; 9 import org.onlab.packet.MacAddress;
10 import org.onlab.packet.VlanId; 10 import org.onlab.packet.VlanId;
11 11
...@@ -24,9 +24,9 @@ public abstract class TestDeviceParams { ...@@ -24,9 +24,9 @@ public abstract class TestDeviceParams {
24 protected static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02"); 24 protected static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02");
25 protected static final VlanId VLAN1 = VlanId.vlanId((short) 11); 25 protected static final VlanId VLAN1 = VlanId.vlanId((short) 11);
26 protected static final VlanId VLAN2 = VlanId.vlanId((short) 22); 26 protected static final VlanId VLAN2 = VlanId.vlanId((short) 22);
27 - protected static final IpAddress IP1 = IpAddress.valueOf("10.0.0.1"); 27 + protected static final IpPrefix IP1 = IpPrefix.valueOf("10.0.0.1");
28 - protected static final IpAddress IP2 = IpAddress.valueOf("10.0.0.2"); 28 + protected static final IpPrefix IP2 = IpPrefix.valueOf("10.0.0.2");
29 - protected static final IpAddress IP3 = IpAddress.valueOf("10.0.0.3"); 29 + protected static final IpPrefix IP3 = IpPrefix.valueOf("10.0.0.3");
30 30
31 protected static final PortNumber P1 = PortNumber.portNumber(100); 31 protected static final PortNumber P1 = PortNumber.portNumber(100);
32 protected static final PortNumber P2 = PortNumber.portNumber(200); 32 protected static final PortNumber P2 = PortNumber.portNumber(200);
...@@ -34,7 +34,7 @@ public abstract class TestDeviceParams { ...@@ -34,7 +34,7 @@ public abstract class TestDeviceParams {
34 protected static final HostId HID2 = HostId.hostId(MAC2, VLAN2); 34 protected static final HostId HID2 = HostId.hostId(MAC2, VLAN2);
35 protected static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L); 35 protected static final HostLocation LOC1 = new HostLocation(DID1, P1, 123L);
36 protected static final HostLocation LOC2 = new HostLocation(DID2, P2, 123L); 36 protected static final HostLocation LOC2 = new HostLocation(DID2, P2, 123L);
37 - protected static final Set<IpAddress> IPSET1 = Sets.newHashSet(IP1, IP2); 37 + protected static final Set<IpPrefix> IPSET1 = Sets.newHashSet(IP1, IP2);
38 - protected static final Set<IpAddress> IPSET2 = Sets.newHashSet(IP1, IP3); 38 + protected static final Set<IpPrefix> IPSET2 = Sets.newHashSet(IP1, IP3);
39 39
40 } 40 }
......
...@@ -9,7 +9,7 @@ import org.junit.Test; ...@@ -9,7 +9,7 @@ import org.junit.Test;
9 import org.onlab.onos.net.DeviceId; 9 import org.onlab.onos.net.DeviceId;
10 import org.onlab.onos.net.HostLocation; 10 import org.onlab.onos.net.HostLocation;
11 import org.onlab.onos.net.PortNumber; 11 import org.onlab.onos.net.PortNumber;
12 -import org.onlab.packet.IpAddress; 12 +import org.onlab.packet.IpPrefix;
13 import org.onlab.packet.MacAddress; 13 import org.onlab.packet.MacAddress;
14 import org.onlab.packet.VlanId; 14 import org.onlab.packet.VlanId;
15 15
...@@ -27,9 +27,9 @@ public class DefualtHostDecriptionTest { ...@@ -27,9 +27,9 @@ public class DefualtHostDecriptionTest {
27 PortNumber.portNumber(100), 27 PortNumber.portNumber(100),
28 123L 28 123L
29 ); 29 );
30 - private static final Set<IpAddress> IPS = Sets.newHashSet( 30 + private static final Set<IpPrefix> IPS = Sets.newHashSet(
31 - IpAddress.valueOf("10.0.0.1"), 31 + IpPrefix.valueOf("10.0.0.1"),
32 - IpAddress.valueOf("10.0.0.2") 32 + IpPrefix.valueOf("10.0.0.2")
33 ); 33 );
34 34
35 @Test 35 @Test
......
...@@ -11,7 +11,7 @@ import org.onlab.onos.net.HostId; ...@@ -11,7 +11,7 @@ import org.onlab.onos.net.HostId;
11 import org.onlab.onos.net.HostLocation; 11 import org.onlab.onos.net.HostLocation;
12 import org.onlab.onos.net.PortNumber; 12 import org.onlab.onos.net.PortNumber;
13 import org.onlab.onos.net.provider.ProviderId; 13 import org.onlab.onos.net.provider.ProviderId;
14 -import org.onlab.packet.IpAddress; 14 +import org.onlab.packet.IpPrefix;
15 import org.onlab.packet.MacAddress; 15 import org.onlab.packet.MacAddress;
16 import org.onlab.packet.VlanId; 16 import org.onlab.packet.VlanId;
17 17
...@@ -27,9 +27,9 @@ public class HostEventTest extends AbstractEventTest { ...@@ -27,9 +27,9 @@ public class HostEventTest extends AbstractEventTest {
27 PortNumber.portNumber(100), 27 PortNumber.portNumber(100),
28 123L 28 123L
29 ); 29 );
30 - Set<IpAddress> ipset = Sets.newHashSet( 30 + Set<IpPrefix> ipset = Sets.newHashSet(
31 - IpAddress.valueOf("10.0.0.1"), 31 + IpPrefix.valueOf("10.0.0.1"),
32 - IpAddress.valueOf("10.0.0.2") 32 + IpPrefix.valueOf("10.0.0.2")
33 ); 33 );
34 HostId hid = HostId.hostId(mac, vlan); 34 HostId hid = HostId.hostId(mac, vlan);
35 35
......
...@@ -4,7 +4,7 @@ import org.onlab.onos.net.ConnectPoint; ...@@ -4,7 +4,7 @@ import org.onlab.onos.net.ConnectPoint;
4 import org.onlab.onos.net.DeviceId; 4 import org.onlab.onos.net.DeviceId;
5 import org.onlab.onos.net.Host; 5 import org.onlab.onos.net.Host;
6 import org.onlab.onos.net.HostId; 6 import org.onlab.onos.net.HostId;
7 -import org.onlab.packet.IpAddress; 7 +import org.onlab.packet.IpPrefix;
8 import org.onlab.packet.MacAddress; 8 import org.onlab.packet.MacAddress;
9 import org.onlab.packet.VlanId; 9 import org.onlab.packet.VlanId;
10 10
...@@ -40,7 +40,7 @@ public class HostServiceAdapter implements HostService { ...@@ -40,7 +40,7 @@ public class HostServiceAdapter implements HostService {
40 } 40 }
41 41
42 @Override 42 @Override
43 - public Set<Host> getHostsByIp(IpAddress ip) { 43 + public Set<Host> getHostsByIp(IpPrefix ip) {
44 return null; 44 return null;
45 } 45 }
46 46
......
...@@ -23,7 +23,7 @@ import org.onlab.onos.net.host.HostService; ...@@ -23,7 +23,7 @@ import org.onlab.onos.net.host.HostService;
23 import org.onlab.onos.net.host.HostStore; 23 import org.onlab.onos.net.host.HostStore;
24 import org.onlab.onos.net.provider.AbstractProviderRegistry; 24 import org.onlab.onos.net.provider.AbstractProviderRegistry;
25 import org.onlab.onos.net.provider.AbstractProviderService; 25 import org.onlab.onos.net.provider.AbstractProviderService;
26 -import org.onlab.packet.IpAddress; 26 +import org.onlab.packet.IpPrefix;
27 import org.onlab.packet.MacAddress; 27 import org.onlab.packet.MacAddress;
28 import org.onlab.packet.VlanId; 28 import org.onlab.packet.VlanId;
29 import org.slf4j.Logger; 29 import org.slf4j.Logger;
...@@ -100,7 +100,7 @@ public class SimpleHostManager ...@@ -100,7 +100,7 @@ public class SimpleHostManager
100 } 100 }
101 101
102 @Override 102 @Override
103 - public Set<Host> getHostsByIp(IpAddress ip) { 103 + public Set<Host> getHostsByIp(IpPrefix ip) {
104 checkNotNull(ip, "IP address cannot be null"); 104 checkNotNull(ip, "IP address cannot be null");
105 return store.getHosts(ip); 105 return store.getHosts(ip);
106 } 106 }
......
...@@ -25,7 +25,7 @@ import org.onlab.onos.net.host.HostDescription; ...@@ -25,7 +25,7 @@ import org.onlab.onos.net.host.HostDescription;
25 import org.onlab.onos.net.host.HostEvent; 25 import org.onlab.onos.net.host.HostEvent;
26 import org.onlab.onos.net.host.HostStore; 26 import org.onlab.onos.net.host.HostStore;
27 import org.onlab.onos.net.provider.ProviderId; 27 import org.onlab.onos.net.provider.ProviderId;
28 -import org.onlab.packet.IpAddress; 28 +import org.onlab.packet.IpPrefix;
29 import org.onlab.packet.MacAddress; 29 import org.onlab.packet.MacAddress;
30 import org.onlab.packet.VlanId; 30 import org.onlab.packet.VlanId;
31 31
...@@ -166,7 +166,7 @@ public class SimpleHostStore implements HostStore { ...@@ -166,7 +166,7 @@ public class SimpleHostStore implements HostStore {
166 } 166 }
167 167
168 @Override 168 @Override
169 - public Set<Host> getHosts(IpAddress ip) { 169 + public Set<Host> getHosts(IpPrefix ip) {
170 Set<Host> ipset = new HashSet<>(); 170 Set<Host> ipset = new HashSet<>();
171 for (Host h : hosts.values()) { 171 for (Host h : hosts.values()) {
172 if (h.ipAddresses().contains(ip)) { 172 if (h.ipAddresses().contains(ip)) {
......
...@@ -28,7 +28,7 @@ import org.onlab.onos.net.host.HostProviderRegistry; ...@@ -28,7 +28,7 @@ import org.onlab.onos.net.host.HostProviderRegistry;
28 import org.onlab.onos.net.host.HostProviderService; 28 import org.onlab.onos.net.host.HostProviderService;
29 import org.onlab.onos.net.provider.AbstractProvider; 29 import org.onlab.onos.net.provider.AbstractProvider;
30 import org.onlab.onos.net.provider.ProviderId; 30 import org.onlab.onos.net.provider.ProviderId;
31 -import org.onlab.packet.IpAddress; 31 +import org.onlab.packet.IpPrefix;
32 import org.onlab.packet.MacAddress; 32 import org.onlab.packet.MacAddress;
33 import org.onlab.packet.VlanId; 33 import org.onlab.packet.VlanId;
34 34
...@@ -51,10 +51,10 @@ public class SimpleHostManagerTest { ...@@ -51,10 +51,10 @@ public class SimpleHostManagerTest {
51 private static final HostId HID1 = HostId.hostId(MAC1, VLAN1); 51 private static final HostId HID1 = HostId.hostId(MAC1, VLAN1);
52 private static final HostId HID2 = HostId.hostId(MAC2, VLAN1); 52 private static final HostId HID2 = HostId.hostId(MAC2, VLAN1);
53 53
54 - private static final IpAddress IP1 = IpAddress.valueOf("10.0.0.1"); 54 + private static final IpPrefix IP1 = IpPrefix.valueOf("10.0.0.1");
55 - private static final IpAddress IP2 = IpAddress.valueOf("10.0.0.2"); 55 + private static final IpPrefix IP2 = IpPrefix.valueOf("10.0.0.2");
56 - private static final Set<IpAddress> IPSET1 = Sets.newHashSet(IP1); 56 + private static final Set<IpPrefix> IPSET1 = Sets.newHashSet(IP1);
57 - private static final Set<IpAddress> IPSET2 = Sets.newHashSet(IP2); 57 + private static final Set<IpPrefix> IPSET2 = Sets.newHashSet(IP2);
58 58
59 private static final DeviceId DID1 = DeviceId.deviceId("of:001"); 59 private static final DeviceId DID1 = DeviceId.deviceId("of:001");
60 private static final DeviceId DID2 = DeviceId.deviceId("of:002"); 60 private static final DeviceId DID2 = DeviceId.deviceId("of:002");
...@@ -98,7 +98,7 @@ public class SimpleHostManagerTest { ...@@ -98,7 +98,7 @@ public class SimpleHostManagerTest {
98 } 98 }
99 99
100 private void detect(HostId hid, MacAddress mac, VlanId vlan, 100 private void detect(HostId hid, MacAddress mac, VlanId vlan,
101 - HostLocation loc, Set<IpAddress> ips) { 101 + HostLocation loc, Set<IpPrefix> ips) {
102 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ips); 102 HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ips);
103 providerService.hostDetected(hid, descr); 103 providerService.hostDetected(hid, descr);
104 assertNotNull("host should be found", mgr.getHost(hid)); 104 assertNotNull("host should be found", mgr.getHost(hid));
......
...@@ -15,7 +15,7 @@ import org.onlab.onos.net.flow.TrafficTreatment; ...@@ -15,7 +15,7 @@ import org.onlab.onos.net.flow.TrafficTreatment;
15 import org.onlab.onos.net.flow.criteria.Criteria; 15 import org.onlab.onos.net.flow.criteria.Criteria;
16 import org.onlab.onos.net.flow.instructions.Instructions; 16 import org.onlab.onos.net.flow.instructions.Instructions;
17 import org.onlab.onos.openflow.controller.Dpid; 17 import org.onlab.onos.openflow.controller.Dpid;
18 -import org.onlab.packet.IpAddress; 18 +import org.onlab.packet.IpPrefix;
19 import org.onlab.packet.MacAddress; 19 import org.onlab.packet.MacAddress;
20 import org.onlab.packet.VlanId; 20 import org.onlab.packet.VlanId;
21 import org.projectfloodlight.openflow.protocol.OFFlowRemoved; 21 import org.projectfloodlight.openflow.protocol.OFFlowRemoved;
...@@ -120,20 +120,20 @@ public class FlowRuleBuilder { ...@@ -120,20 +120,20 @@ public class FlowRuleBuilder {
120 OFActionSetNwDst nwdst = (OFActionSetNwDst) act; 120 OFActionSetNwDst nwdst = (OFActionSetNwDst) act;
121 IPv4Address di = nwdst.getNwAddr(); 121 IPv4Address di = nwdst.getNwAddr();
122 if (di.isCidrMask()) { 122 if (di.isCidrMask()) {
123 - builder.add(Instructions.modL3Dst(IpAddress.valueOf(di.getInt(), 123 + builder.add(Instructions.modL3Dst(IpPrefix.valueOf(di.getInt(),
124 di.asCidrMaskLength()))); 124 di.asCidrMaskLength())));
125 } else { 125 } else {
126 - builder.add(Instructions.modL3Dst(IpAddress.valueOf(di.getInt()))); 126 + builder.add(Instructions.modL3Dst(IpPrefix.valueOf(di.getInt())));
127 } 127 }
128 break; 128 break;
129 case SET_NW_SRC: 129 case SET_NW_SRC:
130 OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act; 130 OFActionSetNwSrc nwsrc = (OFActionSetNwSrc) act;
131 IPv4Address si = nwsrc.getNwAddr(); 131 IPv4Address si = nwsrc.getNwAddr();
132 if (si.isCidrMask()) { 132 if (si.isCidrMask()) {
133 - builder.add(Instructions.modL3Dst(IpAddress.valueOf(si.getInt(), 133 + builder.add(Instructions.modL3Dst(IpPrefix.valueOf(si.getInt(),
134 si.asCidrMaskLength()))); 134 si.asCidrMaskLength())));
135 } else { 135 } else {
136 - builder.add(Instructions.modL3Dst(IpAddress.valueOf(si.getInt()))); 136 + builder.add(Instructions.modL3Dst(IpPrefix.valueOf(si.getInt())));
137 } 137 }
138 break; 138 break;
139 case SET_TP_DST: 139 case SET_TP_DST:
...@@ -190,21 +190,21 @@ public class FlowRuleBuilder { ...@@ -190,21 +190,21 @@ public class FlowRuleBuilder {
190 break; 190 break;
191 case IPV4_DST: 191 case IPV4_DST:
192 IPv4Address di = match.get(MatchField.IPV4_DST); 192 IPv4Address di = match.get(MatchField.IPV4_DST);
193 - IpAddress dip; 193 + IpPrefix dip;
194 if (di.isCidrMask()) { 194 if (di.isCidrMask()) {
195 - dip = IpAddress.valueOf(di.getInt(), di.asCidrMaskLength()); 195 + dip = IpPrefix.valueOf(di.getInt(), di.asCidrMaskLength());
196 } else { 196 } else {
197 - dip = IpAddress.valueOf(di.getInt()); 197 + dip = IpPrefix.valueOf(di.getInt());
198 } 198 }
199 builder.add(Criteria.matchIPDst(dip)); 199 builder.add(Criteria.matchIPDst(dip));
200 break; 200 break;
201 case IPV4_SRC: 201 case IPV4_SRC:
202 IPv4Address si = match.get(MatchField.IPV4_SRC); 202 IPv4Address si = match.get(MatchField.IPV4_SRC);
203 - IpAddress sip; 203 + IpPrefix sip;
204 if (si.isCidrMask()) { 204 if (si.isCidrMask()) {
205 - sip = IpAddress.valueOf(si.getInt(), si.asCidrMaskLength()); 205 + sip = IpPrefix.valueOf(si.getInt(), si.asCidrMaskLength());
206 } else { 206 } else {
207 - sip = IpAddress.valueOf(si.getInt()); 207 + sip = IpPrefix.valueOf(si.getInt());
208 } 208 }
209 builder.add(Criteria.matchIPSrc(sip)); 209 builder.add(Criteria.matchIPSrc(sip));
210 break; 210 break;
......
...@@ -31,7 +31,7 @@ import org.onlab.onos.openflow.controller.OpenFlowPacketContext; ...@@ -31,7 +31,7 @@ import org.onlab.onos.openflow.controller.OpenFlowPacketContext;
31 import org.onlab.onos.openflow.controller.PacketListener; 31 import org.onlab.onos.openflow.controller.PacketListener;
32 import org.onlab.packet.ARP; 32 import org.onlab.packet.ARP;
33 import org.onlab.packet.Ethernet; 33 import org.onlab.packet.Ethernet;
34 -import org.onlab.packet.IpAddress; 34 +import org.onlab.packet.IpPrefix;
35 import org.onlab.packet.VlanId; 35 import org.onlab.packet.VlanId;
36 import org.slf4j.Logger; 36 import org.slf4j.Logger;
37 37
...@@ -110,7 +110,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid ...@@ -110,7 +110,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
110 110
111 HostId hid = HostId.hostId(eth.getSourceMAC(), vlan); 111 HostId hid = HostId.hostId(eth.getSourceMAC(), vlan);
112 ARP arp = (ARP) eth.getPayload(); 112 ARP arp = (ARP) eth.getPayload();
113 - Set<IpAddress> ips = newHashSet(IpAddress.valueOf(arp.getSenderProtocolAddress())); 113 + Set<IpPrefix> ips = newHashSet(IpPrefix.valueOf(arp.getSenderProtocolAddress()));
114 HostDescription hdescr = 114 HostDescription hdescr =
115 new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ips); 115 new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ips);
116 providerService.hostDetected(hid, hdescr); 116 providerService.hostDetected(hid, hdescr);
......
...@@ -36,7 +36,7 @@ import org.onlab.onos.openflow.controller.PacketListener; ...@@ -36,7 +36,7 @@ import org.onlab.onos.openflow.controller.PacketListener;
36 import org.onlab.onos.openflow.controller.RoleState; 36 import org.onlab.onos.openflow.controller.RoleState;
37 import org.onlab.packet.ARP; 37 import org.onlab.packet.ARP;
38 import org.onlab.packet.Ethernet; 38 import org.onlab.packet.Ethernet;
39 -import org.onlab.packet.IpAddress; 39 +import org.onlab.packet.IpPrefix;
40 import org.projectfloodlight.openflow.protocol.OFFactory; 40 import org.projectfloodlight.openflow.protocol.OFFactory;
41 import org.projectfloodlight.openflow.protocol.OFMessage; 41 import org.projectfloodlight.openflow.protocol.OFMessage;
42 import org.projectfloodlight.openflow.protocol.OFPacketIn; 42 import org.projectfloodlight.openflow.protocol.OFPacketIn;
...@@ -113,10 +113,10 @@ public class OpenFlowPacketProviderTest { ...@@ -113,10 +113,10 @@ public class OpenFlowPacketProviderTest {
113 MacAddress mac2 = MacAddress.of("00:00:00:22:00:02"); 113 MacAddress mac2 = MacAddress.of("00:00:00:22:00:02");
114 114
115 ARP arp = new ARP(); 115 ARP arp = new ARP();
116 - arp.setSenderProtocolAddress(IpAddress.ANY) 116 + arp.setSenderProtocolAddress(IpPrefix.ANY)
117 .setSenderHardwareAddress(mac1.getBytes()) 117 .setSenderHardwareAddress(mac1.getBytes())
118 .setTargetHardwareAddress(mac2.getBytes()) 118 .setTargetHardwareAddress(mac2.getBytes())
119 - .setTargetProtocolAddress(IpAddress.ANY) 119 + .setTargetProtocolAddress(IpPrefix.ANY)
120 .setHardwareType((short) 0) 120 .setHardwareType((short) 0)
121 .setProtocolType((short) 0) 121 .setProtocolType((short) 0)
122 .setHardwareAddressLength((byte) 6) 122 .setHardwareAddressLength((byte) 6)
......
...@@ -5,7 +5,7 @@ import java.util.Arrays; ...@@ -5,7 +5,7 @@ import java.util.Arrays;
5 /** 5 /**
6 * A class representing an IPv4 address. 6 * A class representing an IPv4 address.
7 */ 7 */
8 -public final class IpAddress { 8 +public final class IpPrefix {
9 9
10 // TODO a comparator for netmasks? E.g. for sorting by prefix match order. 10 // TODO a comparator for netmasks? E.g. for sorting by prefix match order.
11 11
...@@ -31,13 +31,13 @@ public final class IpAddress { ...@@ -31,13 +31,13 @@ public final class IpAddress {
31 protected byte[] octets; 31 protected byte[] octets;
32 protected int netmask; 32 protected int netmask;
33 33
34 - private IpAddress(Version ver, byte[] octets, int netmask) { 34 + private IpPrefix(Version ver, byte[] octets, int netmask) {
35 this.version = ver; 35 this.version = ver;
36 this.octets = Arrays.copyOf(octets, INET_LEN); 36 this.octets = Arrays.copyOf(octets, INET_LEN);
37 this.netmask = netmask; 37 this.netmask = netmask;
38 } 38 }
39 39
40 - private IpAddress(Version ver, byte[] octets) { 40 + private IpPrefix(Version ver, byte[] octets) {
41 this.version = ver; 41 this.version = ver;
42 this.octets = Arrays.copyOf(octets, INET_LEN); 42 this.octets = Arrays.copyOf(octets, INET_LEN);
43 this.netmask = DEFAULT_MASK; 43 this.netmask = DEFAULT_MASK;
...@@ -49,8 +49,8 @@ public final class IpAddress { ...@@ -49,8 +49,8 @@ public final class IpAddress {
49 * @param address a byte array 49 * @param address a byte array
50 * @return an IP address 50 * @return an IP address
51 */ 51 */
52 - public static IpAddress valueOf(byte [] address) { 52 + public static IpPrefix valueOf(byte [] address) {
53 - return new IpAddress(Version.INET, address); 53 + return new IpPrefix(Version.INET, address);
54 } 54 }
55 55
56 /** 56 /**
...@@ -60,8 +60,8 @@ public final class IpAddress { ...@@ -60,8 +60,8 @@ public final class IpAddress {
60 * @param netmask the CIDR value subnet mask 60 * @param netmask the CIDR value subnet mask
61 * @return an IP address 61 * @return an IP address
62 */ 62 */
63 - public static IpAddress valueOf(byte [] address, int netmask) { 63 + public static IpPrefix valueOf(byte [] address, int netmask) {
64 - return new IpAddress(Version.INET, address, netmask); 64 + return new IpPrefix(Version.INET, address, netmask);
65 } 65 }
66 66
67 /** 67 /**
...@@ -85,8 +85,8 @@ public final class IpAddress { ...@@ -85,8 +85,8 @@ public final class IpAddress {
85 * @param address an integer representing an IP value 85 * @param address an integer representing an IP value
86 * @return an IP address 86 * @return an IP address
87 */ 87 */
88 - public static IpAddress valueOf(int address) { 88 + public static IpPrefix valueOf(int address) {
89 - return new IpAddress(Version.INET, bytes(address)); 89 + return new IpPrefix(Version.INET, bytes(address));
90 } 90 }
91 91
92 /** 92 /**
...@@ -96,8 +96,8 @@ public final class IpAddress { ...@@ -96,8 +96,8 @@ public final class IpAddress {
96 * @param netmask the CIDR value subnet mask 96 * @param netmask the CIDR value subnet mask
97 * @return an IP address 97 * @return an IP address
98 */ 98 */
99 - public static IpAddress valueOf(int address, int netmask) { 99 + public static IpPrefix valueOf(int address, int netmask) {
100 - return new IpAddress(Version.INET, bytes(address), netmask); 100 + return new IpPrefix(Version.INET, bytes(address), netmask);
101 } 101 }
102 102
103 /** 103 /**
...@@ -108,7 +108,7 @@ public final class IpAddress { ...@@ -108,7 +108,7 @@ public final class IpAddress {
108 * @param address a IP address in string form, e.g. "10.0.0.1", "10.0.0.1/24" 108 * @param address a IP address in string form, e.g. "10.0.0.1", "10.0.0.1/24"
109 * @return an IP address 109 * @return an IP address
110 */ 110 */
111 - public static IpAddress valueOf(String address) { 111 + public static IpPrefix valueOf(String address) {
112 112
113 final String [] parts = address.split("\\/"); 113 final String [] parts = address.split("\\/");
114 if (parts.length > 2) { 114 if (parts.length > 2) {
...@@ -135,7 +135,7 @@ public final class IpAddress { ...@@ -135,7 +135,7 @@ public final class IpAddress {
135 for (int i = 0; i < INET_LEN; i++) { 135 for (int i = 0; i < INET_LEN; i++) {
136 bytes[i] = (byte) Short.parseShort(net[i], 10); 136 bytes[i] = (byte) Short.parseShort(net[i], 10);
137 } 137 }
138 - return new IpAddress(Version.INET, bytes, mask); 138 + return new IpPrefix(Version.INET, bytes, mask);
139 } 139 }
140 140
141 /** 141 /**
...@@ -185,8 +185,8 @@ public final class IpAddress { ...@@ -185,8 +185,8 @@ public final class IpAddress {
185 * 185 *
186 * @return the subnet mask 186 * @return the subnet mask
187 */ 187 */
188 - public IpAddress netmask() { 188 + public IpPrefix netmask() {
189 - return new IpAddress(Version.INET, bytes(mask())); 189 + return new IpPrefix(Version.INET, bytes(mask()));
190 } 190 }
191 191
192 /** 192 /**
...@@ -196,9 +196,9 @@ public final class IpAddress { ...@@ -196,9 +196,9 @@ public final class IpAddress {
196 * 196 *
197 * @return the network address or null 197 * @return the network address or null
198 */ 198 */
199 - public IpAddress network() { 199 + public IpPrefix network() {
200 if (netmask == DEFAULT_MASK) { 200 if (netmask == DEFAULT_MASK) {
201 - return new IpAddress(version, ANY, DEFAULT_MASK); 201 + return new IpPrefix(version, ANY, DEFAULT_MASK);
202 } 202 }
203 203
204 byte [] net = new byte [4]; 204 byte [] net = new byte [4];
...@@ -206,7 +206,7 @@ public final class IpAddress { ...@@ -206,7 +206,7 @@ public final class IpAddress {
206 for (int i = 0; i < INET_LEN; i++) { 206 for (int i = 0; i < INET_LEN; i++) {
207 net[i] = (byte) (octets[i] & mask[i]); 207 net[i] = (byte) (octets[i] & mask[i]);
208 } 208 }
209 - return new IpAddress(version, net, netmask); 209 + return new IpPrefix(version, net, netmask);
210 } 210 }
211 211
212 /** 212 /**
...@@ -217,9 +217,9 @@ public final class IpAddress { ...@@ -217,9 +217,9 @@ public final class IpAddress {
217 * 217 *
218 * @return the host address 218 * @return the host address
219 */ 219 */
220 - public IpAddress host() { 220 + public IpPrefix host() {
221 if (netmask == DEFAULT_MASK) { 221 if (netmask == DEFAULT_MASK) {
222 - new IpAddress(version, octets, netmask); 222 + new IpPrefix(version, octets, netmask);
223 } 223 }
224 224
225 byte [] host = new byte [INET_LEN]; 225 byte [] host = new byte [INET_LEN];
...@@ -227,7 +227,7 @@ public final class IpAddress { ...@@ -227,7 +227,7 @@ public final class IpAddress {
227 for (int i = 0; i < INET_LEN; i++) { 227 for (int i = 0; i < INET_LEN; i++) {
228 host[i] = (byte) (octets[i] & ~mask[i]); 228 host[i] = (byte) (octets[i] & ~mask[i]);
229 } 229 }
230 - return new IpAddress(version, host, netmask); 230 + return new IpPrefix(version, host, netmask);
231 } 231 }
232 232
233 public boolean isMasked() { 233 public boolean isMasked() {
...@@ -242,7 +242,7 @@ public final class IpAddress { ...@@ -242,7 +242,7 @@ public final class IpAddress {
242 * @return true if the other IP address is contained in this address' 242 * @return true if the other IP address is contained in this address'
243 * network, otherwise false 243 * network, otherwise false
244 */ 244 */
245 - public boolean contains(IpAddress other) { 245 + public boolean contains(IpPrefix other) {
246 if (this.netmask <= other.netmask) { 246 if (this.netmask <= other.netmask) {
247 // Special case where they're both /32 addresses 247 // Special case where they're both /32 addresses
248 if (this.netmask == MAX_INET_MASK) { 248 if (this.netmask == MAX_INET_MASK) {
...@@ -250,8 +250,8 @@ public final class IpAddress { ...@@ -250,8 +250,8 @@ public final class IpAddress {
250 } 250 }
251 251
252 // Mask the other address with our network mask 252 // Mask the other address with our network mask
253 - IpAddress otherMasked = 253 + IpPrefix otherMasked =
254 - IpAddress.valueOf(other.octets, netmask).network(); 254 + IpPrefix.valueOf(other.octets, netmask).network();
255 255
256 return network().equals(otherMasked); 256 return network().equals(otherMasked);
257 } 257 }
...@@ -279,7 +279,7 @@ public final class IpAddress { ...@@ -279,7 +279,7 @@ public final class IpAddress {
279 if (getClass() != obj.getClass()) { 279 if (getClass() != obj.getClass()) {
280 return false; 280 return false;
281 } 281 }
282 - IpAddress other = (IpAddress) obj; 282 + IpPrefix other = (IpPrefix) obj;
283 if (netmask != other.netmask) { 283 if (netmask != other.netmask) {
284 return false; 284 return false;
285 } 285 }
......
...@@ -7,11 +7,11 @@ import static org.junit.Assert.assertTrue; ...@@ -7,11 +7,11 @@ import static org.junit.Assert.assertTrue;
7 import java.util.Arrays; 7 import java.util.Arrays;
8 8
9 import org.junit.Test; 9 import org.junit.Test;
10 -import org.onlab.packet.IpAddress.Version; 10 +import org.onlab.packet.IpPrefix.Version;
11 11
12 import com.google.common.testing.EqualsTester; 12 import com.google.common.testing.EqualsTester;
13 13
14 -public class IPAddressTest { 14 +public class IpPrefixTest {
15 15
16 private static final byte [] BYTES1 = new byte [] {0xa, 0x0, 0x0, 0xa}; 16 private static final byte [] BYTES1 = new byte [] {0xa, 0x0, 0x0, 0xa};
17 private static final byte [] BYTES2 = new byte [] {0xa, 0x0, 0x0, 0xb}; 17 private static final byte [] BYTES2 = new byte [] {0xa, 0x0, 0x0, 0xb};
...@@ -22,11 +22,11 @@ public class IPAddressTest { ...@@ -22,11 +22,11 @@ public class IPAddressTest {
22 22
23 @Test 23 @Test
24 public void testEquality() { 24 public void testEquality() {
25 - IpAddress ip1 = IpAddress.valueOf(BYTES1); 25 + IpPrefix ip1 = IpPrefix.valueOf(BYTES1);
26 - IpAddress ip2 = IpAddress.valueOf(INTVAL1); 26 + IpPrefix ip2 = IpPrefix.valueOf(INTVAL1);
27 - IpAddress ip3 = IpAddress.valueOf(BYTES2); 27 + IpPrefix ip3 = IpPrefix.valueOf(BYTES2);
28 - IpAddress ip4 = IpAddress.valueOf(INTVAL2); 28 + IpPrefix ip4 = IpPrefix.valueOf(INTVAL2);
29 - IpAddress ip5 = IpAddress.valueOf(STRVAL); 29 + IpPrefix ip5 = IpPrefix.valueOf(STRVAL);
30 30
31 new EqualsTester().addEqualityGroup(ip1, ip2) 31 new EqualsTester().addEqualityGroup(ip1, ip2)
32 .addEqualityGroup(ip3, ip4) 32 .addEqualityGroup(ip3, ip4)
...@@ -34,16 +34,16 @@ public class IPAddressTest { ...@@ -34,16 +34,16 @@ public class IPAddressTest {
34 .testEquals(); 34 .testEquals();
35 35
36 // string conversions 36 // string conversions
37 - IpAddress ip6 = IpAddress.valueOf(BYTES1, MASK); 37 + IpPrefix ip6 = IpPrefix.valueOf(BYTES1, MASK);
38 - IpAddress ip7 = IpAddress.valueOf("10.0.0.10/16"); 38 + IpPrefix ip7 = IpPrefix.valueOf("10.0.0.10/16");
39 - IpAddress ip8 = IpAddress.valueOf(new byte [] {0xa, 0x0, 0x0, 0xc}); 39 + IpPrefix ip8 = IpPrefix.valueOf(new byte [] {0xa, 0x0, 0x0, 0xc});
40 assertEquals("incorrect address conversion", ip6, ip7); 40 assertEquals("incorrect address conversion", ip6, ip7);
41 assertEquals("incorrect address conversion", ip5, ip8); 41 assertEquals("incorrect address conversion", ip5, ip8);
42 } 42 }
43 43
44 @Test 44 @Test
45 public void basics() { 45 public void basics() {
46 - IpAddress ip1 = IpAddress.valueOf(BYTES1, MASK); 46 + IpPrefix ip1 = IpPrefix.valueOf(BYTES1, MASK);
47 final byte [] bytes = new byte [] {0xa, 0x0, 0x0, 0xa}; 47 final byte [] bytes = new byte [] {0xa, 0x0, 0x0, 0xa};
48 48
49 //check fields 49 //check fields
...@@ -57,29 +57,29 @@ public class IPAddressTest { ...@@ -57,29 +57,29 @@ public class IPAddressTest {
57 @Test 57 @Test
58 public void netmasks() { 58 public void netmasks() {
59 // masked 59 // masked
60 - IpAddress ip1 = IpAddress.valueOf(BYTES1, MASK); 60 + IpPrefix ip1 = IpPrefix.valueOf(BYTES1, MASK);
61 61
62 - IpAddress host = IpAddress.valueOf("0.0.0.10/16"); 62 + IpPrefix host = IpPrefix.valueOf("0.0.0.10/16");
63 - IpAddress network = IpAddress.valueOf("10.0.0.0/16"); 63 + IpPrefix network = IpPrefix.valueOf("10.0.0.0/16");
64 assertEquals("incorrect host address", host, ip1.host()); 64 assertEquals("incorrect host address", host, ip1.host());
65 assertEquals("incorrect network address", network, ip1.network()); 65 assertEquals("incorrect network address", network, ip1.network());
66 assertEquals("incorrect netmask", "255.255.0.0", ip1.netmask().toString()); 66 assertEquals("incorrect netmask", "255.255.0.0", ip1.netmask().toString());
67 67
68 //unmasked 68 //unmasked
69 - IpAddress ip2 = IpAddress.valueOf(BYTES1); 69 + IpPrefix ip2 = IpPrefix.valueOf(BYTES1);
70 - IpAddress umhost = IpAddress.valueOf("10.0.0.10/0"); 70 + IpPrefix umhost = IpPrefix.valueOf("10.0.0.10/0");
71 - IpAddress umnet = IpAddress.valueOf("0.0.0.0/0"); 71 + IpPrefix umnet = IpPrefix.valueOf("0.0.0.0/0");
72 assertEquals("incorrect host address", umhost, ip2.host()); 72 assertEquals("incorrect host address", umhost, ip2.host());
73 assertEquals("incorrect host address", umnet, ip2.network()); 73 assertEquals("incorrect host address", umnet, ip2.network());
74 assertTrue("incorrect netmask", 74 assertTrue("incorrect netmask",
75 - Arrays.equals(IpAddress.ANY, ip2.netmask().toOctets())); 75 + Arrays.equals(IpPrefix.ANY, ip2.netmask().toOctets()));
76 } 76 }
77 77
78 @Test 78 @Test
79 public void testContains() { 79 public void testContains() {
80 - IpAddress slash31 = IpAddress.valueOf(BYTES1, 31); 80 + IpPrefix slash31 = IpPrefix.valueOf(BYTES1, 31);
81 - IpAddress slash32 = IpAddress.valueOf(BYTES1, 32); 81 + IpPrefix slash32 = IpPrefix.valueOf(BYTES1, 32);
82 - IpAddress differentSlash32 = IpAddress.valueOf(BYTES2, 32); 82 + IpPrefix differentSlash32 = IpPrefix.valueOf(BYTES2, 32);
83 83
84 assertTrue(slash31.contains(differentSlash32)); 84 assertTrue(slash31.contains(differentSlash32));
85 assertFalse(differentSlash32.contains(slash31)); 85 assertFalse(differentSlash32.contains(slash31));
...@@ -88,11 +88,11 @@ public class IPAddressTest { ...@@ -88,11 +88,11 @@ public class IPAddressTest {
88 assertFalse(slash32.contains(differentSlash32)); 88 assertFalse(slash32.contains(differentSlash32));
89 assertFalse(differentSlash32.contains(slash32)); 89 assertFalse(differentSlash32.contains(slash32));
90 90
91 - IpAddress zero = IpAddress.valueOf("0.0.0.0/0"); 91 + IpPrefix zero = IpPrefix.valueOf("0.0.0.0/0");
92 assertTrue(zero.contains(differentSlash32)); 92 assertTrue(zero.contains(differentSlash32));
93 assertFalse(differentSlash32.contains(zero)); 93 assertFalse(differentSlash32.contains(zero));
94 94
95 - IpAddress slash8 = IpAddress.valueOf("10.0.0.0/8"); 95 + IpPrefix slash8 = IpPrefix.valueOf("10.0.0.0/8");
96 assertTrue(slash8.contains(slash31)); 96 assertTrue(slash8.contains(slash31));
97 assertFalse(slash31.contains(slash8)); 97 assertFalse(slash31.contains(slash8));
98 } 98 }
......
...@@ -6,7 +6,7 @@ import org.junit.Test; ...@@ -6,7 +6,7 @@ import org.junit.Test;
6 6
7 import com.google.common.testing.EqualsTester; 7 import com.google.common.testing.EqualsTester;
8 8
9 -public class VLANIDTest { 9 +public class VlanIdTest {
10 10
11 @Test 11 @Test
12 public void testEquality() { 12 public void testEquality() {
......