Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -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 | */ |
| 16 | |
Ray Milkey | 69ec871 | 2017-08-08 13:00:43 -0700 | [diff] [blame] | 17 | package org.onosproject.routeservice; |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 18 | |
| 19 | import org.onlab.packet.IpAddress; |
Andrea Campanella | cc2424a | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 20 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 21 | import org.onosproject.event.ListenerService; |
| 22 | |
| 23 | import java.util.Collection; |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 24 | import java.util.Optional; |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 25 | |
| 26 | /** |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 27 | * Unicast IP route service. |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 28 | */ |
| 29 | public interface RouteService extends ListenerService<RouteEvent, RouteListener> { |
| 30 | |
| 31 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 32 | * Returns information about all routes in the given route table. |
| 33 | * |
| 34 | * @param id route table ID |
| 35 | * @return collection of route information |
| 36 | */ |
| 37 | Collection<RouteInfo> getRoutes(RouteTableId id); |
| 38 | |
| 39 | /** |
Charles Chan | 11d4dc5 | 2019-05-03 13:19:49 -0700 | [diff] [blame] | 40 | * Returns all resolved routes in the given route table. |
| 41 | * |
| 42 | * @param id route table ID |
| 43 | * @return collection of resolved route |
| 44 | */ |
| 45 | Collection<ResolvedRoute> getResolvedRoutes(RouteTableId id); |
| 46 | |
| 47 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 48 | * Returns the set of route tables in the system. |
| 49 | * |
| 50 | * @return collection of route table IDs. |
| 51 | */ |
| 52 | Collection<RouteTableId> getRouteTables(); |
| 53 | |
| 54 | /** |
Jonathan Hart | 89ef158 | 2017-06-19 11:12:23 -0700 | [diff] [blame] | 55 | * Performs a longest prefix lookup on the given IP address. |
| 56 | * |
| 57 | * @param ip IP address to look up |
| 58 | * @return most specific matching route, if one exists |
| 59 | */ |
| 60 | Optional<ResolvedRoute> longestPrefixLookup(IpAddress ip); |
| 61 | |
| 62 | /** |
Andrea Campanella | cc2424a | 2018-03-07 14:27:54 -0800 | [diff] [blame] | 63 | * Returns all resolved routes stored for the given prefix, including the |
| 64 | * best selected route. |
| 65 | * |
| 66 | * @param prefix IP prefix to look up routes for |
| 67 | * @return all stored resolved routes for this prefix |
| 68 | */ |
| 69 | Collection<ResolvedRoute> getAllResolvedRoutes(IpPrefix prefix); |
| 70 | |
| 71 | /** |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 72 | * Performs a longest prefix match on the given IP address. The call will |
| 73 | * return the route with the most specific prefix that contains the given |
| 74 | * IP address. |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 75 | * |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 76 | * @param ip IP address |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 77 | * @return longest prefix matched route |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 78 | * @deprecated in Kingfisher release. Use {{@link #longestPrefixLookup(IpAddress)}} |
| 79 | * instead. |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 80 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 81 | @Deprecated |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 82 | Route longestPrefixMatch(IpAddress ip); |
Jonathan Hart | 7d7e2f5 | 2016-03-29 16:22:49 -0700 | [diff] [blame] | 83 | } |