Added APIs for binding address information to ports and for monitoring hosts/ips
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java b/core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
index d94449a..29f6c04 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/HostAdminService.java
@@ -1,6 +1,11 @@
package org.onlab.onos.net.host;
+import java.util.Set;
+
+import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.HostId;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
/**
* Service for administering the inventory of end-station hosts.
@@ -14,4 +19,42 @@
*/
void removeHost(HostId hostId);
+ /**
+ * Binds an IP address and optional MAC address to the given connection
+ * point.
+ * <p/>
+ * This method will overwrite any previously held address information for
+ * the connection point.
+ *
+ * @param ip the IP address to bind to the connection point. This parameter
+ * is mandatory and cannot be null.
+ * @param mac the optional MAC address to bind to the connection point. Can
+ * be set to null if no MAC address needs to be bound.
+ * @param connectPoint the connection point to bind the addresses to
+ */
+ void bindAddressesToPort(IpAddress ip, MacAddress mac, ConnectPoint connectPoint);
+
+ /**
+ * Removes all address information for the given connection point.
+ *
+ * @param connectPoint the connection point to remove address information
+ */
+ void unbindAddressesFromPort(ConnectPoint connectPoint);
+
+ /**
+ * Returns the addresses information for all connection points.
+ *
+ * @return the set of address bindings for all connection points
+ */
+ Set<PortAddresses> getAddressBindings();
+
+ /**
+ * Retrieves the addresses that have been bound to the given connection
+ * point.
+ *
+ * @param connectPoint the connection point to retrieve address bindings
+ * for
+ * @return addresses bound to the port
+ */
+ PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint);
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/HostService.java b/core/api/src/main/java/org/onlab/onos/net/host/HostService.java
index 3717bea..a0f51b3 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/HostService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/HostService.java
@@ -6,6 +6,7 @@
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.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -87,7 +88,7 @@
*
* @param ip IP address of the host to monitor
*/
- void monitorIp(IpPrefix ip);
+ void startMonitoringIp(IpAddress ip);
/**
* Stops the host service from monitoring an IP address.
@@ -95,7 +96,18 @@
* @param ip IP address to stop monitoring
*/
// TODO clients can cancel other client's requests
- void stopMonitoringIp(IpPrefix ip);
+ void stopMonitoringIp(IpAddress ip);
+
+ /**
+ * Requests the host service to resolve the MAC address for the given IP
+ * address.
+ * <p/>
+ * This will trigger a notification to the host listeners if the MAC
+ * address is found.
+ *
+ * @param ip IP address to find the MAC address for
+ */
+ void requestMac(IpAddress ip);
/**
* Adds the specified host listener.
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java b/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
index ea316b2..e3667e3 100644
--- a/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/host/HostStore.java
@@ -1,5 +1,7 @@
package org.onlab.onos.net.host;
+import java.util.Set;
+
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Host;
@@ -9,8 +11,6 @@
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
-import java.util.Set;
-
/**
* Manages inventory of end-station hosts; not intended for direct use.
*/
@@ -98,4 +98,34 @@
*/
Set<Host> getConnectedHosts(DeviceId deviceId);
+ /**
+ * Updates the address information for a given port.
+ *
+ * @param addresses the port and address information
+ */
+ void updateAddressBindings(PortAddresses addresses);
+
+ /**
+ * Removes any previously stored address information for a given connection
+ * point.
+ *
+ * @param connectPoint the connection point
+ */
+ void removeAddressBindings(ConnectPoint connectPoint);
+
+ /**
+ * Returns the address bindings stored for all connection points.
+ *
+ * @return the set of address bindings
+ */
+ Set<PortAddresses> getAddressBindings();
+
+ /**
+ * Returns the address bindings for a particular connection point.
+ *
+ * @param connectPoint the connection point to return address information
+ * for
+ * @return address information for the connection point
+ */
+ PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint);
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java b/core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
new file mode 100644
index 0000000..16cc2b1
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/host/PortAddresses.java
@@ -0,0 +1,32 @@
+package org.onlab.onos.net.host;
+
+import org.onlab.onos.net.ConnectPoint;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+/**
+ * Represents address information bound to a port.
+ */
+public interface PortAddresses {
+
+ /**
+ * Returns the connection point this address information is bound to.
+ *
+ * @return the connection point
+ */
+ ConnectPoint connectPoint();
+
+ /**
+ * Returns the IP address bound to the port.
+ *
+ * @return the IP address
+ */
+ IpAddress ip();
+
+ /**
+ * Returns the MAC address bound to the port.
+ *
+ * @return the MAC address if one is bound, otherwise null
+ */
+ MacAddress mac();
+}
diff --git a/core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java b/core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
index 6a270cd..f03621c 100644
--- a/core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
+++ b/core/api/src/test/java/org/onlab/onos/net/host/HostServiceAdapter.java
@@ -6,6 +6,7 @@
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.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -55,11 +56,15 @@
}
@Override
- public void monitorIp(IpPrefix ip) {
+ public void startMonitoringIp(IpAddress ip) {
}
@Override
- public void stopMonitoringIp(IpPrefix ip) {
+ public void stopMonitoringIp(IpAddress ip) {
+ }
+
+ @Override
+ public void requestMac(IpAddress ip) {
}
@Override