alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.flowobjective; |
| 17 | |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficSelector; |
| 21 | import org.onosproject.net.flow.TrafficTreatment; |
| 22 | |
| 23 | /** |
| 24 | * Represents a description of which types of traffic need to |
| 25 | * be forwarded through the device. A forwarding objective may |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 26 | * result in multiple rules at the device. There are two main types |
| 27 | * of forwarding objectives: |
| 28 | * |
| 29 | * - Versatile |
| 30 | * - Specific |
| 31 | * |
| 32 | * A versatile forwarding objective represents a composite rule that matches |
| 33 | * two or more header fields. The use of versatile usually indicates that this |
| 34 | * rule should be inserted in its entirety into the ACL table. Although, |
| 35 | * drivers for some devices are free to implement this differently. |
| 36 | * |
| 37 | * A specific forwarding objective represents a specific rule matching one or |
| 38 | * more header fields. The installation of this rule may result in several rules |
| 39 | * at the device. For example, one per table type. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 40 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 41 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 42 | public interface ForwardingObjective extends Objective { |
| 43 | |
| 44 | /** |
| 45 | * Represents whether this objective is monolithic or |
| 46 | * may be broken down into parts. |
| 47 | */ |
| 48 | enum Flag { |
| 49 | /** |
| 50 | * A decomposable objective. |
| 51 | */ |
| 52 | SPECIFIC, |
| 53 | |
| 54 | /** |
| 55 | * A monolithic objective. |
| 56 | */ |
| 57 | VERSATILE |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Obtain the selector for this objective. |
| 62 | * |
| 63 | * @return a traffic selector |
| 64 | */ |
| 65 | TrafficSelector selector(); |
| 66 | |
| 67 | /** |
| 68 | * Obtain the traffic treatment for this objective. Mutually exclusive with |
| 69 | * 'treatment'. |
| 70 | * |
| 71 | * @return an integer |
| 72 | */ |
| 73 | Integer nextId(); |
| 74 | |
| 75 | /** |
| 76 | * A traffic treatment for this forwarding objective. Mutually exclusive |
| 77 | * with a nextId. |
| 78 | * |
| 79 | * @return a traffic treatment |
| 80 | */ |
| 81 | TrafficTreatment treatment(); |
| 82 | |
| 83 | /** |
| 84 | * Obtain the type of this objective. |
| 85 | * |
| 86 | * @return a flag type |
| 87 | */ |
| 88 | Flag flag(); |
| 89 | |
| 90 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 91 | * Auxiliary optional information provided to the device driver. Typically |
| 92 | * conveys information about selectors (matches) that are intended to |
| 93 | * use this Forwarding Objective. |
| 94 | * |
| 95 | * @return a selector intended to pass meta information to the device driver. |
| 96 | * Value may be null if no meta information is provided. |
| 97 | */ |
| 98 | TrafficSelector meta(); |
| 99 | |
| 100 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 101 | * Returns a new builder set to create a copy of this objective. |
| 102 | * |
| 103 | * @return new builder |
| 104 | */ |
| 105 | @Override |
| 106 | Builder copy(); |
| 107 | |
| 108 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 109 | * A forwarding objective builder. |
| 110 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 111 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 112 | |
| 113 | /** |
| 114 | * Assigns a selector to the forwarding objective. |
| 115 | * |
| 116 | * @param selector a traffic selector |
| 117 | * @return a forwarding objective builder |
| 118 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 119 | Builder withSelector(TrafficSelector selector); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Assigns a next step to the forwarding objective. |
| 123 | * |
| 124 | * @param nextId a next objective id. |
| 125 | * @return a forwarding objective builder |
| 126 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 127 | Builder nextStep(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
| 130 | * Assigns the treatment for this forwarding objective. |
| 131 | * |
| 132 | * @param treatment a traffic treatment |
| 133 | * @return a forwarding objective |
| 134 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 135 | Builder withTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
| 138 | * Assigns the flag to the forwarding objective. |
| 139 | * |
| 140 | * @param flag a flag |
| 141 | * @return a forwarding objective builder |
| 142 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 143 | Builder withFlag(Flag flag); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 144 | |
| 145 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 146 | * Set meta information related to this forwarding objective. |
| 147 | * |
| 148 | * @param selector match conditions |
| 149 | * @return an objective builder |
| 150 | */ |
| 151 | Builder withMeta(TrafficSelector selector); |
| 152 | |
| 153 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 154 | * Assigns an application id. |
| 155 | * |
| 156 | * @param appId an application id |
| 157 | * @return a filtering builder |
| 158 | */ |
| 159 | @Override |
| 160 | Builder fromApp(ApplicationId appId); |
| 161 | |
| 162 | /** |
| 163 | * Sets the priority for this objective. |
| 164 | * |
| 165 | * @param priority an integer |
| 166 | * @return an objective builder |
| 167 | */ |
| 168 | @Override |
| 169 | Builder withPriority(int priority); |
| 170 | |
| 171 | /** |
| 172 | * Makes the filtering objective permanent. |
| 173 | * |
| 174 | * @return an objective builder |
| 175 | */ |
| 176 | @Override |
| 177 | Builder makePermanent(); |
| 178 | |
| 179 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 180 | * Builds the forwarding objective that will be added. |
| 181 | * |
| 182 | * @return a forwarding objective |
| 183 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 184 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 185 | ForwardingObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 186 | |
| 187 | /** |
| 188 | * Builds the forwarding objective that will be removed. |
| 189 | * |
| 190 | * @return a forwarding objective. |
| 191 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 192 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 193 | ForwardingObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 194 | |
| 195 | /** |
| 196 | * Builds the forwarding objective that will be added. |
| 197 | * The context will be used to notify the calling application. |
| 198 | * |
| 199 | * @param context an objective context |
| 200 | * @return a forwarding objective |
| 201 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 202 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 203 | ForwardingObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 204 | |
| 205 | /** |
| 206 | * Builds the forwarding objective that will be removed. |
| 207 | * The context will be used to notify the calling application. |
| 208 | * |
| 209 | * @param context an objective context |
| 210 | * @return a forwarding objective |
| 211 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 212 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 213 | ForwardingObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 214 | } |
| 215 | } |