Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.host; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 17 | |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 18 | import org.onlab.packet.IpAddress; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onlab.packet.VlanId; |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 21 | import org.onosproject.event.ListenerService; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 22 | import org.onosproject.net.ConnectPoint; |
| 23 | import org.onosproject.net.DeviceId; |
| 24 | import org.onosproject.net.Host; |
| 25 | import org.onosproject.net.HostId; |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 26 | |
| 27 | import java.util.Set; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 28 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Service for interacting with the inventory of end-station hosts. |
| 31 | */ |
Thomas Vachuska | 42e8cce | 2015-07-29 19:25:18 -0700 | [diff] [blame] | 32 | public interface HostService |
| 33 | extends ListenerService<HostEvent, HostListener> { |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 34 | |
| 35 | /** |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 36 | * Returns the number of end-station hosts known to the system. |
| 37 | * |
| 38 | * @return number of end-station hosts |
| 39 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 40 | int getHostCount(); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 43 | * 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 | */ |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 55 | Host getHost(HostId hostId); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 56 | |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 57 | /** |
| 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 Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 63 | Set<Host> getHostsByVlan(VlanId vlanId); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 64 | |
| 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 Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 71 | Set<Host> getHostsByMac(MacAddress mac); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 72 | |
| 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 Radoslavov | 33f228a | 2014-10-27 19:33:16 -0700 | [diff] [blame] | 79 | Set<Host> getHostsByIp(IpAddress ip); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 80 | |
tom | a56d5fe | 2014-09-17 11:05:47 -0700 | [diff] [blame] | 81 | // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan); |
| 82 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 83 | /** |
Charles Chan | 2a9492da | 2019-12-06 19:19:30 -0800 | [diff] [blame] | 84 | * Returns the set of hosts that attach to the specified connection point. |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 85 | * |
| 86 | * @param connectPoint connection point |
| 87 | * @return set of hosts connected to the connection point |
| 88 | */ |
| 89 | Set<Host> getConnectedHosts(ConnectPoint connectPoint); |
| 90 | |
| 91 | /** |
Charles Chan | 2a9492da | 2019-12-06 19:19:30 -0800 | [diff] [blame] | 92 | * Returns the set of hosts that attach to the specified device. |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 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 Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 100 | * 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 Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 105 | void startMonitoringIp(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 106 | |
| 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 Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 113 | void stopMonitoringIp(IpAddress ip); |
| 114 | |
| 115 | /** |
| 116 | * Requests the host service to resolve the MAC address for the given IP |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 117 | * address. This will trigger a notification to the host listeners if the MAC |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 118 | * address is found. |
| 119 | * |
| 120 | * @param ip IP address to find the MAC address for |
| 121 | */ |
| 122 | void requestMac(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 123 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 124 | } |