blob: 1d62a2380e19cae15c40ac5dce395fc3082fc343 [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.
alshabibfaa1e362015-04-02 15:01:54 -070040 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070041@Beta
alshabibfaa1e362015-04-02 15:01:54 -070042public 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 Chan4ca2f7f2016-03-25 13:40:16 -070091 * 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 Milkey3004c7d2017-12-13 09:43:20 -0800101 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -0700109 * A forwarding objective builder.
110 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700111 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700112
113 /**
114 * Assigns a selector to the forwarding objective.
115 *
116 * @param selector a traffic selector
117 * @return a forwarding objective builder
118 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700119 Builder withSelector(TrafficSelector selector);
alshabibfaa1e362015-04-02 15:01:54 -0700120
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 SHIMIZU3310a342015-05-13 12:14:05 -0700127 Builder nextStep(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700128
129 /**
130 * Assigns the treatment for this forwarding objective.
131 *
132 * @param treatment a traffic treatment
133 * @return a forwarding objective
134 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700135 Builder withTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700136
137 /**
138 * Assigns the flag to the forwarding objective.
139 *
140 * @param flag a flag
141 * @return a forwarding objective builder
142 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700143 Builder withFlag(Flag flag);
alshabibfaa1e362015-04-02 15:01:54 -0700144
145 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700146 * 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 Milkey3004c7d2017-12-13 09:43:20 -0800154 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -0700180 * Builds the forwarding objective that will be added.
181 *
182 * @return a forwarding objective
183 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800184 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700185 ForwardingObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700186
187 /**
188 * Builds the forwarding objective that will be removed.
189 *
190 * @return a forwarding objective.
191 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800192 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700193 ForwardingObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700194
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 Vachuska00f48162016-02-29 17:07:23 -0800202 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700203 ForwardingObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700204
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 Vachuska00f48162016-02-29 17:07:23 -0800212 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700213 ForwardingObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700214 }
215}