blob: 27ec1c3433991a0f856e567d9235a8a2f7c971ba [file] [log] [blame]
Jonathan Hartbfc5c482016-04-05 18:57:00 -07001/*
Jonathan Hart96c146b2017-02-24 16:32:00 -08002 * Copyright 2017-present Open Networking Laboratory
Jonathan Hartbfc5c482016-04-05 18:57:00 -07003 *
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
17package org.onosproject.incubator.net.routing;
18
Jonathan Hart96c146b2017-02-24 16:32:00 -080019import com.google.common.annotations.Beta;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070020import org.onlab.packet.IpAddress;
Jonathan Hart96c146b2017-02-24 16:32:00 -080021import org.onlab.packet.IpPrefix;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070022import org.onosproject.store.Store;
23
24import java.util.Collection;
Jonathan Hartfd176612016-04-11 10:42:10 -070025import java.util.Map;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070026import java.util.Set;
27
28/**
29 * Unicast route store.
30 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080031public interface RouteStore extends Store<InternalRouteEvent, RouteStoreDelegate> {
Jonathan Hartbfc5c482016-04-05 18:57:00 -070032
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 Hart96c146b2017-02-24 16:32:00 -080055 * Returns the routes in the given route table, grouped by prefix.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070056 *
Jonathan Hart96c146b2017-02-24 16:32:00 -080057 * @param table route table ID
58 * @return routes
Jonathan Hartbfc5c482016-04-05 18:57:00 -070059 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080060 Collection<RouteSet> getRoutes(RouteTableId table);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070061
62 /**
Jonathan Hartfd176612016-04-11 10:42:10 -070063 * 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 Hart96c146b2017-02-24 16:32:00 -080068 // TODO think about including route table info
Jonathan Hartfd176612016-04-11 10:42:10 -070069 Collection<Route> getRoutesForNextHop(IpAddress ip);
70
71 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080072 * 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 Chane4d13102016-11-08 15:38:44 -080082 * Updates a next hop information in the store.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070083 *
84 * @param ip IP address
Charles Chan8fe9f4c2016-10-24 16:46:25 -070085 * @param nextHopData Information of the next hop
Jonathan Hartbfc5c482016-04-05 18:57:00 -070086 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080087 @Deprecated
Charles Chan8fe9f4c2016-10-24 16:46:25 -070088 void updateNextHop(IpAddress ip, NextHopData nextHopData);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070089
90 /**
Charles Chane4d13102016-11-08 15:38:44 -080091 * Removes a next hop information from the store.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070092 *
93 * @param ip IP address
Charles Chan8fe9f4c2016-10-24 16:46:25 -070094 * @param nextHopData Information of the next hop
Jonathan Hartbfc5c482016-04-05 18:57:00 -070095 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080096 @Deprecated
Charles Chan8fe9f4c2016-10-24 16:46:25 -070097 void removeNextHop(IpAddress ip, NextHopData nextHopData);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070098
99 /**
Charles Chane4d13102016-11-08 15:38:44 -0800100 * Returns the information of the given next hop.
Jonathan Hartbfc5c482016-04-05 18:57:00 -0700101 *
102 * @param ip next hop IP
Charles Chan8fe9f4c2016-10-24 16:46:25 -0700103 * @return Information of the next hop
Jonathan Hartbfc5c482016-04-05 18:57:00 -0700104 */
Jonathan Hart96c146b2017-02-24 16:32:00 -0800105 @Deprecated
Charles Chan8fe9f4c2016-10-24 16:46:25 -0700106 NextHopData getNextHop(IpAddress ip);
Jonathan Hartfd176612016-04-11 10:42:10 -0700107
108 /**
109 * Returns all next hops in the route store.
110 *
111 * @return next hops
112 */
Jonathan Hart96c146b2017-02-24 16:32:00 -0800113 @Deprecated
Charles Chan8fe9f4c2016-10-24 16:46:25 -0700114 Map<IpAddress, NextHopData> getNextHops();
Jonathan Hart96c146b2017-02-24 16:32:00 -0800115
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 Hartbfc5c482016-04-05 18:57:00 -0700126}