alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 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 | |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 20 | import org.onosproject.net.flow.TrafficTreatment; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.criteria.Criterion; |
| 22 | |
| 23 | import java.util.Collection; |
| 24 | |
| 25 | /** |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 26 | * Represents a filtering flow objective. Each filtering flow objective |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 27 | * 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 -> {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). |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 46 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 47 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 48 | public interface FilteringObjective extends Objective { |
| 49 | |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 50 | enum Type { |
| 51 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 52 | * 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. |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 55 | */ |
| 56 | PERMIT, |
| 57 | |
| 58 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 59 | * Denies packets that make it through the permit filters. |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 60 | */ |
| 61 | DENY |
| 62 | } |
| 63 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 64 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 65 | * Obtain the key for this filter. The filter may or may not require a key. |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 66 | * |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 67 | * @return a criterion, which could be null if no key was provided. |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 68 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 69 | Criterion key(); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 72 | * Obtain this filtering type. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 73 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 74 | * @return the type |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 75 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 76 | Type type(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 77 | |
| 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 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 86 | * Auxiliary optional information provided to the device driver. Typically |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 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 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 96 | * Builder of Filtering objective entities. |
| 97 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 98 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 101 | * Specify the key for the filter. |
| 102 | * |
| 103 | * @param key a criterion |
| 104 | * @return a filter objective builder |
| 105 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 106 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 109 | * Add a filtering condition. |
| 110 | * |
| 111 | * @param criterion new criterion |
| 112 | * @return a filtering builder |
| 113 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 114 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 117 | * Permit this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 118 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 119 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 120 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 121 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Deny this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 125 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 126 | * @return a filtering builder |
| 127 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 128 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 131 | * Set meta information about this filtering condition set. |
| 132 | * |
Ray Milkey | f64cf41 | 2015-10-28 16:17:30 -0700 | [diff] [blame] | 133 | * @param treatment traffic treatment to use |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 134 | * @return a filtering builder |
| 135 | */ |
Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 136 | Builder withMeta(TrafficTreatment treatment); |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 137 | |
| 138 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 139 | * Assigns an application id. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 140 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 141 | * @param appId an application id |
| 142 | * @return a filtering builder |
| 143 | */ |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 144 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 145 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Builds the filtering objective that will be added. |
| 149 | * |
| 150 | * @return a filtering objective |
| 151 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 152 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 153 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 154 | |
| 155 | /** |
| 156 | * Builds the filtering objective that will be removed. |
| 157 | * |
| 158 | * @return a filtering objective. |
| 159 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 160 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 161 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 162 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 163 | /** |
| 164 | * Builds the filtering objective that will be added. |
| 165 | * The context will be used to notify the calling application. |
| 166 | * |
| 167 | * @param context an objective context |
| 168 | * @return a filtering objective |
| 169 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 170 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 171 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
| 174 | * Builds the filtering objective that will be removed. |
| 175 | * The context will be used to notify the calling application. |
| 176 | * |
| 177 | * @param context an objective context |
| 178 | * @return a filtering objective |
| 179 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 180 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 181 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 182 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 183 | |
| 184 | } |
| 185 | |
| 186 | } |