blob: 5706211619e43d51a17118ca68f719f339f80ade [file] [log] [blame]
Jonathan Hart41349e92015-02-09 14:14:02 -08001/*
2 * Copyright 2015 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 */
Jonathan Hart2da1e602015-02-18 19:09:24 -080016package org.onosproject.routing;
Jonathan Hart41349e92015-02-09 14:14:02 -080017
Pingping Line28ae4c2015-03-13 11:37:03 -070018import org.onlab.packet.IpAddress;
19import org.onlab.packet.MacAddress;
20import org.onosproject.net.ConnectPoint;
21
Jonathan Hart66018992015-07-31 11:19:27 -070022import java.util.Collection;
23
Jonathan Hart41349e92015-02-09 14:14:02 -080024/**
25 * Provides a way of interacting with the RIB management component.
26 */
27public interface RoutingService {
28
Jonathan Hart66018992015-07-31 11:19:27 -070029 String ROUTER_APP_ID = "org.onosproject.router";
30
Jonathan Hart41349e92015-02-09 14:14:02 -080031 /**
Pingping Line28ae4c2015-03-13 11:37:03 -070032 * Specifies the type of an IP address or an IP prefix location.
Jonathan Hart41349e92015-02-09 14:14:02 -080033 */
Jonathan Hart66018992015-07-31 11:19:27 -070034 enum LocationType {
Pingping Line28ae4c2015-03-13 11:37:03 -070035 /**
36 * The location of an IP address or an IP prefix is in local SDN network.
37 */
38 LOCAL,
39 /**
40 * The location of an IP address or an IP prefix is outside local SDN network.
41 */
42 INTERNET,
43 /**
44 * There is no route for this IP address or IP prefix.
45 */
46 NO_ROUTE
47 }
48
49 /**
50 * Specifies the type of traffic.
51 * <p>
52 * We classify traffic by the first packet of each traffic.
53 * </p>
54 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070055 enum TrafficType {
Pingping Line28ae4c2015-03-13 11:37:03 -070056 /**
57 * Traffic from a host located in local SDN network wants to
58 * communicate with destination host located in Internet (outside
59 * local SDN network).
60 */
61 HOST_TO_INTERNET,
62 /**
63 * Traffic from Internet wants to communicate with a host located
64 * in local SDN network.
65 */
66 INTERNET_TO_HOST,
67 /**
68 * Both the source host and destination host of a traffic are in
69 * local SDN network.
70 */
71 HOST_TO_HOST,
72 /**
73 * Traffic from Internet wants to traverse local SDN network.
74 */
75 INTERNET_TO_INTERNET,
76 /**
77 * Any traffic wants to communicate with a destination which has
78 * no route, or traffic from Internet wants to access a local private
79 * IP address.
80 */
81 DROP,
82 /**
83 * Traffic does not belong to the types above.
84 */
85 UNKNOWN
86 }
87
88 /**
89 * Starts the routing service.
90 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070091 void start();
Pingping Line28ae4c2015-03-13 11:37:03 -070092
93 /**
94 * Adds FIB listener.
95 *
96 * @param fibListener listener to send FIB updates to
97 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070098 void addFibListener(FibListener fibListener);
Pingping Line28ae4c2015-03-13 11:37:03 -070099
100 /**
101 * Adds intent creation and submission listener.
102 *
103 * @param intentRequestListener listener to send intent creation and
104 * submission request to
105 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700106 void addIntentRequestListener(IntentRequestListener
Pingping Line28ae4c2015-03-13 11:37:03 -0700107 intentRequestListener);
Jonathan Hart41349e92015-02-09 14:14:02 -0800108
109 /**
110 * Stops the routing service.
111 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700112 void stop();
Jonathan Hart41349e92015-02-09 14:14:02 -0800113
114 /**
115 * Gets all IPv4 routes known to SDN-IP.
116 *
117 * @return the SDN-IP IPv4 routes
118 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700119 Collection<RouteEntry> getRoutes4();
Jonathan Hart41349e92015-02-09 14:14:02 -0800120
121 /**
122 * Gets all IPv6 routes known to SDN-IP.
123 *
124 * @return the SDN-IP IPv6 routes
125 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700126 Collection<RouteEntry> getRoutes6();
Pingping Line28ae4c2015-03-13 11:37:03 -0700127
128 /**
129 * Evaluates the location of an IP address and returns the location type.
130 *
131 * @param ipAddress the IP address to evaluate
132 * @return the IP address location type
133 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700134 LocationType getLocationType(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700135
136 /**
137 * Finds out the route entry which has the longest matchable IP prefix.
138 *
139 * @param ipAddress IP address used to find out longest matchable IP prefix
140 * @return a route entry which has the longest matchable IP prefix if
141 * found, otherwise null
142 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700143 RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700144
145 /**
146 * Finds out the egress connect point where to emit the first packet
147 * based on destination IP address.
148 *
149 * @param dstIpAddress the destination IP address
150 * @return the egress connect point if found, otherwise null
151 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700152 ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700153
154 /**
155 * Routes packet reactively.
156 *
157 * @param dstIpAddress the destination IP address of a packet
158 * @param srcIpAddress the source IP address of a packet
159 * @param srcConnectPoint the connect point where a packet comes from
160 * @param srcMacAddress the source MAC address of a packet
161 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700162 void packetReactiveProcessor(IpAddress dstIpAddress,
Pingping Line28ae4c2015-03-13 11:37:03 -0700163 IpAddress srcIpAddress,
164 ConnectPoint srcConnectPoint,
165 MacAddress srcMacAddress);
Jonathan Hart41349e92015-02-09 14:14:02 -0800166}