alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.net.flowobjective; |
| 17 | |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 18 | import org.onosproject.core.ApplicationId; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 19 | import org.onosproject.net.flow.criteria.Criterion; |
| 20 | |
| 21 | import 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 | */ |
| 29 | public interface FilteringObjective extends Objective { |
| 30 | |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 31 | enum Type { |
| 32 | /** |
| 33 | * Enables the filtering condition. |
| 34 | */ |
| 35 | PERMIT, |
| 36 | |
| 37 | /** |
| 38 | * Disables the filtering condition. |
| 39 | */ |
| 40 | DENY |
| 41 | } |
| 42 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 43 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 44 | * Obtain the key for this filter. |
| 45 | * |
| 46 | * @return a criterion |
| 47 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 48 | Criterion key(); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 49 | |
| 50 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 51 | * Obtain this filtering type. |
| 52 | * @return the type |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 53 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 54 | Type type(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 55 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 66 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 67 | |
| 68 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 69 | * Specify the key for the filter. |
| 70 | * |
| 71 | * @param key a criterion |
| 72 | * @return a filter objective builder |
| 73 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 74 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 77 | * Add a filtering condition. |
| 78 | * |
| 79 | * @param criterion new criterion |
| 80 | * @return a filtering builder |
| 81 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 82 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 85 | * Permit this filtering condition set. |
| 86 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 87 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 88 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 89 | |
| 90 | /** |
| 91 | * Deny this filtering condition set. |
| 92 | * @return a filtering builder |
| 93 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 94 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 95 | |
| 96 | /** |
| 97 | * Assigns an application id. |
| 98 | * @param appId an application id |
| 99 | * @return a filtering builder |
| 100 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 101 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Builds the filtering objective that will be added. |
| 105 | * |
| 106 | * @return a filtering objective |
| 107 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 108 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Builds the filtering objective that will be removed. |
| 112 | * |
| 113 | * @return a filtering objective. |
| 114 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 115 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 116 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 117 | /** |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 124 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 125 | |
| 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 SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame^] | 133 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 134 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 135 | |
| 136 | } |
| 137 | |
| 138 | } |