Jonathan Hart

Added IP addresses to Port

package org.onlab.onos.net;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import static com.google.common.base.MoreObjects.toStringHelper;
import org.onlab.packet.IpAddress;
/**
* Default port implementation.
......@@ -13,6 +17,9 @@ public class DefaultPort implements Port {
private final PortNumber number;
private final boolean isEnabled;
// Attributes
private final Set<IpAddress> ipAddresses;
/**
* Creates a network element attributed to the specified provider.
*
......@@ -22,9 +29,24 @@ public class DefaultPort implements Port {
*/
public DefaultPort(Element element, PortNumber number,
boolean isEnabled) {
this(element, number, isEnabled, null);
}
/**
* Creates a network element attributed to the specified provider.
*
* @param element parent network element
* @param number port number
* @param isEnabled indicator whether the port is up and active
* @param ipAddresses set of IP addresses assigned to the port
*/
public DefaultPort(Element element, PortNumber number,
boolean isEnabled, Set<IpAddress> ipAddresses) {
this.element = element;
this.number = number;
this.isEnabled = isEnabled;
this.ipAddresses = (ipAddresses == null) ? null :
Collections.unmodifiableSet(ipAddresses);
}
@Override
......@@ -67,4 +89,9 @@ public class DefaultPort implements Port {
return element;
}
@Override
public Set<IpAddress> ipAddresses() {
return ipAddresses;
}
}
......
package org.onlab.onos.net;
import java.util.Set;
import org.onlab.packet.IpAddress;
/**
* Abstraction of a network port.
*/
......@@ -28,4 +32,12 @@ public interface Port {
// set of port attributes
/**
* Returns the set of IP addresses that are logically configured on this
* port.
*
* @return the set of IP addresses configured on the port. The set is empty
* if no addresses are configured.
*/
Set<IpAddress> ipAddresses();
}
......