blob: 7f7be50f5d655f1cef452330108f70a794915220 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
tomedf06bb2014-08-27 16:22:15 -070016package org.onlab.onos.net.host;
17
Jonathan Hartfca736c2014-09-19 17:26:59 -070018import java.util.Set;
19
tomedf06bb2014-08-27 16:22:15 -070020import org.onlab.onos.net.ConnectPoint;
21import org.onlab.onos.net.DeviceId;
tomedf06bb2014-08-27 16:22:15 -070022import org.onlab.onos.net.Host;
tom7869ad92014-09-09 14:32:08 -070023import org.onlab.onos.net.HostId;
Jonathan Hartac60c082014-09-23 08:55:17 -070024import org.onlab.packet.IpAddress;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070025import org.onlab.packet.MacAddress;
26import org.onlab.packet.VlanId;
tomedf06bb2014-08-27 16:22:15 -070027
tomedf06bb2014-08-27 16:22:15 -070028/**
29 * Service for interacting with the inventory of end-station hosts.
30 */
31public interface HostService {
32
33 /**
tom7869ad92014-09-09 14:32:08 -070034 * Returns the number of end-station hosts known to the system.
35 *
36 * @return number of end-station hosts
37 */
38 public int getHostCount();
39
40 /**
tomedf06bb2014-08-27 16:22:15 -070041 * Returns a collection of all end-station hosts.
42 *
43 * @return collection of hosts
44 */
45 Iterable<Host> getHosts();
46
47 /**
48 * Returns the host with the specified identifier.
49 *
50 * @param hostId host identifier
51 * @return host or null if one with the given identifier is not known
52 */
tom7869ad92014-09-09 14:32:08 -070053 Host getHost(HostId hostId);
tomedf06bb2014-08-27 16:22:15 -070054
tom7869ad92014-09-09 14:32:08 -070055 /**
56 * Returns the set of hosts that belong to the specified VLAN.
57 *
58 * @param vlanId vlan identifier
59 * @return set of hosts in the given vlan id
60 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070061 Set<Host> getHostsByVlan(VlanId vlanId);
tom7869ad92014-09-09 14:32:08 -070062
63 /**
64 * Returns the set of hosts that have the specified MAC address.
65 *
66 * @param mac mac address
67 * @return set of hosts with the given mac
68 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070069 Set<Host> getHostsByMac(MacAddress mac);
tom7869ad92014-09-09 14:32:08 -070070
71 /**
72 * Returns the set of hosts that have the specified IP address.
73 *
74 * @param ip ip address
75 * @return set of hosts with the given IP
76 */
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -070077 Set<Host> getHostsByIp(IpAddress ip);
tomedf06bb2014-08-27 16:22:15 -070078
toma56d5fe2014-09-17 11:05:47 -070079 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
80
tomedf06bb2014-08-27 16:22:15 -070081 /**
82 * Returns the set of hosts whose most recent location is the specified
83 * connection point.
84 *
85 * @param connectPoint connection point
86 * @return set of hosts connected to the connection point
87 */
88 Set<Host> getConnectedHosts(ConnectPoint connectPoint);
89
90 /**
91 * Returns the set of hosts whose most recent location is the specified
92 * infrastructure device.
93 *
94 * @param deviceId device identifier
95 * @return set of hosts connected to the device
96 */
97 Set<Host> getConnectedHosts(DeviceId deviceId);
98
99 /**
Jonathan Hartfca736c2014-09-19 17:26:59 -0700100 * Requests the host service to monitor hosts with the given IP address and
101 * notify listeners of changes.
102 *
103 * @param ip IP address of the host to monitor
104 */
Jonathan Hartac60c082014-09-23 08:55:17 -0700105 void startMonitoringIp(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -0700106
107 /**
108 * Stops the host service from monitoring an IP address.
109 *
110 * @param ip IP address to stop monitoring
111 */
112 // TODO clients can cancel other client's requests
Jonathan Hartac60c082014-09-23 08:55:17 -0700113 void stopMonitoringIp(IpAddress ip);
114
115 /**
116 * Requests the host service to resolve the MAC address for the given IP
Thomas Vachuska4b420772014-10-30 16:46:17 -0700117 * address. This will trigger a notification to the host listeners if the MAC
Jonathan Hartac60c082014-09-23 08:55:17 -0700118 * address is found.
119 *
120 * @param ip IP address to find the MAC address for
121 */
122 void requestMac(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -0700123
124 /**
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700125 * Returns the addresses information for all connection points.
126 *
127 * @return the set of address bindings for all connection points
128 */
129 Set<PortAddresses> getAddressBindings();
130
131 /**
132 * Retrieves the addresses that have been bound to the given connection
133 * point.
134 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700135 * @param connectPoint the connection point to retrieve address bindings for
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700136 * @return addresses bound to the port
137 */
Jonathan Harta887ba82014-11-03 15:20:52 -0800138 Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint);
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700139
140 /**
tomedf06bb2014-08-27 16:22:15 -0700141 * Adds the specified host listener.
142 *
143 * @param listener host listener
144 */
145 void addListener(HostListener listener);
146
147 /**
148 * Removes the specified host listener.
149 *
150 * @param listener host listener
151 */
152 void removeListener(HostListener listener);
153
154}