tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.host; |
| 2 | |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 3 | import java.util.Set; |
| 4 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 5 | import org.onlab.onos.net.ConnectPoint; |
| 6 | import org.onlab.onos.net.DeviceId; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 7 | import org.onlab.onos.net.Host; |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 8 | import org.onlab.onos.net.HostId; |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 9 | import org.onlab.packet.IpAddress; |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 10 | import org.onlab.packet.IpPrefix; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 11 | import org.onlab.packet.MacAddress; |
| 12 | import org.onlab.packet.VlanId; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 13 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 14 | /** |
| 15 | * Service for interacting with the inventory of end-station hosts. |
| 16 | */ |
| 17 | public interface HostService { |
| 18 | |
| 19 | /** |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 20 | * Returns the number of end-station hosts known to the system. |
| 21 | * |
| 22 | * @return number of end-station hosts |
| 23 | */ |
| 24 | public int getHostCount(); |
| 25 | |
| 26 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 27 | * Returns a collection of all end-station hosts. |
| 28 | * |
| 29 | * @return collection of hosts |
| 30 | */ |
| 31 | Iterable<Host> getHosts(); |
| 32 | |
| 33 | /** |
| 34 | * Returns the host with the specified identifier. |
| 35 | * |
| 36 | * @param hostId host identifier |
| 37 | * @return host or null if one with the given identifier is not known |
| 38 | */ |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 39 | Host getHost(HostId hostId); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 40 | |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 41 | /** |
| 42 | * Returns the set of hosts that belong to the specified VLAN. |
| 43 | * |
| 44 | * @param vlanId vlan identifier |
| 45 | * @return set of hosts in the given vlan id |
| 46 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 47 | Set<Host> getHostsByVlan(VlanId vlanId); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 48 | |
| 49 | /** |
| 50 | * Returns the set of hosts that have the specified MAC address. |
| 51 | * |
| 52 | * @param mac mac address |
| 53 | * @return set of hosts with the given mac |
| 54 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 55 | Set<Host> getHostsByMac(MacAddress mac); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Returns the set of hosts that have the specified IP address. |
| 59 | * |
| 60 | * @param ip ip address |
| 61 | * @return set of hosts with the given IP |
| 62 | */ |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 63 | Set<Host> getHostsByIp(IpPrefix ip); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 64 | |
tom | a56d5fe | 2014-09-17 11:05:47 -0700 | [diff] [blame] | 65 | // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan); |
| 66 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 67 | /** |
| 68 | * Returns the set of hosts whose most recent location is the specified |
| 69 | * connection point. |
| 70 | * |
| 71 | * @param connectPoint connection point |
| 72 | * @return set of hosts connected to the connection point |
| 73 | */ |
| 74 | Set<Host> getConnectedHosts(ConnectPoint connectPoint); |
| 75 | |
| 76 | /** |
| 77 | * Returns the set of hosts whose most recent location is the specified |
| 78 | * infrastructure device. |
| 79 | * |
| 80 | * @param deviceId device identifier |
| 81 | * @return set of hosts connected to the device |
| 82 | */ |
| 83 | Set<Host> getConnectedHosts(DeviceId deviceId); |
| 84 | |
| 85 | /** |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 86 | * Requests the host service to monitor hosts with the given IP address and |
| 87 | * notify listeners of changes. |
| 88 | * |
| 89 | * @param ip IP address of the host to monitor |
| 90 | */ |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 91 | void startMonitoringIp(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Stops the host service from monitoring an IP address. |
| 95 | * |
| 96 | * @param ip IP address to stop monitoring |
| 97 | */ |
| 98 | // TODO clients can cancel other client's requests |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 99 | void stopMonitoringIp(IpAddress ip); |
| 100 | |
| 101 | /** |
| 102 | * Requests the host service to resolve the MAC address for the given IP |
| 103 | * address. |
| 104 | * <p/> |
| 105 | * This will trigger a notification to the host listeners if the MAC |
| 106 | * address is found. |
| 107 | * |
| 108 | * @param ip IP address to find the MAC address for |
| 109 | */ |
| 110 | void requestMac(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 113 | * Adds the specified host listener. |
| 114 | * |
| 115 | * @param listener host listener |
| 116 | */ |
| 117 | void addListener(HostListener listener); |
| 118 | |
| 119 | /** |
| 120 | * Removes the specified host listener. |
| 121 | * |
| 122 | * @param listener host listener |
| 123 | */ |
| 124 | void removeListener(HostListener listener); |
| 125 | |
| 126 | } |