blob: 55ca3f9da21c0e92e152d50daad6564fad5a1fdf [file] [log] [blame]
Jonathan Hart96c146b2017-02-24 16:32:00 -08001/*
2 * Copyright 2017-present Open Networking Laboratory
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
17package org.onosproject.incubator.net.routing.impl;
18
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
21import org.onosproject.incubator.net.routing.ResolvedRoute;
22import org.onosproject.incubator.net.routing.RouteEvent;
23import org.onosproject.incubator.net.routing.RouteTableId;
24
25import java.util.Collection;
26import java.util.Optional;
27import java.util.Set;
28
29/**
30 * Stores resolved routes and best route decisions.
31 */
32public interface ResolvedRouteStore {
33
34 /**
35 * Adds or updates the best route for the given prefix.
36 *
37 * @param route new best route for this prefix
38 * @return event describing the change
39 */
40 RouteEvent updateRoute(ResolvedRoute route);
41
42 /**
43 * Removes the best route for the given prefix.
44 *
45 * @param prefix IP prefix
46 * @return event describing the change
47 */
48 RouteEvent removeRoute(IpPrefix prefix);
49
50 /**
51 * Gets the set of route tables.
52 *
53 * @return set of route table IDs
54 */
55 Set<RouteTableId> getRouteTables();
56
57 /**
58 * Returns the best routes for a give route table.
59 *
60 * @param table route table ID
61 * @return collection of selected routes
62 */
63 Collection<ResolvedRoute> getRoutes(RouteTableId table);
64
65 /**
66 * Returns the best selected route for the given IP prefix.
67 *
68 * @param prefix IP prefix
69 * @return optional best route
70 */
71 Optional<ResolvedRoute> getRoute(IpPrefix prefix);
72
73 /**
74 * Performs a longest prefix match of the best routes on the given IP address.
75 *
76 * @param ip IP address
77 * @return optional longest matching route
78 */
79 Optional<ResolvedRoute> longestPrefixMatch(IpAddress ip);
80}