Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 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'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 | /** |
| 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 Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 102 | * 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 Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 107 | void startMonitoringIp(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 108 | |
| 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 Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 115 | void stopMonitoringIp(IpAddress ip); |
| 116 | |
| 117 | /** |
| 118 | * 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] | 119 | * 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] | 120 | * address is found. |
| 121 | * |
| 122 | * @param ip IP address to find the MAC address for |
| 123 | */ |
| 124 | void requestMac(IpAddress ip); |
Jonathan Hart | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 127 | * Returns the addresses information for all connection points. |
| 128 | * |
| 129 | * @return the set of address bindings for all connection points |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 130 | * @deprecated in Drake release: use InterfaceService instead |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 131 | */ |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 132 | @Deprecated |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 133 | Set<PortAddresses> getAddressBindings(); |
| 134 | |
| 135 | /** |
| 136 | * Retrieves the addresses that have been bound to the given connection |
| 137 | * point. |
| 138 | * |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 139 | * @param connectPoint the connection point to retrieve address bindings for |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 140 | * @return addresses bound to the port |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 141 | * @deprecated in Drake release: use InterfaceService instead |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 142 | */ |
Jonathan Hart | eb8c947 | 2015-08-05 07:43:13 -0700 | [diff] [blame] | 143 | @Deprecated |
Jonathan Hart | a887ba8 | 2014-11-03 15:20:52 -0800 | [diff] [blame] | 144 | Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 145 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 146 | } |