blob: 8b7040e2a2312efa4329ffdfc6317eba2b0cbc58 [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;
Jonathan Hart4cb39882015-08-12 23:50:55 -040021import org.onosproject.routing.config.BgpConfig;
Pingping Line28ae4c2015-03-13 11:37:03 -070022
Jonathan Hart66018992015-07-31 11:19:27 -070023import java.util.Collection;
24
Jonathan Hart41349e92015-02-09 14:14:02 -080025/**
26 * Provides a way of interacting with the RIB management component.
27 */
28public interface RoutingService {
29
Jonathan Hart66018992015-07-31 11:19:27 -070030 String ROUTER_APP_ID = "org.onosproject.router";
31
Jonathan Hart4cb39882015-08-12 23:50:55 -040032 Class<BgpConfig> CONFIG_CLASS = BgpConfig.class;
33
Jonathan Hart41349e92015-02-09 14:14:02 -080034 /**
Pingping Line28ae4c2015-03-13 11:37:03 -070035 * Specifies the type of an IP address or an IP prefix location.
Jonathan Hart41349e92015-02-09 14:14:02 -080036 */
Jonathan Hart66018992015-07-31 11:19:27 -070037 enum LocationType {
Pingping Line28ae4c2015-03-13 11:37:03 -070038 /**
39 * The location of an IP address or an IP prefix is in local SDN network.
40 */
41 LOCAL,
42 /**
43 * The location of an IP address or an IP prefix is outside local SDN network.
44 */
45 INTERNET,
46 /**
47 * There is no route for this IP address or IP prefix.
48 */
49 NO_ROUTE
50 }
51
52 /**
53 * Specifies the type of traffic.
54 * <p>
55 * We classify traffic by the first packet of each traffic.
56 * </p>
57 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070058 enum TrafficType {
Pingping Line28ae4c2015-03-13 11:37:03 -070059 /**
60 * Traffic from a host located in local SDN network wants to
61 * communicate with destination host located in Internet (outside
62 * local SDN network).
63 */
64 HOST_TO_INTERNET,
65 /**
66 * Traffic from Internet wants to communicate with a host located
67 * in local SDN network.
68 */
69 INTERNET_TO_HOST,
70 /**
71 * Both the source host and destination host of a traffic are in
72 * local SDN network.
73 */
74 HOST_TO_HOST,
75 /**
76 * Traffic from Internet wants to traverse local SDN network.
77 */
78 INTERNET_TO_INTERNET,
79 /**
80 * Any traffic wants to communicate with a destination which has
81 * no route, or traffic from Internet wants to access a local private
82 * IP address.
83 */
84 DROP,
85 /**
86 * Traffic does not belong to the types above.
87 */
88 UNKNOWN
89 }
90
91 /**
92 * Starts the routing service.
93 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070094 void start();
Pingping Line28ae4c2015-03-13 11:37:03 -070095
96 /**
97 * Adds FIB listener.
98 *
99 * @param fibListener listener to send FIB updates to
100 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700101 void addFibListener(FibListener fibListener);
Pingping Line28ae4c2015-03-13 11:37:03 -0700102
103 /**
104 * Adds intent creation and submission listener.
105 *
106 * @param intentRequestListener listener to send intent creation and
107 * submission request to
108 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700109 void addIntentRequestListener(IntentRequestListener
Pingping Line28ae4c2015-03-13 11:37:03 -0700110 intentRequestListener);
Jonathan Hart41349e92015-02-09 14:14:02 -0800111
112 /**
113 * Stops the routing service.
114 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700115 void stop();
Jonathan Hart41349e92015-02-09 14:14:02 -0800116
117 /**
118 * Gets all IPv4 routes known to SDN-IP.
119 *
120 * @return the SDN-IP IPv4 routes
121 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700122 Collection<RouteEntry> getRoutes4();
Jonathan Hart41349e92015-02-09 14:14:02 -0800123
124 /**
125 * Gets all IPv6 routes known to SDN-IP.
126 *
127 * @return the SDN-IP IPv6 routes
128 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700129 Collection<RouteEntry> getRoutes6();
Pingping Line28ae4c2015-03-13 11:37:03 -0700130
131 /**
132 * Evaluates the location of an IP address and returns the location type.
133 *
134 * @param ipAddress the IP address to evaluate
135 * @return the IP address location type
136 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700137 LocationType getLocationType(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700138
139 /**
140 * Finds out the route entry which has the longest matchable IP prefix.
141 *
142 * @param ipAddress IP address used to find out longest matchable IP prefix
143 * @return a route entry which has the longest matchable IP prefix if
144 * found, otherwise null
145 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700146 RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700147
148 /**
149 * Finds out the egress connect point where to emit the first packet
150 * based on destination IP address.
151 *
152 * @param dstIpAddress the destination IP address
153 * @return the egress connect point if found, otherwise null
154 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700155 ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress);
Pingping Line28ae4c2015-03-13 11:37:03 -0700156
157 /**
158 * Routes packet reactively.
159 *
160 * @param dstIpAddress the destination IP address of a packet
161 * @param srcIpAddress the source IP address of a packet
162 * @param srcConnectPoint the connect point where a packet comes from
163 * @param srcMacAddress the source MAC address of a packet
164 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700165 void packetReactiveProcessor(IpAddress dstIpAddress,
Pingping Line28ae4c2015-03-13 11:37:03 -0700166 IpAddress srcIpAddress,
167 ConnectPoint srcConnectPoint,
168 MacAddress srcMacAddress);
Jonathan Hart41349e92015-02-09 14:14:02 -0800169}