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 | |
| 18 | import java.util.Collection; |
| 19 | |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 20 | import org.onlab.packet.IpAddress; |
| 21 | import org.onlab.packet.MacAddress; |
| 22 | import org.onosproject.net.ConnectPoint; |
| 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 | |
| 29 | /** |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 30 | * Specifies the type of an IP address or an IP prefix location. |
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 | public static enum LocationType { |
| 33 | /** |
| 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 | */ |
| 53 | public enum TrafficType { |
| 54 | /** |
| 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 | */ |
| 89 | public void start(); |
| 90 | |
| 91 | /** |
| 92 | * Adds FIB listener. |
| 93 | * |
| 94 | * @param fibListener listener to send FIB updates to |
| 95 | */ |
| 96 | public void addFibListener(FibListener fibListener); |
| 97 | |
| 98 | /** |
| 99 | * Adds intent creation and submission listener. |
| 100 | * |
| 101 | * @param intentRequestListener listener to send intent creation and |
| 102 | * submission request to |
| 103 | */ |
| 104 | public void addIntentRequestListener(IntentRequestListener |
| 105 | intentRequestListener); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Stops the routing service. |
| 109 | */ |
| 110 | public void stop(); |
| 111 | |
| 112 | /** |
| 113 | * Gets all IPv4 routes known to SDN-IP. |
| 114 | * |
| 115 | * @return the SDN-IP IPv4 routes |
| 116 | */ |
| 117 | public Collection<RouteEntry> getRoutes4(); |
| 118 | |
| 119 | /** |
| 120 | * Gets all IPv6 routes known to SDN-IP. |
| 121 | * |
| 122 | * @return the SDN-IP IPv6 routes |
| 123 | */ |
| 124 | public Collection<RouteEntry> getRoutes6(); |
Pingping Lin | e28ae4c | 2015-03-13 11:37:03 -0700 | [diff] [blame] | 125 | |
| 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 | */ |
| 132 | public LocationType getLocationType(IpAddress ipAddress); |
| 133 | |
| 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 | */ |
| 141 | public RouteEntry getLongestMatchableRouteEntry(IpAddress ipAddress); |
| 142 | |
| 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 | */ |
| 150 | public ConnectPoint getEgressConnectPoint(IpAddress dstIpAddress); |
| 151 | |
| 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 | */ |
| 160 | public void packetReactiveProcessor(IpAddress dstIpAddress, |
| 161 | IpAddress srcIpAddress, |
| 162 | ConnectPoint srcConnectPoint, |
| 163 | MacAddress srcMacAddress); |
Jonathan Hart | 41349e9 | 2015-02-09 14:14:02 -0800 | [diff] [blame] | 164 | } |