Ayaka Koshibe

renamed VLAN, IP, and MACAddress classes

Change-Id: Ib4df413db1f3d9ee96213fc487519536d7993c5b
Showing 27 changed files with 233 additions and 233 deletions
......@@ -16,7 +16,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.IPAddress;
import org.onlab.packet.IpAddress;
import org.onlab.rest.BaseResource;
import javax.ws.rs.GET;
......@@ -74,8 +74,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<IPAddress> ipAddresses = host.ipAddresses();
IPAddress 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))));
......
......@@ -8,27 +8,27 @@ import java.util.Objects;
import java.util.Set;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
/**
* A basic implementation of a Host.
*/
public class DefaultHost extends AbstractElement implements Host {
private final MACAddress mac;
private final VLANID vlan;
private final MacAddress mac;
private final VlanId vlan;
private final HostLocation location;
private final Set<IPAddress> ips;
private final Set<IpAddress> ips;
public DefaultHost(ProviderId providerId, HostId id, MACAddress mac,
VLANID vlan, HostLocation loc, Set<IPAddress> ips) {
public DefaultHost(ProviderId providerId, HostId id, MacAddress mac,
VlanId vlan, HostLocation loc, Set<IpAddress> ips) {
super(providerId, id);
this.mac = mac;
this.vlan = vlan;
this.location = loc;
this.ips = new HashSet<IPAddress>(ips);
this.ips = new HashSet<IpAddress>(ips);
}
@Override
......@@ -37,12 +37,12 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public MACAddress mac() {
public MacAddress mac() {
return mac;
}
@Override
public Set<IPAddress> ipAddresses() {
public Set<IpAddress> ipAddresses() {
return Collections.unmodifiableSet(ips);
}
......@@ -52,7 +52,7 @@ public class DefaultHost extends AbstractElement implements Host {
}
@Override
public VLANID vlan() {
public VlanId vlan() {
return vlan;
}
......
package org.onlab.onos.net;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import java.util.Set;
......@@ -24,21 +24,21 @@ public interface Host extends Element {
*
* @return mac address
*/
MACAddress mac();
MacAddress mac();
/**
* Returns the VLAN ID tied to this host.
*
* @return VLAN ID value
*/
VLANID vlan();
VlanId vlan();
/**
* Returns set of IP addresses currently bound to the host MAC address.
*
* @return set of IP addresses; empty if no IP address is bound
*/
Set<IPAddress> ipAddresses();
Set<IpAddress> ipAddresses();
/**
* Returns the most recent host location where the host attaches to the
......
package org.onlab.onos.net;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import java.net.URI;
......@@ -42,7 +42,7 @@ public final class HostId extends ElementId {
* @param vlanId vlan identifier
* @return host identifier
*/
public static HostId hostId(MACAddress mac, VLANID vlanId) {
public static HostId hostId(MacAddress mac, VlanId vlanId) {
// FIXME: use more efficient means of encoding
return hostId("nic" + ":" + mac + "-" + vlanId);
}
......@@ -53,8 +53,8 @@ public final class HostId extends ElementId {
* @param mac mac address
* @return host identifier
*/
public static HostId hostId(MACAddress mac) {
return hostId(mac, VLANID.vlanId(VLANID.UNTAGGED));
public static HostId hostId(MacAddress mac) {
return hostId(mac, VlanId.vlanId(VlanId.UNTAGGED));
}
}
......
......@@ -2,9 +2,9 @@ package org.onlab.onos.net.flow.criteria;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.flow.criteria.Criterion.Type;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
/**
* Factory class to create various traffic selection criteria.
......@@ -34,7 +34,7 @@ public final class Criteria {
* @param macValue MAC address value or wildcard mask
* @return match criterion
*/
public static Criterion matchEthSrc(MACAddress mac) {
public static Criterion matchEthSrc(MacAddress mac) {
return new EthCriterion(mac, Type.ETH_SRC);
}
......@@ -45,7 +45,7 @@ public final class Criteria {
* @param macValue MAC address value or wildcard mask
* @return match criterion
*/
public static Criterion matchEthDst(MACAddress mac) {
public static Criterion matchEthDst(MacAddress mac) {
return new EthCriterion(mac, Type.ETH_DST);
}
......@@ -65,7 +65,7 @@ public final class Criteria {
* @param vlanId vlan id value
* @return match criterion
*/
public static Criterion matchVlanId(VLANID vlanId) {
public static Criterion matchVlanId(VlanId vlanId) {
return new VlanIdCriterion(vlanId);
}
......@@ -95,7 +95,7 @@ public final class Criteria {
* @param ip ip src value
* @return match criterion
*/
public static Criterion matchIPSrc(IPAddress ip) {
public static Criterion matchIPSrc(IpAddress ip) {
return new IPCriterion(ip, Type.IPV4_SRC);
}
......@@ -105,7 +105,7 @@ public final class Criteria {
* @param ip ip src value
* @return match criterion
*/
public static Criterion matchIPDst(IPAddress ip) {
public static Criterion matchIPDst(IpAddress ip) {
return new IPCriterion(ip, Type.IPV4_DST);
}
......@@ -133,10 +133,10 @@ public final class Criteria {
public static final class EthCriterion implements Criterion {
private final MACAddress mac;
private final MacAddress mac;
private final Type type;
public EthCriterion(MACAddress mac, Type type) {
public EthCriterion(MacAddress mac, Type type) {
this.mac = mac;
this.type = type;
}
......@@ -146,7 +146,7 @@ public final class Criteria {
return this.type;
}
public MACAddress mac() {
public MacAddress mac() {
return this.mac;
}
}
......@@ -173,10 +173,10 @@ public final class Criteria {
public static final class IPCriterion implements Criterion {
private final IPAddress ip;
private final IpAddress ip;
private final Type type;
public IPCriterion(IPAddress ip, Type type) {
public IPCriterion(IpAddress ip, Type type) {
this.ip = ip;
this.type = type;
}
......@@ -186,7 +186,7 @@ public final class Criteria {
return this.type;
}
public IPAddress ip() {
public IpAddress ip() {
return this.ip;
}
......@@ -237,9 +237,9 @@ public final class Criteria {
public static final class VlanIdCriterion implements Criterion {
private final VLANID vlanId;
private final VlanId vlanId;
public VlanIdCriterion(VLANID vlanId) {
public VlanIdCriterion(VlanId vlanId) {
this.vlanId = vlanId;
}
......@@ -248,7 +248,7 @@ public final class Criteria {
return Type.VLAN_VID;
}
public VLANID vlanId() {
public VlanId vlanId() {
return vlanId;
}
......
......@@ -8,9 +8,9 @@ import org.onlab.onos.net.flow.instructions.L2ModificationInstruction.ModEtherIn
import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.L3SubType;
import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPInstruction;
import org.onlab.onos.net.flow.instructions.L3ModificationInstruction.ModIPProtoInstruction;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
/**
* Factory class for creating various traffic treatment instructions.
*/
......@@ -45,7 +45,7 @@ public final class Instructions {
* @param addr the mac address to modify to.
* @return a l2 modification
*/
public static L2ModificationInstruction modL2Src(MACAddress addr) {
public static L2ModificationInstruction modL2Src(MacAddress addr) {
checkNotNull(addr, "Src l2 address cannot be null");
return new ModEtherInstruction(L2SubType.L2_SRC, addr);
}
......@@ -55,7 +55,7 @@ public final class Instructions {
* @param addr the mac address to modify to.
* @return a L2 modification
*/
public static L2ModificationInstruction modL2Dst(MACAddress addr) {
public static L2ModificationInstruction modL2Dst(MacAddress addr) {
checkNotNull(addr, "Dst l2 address cannot be null");
return new L2ModificationInstruction.ModEtherInstruction(L2SubType.L2_DST, addr);
}
......@@ -75,7 +75,7 @@ public final class Instructions {
* @param vlanId the vlan id to modify to.
* @return a L2 modification
*/
public static L2ModificationInstruction modVlanId(VLANID vlanId) {
public static L2ModificationInstruction modVlanId(VlanId vlanId) {
checkNotNull(vlanId, "VLAN id cannot be null");
return new L2ModificationInstruction.ModVlanIdInstruction(vlanId);
}
......@@ -95,7 +95,7 @@ public final class Instructions {
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public static L3ModificationInstruction modL3Src(IPAddress addr) {
public static L3ModificationInstruction modL3Src(IpAddress addr) {
checkNotNull(addr, "Src l3 address cannot be null");
return new ModIPInstruction(L3SubType.L3_SRC, addr);
}
......@@ -105,7 +105,7 @@ public final class Instructions {
* @param addr the ip address to modify to.
* @return a L3 modification
*/
public static L3ModificationInstruction modL3Dst(IPAddress addr) {
public static L3ModificationInstruction modL3Dst(IpAddress addr) {
checkNotNull(addr, "Dst l3 address cannot be null");
return new ModIPInstruction(L3SubType.L3_DST, addr);
}
......
package org.onlab.onos.net.flow.instructions;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
/**
* Abstraction of a single traffic treatment step.
......@@ -56,9 +56,9 @@ public abstract class L2ModificationInstruction implements Instruction {
public static final class ModEtherInstruction extends L2ModificationInstruction {
private final SubType subtype;
private final MACAddress mac;
private final MacAddress mac;
public ModEtherInstruction(SubType subType, MACAddress addr) {
public ModEtherInstruction(SubType subType, MacAddress addr) {
this.subtype = subType;
this.mac = addr;
}
......@@ -68,7 +68,7 @@ public abstract class L2ModificationInstruction implements Instruction {
return this.subtype;
}
public MACAddress mac() {
public MacAddress mac() {
return this.mac;
}
......@@ -101,9 +101,9 @@ public abstract class L2ModificationInstruction implements Instruction {
*/
public static final class ModVlanIdInstruction extends L2ModificationInstruction {
public final VLANID vlanId;
public final VlanId vlanId;
public ModVlanIdInstruction(VLANID vlanId) {
public ModVlanIdInstruction(VlanId vlanId) {
this.vlanId = vlanId;
}
......@@ -112,7 +112,7 @@ public abstract class L2ModificationInstruction implements Instruction {
return L2SubType.VLAN_ID;
}
public VLANID vlanId() {
public VlanId vlanId() {
return this.vlanId;
}
......
package org.onlab.onos.net.flow.instructions;
import org.onlab.packet.IPAddress;
import org.onlab.packet.IpAddress;
/**
* Abstraction of a single traffic treatment step.
......@@ -47,9 +47,9 @@ public abstract class L3ModificationInstruction implements Instruction {
public static final class ModIPInstruction extends L3ModificationInstruction {
private final SubType subtype;
private final IPAddress ip;
private final IpAddress ip;
public ModIPInstruction(SubType subType, IPAddress addr) {
public ModIPInstruction(SubType subType, IpAddress addr) {
this.subtype = subType;
this.ip = addr;
}
......@@ -59,7 +59,7 @@ public abstract class L3ModificationInstruction implements Instruction {
return this.subtype;
}
public IPAddress ip() {
public IpAddress ip() {
return this.ip;
}
......
......@@ -6,42 +6,42 @@ import java.util.HashSet;
import java.util.Set;
import org.onlab.onos.net.HostLocation;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.ImmutableSet;
public class DefaultHostDescription implements HostDescription {
private final MACAddress mac;
private final VLANID vlan;
private final MacAddress mac;
private final VlanId vlan;
private final HostLocation location;
private final Set<IPAddress> ips;
private final Set<IpAddress> ips;
public DefaultHostDescription(MACAddress mac, VLANID vlan,
public DefaultHostDescription(MacAddress mac, VlanId vlan,
HostLocation loc) {
this.mac = mac;
this.vlan = vlan;
this.location = loc;
this.ips = new HashSet<IPAddress>();
this.ips = new HashSet<IpAddress>();
}
public DefaultHostDescription(MACAddress mac, VLANID vlan,
HostLocation loc, Set<IPAddress> ips) {
public DefaultHostDescription(MacAddress mac, VlanId vlan,
HostLocation loc, Set<IpAddress> ips) {
this.mac = mac;
this.vlan = vlan;
this.location = loc;
this.ips = new HashSet<IPAddress>(ips);
this.ips = new HashSet<IpAddress>(ips);
}
@Override
public MACAddress hwAddress() {
public MacAddress hwAddress() {
return mac;
}
@Override
public VLANID vlan() {
public VlanId vlan() {
return vlan;
}
......@@ -51,7 +51,7 @@ public class DefaultHostDescription implements HostDescription {
}
@Override
public Set<IPAddress> ipAddresses() {
public Set<IpAddress> ipAddresses() {
return ImmutableSet.copyOf(ips);
}
......
......@@ -4,9 +4,9 @@ import java.util.Set;
import org.onlab.onos.net.Description;
import org.onlab.onos.net.HostLocation;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
/**
* Information describing host and its location.
......@@ -18,14 +18,14 @@ public interface HostDescription extends Description {
*
* @return the MAC address of this host
*/
MACAddress hwAddress();
MacAddress hwAddress();
/**
* Returns the VLAN associated with this host.
*
* @return the VLAN ID value
*/
VLANID vlan();
VlanId vlan();
/**
* Returns the location of the host on the network edge.
......@@ -39,6 +39,6 @@ public interface HostDescription extends Description {
*
* @return a set of IP addresses.
*/
Set<IPAddress> ipAddresses();
Set<IpAddress> ipAddresses();
}
......
......@@ -4,9 +4,9 @@ import org.onlab.onos.net.ConnectPoint;
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.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import java.util.Set;
......@@ -44,7 +44,7 @@ public interface HostService {
* @return set of hosts in the given vlan id
*/
// FIXME: change long to VLanId
Set<Host> getHostsByVlan(VLANID vlanId);
Set<Host> getHostsByVlan(VlanId vlanId);
/**
* Returns the set of hosts that have the specified MAC address.
......@@ -52,7 +52,7 @@ public interface HostService {
* @param mac mac address
* @return set of hosts with the given mac
*/
Set<Host> getHostsByMac(MACAddress mac);
Set<Host> getHostsByMac(MacAddress mac);
/**
* Returns the set of hosts that have the specified IP address.
......@@ -60,7 +60,7 @@ public interface HostService {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set<Host> getHostsByIp(IPAddress ip);
Set<Host> getHostsByIp(IpAddress ip);
/**
* Returns the set of hosts whose most recent location is the specified
......
......@@ -3,8 +3,8 @@ package org.onlab.onos.net;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import static org.onlab.onos.net.HostId.hostId;
......@@ -13,10 +13,10 @@ import static org.onlab.onos.net.HostId.hostId;
*/
public class HostIdTest extends ElementIdTest {
private static final MACAddress MAC1 = MACAddress.valueOf("00:11:00:00:00:01");
private static final MACAddress MAC2 = MACAddress.valueOf("00:22:00:00:00:02");
private static final VLANID VLAN1 = VLANID.vlanId((short) 11);
private static final VLANID VLAN2 = VLANID.vlanId((short) 22);
private static final MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01");
private static final MacAddress MAC2 = MacAddress.valueOf("00:22:00:00:00:02");
private static final VlanId VLAN1 = VlanId.vlanId((short) 11);
private static final VlanId VLAN2 = VlanId.vlanId((short) 22);
@Override
@Test
......
......@@ -5,9 +5,9 @@ import static org.onlab.onos.net.DeviceId.deviceId;
import java.util.Set;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.Sets;
......@@ -20,13 +20,13 @@ public abstract class TestDeviceParams {
protected static final ProviderId PID = new ProviderId("foo");
protected static final DeviceId DID1 = deviceId("of:foo");
protected static final DeviceId DID2 = deviceId("of:bar");
protected static final MACAddress MAC1 = MACAddress.valueOf("00:11:00:00:00:01");
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 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 MacAddress MAC1 = MacAddress.valueOf("00:11:00:00:00:01");
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 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<IPAddress> IPSET1 = Sets.newHashSet(IP1, IP2);
protected static final Set<IPAddress> 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);
}
......
......@@ -9,9 +9,9 @@ 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.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.Sets;
......@@ -20,16 +20,16 @@ import com.google.common.collect.Sets;
*/
public class DefualtHostDecriptionTest {
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 MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
private static final VlanId VLAN = VlanId.vlanId((short) 10);
private static final HostLocation LOC = new HostLocation(
DeviceId.deviceId("of:foo"),
PortNumber.portNumber(100),
123L
);
private static final Set<IPAddress> IPS = Sets.newHashSet(
IPAddress.valueOf("10.0.0.1"),
IPAddress.valueOf("10.0.0.2")
private static final Set<IpAddress> IPS = Sets.newHashSet(
IpAddress.valueOf("10.0.0.1"),
IpAddress.valueOf("10.0.0.2")
);
@Test
......
......@@ -11,25 +11,25 @@ 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.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.Sets;
public class HostEventTest extends AbstractEventTest {
private Host createHost() {
MACAddress mac = MACAddress.valueOf("00:00:11:00:00:01");
VLANID vlan = VLANID.vlanId((short) 10);
MacAddress mac = MacAddress.valueOf("00:00:11:00:00:01");
VlanId vlan = VlanId.vlanId((short) 10);
HostLocation loc = new HostLocation(
DeviceId.deviceId("of:foo"),
PortNumber.portNumber(100),
123L
);
Set<IPAddress> ipset = Sets.newHashSet(
IPAddress.valueOf("10.0.0.1"),
IPAddress.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);
......
......@@ -4,9 +4,9 @@ import org.onlab.onos.net.ConnectPoint;
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.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import java.util.Set;
......@@ -30,17 +30,17 @@ public class HostServiceAdapter implements HostService {
}
@Override
public Set<Host> getHostsByVlan(VLANID vlanId) {
public Set<Host> getHostsByVlan(VlanId vlanId) {
return null;
}
@Override
public Set<Host> getHostsByMac(MACAddress mac) {
public Set<Host> getHostsByMac(MacAddress mac) {
return null;
}
@Override
public Set<Host> getHostsByIp(IPAddress ip) {
public Set<Host> getHostsByIp(IpAddress ip) {
return null;
}
......
......@@ -22,9 +22,9 @@ import org.onlab.onos.net.host.HostProviderService;
import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
import java.util.Set;
......@@ -87,18 +87,18 @@ public class SimpleHostManager
}
@Override
public Set<Host> getHostsByVlan(VLANID vlanId) {
public Set<Host> getHostsByVlan(VlanId vlanId) {
return store.getHosts(vlanId);
}
@Override
public Set<Host> getHostsByMac(MACAddress mac) {
public Set<Host> getHostsByMac(MacAddress mac) {
checkNotNull(mac, "MAC address cannot be null");
return store.getHosts(mac);
}
@Override
public Set<Host> getHostsByIp(IPAddress ip) {
public Set<Host> getHostsByIp(IpAddress ip) {
checkNotNull(ip, "IP address cannot be null");
return store.getHosts(ip);
}
......
......@@ -19,9 +19,9 @@ import org.onlab.onos.net.HostId;
import org.onlab.onos.net.host.HostDescription;
import org.onlab.onos.net.host.HostEvent;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
......@@ -153,7 +153,7 @@ public class SimpleHostStore {
* @param vlanId vlan id
* @return set of hosts in the vlan
*/
Set<Host> getHosts(VLANID vlanId) {
Set<Host> getHosts(VlanId vlanId) {
Set<Host> vlanset = new HashSet<Host>();
for (Host h : hosts.values()) {
if (h.vlan().equals(vlanId)) {
......@@ -169,7 +169,7 @@ public class SimpleHostStore {
* @param mac mac address
* @return set of hosts with the given mac
*/
Set<Host> getHosts(MACAddress mac) {
Set<Host> getHosts(MacAddress mac) {
Set<Host> macset = new HashSet<>();
for (Host h : hosts.values()) {
if (h.mac().equals(mac)) {
......@@ -185,7 +185,7 @@ public class SimpleHostStore {
* @param ip ip address
* @return set of hosts with the given IP
*/
Set<Host> getHosts(IPAddress ip) {
Set<Host> getHosts(IpAddress ip) {
Set<Host> ipset = new HashSet<>();
for (Host h : hosts.values()) {
if (h.ipAddresses().contains(ip)) {
......
......@@ -28,9 +28,9 @@ import org.onlab.onos.net.host.HostProviderRegistry;
import org.onlab.onos.net.host.HostProviderService;
import org.onlab.onos.net.provider.AbstractProvider;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IPAddress;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
......@@ -44,17 +44,17 @@ public class SimpleHostManagerTest {
private static final ProviderId PID = new ProviderId("foo");
private static final VLANID VLAN1 = VLANID.vlanId((short) 1);
private static final VLANID VLAN2 = VLANID.vlanId((short) 2);
private static final MACAddress MAC1 = MACAddress.valueOf("00:00:11:00:00:01");
private static final MACAddress MAC2 = MACAddress.valueOf("00:00:22:00:00:02");
private static final VlanId VLAN1 = VlanId.vlanId((short) 1);
private static final VlanId VLAN2 = VlanId.vlanId((short) 2);
private static final MacAddress MAC1 = MacAddress.valueOf("00:00:11:00:00:01");
private static final MacAddress MAC2 = MacAddress.valueOf("00:00:22:00:00:02");
private static final HostId HID1 = HostId.hostId(MAC1, VLAN1);
private static final HostId HID2 = HostId.hostId(MAC2, VLAN1);
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 Set<IPAddress> IPSET1 = Sets.newHashSet(IP1);
private static final Set<IPAddress> IPSET2 = Sets.newHashSet(IP2);
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 Set<IpAddress> IPSET1 = Sets.newHashSet(IP1);
private static final Set<IpAddress> IPSET2 = Sets.newHashSet(IP2);
private static final DeviceId DID1 = DeviceId.deviceId("of:001");
private static final DeviceId DID2 = DeviceId.deviceId("of:002");
......@@ -96,8 +96,8 @@ public class SimpleHostManagerTest {
mgr.eventDispatcher = null;
}
private void detect(HostId hid, MACAddress mac, VLANID vlan,
HostLocation loc, Set<IPAddress> ips) {
private void detect(HostId hid, MacAddress mac, VlanId vlan,
HostLocation loc, Set<IpAddress> ips) {
HostDescription descr = new DefaultHostDescription(mac, vlan, loc, ips);
providerService.hostDetected(hid, descr);
assertNotNull("host should be found", mgr.getHost(hid));
......
......@@ -31,8 +31,8 @@ import org.onlab.onos.of.controller.OpenFlowPacketContext;
import org.onlab.onos.of.controller.PacketListener;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
import org.onlab.packet.IPAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.IpAddress;
import org.onlab.packet.VlanId;
import org.slf4j.Logger;
/**
......@@ -94,7 +94,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
// Potentially a new or moved host
if (eth.getEtherType() == Ethernet.TYPE_ARP) {
VLANID vlan = VLANID.vlanId(eth.getVlanID());
VlanId vlan = VlanId.vlanId(eth.getVlanID());
ConnectPoint heardOn = new ConnectPoint(deviceId(Dpid.uri(pktCtx.dpid())),
portNumber(pktCtx.inPort()));
......@@ -110,7 +110,7 @@ public class OpenFlowHostProvider extends AbstractProvider implements HostProvid
HostId hid = HostId.hostId(eth.getSourceMAC(), vlan);
ARP arp = (ARP) eth.getPayload();
Set<IPAddress> ips = newHashSet(IPAddress.valueOf(arp.getSenderProtocolAddress()));
Set<IpAddress> ips = newHashSet(IpAddress.valueOf(arp.getSenderProtocolAddress()));
HostDescription hdescr =
new DefaultHostDescription(eth.getSourceMAC(), vlan, hloc, ips);
providerService.hostDetected(hid, hdescr);
......
......@@ -19,8 +19,8 @@ import org.onlab.onos.of.controller.OpenflowControllerAdapter;
import org.onlab.onos.of.controller.PacketListener;
import org.onlab.packet.ARP;
import org.onlab.packet.Ethernet;
import org.onlab.packet.MACAddress;
import org.onlab.packet.VLANID;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.projectfloodlight.openflow.protocol.OFMessage;
import org.projectfloodlight.openflow.types.OFPort;
......@@ -35,9 +35,9 @@ public class OpenFlowHostProviderTest {
private static final Dpid DPID2 = new Dpid(200);
private static final Dpid DPID3 = new Dpid(300);
private static final VLANID VLAN = VLANID.vlanId();
private static final MACAddress MAC = MACAddress.valueOf("00:00:11:00:00:01");
private static final MACAddress BCMAC = MACAddress.valueOf("ff:ff:ff:ff:ff:ff");
private static final VlanId VLAN = VlanId.vlanId();
private static final MacAddress MAC = MacAddress.valueOf("00:00:11:00:00:01");
private static final MacAddress BCMAC = MacAddress.valueOf("ff:ff:ff:ff:ff:ff");
private static final byte[] IP = new byte[]{10, 0, 0, 1};
private OpenFlowHostProvider provider = new OpenFlowHostProvider();
......
......@@ -60,8 +60,8 @@ public class Ethernet extends BasePacket {
Ethernet.etherTypeClassMap.put(Ethernet.TYPE_LLDP, LLDP.class);
}
protected MACAddress destinationMACAddress;
protected MACAddress sourceMACAddress;
protected MacAddress destinationMACAddress;
protected MacAddress sourceMACAddress;
protected byte priorityCode;
protected short vlanID;
protected short etherType;
......@@ -89,7 +89,7 @@ public class Ethernet extends BasePacket {
*
* @return the destination MAC
*/
public MACAddress getDestinationMAC() {
public MacAddress getDestinationMAC() {
return this.destinationMACAddress;
}
......@@ -100,7 +100,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public Ethernet setDestinationMACAddress(final byte[] destMac) {
this.destinationMACAddress = MACAddress.valueOf(destMac);
this.destinationMACAddress = MacAddress.valueOf(destMac);
return this;
}
......@@ -111,7 +111,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public Ethernet setDestinationMACAddress(final String destMac) {
this.destinationMACAddress = MACAddress.valueOf(destMac);
this.destinationMACAddress = MacAddress.valueOf(destMac);
return this;
}
......@@ -129,7 +129,7 @@ public class Ethernet extends BasePacket {
*
* @return the source MACAddress
*/
public MACAddress getSourceMAC() {
public MacAddress getSourceMAC() {
return this.sourceMACAddress;
}
......@@ -140,7 +140,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public Ethernet setSourceMACAddress(final byte[] sourceMac) {
this.sourceMACAddress = MACAddress.valueOf(sourceMac);
this.sourceMACAddress = MacAddress.valueOf(sourceMac);
return this;
}
......@@ -151,7 +151,7 @@ public class Ethernet extends BasePacket {
* @return the Ethernet frame
*/
public Ethernet setSourceMACAddress(final String sourceMac) {
this.sourceMACAddress = MACAddress.valueOf(sourceMac);
this.sourceMACAddress = MacAddress.valueOf(sourceMac);
return this;
}
......@@ -288,18 +288,18 @@ public class Ethernet extends BasePacket {
}
final ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
if (this.destinationMACAddress == null) {
this.destinationMACAddress = MACAddress.valueOf(new byte[6]);
this.destinationMACAddress = MacAddress.valueOf(new byte[6]);
}
final byte[] dstAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
final byte[] dstAddr = new byte[MacAddress.MAC_ADDRESS_LENGTH];
bb.get(dstAddr);
this.destinationMACAddress = MACAddress.valueOf(dstAddr);
this.destinationMACAddress = MacAddress.valueOf(dstAddr);
if (this.sourceMACAddress == null) {
this.sourceMACAddress = MACAddress.valueOf(new byte[6]);
this.sourceMACAddress = MacAddress.valueOf(new byte[6]);
}
final byte[] srcAddr = new byte[MACAddress.MAC_ADDRESS_LENGTH];
final byte[] srcAddr = new byte[MacAddress.MAC_ADDRESS_LENGTH];
bb.get(srcAddr);
this.sourceMACAddress = MACAddress.valueOf(srcAddr);
this.sourceMACAddress = MacAddress.valueOf(srcAddr);
short ethType = bb.getShort();
if (ethType == (short) 0x8100) {
......@@ -361,7 +361,7 @@ public class Ethernet extends BasePacket {
* @return The macAddress as a byte array
*/
public static byte[] toMACAddress(final String macAddress) {
return MACAddress.valueOf(macAddress).toBytes();
return MacAddress.valueOf(macAddress).toBytes();
}
/**
......@@ -372,7 +372,7 @@ public class Ethernet extends BasePacket {
* @return a long containing the mac address bytes
*/
public static long toLong(final byte[] macAddress) {
return MACAddress.valueOf(macAddress).toLong();
return MacAddress.valueOf(macAddress).toLong();
}
/**
......@@ -382,7 +382,7 @@ public class Ethernet extends BasePacket {
* @return the bytes of the mac address
*/
public static byte[] toByteArray(final long macAddress) {
return MACAddress.valueOf(macAddress).toBytes();
return MacAddress.valueOf(macAddress).toBytes();
}
/*
......
......@@ -5,7 +5,7 @@ import java.util.Arrays;
/**
* A class representing an IPv4 address.
*/
public class IPAddress {
public class IpAddress {
//IP Versions
public enum Version { INET, INET6 };
......@@ -18,7 +18,7 @@ public class IPAddress {
//does it make more sense to have a integral address?
protected byte[] octets;
protected IPAddress(Version ver, byte[] octets) {
protected IpAddress(Version ver, byte[] octets) {
this.version = ver;
this.octets = Arrays.copyOf(octets, INET_LEN);
}
......@@ -29,8 +29,8 @@ public class IPAddress {
* @param address a byte array
* @return an IP address
*/
public static IPAddress valueOf(byte [] address) {
return new IPAddress(Version.INET, address);
public static IpAddress valueOf(byte [] address) {
return new IpAddress(Version.INET, address);
}
/**
......@@ -39,13 +39,13 @@ public class IPAddress {
* @param address an integer representing an IP value
* @return an IP address
*/
public static IPAddress valueOf(int address) {
public static IpAddress valueOf(int address) {
byte [] bytes = new byte [INET_LEN];
for (int i = 0; i < INET_LEN; i++) {
bytes[i] = (byte) ((address >> (INET_LEN - (i + 1)) * 8) & 0xff);
}
return new IPAddress(Version.INET, bytes);
return new IpAddress(Version.INET, bytes);
}
/**
......@@ -55,7 +55,7 @@ public class IPAddress {
* @param address a string representing an IP address, e.g. "10.0.0.1"
* @return an IP address
*/
public static IPAddress valueOf(String address) {
public static IpAddress valueOf(String address) {
final String [] parts = address.split("\\.");
if (parts.length != INET_LEN) {
throw new IllegalArgumentException("Malformed IP address string; "
......@@ -65,7 +65,7 @@ public class IPAddress {
for (int i = 0; i < INET_LEN; i++) {
bytes[i] = Byte.parseByte(parts[i], 10);
}
return new IPAddress(Version.INET, bytes);
return new IpAddress(Version.INET, bytes);
}
/**
......@@ -119,8 +119,8 @@ public class IPAddress {
@Override
public boolean equals(Object obj) {
if (obj instanceof IPAddress) {
IPAddress other = (IPAddress) obj;
if (obj instanceof IpAddress) {
IpAddress other = (IpAddress) obj;
if (this.version.equals(other.version)
&& (Arrays.equals(this.octets, other.octets))) {
......
......@@ -21,12 +21,12 @@ import java.util.Arrays;
* The class representing MAC address.
*
*/
public class MACAddress {
public class MacAddress {
public static final int MAC_ADDRESS_LENGTH = 6;
private byte[] address = new byte[MACAddress.MAC_ADDRESS_LENGTH];
private byte[] address = new byte[MacAddress.MAC_ADDRESS_LENGTH];
public MACAddress(final byte[] address) {
this.address = Arrays.copyOf(address, MACAddress.MAC_ADDRESS_LENGTH);
public MacAddress(final byte[] address) {
this.address = Arrays.copyOf(address, MacAddress.MAC_ADDRESS_LENGTH);
}
/**
......@@ -40,21 +40,21 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the string cannot be parsed as a MAC address.
*/
public static MACAddress valueOf(final String address) {
public static MacAddress valueOf(final String address) {
final String[] elements = address.split(":");
if (elements.length != MACAddress.MAC_ADDRESS_LENGTH) {
if (elements.length != MacAddress.MAC_ADDRESS_LENGTH) {
throw new IllegalArgumentException(
"Specified MAC Address must contain 12 hex digits"
+ " separated pairwise by :'s.");
}
final byte[] addressInBytes = new byte[MACAddress.MAC_ADDRESS_LENGTH];
for (int i = 0; i < MACAddress.MAC_ADDRESS_LENGTH; i++) {
final byte[] addressInBytes = new byte[MacAddress.MAC_ADDRESS_LENGTH];
for (int i = 0; i < MacAddress.MAC_ADDRESS_LENGTH; i++) {
final String element = elements[i];
addressInBytes[i] = (byte) Integer.parseInt(element, 16);
}
return new MACAddress(addressInBytes);
return new MacAddress(addressInBytes);
}
/**
......@@ -68,13 +68,13 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the byte array cannot be parsed as a MAC address.
*/
public static MACAddress valueOf(final byte[] address) {
if (address.length != MACAddress.MAC_ADDRESS_LENGTH) {
public static MacAddress valueOf(final byte[] address) {
if (address.length != MacAddress.MAC_ADDRESS_LENGTH) {
throw new IllegalArgumentException("the length is not "
+ MACAddress.MAC_ADDRESS_LENGTH);
+ MacAddress.MAC_ADDRESS_LENGTH);
}
return new MACAddress(address);
return new MacAddress(address);
}
/**
......@@ -90,13 +90,13 @@ public class MACAddress {
* @throws IllegalArgumentException
* if the long value cannot be parsed as a MAC address.
*/
public static MACAddress valueOf(final long address) {
public static MacAddress valueOf(final long address) {
final byte[] addressInBytes = new byte[] {
(byte) (address >> 40 & 0xff), (byte) (address >> 32 & 0xff),
(byte) (address >> 24 & 0xff), (byte) (address >> 16 & 0xff),
(byte) (address >> 8 & 0xff), (byte) (address >> 0 & 0xff) };
return new MACAddress(addressInBytes);
return new MacAddress(addressInBytes);
}
/**
......@@ -165,11 +165,11 @@ public class MACAddress {
return true;
}
if (!(o instanceof MACAddress)) {
if (!(o instanceof MacAddress)) {
return false;
}
final MACAddress other = (MACAddress) o;
final MacAddress other = (MacAddress) o;
return Arrays.equals(this.address, other.address);
}
......
......@@ -4,7 +4,7 @@ package org.onlab.packet;
* Representation of a VLAN ID.
*/
// FIXME: This will end-up looking like a constant; we should name it 'VlanId', 'IpAddress', 'MacAddress'.
public class VLANID {
public class VlanId {
private final short value;
// Based on convention used elsewhere? Check and change if needed
......@@ -12,28 +12,28 @@ public class VLANID {
// A VLAN ID is actually 12 bits of a VLAN tag.
public static final short MAX_VLAN = 4095;
protected VLANID() {
protected VlanId() {
this.value = UNTAGGED;
}
protected VLANID(short value) {
protected VlanId(short value) {
this.value = value;
}
public static VLANID vlanId() {
return new VLANID(UNTAGGED);
public static VlanId vlanId() {
return new VlanId(UNTAGGED);
}
public static VLANID vlanId(short value) {
public static VlanId vlanId(short value) {
if (value == UNTAGGED) {
return new VLANID();
return new VlanId();
}
if (value > MAX_VLAN) {
throw new IllegalArgumentException(
"value exceeds allowed maximum VLAN ID value (4095)");
}
return new VLANID(value);
return new VlanId(value);
}
public short toShort() {
......@@ -46,9 +46,9 @@ public class VLANID {
return true;
}
if (obj instanceof VLANID) {
if (obj instanceof VlanId) {
VLANID other = (VLANID) obj;
VlanId other = (VlanId) obj;
if (this.value == other.value) {
return true;
......
......@@ -5,7 +5,7 @@ import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import org.junit.Test;
import org.onlab.packet.IPAddress.Version;
import org.onlab.packet.IpAddress.Version;
import com.google.common.testing.EqualsTester;
......@@ -19,11 +19,11 @@ public class IPAddressTest {
@Test
public void testEquality() {
IPAddress ip1 = IPAddress.valueOf(BYTES1);
IPAddress ip2 = IPAddress.valueOf(BYTES2);
IPAddress ip3 = IPAddress.valueOf(INTVAL1);
IPAddress ip4 = IPAddress.valueOf(INTVAL2);
IPAddress ip5 = IPAddress.valueOf(STRVAL);
IpAddress ip1 = IpAddress.valueOf(BYTES1);
IpAddress ip2 = IpAddress.valueOf(BYTES2);
IpAddress ip3 = IpAddress.valueOf(INTVAL1);
IpAddress ip4 = IpAddress.valueOf(INTVAL2);
IpAddress ip5 = IpAddress.valueOf(STRVAL);
new EqualsTester().addEqualityGroup(ip1, ip3)
.addEqualityGroup(ip2, ip5)
......@@ -33,7 +33,7 @@ public class IPAddressTest {
@Test
public void basics() {
IPAddress ip4 = IPAddress.valueOf(BYTES1);
IpAddress ip4 = IpAddress.valueOf(BYTES1);
assertEquals("incorrect IP Version", Version.INET, ip4.version());
assertEquals("faulty toOctets()", Arrays.equals(
new byte [] {0x0, 0x0, 0x0, 0xa}, ip4.toOctets()), true);
......
......@@ -11,28 +11,28 @@ public class VLANIDTest {
@Test
public void testEquality() {
VLANID vlan1 = VLANID.vlanId((short) -1);
VLANID vlan2 = VLANID.vlanId((short) 100);
VLANID vlan3 = VLANID.vlanId((short) 100);
VlanId vlan1 = VlanId.vlanId((short) -1);
VlanId vlan2 = VlanId.vlanId((short) 100);
VlanId vlan3 = VlanId.vlanId((short) 100);
new EqualsTester().addEqualityGroup(VLANID.vlanId(), vlan1)
new EqualsTester().addEqualityGroup(VlanId.vlanId(), vlan1)
.addEqualityGroup(vlan2, vlan3)
.addEqualityGroup(VLANID.vlanId((short) 10));
.addEqualityGroup(VlanId.vlanId((short) 10));
}
@Test
public void basics() {
// purposefully create UNTAGGED VLAN
VLANID vlan1 = VLANID.vlanId((short) 10);
VLANID vlan2 = VLANID.vlanId((short) -1);
VlanId vlan1 = VlanId.vlanId((short) 10);
VlanId vlan2 = VlanId.vlanId((short) -1);
assertEquals("incorrect VLAN value", 10, vlan1.toShort());
assertEquals("invalid untagged value", VLANID.UNTAGGED, vlan2.toShort());
assertEquals("invalid untagged value", VlanId.UNTAGGED, vlan2.toShort());
}
@Test(expected = IllegalArgumentException.class)
public void testIllicitVLAN() {
VLANID.vlanId((short) 5000);
VlanId.vlanId((short) 5000);
}
}
......