blob: 4cc8478d39b50ad5ecdc6d7aad2098f7fd84986b [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
alshabibfaa1e362015-04-02 15:01:54 -07003 *
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 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabib2a441c62015-04-13 18:39:38 -070019import org.onosproject.core.ApplicationId;
Saurav Das8a0732e2015-11-20 15:27:53 -080020import org.onosproject.net.flow.TrafficSelector;
alshabibfaa1e362015-04-02 15:01:54 -070021import org.onosproject.net.flow.TrafficTreatment;
22
23import java.util.Collection;
24
25/**
26 * Represents a nexthop which will be translated by a driver
27 * into the appropriate group or actions needed to implement
alshabib9d9e3a32015-06-25 18:33:50 -070028 * the egress function.
29 *
Sho SHIMIZUfee286d2015-07-01 10:19:10 -070030 * A next objective is made up of a collection of traffic treatments
alshabib9d9e3a32015-06-25 18:33:50 -070031 * associated with a type. These types are:
32 *
33 * - Hashed
34 * - Broadcast
35 * - Failover
36 * - Simple
37 *
Saurav Das8a0732e2015-11-20 15:27:53 -080038 * These types will indicate to the driver what the intended behavior is.
alshabib9d9e3a32015-06-25 18:33:50 -070039 * For example, a broadcast next objective with a collection of output
40 * treatments will indicate to a driver that all output actions are expected
41 * to be executed simultaneously. The driver is then free to implement this
42 * as a group or a simple action list.
alshabibfaa1e362015-04-02 15:01:54 -070043 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070044@Beta
alshabibfaa1e362015-04-02 15:01:54 -070045public interface NextObjective extends Objective {
46
47 /**
48 * Represents the type of next phase to build.
49 */
50 enum Type {
51 /**
52 * A hashed packet processing.
53 */
54 HASHED,
55
56 /**
57 * Broadcast packet process.
58 */
59 BROADCAST,
60
61 /**
62 * Failover handling.
63 */
64 FAILOVER,
65
66 /**
67 * Simple processing. Could be a group or a treatment.
68 */
69 SIMPLE
70 }
71
72 /**
73 * The collection of treatments that need to be applied to a set of traffic.
74 *
75 * @return a collection of traffic treatments
76 */
77 Collection<TrafficTreatment> next();
78
79 /**
80 * The type of operation that will be applied to the traffic using the collection
81 * of treatments.
82 *
83 * @return a type
84 */
85 Type type();
86
87 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -070088 * Auxiliary optional information provided to the device driver. Typically
Saurav Das8a0732e2015-11-20 15:27:53 -080089 * conveys information about selectors (matches) that are intended to
90 * use this Next Objective.
91 *
92 * @return a selector intended to pass meta information to the device driver.
93 * Value may be null if no meta information is provided.
94 */
95 TrafficSelector meta();
96
97 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -080098 * Returns a new builder set to create a copy of this objective.
99 *
100 * @return new builder
101 */
102 @Override
103 Builder copy();
104
105 /**
alshabibfaa1e362015-04-02 15:01:54 -0700106 * A next step builder.
107 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700108 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Specifies the id for this next objective.
112 *
113 * @param nextId an integer
114 * @return a next objective builder
115 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700116 Builder withId(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700117
118 /**
119 * Sets the type of next step.
120 *
121 * @param type a type
122 * @return a next step builder
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Builder withType(Type type);
alshabibfaa1e362015-04-02 15:01:54 -0700125
126 /**
127 * Adds a treatment to this next step.
128 *
129 * @param treatment a traffic treatment
130 * @return a next step builder
131 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700132 Builder addTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700133
Ray Milkey810d6e72015-08-14 10:35:06 -0700134 /**
135 * Specifies the application which applied the filter.
136 *
137 * @param appId an application id
138 * @return an objective builder
139 */
alshabib2a441c62015-04-13 18:39:38 -0700140 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700141 Builder fromApp(ApplicationId appId);
alshabib2a441c62015-04-13 18:39:38 -0700142
alshabibfaa1e362015-04-02 15:01:54 -0700143 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700144 * Sets the priority for this objective.
145 *
146 * @param priority an integer
147 * @return an objective builder
148 */
149 @Override
150 Builder withPriority(int priority);
151
152 /**
Saurav Das8a0732e2015-11-20 15:27:53 -0800153 * Set meta information related to this next objective.
154 *
155 * @param selector match conditions
156 * @return an objective builder
157 */
Saurav Das4ce45962015-11-24 23:21:05 -0800158 Builder withMeta(TrafficSelector selector);
Saurav Das8a0732e2015-11-20 15:27:53 -0800159
160 /**
alshabib2a441c62015-04-13 18:39:38 -0700161 * Builds the next objective that will be added.
alshabibfaa1e362015-04-02 15:01:54 -0700162 *
alshabib2a441c62015-04-13 18:39:38 -0700163 * @return a next objective
alshabibfaa1e362015-04-02 15:01:54 -0700164 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800165 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700166 NextObjective add();
alshabib2a441c62015-04-13 18:39:38 -0700167
168 /**
169 * Builds the next objective that will be removed.
170 *
171 * @return a next objective.
172 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800173 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700174 NextObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700175
176 /**
177 * Builds the next objective that will be added.
178 * The context will be used to notify the calling application.
179 *
180 * @param context an objective context
181 * @return a next objective
182 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800183 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700184 NextObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700185
186 /**
187 * Builds the next objective that will be removed.
188 * The context will be used to notify the calling application.
189 *
190 * @param context an objective context
191 * @return a next objective
192 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800193 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700194 NextObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700195
Saurav Das8a0732e2015-11-20 15:27:53 -0800196 /**
197 * Build the next objective that will be added, with {@link Operation}
198 * ADD_TO_EXISTING.
199 *
200 * @return a next objective
201 */
202 NextObjective addToExisting();
203
204 /**
205 * Build the next objective that will be removed, with {@link Operation}
206 * REMOVE_FROM_EXISTING.
207 *
208 * @return a next objective
209 */
210 NextObjective removeFromExisting();
211
212 /**
213 * Builds the next objective that will be added, with {@link Operation}
214 * ADD_TO_EXISTING. The context will be used to notify the calling application.
215 *
216 * @param context an objective context
217 * @return a next objective
218 */
219 NextObjective addToExisting(ObjectiveContext context);
220
221 /**
222 * Builds the next objective that will be removed, with {@link Operation}
223 * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
224 *
225 * @param context an objective context
226 * @return a next objective
227 */
228 NextObjective removeFromExisting(ObjectiveContext context);
229
Saurav Dasceccf242017-08-03 18:30:35 -0700230 /**
Jonghwan Hyunf810a7a2018-02-12 16:43:45 +0900231 * Build the next objective that will be modified with {@link Operation}
232 * MODIFY.
233 *
234 * @return a next objective
235 */
236
237 NextObjective modify();
238 /**
239 * Build the next objective that will be modified, with {@link Operation}
240 * MODIFY. The context will be used to notify the calling application.
241 *
242 * @param context an objective context
243 * @return a next objective
244 */
245 NextObjective modify(ObjectiveContext context);
246
247 /**
Saurav Dasceccf242017-08-03 18:30:35 -0700248 * Builds the next objective that needs to be verified.
249 *
250 * @return a next objective with {@link Operation} VERIFY
251 */
252 NextObjective verify();
253
254 /**
255 * Builds the next objective that needs to be verified. The context will
256 * be used to notify the calling application.
257 *
258 * @param context an objective context
259 * @return a next objective with {@link Operation} VERIFY
260 */
261 NextObjective verify(ObjectiveContext context);
262
alshabibfaa1e362015-04-02 15:01:54 -0700263 }
264
265}