blob: 5eaa898c1ed4dba5b32c26061e5367c75853642f [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 /**
41 * Removes the given route from the store.
42 *
43 * @param route route to remove
44 */
45 void removeRoute(Route route);
46
47 /**
Daniel Ginsburg83b76452018-06-09 01:43:59 +030048 * 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 Hartbfc5c482016-04-05 18:57:00 -070058 * Returns the IDs for all route tables in the store.
59 *
60 * @return route table IDs
61 */
62 Set<RouteTableId> getRouteTables();
63
64 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080065 * Returns the routes in the given route table, grouped by prefix.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070066 *
Jonathan Hart96c146b2017-02-24 16:32:00 -080067 * @param table route table ID
68 * @return routes
Jonathan Hartbfc5c482016-04-05 18:57:00 -070069 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080070 Collection<RouteSet> getRoutes(RouteTableId table);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070071
72 /**
Jonathan Hartfd176612016-04-11 10:42:10 -070073 * 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 Hart96c146b2017-02-24 16:32:00 -080078 // TODO think about including route table info
Jonathan Hartfd176612016-04-11 10:42:10 -070079 Collection<Route> getRoutesForNextHop(IpAddress ip);
80
81 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080082 * 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 Chan4f365732017-07-20 17:11:57 -070091 /**
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 Hartbfc5c482016-04-05 18:57:00 -070099}