blob: a0c81af54eb6c8ad31cbd352f665d0422da33c5c [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;
alshabibfaa1e362015-04-02 15:01:54 -070020import org.onosproject.net.flow.TrafficSelector;
21import 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
alshabib9d9e3a32015-06-25 18:33:50 -070026 * 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.
Jonghwan Hyun800d9d02018-04-09 09:40:50 -070040 *
41 * There is one additional type of forwarding objective:
42 *
43 * - Egress
44 *
45 * An egress forwarding objecrive represents a flow rule that is inserted into
46 * egress tables, only if they exist in the device.
47 *
alshabibfaa1e362015-04-02 15:01:54 -070048 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070049@Beta
alshabibfaa1e362015-04-02 15:01:54 -070050public interface ForwardingObjective extends Objective {
51
52 /**
53 * Represents whether this objective is monolithic or
54 * may be broken down into parts.
55 */
56 enum Flag {
57 /**
58 * A decomposable objective.
59 */
60 SPECIFIC,
61
62 /**
63 * A monolithic objective.
64 */
Jonghwan Hyun800d9d02018-04-09 09:40:50 -070065 VERSATILE,
66
67 /**
68 * An objective to program egress pipeline.
69 */
70 EGRESS
alshabibfaa1e362015-04-02 15:01:54 -070071 }
72
73 /**
74 * Obtain the selector for this objective.
75 *
76 * @return a traffic selector
77 */
78 TrafficSelector selector();
79
80 /**
81 * Obtain the traffic treatment for this objective. Mutually exclusive with
82 * 'treatment'.
83 *
84 * @return an integer
85 */
86 Integer nextId();
87
88 /**
89 * A traffic treatment for this forwarding objective. Mutually exclusive
90 * with a nextId.
91 *
92 * @return a traffic treatment
93 */
94 TrafficTreatment treatment();
95
96 /**
97 * Obtain the type of this objective.
98 *
99 * @return a flag type
100 */
101 Flag flag();
102
103 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700104 * Auxiliary optional information provided to the device driver. Typically
105 * conveys information about selectors (matches) that are intended to
106 * use this Forwarding Objective.
107 *
108 * @return a selector intended to pass meta information to the device driver.
109 * Value may be null if no meta information is provided.
110 */
111 TrafficSelector meta();
112
113 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800114 * Returns a new builder set to create a copy of this objective.
115 *
116 * @return new builder
117 */
118 @Override
119 Builder copy();
120
121 /**
alshabibfaa1e362015-04-02 15:01:54 -0700122 * A forwarding objective builder.
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700125
126 /**
127 * Assigns a selector to the forwarding objective.
128 *
129 * @param selector a traffic selector
130 * @return a forwarding objective builder
131 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700132 Builder withSelector(TrafficSelector selector);
alshabibfaa1e362015-04-02 15:01:54 -0700133
134 /**
135 * Assigns a next step to the forwarding objective.
136 *
137 * @param nextId a next objective id.
138 * @return a forwarding objective builder
139 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700140 Builder nextStep(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700141
142 /**
143 * Assigns the treatment for this forwarding objective.
144 *
145 * @param treatment a traffic treatment
146 * @return a forwarding objective
147 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700148 Builder withTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700149
150 /**
151 * Assigns the flag to the forwarding objective.
152 *
153 * @param flag a flag
154 * @return a forwarding objective builder
155 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700156 Builder withFlag(Flag flag);
alshabibfaa1e362015-04-02 15:01:54 -0700157
158 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700159 * Set meta information related to this forwarding objective.
160 *
161 * @param selector match conditions
162 * @return an objective builder
163 */
164 Builder withMeta(TrafficSelector selector);
165
166 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800167 * Assigns an application id.
168 *
169 * @param appId an application id
170 * @return a filtering builder
171 */
172 @Override
173 Builder fromApp(ApplicationId appId);
174
175 /**
176 * Sets the priority for this objective.
177 *
178 * @param priority an integer
179 * @return an objective builder
180 */
181 @Override
182 Builder withPriority(int priority);
183
184 /**
185 * Makes the filtering objective permanent.
186 *
187 * @return an objective builder
188 */
189 @Override
190 Builder makePermanent();
191
192 /**
alshabibfaa1e362015-04-02 15:01:54 -0700193 * Builds the forwarding objective that will be added.
194 *
195 * @return a forwarding objective
196 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800197 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700198 ForwardingObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700199
200 /**
201 * Builds the forwarding objective that will be removed.
202 *
203 * @return a forwarding objective.
204 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800205 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700206 ForwardingObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700207
208 /**
209 * Builds the forwarding objective that will be added.
210 * The context will be used to notify the calling application.
211 *
212 * @param context an objective context
213 * @return a forwarding objective
214 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800215 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700216 ForwardingObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700217
218 /**
219 * Builds the forwarding objective that will be removed.
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 remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700227 }
228}