Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 1 | /* |
| 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 Hart | 2da1e60 | 2015-02-18 19:09:24 -0800 | [diff] [blame] | 16 | package org.onosproject.routing; |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 17 | |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 18 | import org.onlab.packet.IpAddress; |
| 19 | import org.onlab.packet.MacAddress; |
| 20 | import org.onosproject.net.ConnectPoint; |
| 21 | |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 22 | import java.util.Collection; |
| 23 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 24 | /** |
| 25 | * Provides a way of interacting with the RIB management component. |
| 26 | */ |
| 27 | public interface RoutingService { |
| 28 | |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 29 | String ROUTER_APP_ID = "org.onosproject.router"; |
| 30 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 31 | /** |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 32 | * Specifies the type of an IP address or an IP prefix location. |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 33 | */ |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 34 | enum LocationType { |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 35 | /** |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 55 | enum TrafficType { |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 56 | /** |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 91 | void start(); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * Adds FIB listener. |
| 95 | * |
| 96 | * @param fibListener listener to send FIB updates to |
| 97 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 98 | void addFibListener(FibListener fibListener); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
| 101 | * Adds intent creation and submission listener. |
| 102 | * |
| 103 | * @param intentRequestListener listener to send intent creation and |
| 104 | * submission request to |
| 105 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 106 | void addIntentRequestListener(IntentRequestListener |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 107 | intentRequestListener); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * Stops the routing service. |
| 111 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 112 | void stop(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 113 | |
| 114 | /** |
| 115 | * Gets all IPv4 routes known to SDN-IP. |
| 116 | * |
| 117 | * @return the SDN-IP IPv4 routes |
| 118 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 119 | Collection<RouteEntry> getRoutes4(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Gets all IPv6 routes known to SDN-IP. |
| 123 | * |
| 124 | * @return the SDN-IP IPv6 routes |
| 125 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 126 | Collection<RouteEntry> getRoutes6(); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 127 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 134 | LocationType getLocationType(IpAddress ipAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 135 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 143 | RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 144 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 152 | ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 153 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 162 | void packetReactiveProcessor(IpAddress dstIpAddress, |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 163 | IpAddress srcIpAddress, |
| 164 | ConnectPoint srcConnectPoint, |
| 165 | MacAddress srcMacAddress); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 166 | } |