blob: 2171fcb49b87c05f079aa797613980b410a09ce7 [file] [log] [blame]
Jonathan Hartbfc5c482016-04-05 18:57:00 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
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
Ray Milkey69ec8712017-08-08 13:00:43 -070017package org.onosproject.routeservice;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070018
Jonathan Hart96c146b2017-02-24 16:32:00 -080019import com.google.common.annotations.Beta;
Daniel Ginsburg83b76452018-06-09 01:43:59 +030020import org.apache.commons.lang3.NotImplementedException;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070021import org.onlab.packet.IpAddress;
Jonathan Hart96c146b2017-02-24 16:32:00 -080022import org.onlab.packet.IpPrefix;
Jonathan Hartbfc5c482016-04-05 18:57:00 -070023import org.onosproject.store.Store;
24
25import java.util.Collection;
26import 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 /**
pier8a86db22019-10-16 16:58:20 +020041 * Adds or updates the given routes in the store.
42 *
43 * @param routes routes to add or update
44 */
45 void updateRoutes(Collection<Route> routes);
46
47 /**
Jonathan Hartbfc5c482016-04-05 18:57:00 -070048 * Removes the given route from the store.
49 *
50 * @param route route to remove
51 */
52 void removeRoute(Route route);
53
54 /**
pier8a86db22019-10-16 16:58:20 +020055 * Removes the given routes from the store.
56 *
57 * @param routes routes to remove
58 */
59 void removeRoutes(Collection<Route> routes);
60
61 /**
Daniel Ginsburg83b76452018-06-09 01:43:59 +030062 * Replaces the all the routes for a prefix
63 * with the given route.
64 *
65 * @param route route
66 */
67 default void replaceRoute(Route route) {
68 throw new NotImplementedException("replaceRoute is not implemented");
69 }
70
71 /**
Jonathan Hartbfc5c482016-04-05 18:57:00 -070072 * Returns the IDs for all route tables in the store.
73 *
74 * @return route table IDs
75 */
76 Set<RouteTableId> getRouteTables();
77
78 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080079 * Returns the routes in the given route table, grouped by prefix.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070080 *
Jonathan Hart96c146b2017-02-24 16:32:00 -080081 * @param table route table ID
82 * @return routes
Jonathan Hartbfc5c482016-04-05 18:57:00 -070083 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080084 Collection<RouteSet> getRoutes(RouteTableId table);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070085
86 /**
Jonathan Hartfd176612016-04-11 10:42:10 -070087 * Returns the routes that point to the given next hop IP address.
88 *
89 * @param ip IP address of the next hop
90 * @return routes for the given next hop
91 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080092 // TODO think about including route table info
Jonathan Hartfd176612016-04-11 10:42:10 -070093 Collection<Route> getRoutesForNextHop(IpAddress ip);
94
95 /**
pier8a86db22019-10-16 16:58:20 +020096 * Returns all routes that point to any of the given next hops IP addresses.
97 *
98 * @param nextHops next hops IP addresses
99 * @return collection of routes sets
100 */
101 Collection<RouteSet> getRoutesForNextHops(Collection<IpAddress> nextHops);
102
103 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -0800104 * Returns the set of routes in the default route table for the given prefix.
105 *
106 * @param prefix IP prefix
107 * @return route set
108 */
109 // TODO needs to be generalizable across route tables
110 @Beta
111 RouteSet getRoutes(IpPrefix prefix);
112
Charles Chan4f365732017-07-20 17:11:57 -0700113 /**
114 * Returns the name of this route store.
115 *
116 * @return the name of this route store
117 */
118 default String name() {
119 return getClass().getName();
120 }
Jonathan Hartbfc5c482016-04-05 18:57:00 -0700121}