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
diff --git a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
index 1c4cef7..e2c9858 100644
--- a/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/host/impl/HostManager.java
@@ -26,8 +26,10 @@
import org.onlab.onos.net.host.HostProviderService;
import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.host.HostStore;
+import org.onlab.onos.net.host.PortAddresses;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
+import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
@@ -118,13 +120,18 @@
}
@Override
- public void monitorIp(IpPrefix ip) {
- // TODO pass through to SimpleHostMonitor
+ public void startMonitoringIp(IpAddress ip) {
+ // TODO pass through to HostMonitor
}
@Override
- public void stopMonitoringIp(IpPrefix ip) {
- // TODO pass through to SimpleHostMonitor
+ public void stopMonitoringIp(IpAddress ip) {
+ // TODO pass through to HostMonitor
+ }
+
+ @Override
+ public void requestMac(IpAddress ip) {
+ // TODO Auto-generated method stub
}
@Override
@@ -147,6 +154,31 @@
}
}
+ @Override
+ public void bindAddressesToPort(IpAddress ip, MacAddress mac,
+ ConnectPoint connectPoint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void unbindAddressesFromPort(ConnectPoint connectPoint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Set<PortAddresses> getAddressBindings() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
// Personalized host provider service issued to the supplied provider.
private class InternalHostProviderService
extends AbstractProviderService<HostProvider>
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
index 4a4d6d3..752ec9e 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/impl/SimpleHostStore.java
@@ -24,15 +24,16 @@
import org.onlab.onos.net.host.HostDescription;
import org.onlab.onos.net.host.HostEvent;
import org.onlab.onos.net.host.HostStore;
+import org.onlab.onos.net.host.PortAddresses;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.packet.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
+import org.slf4j.Logger;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
-import org.slf4j.Logger;
/**
* Manages inventory of end-station hosts using trivial in-memory
@@ -192,4 +193,28 @@
return hostset;
}
+ @Override
+ public void updateAddressBindings(PortAddresses addresses) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void removeAddressBindings(ConnectPoint connectPoint) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Set<PortAddresses> getAddressBindings() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PortAddresses getAddressBindingsForPort(ConnectPoint connectPoint) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}