blob: bf81cfaeb8ccda488d3ea81f5b1b59a6910de048 [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.
68 * @return the type
alshabibfaa1e362015-04-02 15:01:54 -070069 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070070 Type type();
alshabibfaa1e362015-04-02 15:01:54 -070071
72 /**
73 * The set of conditions the filter must provision at the device.
74 *
75 * @return a collection of criteria
76 */
77 Collection<Criterion> conditions();
78
79 /**
80 * Builder of Filtering objective entities.
81 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070082 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -070083
84 /**
alshabiba3a476d2015-04-10 14:35:38 -070085 * Specify the key for the filter.
86 *
87 * @param key a criterion
88 * @return a filter objective builder
89 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070090 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -070091
92 /**
alshabibfaa1e362015-04-02 15:01:54 -070093 * Add a filtering condition.
94 *
95 * @param criterion new criterion
96 * @return a filtering builder
97 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070098 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -070099
100 /**
alshabib910aff12015-04-09 16:55:57 -0700101 * Permit this filtering condition set.
102 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -0700103 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700104 Builder permit();
alshabib910aff12015-04-09 16:55:57 -0700105
106 /**
107 * Deny this filtering condition set.
108 * @return a filtering builder
109 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700110 Builder deny();
alshabib910aff12015-04-09 16:55:57 -0700111
112 /**
113 * Assigns an application id.
114 * @param appId an application id
115 * @return a filtering builder
116 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700117 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700118
119 /**
120 * Builds the filtering objective that will be added.
121 *
122 * @return a filtering objective
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700125
126 /**
127 * Builds the filtering objective that will be removed.
128 *
129 * @return a filtering objective.
130 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700131 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700132
alshabib2a441c62015-04-13 18:39:38 -0700133 /**
134 * Builds the filtering objective that will be added.
135 * The context will be used to notify the calling application.
136 *
137 * @param context an objective context
138 * @return a filtering objective
139 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700140 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700141
142 /**
143 * Builds the filtering objective that will be removed.
144 * The context will be used to notify the calling application.
145 *
146 * @param context an objective context
147 * @return a filtering objective
148 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700149 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700150
alshabibfaa1e362015-04-02 15:01:54 -0700151
152 }
153
154}