blob: 8ed793d0303e3b7b55012a931e0d663610445b48 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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 /**
Saurav Das88f4c842015-10-27 13:13:19 -070086 * Auxiliary optional information provided to the device-driver.Typically
87 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -070096 * Builder of Filtering objective entities.
97 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070098 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -070099
100 /**
alshabiba3a476d2015-04-10 14:35:38 -0700101 * Specify the key for the filter.
102 *
103 * @param key a criterion
104 * @return a filter objective builder
105 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700106 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -0700107
108 /**
alshabibfaa1e362015-04-02 15:01:54 -0700109 * Add a filtering condition.
110 *
111 * @param criterion new criterion
112 * @return a filtering builder
113 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700114 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -0700115
116 /**
alshabib910aff12015-04-09 16:55:57 -0700117 * Permit this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700118 *
alshabib910aff12015-04-09 16:55:57 -0700119 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -0700120 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700121 Builder permit();
alshabib910aff12015-04-09 16:55:57 -0700122
123 /**
124 * Deny this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700125 *
alshabib910aff12015-04-09 16:55:57 -0700126 * @return a filtering builder
127 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700128 Builder deny();
alshabib910aff12015-04-09 16:55:57 -0700129
130 /**
Saurav Das88f4c842015-10-27 13:13:19 -0700131 * Set meta information about this filtering condition set.
132 *
Ray Milkeyf64cf412015-10-28 16:17:30 -0700133 * @param treatment traffic treatment to use
Saurav Das88f4c842015-10-27 13:13:19 -0700134 * @return a filtering builder
135 */
Saurav Das4ce45962015-11-24 23:21:05 -0800136 Builder withMeta(TrafficTreatment treatment);
Saurav Das88f4c842015-10-27 13:13:19 -0700137
138 /**
alshabib910aff12015-04-09 16:55:57 -0700139 * Assigns an application id.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700140 *
alshabib910aff12015-04-09 16:55:57 -0700141 * @param appId an application id
142 * @return a filtering builder
143 */
Saurav Das88f4c842015-10-27 13:13:19 -0700144 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700145 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700146
147 /**
148 * Builds the filtering objective that will be added.
149 *
150 * @return a filtering objective
151 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700152 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700153
154 /**
155 * Builds the filtering objective that will be removed.
156 *
157 * @return a filtering objective.
158 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700159 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700160
alshabib2a441c62015-04-13 18:39:38 -0700161 /**
162 * Builds the filtering objective that will be added.
163 * The context will be used to notify the calling application.
164 *
165 * @param context an objective context
166 * @return a filtering objective
167 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700168 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700169
170 /**
171 * Builds the filtering objective that will be removed.
172 * The context will be used to notify the calling application.
173 *
174 * @param context an objective context
175 * @return a filtering objective
176 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700177 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700178
alshabibfaa1e362015-04-02 15:01:54 -0700179
180 }
181
182}