Jonathan Hart

Added APIs for binding address information to ports and for monitoring hosts/ips

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 @@ public interface HostAdminService {
*/
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);
}
......
......@@ -6,6 +6,7 @@ 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.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -87,7 +88,7 @@ public interface HostService {
*
* @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 @@ public interface HostService {
* @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.
......
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.IpPrefix;
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 @@ public interface HostStore {
*/
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);
}
......
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();
}
......@@ -6,6 +6,7 @@ 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.IpPrefix;
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
......@@ -55,11 +56,15 @@ public class HostServiceAdapter implements HostService {
}
@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
......
......@@ -26,8 +26,10 @@ import org.onlab.onos.net.host.HostProviderRegistry;
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 @@ public class HostManager
}
@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 @@ public class HostManager
}
}
@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>
......
......@@ -24,15 +24,16 @@ 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.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 @@ public class SimpleHostStore implements HostStore {
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;
}
}
......