blob: 6866762488260c79f0b2d2e1d6352478ef2f1eb0 [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;
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;
25import java.util.Set;
26
27/**
28 * Unicast route store.
29 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080030public interface RouteStore extends Store<InternalRouteEvent, RouteStoreDelegate> {
Jonathan Hartbfc5c482016-04-05 18:57:00 -070031
32 /**
33 * Adds or updates the given route in the store.
34 *
35 * @param route route to add or update
36 */
37 void updateRoute(Route route);
38
39 /**
40 * Removes the given route from the store.
41 *
42 * @param route route to remove
43 */
44 void removeRoute(Route route);
45
46 /**
47 * Returns the IDs for all route tables in the store.
48 *
49 * @return route table IDs
50 */
51 Set<RouteTableId> getRouteTables();
52
53 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080054 * Returns the routes in the given route table, grouped by prefix.
Jonathan Hartbfc5c482016-04-05 18:57:00 -070055 *
Jonathan Hart96c146b2017-02-24 16:32:00 -080056 * @param table route table ID
57 * @return routes
Jonathan Hartbfc5c482016-04-05 18:57:00 -070058 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080059 Collection<RouteSet> getRoutes(RouteTableId table);
Jonathan Hartbfc5c482016-04-05 18:57:00 -070060
61 /**
Jonathan Hartfd176612016-04-11 10:42:10 -070062 * Returns the routes that point to the given next hop IP address.
63 *
64 * @param ip IP address of the next hop
65 * @return routes for the given next hop
66 */
Jonathan Hart96c146b2017-02-24 16:32:00 -080067 // TODO think about including route table info
Jonathan Hartfd176612016-04-11 10:42:10 -070068 Collection<Route> getRoutesForNextHop(IpAddress ip);
69
70 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080071 * Returns the set of routes in the default route table for the given prefix.
72 *
73 * @param prefix IP prefix
74 * @return route set
75 */
76 // TODO needs to be generalizable across route tables
77 @Beta
78 RouteSet getRoutes(IpPrefix prefix);
79
Charles Chan4f365732017-07-20 17:11:57 -070080 /**
81 * Returns the name of this route store.
82 *
83 * @return the name of this route store
84 */
85 default String name() {
86 return getClass().getName();
87 }
Jonathan Hartbfc5c482016-04-05 18:57:00 -070088}