blob: f18569f96e346872e7db0338543e4b9f778190dd [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 Koshibea9c199f2014-09-16 16:21:40 -070010import org.onlab.packet.MacAddress;
11import org.onlab.packet.VlanId;
tomedf06bb2014-08-27 16:22:15 -070012
tomedf06bb2014-08-27 16:22:15 -070013/**
14 * Service for interacting with the inventory of end-station hosts.
15 */
16public interface HostService {
17
18 /**
tom7869ad92014-09-09 14:32:08 -070019 * 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 /**
tomedf06bb2014-08-27 16:22:15 -070026 * 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 */
tom7869ad92014-09-09 14:32:08 -070038 Host getHost(HostId hostId);
tomedf06bb2014-08-27 16:22:15 -070039
tom7869ad92014-09-09 14:32:08 -070040 /**
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 Koshibea9c199f2014-09-16 16:21:40 -070046 Set<Host> getHostsByVlan(VlanId vlanId);
tom7869ad92014-09-09 14:32:08 -070047
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 Koshibea9c199f2014-09-16 16:21:40 -070054 Set<Host> getHostsByMac(MacAddress mac);
tom7869ad92014-09-09 14:32:08 -070055
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 Radoslavov33f228a2014-10-27 19:33:16 -070062 Set<Host> getHostsByIp(IpAddress ip);
tomedf06bb2014-08-27 16:22:15 -070063
toma56d5fe2014-09-17 11:05:47 -070064 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
65
tomedf06bb2014-08-27 16:22:15 -070066 /**
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 Hartfca736c2014-09-19 17:26:59 -070085 * 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 Hartac60c082014-09-23 08:55:17 -070090 void startMonitoringIp(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -070091
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 Hartac60c082014-09-23 08:55:17 -070098 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 Hartfca736c2014-09-19 17:26:59 -0700110
111 /**
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700112 * 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 /**
tomedf06bb2014-08-27 16:22:15 -0700129 * 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}