blob: 0ae592035ce854699d9de3784ec23060a0f5f7d6 [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;
Ray Milkey3004c7d2017-12-13 09:43:20 -080019import org.onosproject.core.ApplicationId;
Andrea Campanellacbd16942021-06-01 16:33:14 +020020import org.onosproject.net.Annotations;
alshabibfaa1e362015-04-02 15:01:54 -070021import org.onosproject.net.flow.TrafficSelector;
22import org.onosproject.net.flow.TrafficTreatment;
23
24/**
25 * Represents a description of which types of traffic need to
26 * be forwarded through the device. A forwarding objective may
alshabib9d9e3a32015-06-25 18:33:50 -070027 * result in multiple rules at the device. There are two main types
28 * of forwarding objectives:
29 *
30 * - Versatile
31 * - Specific
32 *
33 * A versatile forwarding objective represents a composite rule that matches
34 * two or more header fields. The use of versatile usually indicates that this
35 * rule should be inserted in its entirety into the ACL table. Although,
36 * drivers for some devices are free to implement this differently.
37 *
38 * A specific forwarding objective represents a specific rule matching one or
39 * more header fields. The installation of this rule may result in several rules
40 * at the device. For example, one per table type.
Jonghwan Hyun800d9d02018-04-09 09:40:50 -070041 *
42 * There is one additional type of forwarding objective:
43 *
44 * - Egress
45 *
46 * An egress forwarding objecrive represents a flow rule that is inserted into
47 * egress tables, only if they exist in the device.
48 *
alshabibfaa1e362015-04-02 15:01:54 -070049 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070050@Beta
alshabibfaa1e362015-04-02 15:01:54 -070051public interface ForwardingObjective extends Objective {
52
53 /**
54 * Represents whether this objective is monolithic or
55 * may be broken down into parts.
56 */
57 enum Flag {
58 /**
59 * A decomposable objective.
60 */
61 SPECIFIC,
62
63 /**
64 * A monolithic objective.
65 */
Jonghwan Hyun800d9d02018-04-09 09:40:50 -070066 VERSATILE,
67
68 /**
69 * An objective to program egress pipeline.
70 */
71 EGRESS
alshabibfaa1e362015-04-02 15:01:54 -070072 }
73
74 /**
75 * Obtain the selector for this objective.
76 *
77 * @return a traffic selector
78 */
79 TrafficSelector selector();
80
81 /**
82 * Obtain the traffic treatment for this objective. Mutually exclusive with
83 * 'treatment'.
84 *
85 * @return an integer
86 */
87 Integer nextId();
88
89 /**
90 * A traffic treatment for this forwarding objective. Mutually exclusive
91 * with a nextId.
92 *
93 * @return a traffic treatment
94 */
95 TrafficTreatment treatment();
96
97 /**
98 * Obtain the type of this objective.
99 *
100 * @return a flag type
101 */
102 Flag flag();
103
104 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700105 * Auxiliary optional information provided to the device driver. Typically
106 * conveys information about selectors (matches) that are intended to
107 * use this Forwarding Objective.
108 *
109 * @return a selector intended to pass meta information to the device driver.
110 * Value may be null if no meta information is provided.
111 */
112 TrafficSelector meta();
113
114 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800115 * Returns a new builder set to create a copy of this objective.
116 *
117 * @return new builder
118 */
119 @Override
120 Builder copy();
121
122 /**
alshabibfaa1e362015-04-02 15:01:54 -0700123 * A forwarding objective builder.
124 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700125 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700126
127 /**
128 * Assigns a selector to the forwarding objective.
129 *
130 * @param selector a traffic selector
131 * @return a forwarding objective builder
132 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700133 Builder withSelector(TrafficSelector selector);
alshabibfaa1e362015-04-02 15:01:54 -0700134
135 /**
136 * Assigns a next step to the forwarding objective.
137 *
138 * @param nextId a next objective id.
139 * @return a forwarding objective builder
140 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700141 Builder nextStep(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700142
143 /**
144 * Assigns the treatment for this forwarding objective.
145 *
146 * @param treatment a traffic treatment
147 * @return a forwarding objective
148 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700149 Builder withTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700150
151 /**
152 * Assigns the flag to the forwarding objective.
153 *
154 * @param flag a flag
155 * @return a forwarding objective builder
156 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700157 Builder withFlag(Flag flag);
alshabibfaa1e362015-04-02 15:01:54 -0700158
159 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700160 * Set meta information related to this forwarding objective.
161 *
162 * @param selector match conditions
163 * @return an objective builder
164 */
165 Builder withMeta(TrafficSelector selector);
166
167 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800168 * Assigns an application id.
169 *
170 * @param appId an application id
171 * @return a filtering builder
172 */
173 @Override
174 Builder fromApp(ApplicationId appId);
175
176 /**
177 * Sets the priority for this objective.
178 *
179 * @param priority an integer
180 * @return an objective builder
181 */
182 @Override
183 Builder withPriority(int priority);
184
185 /**
Andrea Campanellacbd16942021-06-01 16:33:14 +0200186 * Makes the forwarding objective permanent.
Ray Milkey3004c7d2017-12-13 09:43:20 -0800187 *
188 * @return an objective builder
189 */
190 @Override
191 Builder makePermanent();
192
193 /**
Andrea Campanellacbd16942021-06-01 16:33:14 +0200194 * Adds annotations to the forwarding objective.
195 *
196 * @param annotations the annotations for the forwarding objective
197 * @return a forwarding objective builder
198 */
199 @Override
200 Builder withAnnotations(Annotations annotations);
201
202 /**
alshabibfaa1e362015-04-02 15:01:54 -0700203 * Builds the forwarding objective that will be added.
204 *
205 * @return a forwarding objective
206 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800207 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700208 ForwardingObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700209
210 /**
211 * Builds the forwarding objective that will be removed.
212 *
213 * @return a forwarding objective.
214 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800215 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700216 ForwardingObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700217
218 /**
219 * Builds the forwarding objective that will be added.
220 * The context will be used to notify the calling application.
221 *
222 * @param context an objective context
223 * @return a forwarding objective
224 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800225 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700226 ForwardingObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700227
228 /**
229 * Builds the forwarding objective that will be removed.
230 * The context will be used to notify the calling application.
231 *
232 * @param context an objective context
233 * @return a forwarding objective
234 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800235 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700236 ForwardingObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700237 }
238}