blob: a2a829196c88ae50b634b84e62a60acdcc145e7c [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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.host;
tomedf06bb2014-08-27 16:22:15 -070017
Jonathan Hartfca736c2014-09-19 17:26:59 -070018import java.util.Set;
19
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070020import org.onosproject.event.ListenerService;
Brian O'Connorabafb502014-12-02 22:26:20 -080021import org.onosproject.net.ConnectPoint;
22import org.onosproject.net.DeviceId;
23import org.onosproject.net.Host;
24import org.onosproject.net.HostId;
Jonathan Hartac60c082014-09-23 08:55:17 -070025import org.onlab.packet.IpAddress;
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070026import org.onlab.packet.MacAddress;
27import org.onlab.packet.VlanId;
tomedf06bb2014-08-27 16:22:15 -070028
tomedf06bb2014-08-27 16:22:15 -070029/**
30 * Service for interacting with the inventory of end-station hosts.
31 */
Thomas Vachuska42e8cce2015-07-29 19:25:18 -070032public interface HostService
33 extends ListenerService<HostEvent, HostListener> {
tomedf06bb2014-08-27 16:22:15 -070034
35 /**
tom7869ad92014-09-09 14:32:08 -070036 * Returns the number of end-station hosts known to the system.
37 *
38 * @return number of end-station hosts
39 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070040 int getHostCount();
tom7869ad92014-09-09 14:32:08 -070041
42 /**
tomedf06bb2014-08-27 16:22:15 -070043 * Returns a collection of all end-station hosts.
44 *
45 * @return collection of hosts
46 */
47 Iterable<Host> getHosts();
48
49 /**
50 * Returns the host with the specified identifier.
51 *
52 * @param hostId host identifier
53 * @return host or null if one with the given identifier is not known
54 */
tom7869ad92014-09-09 14:32:08 -070055 Host getHost(HostId hostId);
tomedf06bb2014-08-27 16:22:15 -070056
tom7869ad92014-09-09 14:32:08 -070057 /**
58 * Returns the set of hosts that belong to the specified VLAN.
59 *
60 * @param vlanId vlan identifier
61 * @return set of hosts in the given vlan id
62 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070063 Set<Host> getHostsByVlan(VlanId vlanId);
tom7869ad92014-09-09 14:32:08 -070064
65 /**
66 * Returns the set of hosts that have the specified MAC address.
67 *
68 * @param mac mac address
69 * @return set of hosts with the given mac
70 */
Ayaka Koshibea9c199f2014-09-16 16:21:40 -070071 Set<Host> getHostsByMac(MacAddress mac);
tom7869ad92014-09-09 14:32:08 -070072
73 /**
74 * Returns the set of hosts that have the specified IP address.
75 *
76 * @param ip ip address
77 * @return set of hosts with the given IP
78 */
Pavlin Radoslavov33f228a2014-10-27 19:33:16 -070079 Set<Host> getHostsByIp(IpAddress ip);
tomedf06bb2014-08-27 16:22:15 -070080
toma56d5fe2014-09-17 11:05:47 -070081 // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
82
tomedf06bb2014-08-27 16:22:15 -070083 /**
84 * Returns the set of hosts whose most recent location is the specified
85 * connection point.
86 *
87 * @param connectPoint connection point
88 * @return set of hosts connected to the connection point
89 */
90 Set<Host> getConnectedHosts(ConnectPoint connectPoint);
91
92 /**
93 * Returns the set of hosts whose most recent location is the specified
94 * infrastructure device.
95 *
96 * @param deviceId device identifier
97 * @return set of hosts connected to the device
98 */
99 Set<Host> getConnectedHosts(DeviceId deviceId);
100
101 /**
Jonathan Hartfca736c2014-09-19 17:26:59 -0700102 * Requests the host service to monitor hosts with the given IP address and
103 * notify listeners of changes.
104 *
105 * @param ip IP address of the host to monitor
106 */
Jonathan Hartac60c082014-09-23 08:55:17 -0700107 void startMonitoringIp(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -0700108
109 /**
110 * Stops the host service from monitoring an IP address.
111 *
112 * @param ip IP address to stop monitoring
113 */
114 // TODO clients can cancel other client's requests
Jonathan Hartac60c082014-09-23 08:55:17 -0700115 void stopMonitoringIp(IpAddress ip);
116
117 /**
118 * Requests the host service to resolve the MAC address for the given IP
Thomas Vachuska4b420772014-10-30 16:46:17 -0700119 * address. This will trigger a notification to the host listeners if the MAC
Jonathan Hartac60c082014-09-23 08:55:17 -0700120 * address is found.
121 *
122 * @param ip IP address to find the MAC address for
123 */
124 void requestMac(IpAddress ip);
Jonathan Hartfca736c2014-09-19 17:26:59 -0700125
126 /**
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700127 * Returns the addresses information for all connection points.
128 *
129 * @return the set of address bindings for all connection points
130 */
131 Set<PortAddresses> getAddressBindings();
132
133 /**
134 * Retrieves the addresses that have been bound to the given connection
135 * point.
136 *
Thomas Vachuska4b420772014-10-30 16:46:17 -0700137 * @param connectPoint the connection point to retrieve address bindings for
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700138 * @return addresses bound to the port
139 */
Jonathan Harta887ba82014-11-03 15:20:52 -0800140 Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint);
Jonathan Hartdbdbdbb2014-10-06 18:35:30 -0700141
tomedf06bb2014-08-27 16:22:15 -0700142}