Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 1 | /* |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Laboratory |
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 | |
| 17 | package org.onosproject.incubator.net.routing; |
| 18 | |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 19 | import com.google.common.annotations.Beta; |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 20 | import org.onlab.packet.IpAddress; |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 21 | import org.onlab.packet.IpPrefix; |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 22 | import org.onosproject.store.Store; |
| 23 | |
| 24 | import java.util.Collection; |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 25 | import java.util.Map; |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 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 | /** |
| 48 | * Returns the IDs for all route tables in the store. |
| 49 | * |
| 50 | * @return route table IDs |
| 51 | */ |
| 52 | Set<RouteTableId> getRouteTables(); |
| 53 | |
| 54 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 55 | * Returns the routes in the given route table, grouped by prefix. |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 56 | * |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 57 | * @param table route table ID |
| 58 | * @return routes |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 59 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 60 | Collection<RouteSet> getRoutes(RouteTableId table); |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 63 | * Returns the routes that point to the given next hop IP address. |
| 64 | * |
| 65 | * @param ip IP address of the next hop |
| 66 | * @return routes for the given next hop |
| 67 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 68 | // TODO think about including route table info |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 69 | Collection<Route> getRoutesForNextHop(IpAddress ip); |
| 70 | |
| 71 | /** |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 72 | * Returns the set of routes in the default route table for the given prefix. |
| 73 | * |
| 74 | * @param prefix IP prefix |
| 75 | * @return route set |
| 76 | */ |
| 77 | // TODO needs to be generalizable across route tables |
| 78 | @Beta |
| 79 | RouteSet getRoutes(IpPrefix prefix); |
| 80 | |
| 81 | /** |
Charles Chan | e4d1310 | 2016-11-08 15:38:44 -0800 | [diff] [blame] | 82 | * Updates a next hop information in the store. |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 83 | * |
| 84 | * @param ip IP address |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 85 | * @param nextHopData Information of the next hop |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 86 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 87 | @Deprecated |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 88 | void updateNextHop(IpAddress ip, NextHopData nextHopData); |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
Charles Chan | e4d1310 | 2016-11-08 15:38:44 -0800 | [diff] [blame] | 91 | * Removes a next hop information from the store. |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 92 | * |
| 93 | * @param ip IP address |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 94 | * @param nextHopData Information of the next hop |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 95 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 96 | @Deprecated |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 97 | void removeNextHop(IpAddress ip, NextHopData nextHopData); |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
Charles Chan | e4d1310 | 2016-11-08 15:38:44 -0800 | [diff] [blame] | 100 | * Returns the information of the given next hop. |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 101 | * |
| 102 | * @param ip next hop IP |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 103 | * @return Information of the next hop |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 104 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 105 | @Deprecated |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 106 | NextHopData getNextHop(IpAddress ip); |
Jonathan Hart | fd17661 | 2016-04-11 10:42:10 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Returns all next hops in the route store. |
| 110 | * |
| 111 | * @return next hops |
| 112 | */ |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 113 | @Deprecated |
Charles Chan | 8fe9f4c | 2016-10-24 16:46:25 -0700 | [diff] [blame] | 114 | Map<IpAddress, NextHopData> getNextHops(); |
Jonathan Hart | 96c146b | 2017-02-24 16:32:00 -0800 | [diff] [blame] | 115 | |
| 116 | /** |
| 117 | * Performs a longest prefix match with the given IP address. |
| 118 | * |
| 119 | * @param ip IP to look up |
| 120 | * @return longest prefix match route |
| 121 | * @deprecated in Kingfisher release. Now handled by the manager instead of |
| 122 | * the store |
| 123 | */ |
| 124 | @Deprecated |
| 125 | Route longestPrefixMatch(IpAddress ip); |
Jonathan Hart | bfc5c48 | 2016-04-05 18:57:00 -0700 | [diff] [blame] | 126 | } |