blob: 5830457128a2ea8e69d4f9fcfb475d5630c46f2b [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;
alshabibfaa1e362015-04-02 15:01:54 -070020import org.onosproject.net.flow.criteria.Criterion;
21
22import java.util.Collection;
23
24/**
alshabib9d9e3a32015-06-25 18:33:50 -070025 * Represents a filtering flow objective. Each filtering flow objective
26 * is made up of a key (criterion) to a set of criteria. Using this information
27 * a pipeline aware driver will decide how this objective should be mapped
28 * to the specific device pipeline. For example, consider the following
29 * filtering objective:
30 *
31 * portX -> {MAC1, IP1, MAC2}
32 *
33 * The driver could decide to pass L3 packet to the L3 table and L2 packets to
34 * the L2 table for packets arriving on portX.
35 *
36 * Filtering objectives do not only represent what should be permitted into the
37 * pipeline but can also be used to deny or drop unwanted packets by specifying
38 * the appropriate type of filtering objective. It is also important to note
39 * that submitting a filtering objective does not necessarily result in rules
40 * programmed at the switch, the driver is free to decide when these rules are
41 * programmed. For example, a filtering rule may only be programmed once a
42 * corresponding forwarding objective has been received.
alshabibfaa1e362015-04-02 15:01:54 -070043 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070044@Beta
alshabibfaa1e362015-04-02 15:01:54 -070045public interface FilteringObjective extends Objective {
46
alshabib910aff12015-04-09 16:55:57 -070047 enum Type {
48 /**
49 * Enables the filtering condition.
50 */
51 PERMIT,
52
53 /**
54 * Disables the filtering condition.
55 */
56 DENY
57 }
58
alshabibfaa1e362015-04-02 15:01:54 -070059 /**
alshabiba3a476d2015-04-10 14:35:38 -070060 * Obtain the key for this filter.
61 *
62 * @return a criterion
63 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070064 Criterion key();
alshabiba3a476d2015-04-10 14:35:38 -070065
66 /**
alshabib910aff12015-04-09 16:55:57 -070067 * Obtain this filtering type.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -070068 *
alshabib910aff12015-04-09 16:55:57 -070069 * @return the type
alshabibfaa1e362015-04-02 15:01:54 -070070 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070071 Type type();
alshabibfaa1e362015-04-02 15:01:54 -070072
73 /**
74 * The set of conditions the filter must provision at the device.
75 *
76 * @return a collection of criteria
77 */
78 Collection<Criterion> conditions();
79
80 /**
81 * Builder of Filtering objective entities.
82 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070083 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -070084
85 /**
alshabiba3a476d2015-04-10 14:35:38 -070086 * Specify the key for the filter.
87 *
88 * @param key a criterion
89 * @return a filter objective builder
90 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070091 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -070092
93 /**
alshabibfaa1e362015-04-02 15:01:54 -070094 * Add a filtering condition.
95 *
96 * @param criterion new criterion
97 * @return a filtering builder
98 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070099 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -0700100
101 /**
alshabib910aff12015-04-09 16:55:57 -0700102 * Permit this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700103 *
alshabib910aff12015-04-09 16:55:57 -0700104 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -0700105 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700106 Builder permit();
alshabib910aff12015-04-09 16:55:57 -0700107
108 /**
109 * Deny this filtering condition set.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700110 *
alshabib910aff12015-04-09 16:55:57 -0700111 * @return a filtering builder
112 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700113 Builder deny();
alshabib910aff12015-04-09 16:55:57 -0700114
115 /**
116 * Assigns an application id.
Sho SHIMIZUf3ae3fb2015-07-01 09:52:35 -0700117 *
alshabib910aff12015-04-09 16:55:57 -0700118 * @param appId an application id
119 * @return a filtering builder
120 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700121 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700122
123 /**
124 * Builds the filtering objective that will be added.
125 *
126 * @return a filtering objective
127 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700128 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700129
130 /**
131 * Builds the filtering objective that will be removed.
132 *
133 * @return a filtering objective.
134 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700135 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700136
alshabib2a441c62015-04-13 18:39:38 -0700137 /**
138 * Builds the filtering objective that will be added.
139 * The context will be used to notify the calling application.
140 *
141 * @param context an objective context
142 * @return a filtering objective
143 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700144 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700145
146 /**
147 * Builds the filtering objective that will be removed.
148 * The context will be used to notify the calling application.
149 *
150 * @param context an objective context
151 * @return a filtering objective
152 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700153 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700154
alshabibfaa1e362015-04-02 15:01:54 -0700155
156 }
157
158}