added default host constructs to API
Change-Id: I3ef3e08559c7c4d73d8e4aee693589ee0830ed85
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java b/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
new file mode 100644
index 0000000..2129082
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/host/DefaultHostDescription.java
@@ -0,0 +1,58 @@
+package org.onlab.onos.net.host;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.onlab.onos.net.HostLocation;
+import org.onlab.packet.IPv4;
+import org.onlab.packet.MACAddress;
+
+public class DefaultHostDescription implements HostDescription {
+
+ private final MACAddress mac;
+ private final short vlan;
+ private final HostLocation location;
+ private final Set<IPv4> ips;
+
+ public DefaultHostDescription(MACAddress mac, short vlan,
+ HostLocation loc, Set<IPv4> ips) {
+ this.mac = mac;
+ this.vlan = vlan;
+ this.location = loc;
+ this.ips = new HashSet<IPv4>(ips);
+ }
+
+ @Override
+ public MACAddress hwAddress() {
+ return mac;
+ }
+
+ @Override
+ public short vlan() {
+ return vlan;
+ }
+
+ @Override
+ public HostLocation location() {
+ return location;
+ }
+
+ @Override
+ public Set<IPv4> ipAddresses() {
+ return Collections.unmodifiableSet(ips);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("mac", mac)
+ .add("vlan", vlan)
+ .add("location", location)
+ .add("ipAddresses", ips)
+ .toString();
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java b/core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
index e3c67b9..62a4c9a 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/HostDescription.java
@@ -1,11 +1,43 @@
package org.onlab.onos.net.host;
+import java.util.Set;
+
+import org.onlab.onos.net.Description;
+import org.onlab.onos.net.HostLocation;
+import org.onlab.packet.IPv4;
+import org.onlab.packet.MACAddress;
+
/**
* Information describing host and its location.
*/
-public interface HostDescription {
+public interface HostDescription extends Description {
- // IP, MAC, VLAN-ID, HostLocation -> (ConnectionPoint + timestamp)
+ /**
+ * Returns the MAC address associated with this host (NIC).
+ *
+ * @return the MAC address of this host
+ */
+ MACAddress hwAddress();
+
+ /**
+ * Returns the VLAN associated with this host.
+ *
+ * @return the VLAN ID value
+ */
+ short vlan();
+
+ /**
+ * Returns the location of the host on the network edge.
+ *
+ * @return the network location
+ */
+ HostLocation location();
+
+ /**
+ * Returns zero or more IP address(es) associated with this host's MAC.
+ *
+ * @return a set of IP addresses.
+ */
+ Set<IPv4> ipAddresses();
}
-