blob: 36098d7102ff565fafc97a3f3d1b29e26e2f04f5 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
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 */
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 /**
Saurav Das8a0732e2015-11-20 15:27:53 -080088 * Auxiliary optional information provided to the device-driver.Typically
89 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -070098 * A next step builder.
99 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700100 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700101
102 /**
103 * Specifies the id for this next objective.
104 *
105 * @param nextId an integer
106 * @return a next objective builder
107 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700108 Builder withId(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Sets the type of next step.
112 *
113 * @param type a type
114 * @return a next step builder
115 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700116 Builder withType(Type type);
alshabibfaa1e362015-04-02 15:01:54 -0700117
118 /**
119 * Adds a treatment to this next step.
120 *
121 * @param treatment a traffic treatment
122 * @return a next step builder
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Builder addTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700125
Ray Milkey810d6e72015-08-14 10:35:06 -0700126 /**
127 * Specifies the application which applied the filter.
128 *
129 * @param appId an application id
130 * @return an objective builder
131 */
alshabib2a441c62015-04-13 18:39:38 -0700132 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700133 Builder fromApp(ApplicationId appId);
alshabib2a441c62015-04-13 18:39:38 -0700134
alshabibfaa1e362015-04-02 15:01:54 -0700135 /**
Ray Milkey810d6e72015-08-14 10:35:06 -0700136 * Sets the priority for this objective.
137 *
138 * @param priority an integer
139 * @return an objective builder
140 */
141 @Override
142 Builder withPriority(int priority);
143
144 /**
Saurav Das8a0732e2015-11-20 15:27:53 -0800145 * Set meta information related to this next objective.
146 *
147 * @param selector match conditions
148 * @return an objective builder
149 */
Saurav Das4ce45962015-11-24 23:21:05 -0800150 Builder withMeta(TrafficSelector selector);
Saurav Das8a0732e2015-11-20 15:27:53 -0800151
152 /**
alshabib2a441c62015-04-13 18:39:38 -0700153 * Builds the next objective that will be added.
alshabibfaa1e362015-04-02 15:01:54 -0700154 *
alshabib2a441c62015-04-13 18:39:38 -0700155 * @return a next objective
alshabibfaa1e362015-04-02 15:01:54 -0700156 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700157 NextObjective add();
alshabib2a441c62015-04-13 18:39:38 -0700158
159 /**
160 * Builds the next objective that will be removed.
161 *
162 * @return a next objective.
163 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700164 NextObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700165
166 /**
167 * Builds the next objective that will be added.
168 * The context will be used to notify the calling application.
169 *
170 * @param context an objective context
171 * @return a next objective
172 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700173 NextObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700174
175 /**
176 * Builds the next objective that will be removed.
177 * The context will be used to notify the calling application.
178 *
179 * @param context an objective context
180 * @return a next objective
181 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700182 NextObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700183
Saurav Das8a0732e2015-11-20 15:27:53 -0800184 /**
185 * Build the next objective that will be added, with {@link Operation}
186 * ADD_TO_EXISTING.
187 *
188 * @return a next objective
189 */
190 NextObjective addToExisting();
191
192 /**
193 * Build the next objective that will be removed, with {@link Operation}
194 * REMOVE_FROM_EXISTING.
195 *
196 * @return a next objective
197 */
198 NextObjective removeFromExisting();
199
200 /**
201 * Builds the next objective that will be added, with {@link Operation}
202 * ADD_TO_EXISTING. The context will be used to notify the calling application.
203 *
204 * @param context an objective context
205 * @return a next objective
206 */
207 NextObjective addToExisting(ObjectiveContext context);
208
209 /**
210 * Builds the next objective that will be removed, with {@link Operation}
211 * REMOVE_FROM_EXISTING. The context will be used to notify the calling application.
212 *
213 * @param context an objective context
214 * @return a next objective
215 */
216 NextObjective removeFromExisting(ObjectiveContext context);
217
alshabibfaa1e362015-04-02 15:01:54 -0700218 }
219
220}