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; |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 21 | import org.onosproject.routing.config.BgpConfig; |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 22 | |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 23 | import java.util.Collection; |
| 24 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 25 | /** |
| 26 | * Provides a way of interacting with the RIB management component. |
| 27 | */ |
| 28 | public interface RoutingService { |
| 29 | |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 30 | String ROUTER_APP_ID = "org.onosproject.router"; |
| 31 | |
Jonathan Hart | 4cb3988 | 2015-08-12 23:50:55 -0400 | [diff] [blame] | 32 | Class<BgpConfig> CONFIG_CLASS = BgpConfig.class; |
| 33 | |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 34 | /** |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 35 | * Specifies the type of an IP address or an IP prefix location. |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 36 | */ |
Jonathan Hart | 6601899 | 2015-07-31 11:19:27 -0700 | [diff] [blame] | 37 | enum LocationType { |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 38 | /** |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 58 | enum TrafficType { |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 59 | /** |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 94 | void start(); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Adds FIB listener. |
| 98 | * |
| 99 | * @param fibListener listener to send FIB updates to |
| 100 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 101 | void addFibListener(FibListener fibListener); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Adds intent creation and submission listener. |
| 105 | * |
| 106 | * @param intentRequestListener listener to send intent creation and |
| 107 | * submission request to |
| 108 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 109 | void addIntentRequestListener(IntentRequestListener |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 110 | intentRequestListener); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Stops the routing service. |
| 114 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 115 | void stop(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 116 | |
| 117 | /** |
| 118 | * Gets all IPv4 routes known to SDN-IP. |
| 119 | * |
| 120 | * @return the SDN-IP IPv4 routes |
| 121 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 122 | Collection<RouteEntry> getRoutes4(); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Gets all IPv6 routes known to SDN-IP. |
| 126 | * |
| 127 | * @return the SDN-IP IPv6 routes |
| 128 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 129 | Collection<RouteEntry> getRoutes6(); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 130 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 137 | LocationType getLocationType(IpAddress ipAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 138 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 146 | RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 147 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 155 | ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 156 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 165 | void packetReactiveProcessor(IpAddress dstIpAddress, |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 166 | IpAddress srcIpAddress, |
| 167 | ConnectPoint srcConnectPoint, |
| 168 | MacAddress srcMacAddress); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 169 | } |