blob: a0f51b34a458232a24a0b142ad13a505e951f2a5 [file] [log] [blame]
tomedf06bb2014-08-27 16:22:15 -07001package org.onlab.onos.net.host;
2
Jonathan Hartfca736c2014-09-19 17:26:59 -07003import java.util.Set;
4
tomedf06bb2014-08-27 16:22:15 -07005import org.onlab.onos.net.ConnectPoint;
6import org.onlab.onos.net.DeviceId;
tomedf06bb2014-08-27 16:22:15 -07007import org.onlab.onos.net.Host;
tom7869ad92014-09-09 14:32:08 -07008import org.onlab.onos.net.HostId;
Jonathan Hartac60c082014-09-23 08:55:17 -07009import org.onlab.packet.IpAddress;
Ayaka Koshibe1d56fe42014-09-19 16:51:58 -070010import org.onlab.packet.IpPrefix;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070011import org.onlab.packet.MacAddress;
12import org.onlab.packet.VlanId;
tomedf06bb2014-08-27 16:22:15 -070013
tomedf06bb2014-08-27 16:22:15 -070014/**
15 * Service for interacting with the inventory of end-station hosts.
16 */
17public interface HostService {
18
19 /**
tom7869ad92014-09-09 14:32:08 -070020 * 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 /**
tomedf06bb2014-08-27 16:22:15 -070027 * 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 */
tom7869ad92014-09-09 14:32:08 -070039 Host getHost(HostId hostId);
tomedf06bb2014-08-27 16:22:15 -070040
tom7869ad92014-09-09 14:32:08 -070041 /**
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 Koshibea9c199f2014-09-16 16:21:40 -070047 Set<Host> getHostsByVlan(VlanId vlanId);
tom7869ad92014-09-09 14:32:08 -070048
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 Koshibea9c199f2014-09-16 16:21:40 -070055 Set<Host> getHostsByMac(MacAddress mac);
tom7869ad92014-09-09 14:32:08 -070056
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 Koshibe1d56fe42014-09-19 16:51:58 -070063 Set<Host> getHostsByIp(IpPrefix ip);
tomedf06bb2014-08-27 16:22:15 -070064
toma56d5fe2014-09-17 11:05:47 -070065 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
66
tomedf06bb2014-08-27 16:22:15 -070067 /**
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 Hartfca736c2014-09-19 17:26:59 -070086 * 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 Hartac60c082014-09-23 08:55:17 -070091 void startMonitoringIp(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -070092
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 Hartac60c082014-09-23 08:55:17 -070099 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 Hartfca736c2014-09-19 17:26:59 -0700111
112 /**
tomedf06bb2014-08-27 16:22:15 -0700113 * 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}