blob: 641ba882102b95953138c5791dd87291510e1577 [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;
alshabib910aff12015-04-09 16:55:57 -070019import org.onosproject.core.ApplicationId;
Andrea Campanellacbd16942021-06-01 16:33:14 +020020import org.onosproject.net.Annotations;
Saurav Das88f4c842015-10-27 13:13:19 -070021import org.onosproject.net.flow.TrafficTreatment;
alshabibfaa1e362015-04-02 15:01:54 -070022import org.onosproject.net.flow.criteria.Criterion;
23
24import java.util.Collection;
25
26/**
alshabib9d9e3a32015-06-25 18:33:50 -070027 * Represents a filtering flow objective. Each filtering flow objective
Saurav Das88f4c842015-10-27 13:13:19 -070028 * is made up of a key (typically a PortCriterion) mapped to a set of criteria.
29 * Using this information, a pipeline aware driver will decide how this objective
30 * should be mapped to the device specific pipeline-tables in order to satisfy the
31 * filtering condition. For example, consider the following PERMIT filtering
32 * objective:
33 * <p>
34 * portX -&gt; {MAC1, VLAN1}
35 * <p>
36 * The driver could decide to pass packets to the MAC table or VLAN or PORT
37 * tables to ensure that only those packets arriving with the correct dst MAC
38 * and VLAN ids from Port X are allowed into the pipeline.
39 * <p>
40 * Filtering objectives of type PERMIT allow packets that match the key:criteria
41 * to enter the pipeline. As a result, the implication is that packets that don't
42 * match are automatically denied (dropped).
43 * <p>
44 * Filtering objectives of type DENY, are used to deny packets that would
45 * otherwise be permitted and forwarded through the pipeline (ie. those packets
46 * that make it through the PERMIT filters).
alshabibfaa1e362015-04-02 15:01:54 -070047 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070048@Beta
alshabibfaa1e362015-04-02 15:01:54 -070049public interface FilteringObjective extends Objective {
50
alshabib910aff12015-04-09 16:55:57 -070051 enum Type {
52 /**
Saurav Das88f4c842015-10-27 13:13:19 -070053 * Permits packets that match the filtering condition to be processed
54 * by the rest of the pipeline. Automatically denies packets that don't
55 * match the criteria.
alshabib910aff12015-04-09 16:55:57 -070056 */
57 PERMIT,
58
59 /**
Saurav Das88f4c842015-10-27 13:13:19 -070060 * Denies packets that make it through the permit filters.
alshabib910aff12015-04-09 16:55:57 -070061 */
62 DENY
63 }
64
alshabibfaa1e362015-04-02 15:01:54 -070065 /**
Saurav Das88f4c842015-10-27 13:13:19 -070066 * Obtain the key for this filter. The filter may or may not require a key.
alshabiba3a476d2015-04-10 14:35:38 -070067 *
Saurav Das88f4c842015-10-27 13:13:19 -070068 * @return a criterion, which could be null if no key was provided.
alshabiba3a476d2015-04-10 14:35:38 -070069 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070070 Criterion key();
alshabiba3a476d2015-04-10 14:35:38 -070071
72 /**
alshabib910aff12015-04-09 16:55:57 -070073 * Obtain this filtering type.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -070074 *
alshabib910aff12015-04-09 16:55:57 -070075 * @return the type
alshabibfaa1e362015-04-02 15:01:54 -070076 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070077 Type type();
alshabibfaa1e362015-04-02 15:01:54 -070078
79 /**
80 * The set of conditions the filter must provision at the device.
81 *
82 * @return a collection of criteria
83 */
84 Collection<Criterion> conditions();
85
86 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -070087 * Auxiliary optional information provided to the device driver. Typically
Saurav Das88f4c842015-10-27 13:13:19 -070088 * conveys information about changes (treatments) to packets that are
89 * permitted into the pipeline by the PERMIT filtering condition.
90 *
91 * @return a treatment on the packets that make it through the PERMIT filters.
92 * Value may be null if no meta information is provided.
93 */
94 TrafficTreatment meta();
95
96 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -080097 * Returns a new builder set to create a copy of this objective.
98 *
99 * @return new builder
100 */
101 @Override
102 Builder copy();
103
104 /**
alshabibfaa1e362015-04-02 15:01:54 -0700105 * Builder of Filtering objective entities.
106 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700107 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700108
109 /**
alshabiba3a476d2015-04-10 14:35:38 -0700110 * Specify the key for the filter.
111 *
112 * @param key a criterion
113 * @return a filter objective builder
114 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700115 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -0700116
117 /**
alshabibfaa1e362015-04-02 15:01:54 -0700118 * Add a filtering condition.
119 *
120 * @param criterion new criterion
121 * @return a filtering builder
122 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700123 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -0700124
125 /**
alshabib910aff12015-04-09 16:55:57 -0700126 * Permit this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700127 *
alshabib910aff12015-04-09 16:55:57 -0700128 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -0700129 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700130 Builder permit();
alshabib910aff12015-04-09 16:55:57 -0700131
132 /**
133 * Deny this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700134 *
alshabib910aff12015-04-09 16:55:57 -0700135 * @return a filtering builder
136 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700137 Builder deny();
alshabib910aff12015-04-09 16:55:57 -0700138
139 /**
Saurav Das88f4c842015-10-27 13:13:19 -0700140 * Set meta information about this filtering condition set.
141 *
Ray Milkeyf64cf412015-10-28 16:17:30 -0700142 * @param treatment traffic treatment to use
Saurav Das88f4c842015-10-27 13:13:19 -0700143 * @return a filtering builder
144 */
Saurav Das4ce45962015-11-24 23:21:05 -0800145 Builder withMeta(TrafficTreatment treatment);
Saurav Das88f4c842015-10-27 13:13:19 -0700146
147 /**
alshabib910aff12015-04-09 16:55:57 -0700148 * Assigns an application id.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700149 *
alshabib910aff12015-04-09 16:55:57 -0700150 * @param appId an application id
151 * @return a filtering builder
152 */
Saurav Das88f4c842015-10-27 13:13:19 -0700153 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700154 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700155
156 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800157 * Sets the priority for this objective.
158 *
159 * @param priority an integer
160 * @return an objective builder
161 */
162 @Override
163 Builder withPriority(int priority);
164
165 /**
166 * Makes the filtering objective permanent.
167 *
168 * @return an objective builder
169 */
170 @Override
171 public Builder makePermanent();
172
Andrea Campanellacbd16942021-06-01 16:33:14 +0200173
174 /**
175 * Adds annotations to the filtering objective.
176 *
177 * @param annotations the annotations for the filtering objective
178 * @return a filtering objective builder
179 */
180 @Override
181 Builder withAnnotations(Annotations annotations);
182
Ray Milkey3004c7d2017-12-13 09:43:20 -0800183 /**
alshabibfaa1e362015-04-02 15:01:54 -0700184 * Builds the filtering objective that will be added.
185 *
186 * @return a filtering objective
187 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800188 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700189 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700190
191 /**
192 * Builds the filtering objective that will be removed.
193 *
194 * @return a filtering objective.
195 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800196 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700197 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700198
alshabib2a441c62015-04-13 18:39:38 -0700199 /**
200 * Builds the filtering objective that will be added.
201 * The context will be used to notify the calling application.
202 *
203 * @param context an objective context
204 * @return a filtering objective
205 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800206 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700207 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700208
209 /**
210 * Builds the filtering objective that will be removed.
211 * The context will be used to notify the calling application.
212 *
213 * @param context an objective context
214 * @return a filtering objective
215 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800216 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700217 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700218
alshabibfaa1e362015-04-02 15:01:54 -0700219
220 }
221
222}