blob: 7774082222e70dd5344b6a8bbee11865ac2068c0 [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
18import java.util.Collection;
19
Pingping Line28ae4c2015-03-13 11:37:03 -070020import org.onlab.packet.IpAddress;
21import org.onlab.packet.MacAddress;
22import org.onosproject.net.ConnectPoint;
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
29 /**
Pingping Line28ae4c2015-03-13 11:37:03 -070030 * Specifies the type of an IP address or an IP prefix location.
Jonathan Hart41349e92015-02-09 14:14:02 -080031 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070032 static enum LocationType {
Pingping Line28ae4c2015-03-13 11:37:03 -070033 /**
34 * The location of an IP address or an IP prefix is in local SDN network.
35 */
36 LOCAL,
37 /**
38 * The location of an IP address or an IP prefix is outside local SDN network.
39 */
40 INTERNET,
41 /**
42 * There is no route for this IP address or IP prefix.
43 */
44 NO_ROUTE
45 }
46
47 /**
48 * Specifies the type of traffic.
49 * <p>
50 * We classify traffic by the first packet of each traffic.
51 * </p>
52 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070053 enum TrafficType {
Pingping Line28ae4c2015-03-13 11:37:03 -070054 /**
55 * Traffic from a host located in local SDN network wants to
56 * communicate with destination host located in Internet (outside
57 * local SDN network).
58 */
59 HOST_TO_INTERNET,
60 /**
61 * Traffic from Internet wants to communicate with a host located
62 * in local SDN network.
63 */
64 INTERNET_TO_HOST,
65 /**
66 * Both the source host and destination host of a traffic are in
67 * local SDN network.
68 */
69 HOST_TO_HOST,
70 /**
71 * Traffic from Internet wants to traverse local SDN network.
72 */
73 INTERNET_TO_INTERNET,
74 /**
75 * Any traffic wants to communicate with a destination which has
76 * no route, or traffic from Internet wants to access a local private
77 * IP address.
78 */
79 DROP,
80 /**
81 * Traffic does not belong to the types above.
82 */
83 UNKNOWN
84 }
85
86 /**
87 * Starts the routing service.
88 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070089 void start();
Pingping Line28ae4c2015-03-13 11:37:03 -070090
91 /**
92 * Adds FIB listener.
93 *
94 * @param fibListener listener to send FIB updates to
95 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070096 void addFibListener(FibListener fibListener);
Pingping Line28ae4c2015-03-13 11:37:03 -070097
98 /**
99 * Adds intent creation and submission listener.
100 *
101 * @param intentRequestListener listener to send intent creation and
102 * submission request to
103 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700104 void addIntentRequestListener(IntentRequestListener
Pingping Line28ae4c2015-03-13 11:37:03 -0700105 intentRequestListener);
Jonathan Hart41349e92015-02-09 14:14:02 -0800106
107 /**
108 * Stops the routing service.
109 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700110 void stop();
Jonathan Hart41349e92015-02-09 14:14:02 -0800111
112 /**
113 * Gets all IPv4 routes known to SDN-IP.
114 *
115 * @return the SDN-IP IPv4 routes
116 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700117 Collection<RouteEntry> getRoutes4();
Jonathan Hart41349e92015-02-09 14:14:02 -0800118
119 /**
120 * Gets all IPv6 routes known to SDN-IP.
121 *
122 * @return the SDN-IP IPv6 routes
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Collection<RouteEntry> getRoutes6();
Pingping Line28ae4c2015-03-13 11:37:03 -0700125
126 /**
127 * Evaluates the location of an IP address and returns the location type.
128 *
129 * @param ipAddress the IP address to evaluate
130 * @return the IP address location type
131 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700132 LocationType getLocationType(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700133
134 /**
135 * Finds out the route entry which has the longest matchable IP prefix.
136 *
137 * @param ipAddress IP address used to find out longest matchable IP prefix
138 * @return a route entry which has the longest matchable IP prefix if
139 * found, otherwise null
140 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700141 RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700142
143 /**
144 * Finds out the egress connect point where to emit the first packet
145 * based on destination IP address.
146 *
147 * @param dstIpAddress the destination IP address
148 * @return the egress connect point if found, otherwise null
149 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700150 ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700151
152 /**
153 * Routes packet reactively.
154 *
155 * @param dstIpAddress the destination IP address of a packet
156 * @param srcIpAddress the source IP address of a packet
157 * @param srcConnectPoint the connect point where a packet comes from
158 * @param srcMacAddress the source MAC address of a packet
159 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700160 void packetReactiveProcessor(IpAddress dstIpAddress,
Pingping Line28ae4c2015-03-13 11:37:03 -0700161 IpAddress srcIpAddress,
162 ConnectPoint srcConnectPoint,
163 MacAddress srcMacAddress);
Jonathan Hart41349e92015-02-09 14:14:02 -0800164}