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 | fca736c | 2014-09-19 17:26:59 -0700 | [diff] [blame] | 18 | import java.util.Set; |
| 19 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.ConnectPoint; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.Host; |
| 23 | import org.onosproject.net.HostId; |
Jonathan Hart | ac60c08 | 2014-09-23 08:55:17 -0700 | [diff] [blame] | 24 | import org.onlab.packet.IpAddress; |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 25 | import org.onlab.packet.MacAddress; |
| 26 | import org.onlab.packet.VlanId; |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 27 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 28 | /** |
| 29 | * Service for interacting with the inventory of end-station hosts. |
| 30 | */ |
| 31 | public interface HostService { |
| 32 | |
| 33 | /** |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 34 | * Returns the number of end-station hosts known to the system. |
| 35 | * |
| 36 | * @return number of end-station hosts |
| 37 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 38 | int getHostCount(); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 39 | |
| 40 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 41 | * 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 | */ |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 53 | Host getHost(HostId hostId); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 54 | |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 55 | /** |
| 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 Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 61 | Set<Host> getHostsByVlan(VlanId vlanId); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 62 | |
| 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 Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 69 | Set<Host> getHostsByMac(MacAddress mac); |
tom | 7869ad9 | 2014-09-09 14:32:08 -0700 | [diff] [blame] | 70 | |
| 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 Radoslavov | 33f228a | 2014-10-27 19:33:16 -0700 | [diff] [blame] | 77 | Set<Host> getHostsByIp(IpAddress ip); |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 78 | |
tom | a56d5fe | 2014-09-17 11:05:47 -0700 | [diff] [blame] | 79 | // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan); |
| 80 | |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 81 | /** |
| 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 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 | |
| 124 | /** |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 125 | * 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 Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 135 | * @param connectPoint the connection point to retrieve address bindings for |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 136 | * @return addresses bound to the port |
| 137 | */ |
Jonathan Hart | a887ba8 | 2014-11-03 15:20:52 -0800 | [diff] [blame] | 138 | Set<PortAddresses> getAddressBindingsForPort(ConnectPoint connectPoint); |
Jonathan Hart | dbdbdbb | 2014-10-06 18:35:30 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
tom | edf06bb | 2014-08-27 16:22:15 -0700 | [diff] [blame] | 141 | * 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 | } |