Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [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.impl; |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 18 | |
| 19 | import org.onlab.packet.IpAddress; |
| 20 | import org.onlab.packet.IpPrefix; |
Ray Milkey | 69ec871 | 2017-08-08 13:00:43 -0700 | [diff] [blame] | 21 | import org.onosproject.routeservice.ResolvedRoute; |
| 22 | import org.onosproject.routeservice.RouteEvent; |
| 23 | import org.onosproject.routeservice.RouteTableId; |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 24 | |
| 25 | import java.util.Collection; |
| 26 | import java.util.Optional; |
| 27 | import java.util.Set; |
| 28 | |
| 29 | /** |
| 30 | * Stores resolved routes and best route decisions. |
| 31 | */ |
| 32 | public interface ResolvedRouteStore { |
| 33 | |
| 34 | /** |
| 35 | * Adds or updates the best route for the given prefix. |
| 36 | * |
| 37 | * @param route new best route for this prefix |
Jonathan Hart | f702168 | 2017-03-22 18:17:21 -0700 | [diff] [blame] | 38 | * @param alternatives alternative resolved routes |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 39 | * @return event describing the change |
| 40 | */ |
Jonathan Hart | f702168 | 2017-03-22 18:17:21 -0700 | [diff] [blame] | 41 | RouteEvent updateRoute(ResolvedRoute route, Set<ResolvedRoute> alternatives); |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 42 | |
| 43 | /** |
| 44 | * Removes the best route for the given prefix. |
| 45 | * |
| 46 | * @param prefix IP prefix |
| 47 | * @return event describing the change |
| 48 | */ |
| 49 | RouteEvent removeRoute(IpPrefix prefix); |
| 50 | |
| 51 | /** |
| 52 | * Gets the set of route tables. |
| 53 | * |
| 54 | * @return set of route table IDs |
| 55 | */ |
| 56 | Set<RouteTableId> getRouteTables(); |
| 57 | |
| 58 | /** |
| 59 | * Returns the best routes for a give route table. |
| 60 | * |
| 61 | * @param table route table ID |
| 62 | * @return collection of selected routes |
| 63 | */ |
| 64 | Collection<ResolvedRoute> getRoutes(RouteTableId table); |
| 65 | |
| 66 | /** |
| 67 | * Returns the best selected route for the given IP prefix. |
| 68 | * |
| 69 | * @param prefix IP prefix |
| 70 | * @return optional best route |
| 71 | */ |
| 72 | Optional<ResolvedRoute> getRoute(IpPrefix prefix); |
| 73 | |
| 74 | /** |
Jonathan Hart | f702168 | 2017-03-22 18:17:21 -0700 | [diff] [blame] | 75 | * Returns all resolved routes stored for the given prefix, including the |
| 76 | * best selected route. |
| 77 | * |
| 78 | * @param prefix IP prefix to look up routes for |
| 79 | * @return all stored resolved routes for this prefix |
| 80 | */ |
| 81 | Collection<ResolvedRoute> getAllRoutes(IpPrefix prefix); |
| 82 | |
| 83 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 84 | * Performs a longest prefix match of the best routes on the given IP address. |
| 85 | * |
| 86 | * @param ip IP address |
| 87 | * @return optional longest matching route |
| 88 | */ |
| 89 | Optional<ResolvedRoute> longestPrefixMatch(IpAddress ip); |
| 90 | } |