blob: d037764e759881ef7fbac7e31eadbbae8891ed9d [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
alshabib910aff12015-04-09 16:55:57 -070018import org.onosproject.core.ApplicationId;
alshabibfaa1e362015-04-02 15:01:54 -070019import org.onosproject.net.flow.criteria.Criterion;
20
21import java.util.Collection;
22
23/**
24 * Represents a filtering flow objective. Each filter is mapping
25 * from a criterion to a collection of criteria. The mapping will
26 * be used by a device driver to construct the actual flow rules to
27 * be installed on the device.
28 */
29public interface FilteringObjective extends Objective {
30
alshabib910aff12015-04-09 16:55:57 -070031 enum Type {
32 /**
33 * Enables the filtering condition.
34 */
35 PERMIT,
36
37 /**
38 * Disables the filtering condition.
39 */
40 DENY
41 }
42
alshabibfaa1e362015-04-02 15:01:54 -070043 /**
alshabiba3a476d2015-04-10 14:35:38 -070044 * Obtain the key for this filter.
45 *
46 * @return a criterion
47 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070048 Criterion key();
alshabiba3a476d2015-04-10 14:35:38 -070049
50 /**
alshabib910aff12015-04-09 16:55:57 -070051 * Obtain this filtering type.
52 * @return the type
alshabibfaa1e362015-04-02 15:01:54 -070053 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070054 Type type();
alshabibfaa1e362015-04-02 15:01:54 -070055
56 /**
57 * The set of conditions the filter must provision at the device.
58 *
59 * @return a collection of criteria
60 */
61 Collection<Criterion> conditions();
62
63 /**
64 * Builder of Filtering objective entities.
65 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070066 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -070067
68 /**
alshabiba3a476d2015-04-10 14:35:38 -070069 * Specify the key for the filter.
70 *
71 * @param key a criterion
72 * @return a filter objective builder
73 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070074 Builder withKey(Criterion key);
alshabiba3a476d2015-04-10 14:35:38 -070075
76 /**
alshabibfaa1e362015-04-02 15:01:54 -070077 * Add a filtering condition.
78 *
79 * @param criterion new criterion
80 * @return a filtering builder
81 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070082 Builder addCondition(Criterion criterion);
alshabibfaa1e362015-04-02 15:01:54 -070083
84 /**
alshabib910aff12015-04-09 16:55:57 -070085 * Permit this filtering condition set.
86 * @return a filtering builder
alshabibfaa1e362015-04-02 15:01:54 -070087 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070088 Builder permit();
alshabib910aff12015-04-09 16:55:57 -070089
90 /**
91 * Deny this filtering condition set.
92 * @return a filtering builder
93 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070094 Builder deny();
alshabib910aff12015-04-09 16:55:57 -070095
96 /**
97 * Assigns an application id.
98 * @param appId an application id
99 * @return a filtering builder
100 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700101 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700102
103 /**
104 * Builds the filtering objective that will be added.
105 *
106 * @return a filtering objective
107 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700108 FilteringObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Builds the filtering objective that will be removed.
112 *
113 * @return a filtering objective.
114 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700115 FilteringObjective remove();
alshabibfaa1e362015-04-02 15:01:54 -0700116
alshabib2a441c62015-04-13 18:39:38 -0700117 /**
118 * Builds the filtering objective that will be added.
119 * The context will be used to notify the calling application.
120 *
121 * @param context an objective context
122 * @return a filtering objective
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 FilteringObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700125
126 /**
127 * Builds the filtering objective that will be removed.
128 * The context will be used to notify the calling application.
129 *
130 * @param context an objective context
131 * @return a filtering objective
132 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700133 FilteringObjective remove(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700134
alshabibfaa1e362015-04-02 15:01:54 -0700135
136 }
137
138}