blob: a6db108d441430a63fd6cb9adf209155cb0d0561 [file] [log] [blame]
Jonathan Hart96c146b2017-02-24 16:32:00 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Jonathan Hart96c146b2017-02-24 16:32:00 -08003 *
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.impl;
Jonathan Hart96c146b2017-02-24 16:32:00 -080018
19import org.onlab.packet.IpAddress;
20import org.onlab.packet.IpPrefix;
Ray Milkey69ec8712017-08-08 13:00:43 -070021import org.onosproject.routeservice.ResolvedRoute;
22import org.onosproject.routeservice.RouteEvent;
23import org.onosproject.routeservice.RouteTableId;
Jonathan Hart96c146b2017-02-24 16:32:00 -080024
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
Jonathan Hartf7021682017-03-22 18:17:21 -070038 * @param alternatives alternative resolved routes
Jonathan Hart96c146b2017-02-24 16:32:00 -080039 * @return event describing the change
40 */
Jonathan Hartf7021682017-03-22 18:17:21 -070041 RouteEvent updateRoute(ResolvedRoute route, Set<ResolvedRoute> alternatives);
Jonathan Hart96c146b2017-02-24 16:32:00 -080042
43 /**
44 * Removes the best route for the given prefix.
45 *
46 * @param prefix IP prefix
47 * @return event describing the change
48 */
49 RouteEvent removeRoute(IpPrefix prefix);
50
51 /**
52 * Gets the set of route tables.
53 *
54 * @return set of route table IDs
55 */
56 Set<RouteTableId> getRouteTables();
57
58 /**
59 * Returns the best routes for a give route table.
60 *
61 * @param table route table ID
62 * @return collection of selected routes
63 */
64 Collection<ResolvedRoute> getRoutes(RouteTableId table);
65
66 /**
67 * Returns the best selected route for the given IP prefix.
68 *
69 * @param prefix IP prefix
70 * @return optional best route
71 */
72 Optional<ResolvedRoute> getRoute(IpPrefix prefix);
73
74 /**
Jonathan Hartf7021682017-03-22 18:17:21 -070075 * Returns all resolved routes stored for the given prefix, including the
76 * best selected route.
77 *
78 * @param prefix IP prefix to look up routes for
79 * @return all stored resolved routes for this prefix
80 */
81 Collection<ResolvedRoute> getAllRoutes(IpPrefix prefix);
82
83 /**
Jonathan Hart96c146b2017-02-24 16:32:00 -080084 * Performs a longest prefix match of the best routes on the given IP address.
85 *
86 * @param ip IP address
87 * @return optional longest matching route
88 */
89 Optional<ResolvedRoute> longestPrefixMatch(IpAddress ip);
90}