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