blob: 623de3b46a593609d95efcb829a94c571c461b19 [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;
Saurav Das88f4c842015-10-27 13:13:19 -070020import org.onosproject.net.flow.TrafficTreatment;
alshabibfaa1e362015-04-02 15:01:54 -070021import org.onosproject.net.flow.criteria.Criterion;
22
23import java.util.Collection;
24
25/**
alshabib9d9e3a32015-06-25 18:33:50 -070026 * Represents a filtering flow objective. Each filtering flow objective
Saurav Das88f4c842015-10-27 13:13:19 -070027 * is made up of a key (typically a PortCriterion) mapped to a set of criteria.
28 * Using this information, a pipeline aware driver will decide how this objective
29 * should be mapped to the device specific pipeline-tables in order to satisfy the
30 * filtering condition. For example, consider the following PERMIT filtering
31 * objective:
32 * <p>
33 * portX -&gt; {MAC1, VLAN1}
34 * <p>
35 * The driver could decide to pass packets to the MAC table or VLAN or PORT
36 * tables to ensure that only those packets arriving with the correct dst MAC
37 * and VLAN ids from Port X are allowed into the pipeline.
38 * <p>
39 * Filtering objectives of type PERMIT allow packets that match the key:criteria
40 * to enter the pipeline. As a result, the implication is that packets that don't
41 * match are automatically denied (dropped).
42 * <p>
43 * Filtering objectives of type DENY, are used to deny packets that would
44 * otherwise be permitted and forwarded through the pipeline (ie. those packets
45 * that make it through the PERMIT filters).
alshabibfaa1e362015-04-02 15:01:54 -070046 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070047@Beta
alshabibfaa1e362015-04-02 15:01:54 -070048public interface FilteringObjective extends Objective {
49
alshabib910aff12015-04-09 16:55:57 -070050 enum Type {
51 /**
Saurav Das88f4c842015-10-27 13:13:19 -070052 * Permits packets that match the filtering condition to be processed
53 * by the rest of the pipeline. Automatically denies packets that don't
54 * match the criteria.
alshabib910aff12015-04-09 16:55:57 -070055 */
56 PERMIT,
57
58 /**
Saurav Das88f4c842015-10-27 13:13:19 -070059 * Denies packets that make it through the permit filters.
alshabib910aff12015-04-09 16:55:57 -070060 */
61 DENY
62 }
63
alshabibfaa1e362015-04-02 15:01:54 -070064 /**
Saurav Das88f4c842015-10-27 13:13:19 -070065 * Obtain the key for this filter. The filter may or may not require a key.
alshabiba3a476d2015-04-10 14:35:38 -070066 *
Saurav Das88f4c842015-10-27 13:13:19 -070067 * @return a criterion, which could be null if no key was provided.
alshabiba3a476d2015-04-10 14:35:38 -070068 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070069 Criterion key();
alshabiba3a476d2015-04-10 14:35:38 -070070
71 /**
alshabib910aff12015-04-09 16:55:57 -070072 * Obtain this filtering type.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -070073 *
alshabib910aff12015-04-09 16:55:57 -070074 * @return the type
alshabibfaa1e362015-04-02 15:01:54 -070075 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070076 Type type();
alshabibfaa1e362015-04-02 15:01:54 -070077
78 /**
79 * The set of conditions the filter must provision at the device.
80 *
81 * @return a collection of criteria
82 */
83 Collection<Criterion> conditions();
84
85 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -070086 * Auxiliary optional information provided to the device driver. Typically
Saurav Das88f4c842015-10-27 13:13:19 -070087 * conveys information about changes (treatments) to packets that are
88 * permitted into the pipeline by the PERMIT filtering condition.
89 *
90 * @return a treatment on the packets that make it through the PERMIT filters.
91 * Value may be null if no meta information is provided.
92 */
93 TrafficTreatment meta();
94
95 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -080096 * Returns a new builder set to create a copy of this objective.
97 *
98 * @return new builder
99 */
100 @Override
101 Builder copy();
102
103 /**
alshabibfaa1e362015-04-02 15:01:54 -0700104 * Builder of Filtering objective entities.
105 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700106 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700107
108 /**
alshabiba3a476d2015-04-10 14:35:38 -0700109 * Specify the key for the filter.
110 *
111 * @param key a criterion
112 * @return a filter objective builder
113 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700114 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -0700115
116 /**
alshabibfaa1e362015-04-02 15:01:54 -0700117 * Add a filtering condition.
118 *
119 * @param criterion new criterion
120 * @return a filtering builder
121 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700122 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -0700123
124 /**
alshabib910aff12015-04-09 16:55:57 -0700125 * Permit this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700126 *
alshabib910aff12015-04-09 16:55:57 -0700127 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -0700128 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700129 Builder permit();
alshabib910aff12015-04-09 16:55:57 -0700130
131 /**
132 * Deny this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700133 *
alshabib910aff12015-04-09 16:55:57 -0700134 * @return a filtering builder
135 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700136 Builder deny();
alshabib910aff12015-04-09 16:55:57 -0700137
138 /**
Saurav Das88f4c842015-10-27 13:13:19 -0700139 * Set meta information about this filtering condition set.
140 *
Ray Milkeyf64cf412015-10-28 16:17:30 -0700141 * @param treatment traffic treatment to use
Saurav Das88f4c842015-10-27 13:13:19 -0700142 * @return a filtering builder
143 */
Saurav Das4ce45962015-11-24 23:21:05 -0800144 Builder withMeta(TrafficTreatment treatment);
Saurav Das88f4c842015-10-27 13:13:19 -0700145
146 /**
alshabib910aff12015-04-09 16:55:57 -0700147 * Assigns an application id.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700148 *
alshabib910aff12015-04-09 16:55:57 -0700149 * @param appId an application id
150 * @return a filtering builder
151 */
Saurav Das88f4c842015-10-27 13:13:19 -0700152 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700153 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700154
155 /**
Ray Milkey3004c7d2017-12-13 09:43:20 -0800156 * Sets the priority for this objective.
157 *
158 * @param priority an integer
159 * @return an objective builder
160 */
161 @Override
162 Builder withPriority(int priority);
163
164 /**
165 * Makes the filtering objective permanent.
166 *
167 * @return an objective builder
168 */
169 @Override
170 public Builder makePermanent();
171
172 /**
alshabibfaa1e362015-04-02 15:01:54 -0700173 * Builds the filtering objective that will be added.
174 *
175 * @return a filtering objective
176 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800177 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700178 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700179
180 /**
181 * Builds the filtering objective that will be removed.
182 *
183 * @return a filtering objective.
184 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800185 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700186 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700187
alshabib2a441c62015-04-13 18:39:38 -0700188 /**
189 * Builds the filtering objective that will be added.
190 * The context will be used to notify the calling application.
191 *
192 * @param context an objective context
193 * @return a filtering objective
194 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800195 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700196 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700197
198 /**
199 * Builds the filtering objective that will be removed.
200 * The context will be used to notify the calling application.
201 *
202 * @param context an objective context
203 * @return a filtering objective
204 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800205 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700206 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700207
alshabibfaa1e362015-04-02 15:01:54 -0700208
209 }
210
211}