Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [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 | bfc5c48 | 2016-04-05 18:57:00 -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 | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 18 | |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Daniel Ginsburg | 83b7645 | 2018-06-09 01:43:59 +0300 | [diff] [blame] | 20 | import org.apache.commons.lang3.NotImplementedException; |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 21 | import org.onlab.packet.IpAddress; |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 22 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 23 | import org.onosproject.store.Store; |
| 24 | |
| 25 | import java.util.Collection; |
| 26 | import java.util.Set; |
| 27 | |
| 28 | /** |
| 29 | * Unicast route store. |
| 30 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 31 | public interface RouteStore extends Store<InternalRouteEvent, RouteStoreDelegate> { |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Adds or updates the given route in the store. |
| 35 | * |
| 36 | * @param route route to add or update |
| 37 | */ |
| 38 | void updateRoute(Route route); |
| 39 | |
| 40 | /** |
| 41 | * Removes the given route from the store. |
| 42 | * |
| 43 | * @param route route to remove |
| 44 | */ |
| 45 | void removeRoute(Route route); |
| 46 | |
| 47 | /** |
Daniel Ginsburg | 83b7645 | 2018-06-09 01:43:59 +0300 | [diff] [blame] | 48 | * Replaces the all the routes for a prefix |
| 49 | * with the given route. |
| 50 | * |
| 51 | * @param route route |
| 52 | */ |
| 53 | default void replaceRoute(Route route) { |
| 54 | throw new NotImplementedException("replaceRoute is not implemented"); |
| 55 | } |
| 56 | |
| 57 | /** |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 58 | * Returns the IDs for all route tables in the store. |
| 59 | * |
| 60 | * @return route table IDs |
| 61 | */ |
| 62 | Set<RouteTableId> getRouteTables(); |
| 63 | |
| 64 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 65 | * Returns the routes in the given route table, grouped by prefix. |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 66 | * |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 67 | * @param table route table ID |
| 68 | * @return routes |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 69 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 70 | Collection<RouteSet> getRoutes(RouteTableId table); |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 73 | * Returns the routes that point to the given next hop IP address. |
| 74 | * |
| 75 | * @param ip IP address of the next hop |
| 76 | * @return routes for the given next hop |
| 77 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 78 | // TODO think about including route table info |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 79 | Collection<Route> getRoutesForNextHop(IpAddress ip); |
| 80 | |
| 81 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 82 | * Returns the set of routes in the default route table for the given prefix. |
| 83 | * |
| 84 | * @param prefix IP prefix |
| 85 | * @return route set |
| 86 | */ |
| 87 | // TODO needs to be generalizable across route tables |
| 88 | @Beta |
| 89 | RouteSet getRoutes(IpPrefix prefix); |
| 90 | |
Charles Chan | 4f36573 | 2017-07-20 17:11:57 -0700 | [diff] [blame] | 91 | /** |
| 92 | * Returns the name of this route store. |
| 93 | * |
| 94 | * @return the name of this route store |
| 95 | */ |
| 96 | default String name() { |
| 97 | return getClass().getName(); |
| 98 | } |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 99 | } |