alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
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; |
Andrea Campanella | cbd1694 | 2021-06-01 16:33:14 +0200 | [diff] [blame] | 20 | import org.onosproject.net.Annotations; |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 21 | import org.onosproject.net.flow.TrafficTreatment; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 22 | import org.onosproject.net.flow.criteria.Criterion; |
| 23 | |
| 24 | import java.util.Collection; |
| 25 | |
| 26 | /** |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 27 | * Represents a filtering flow objective. Each filtering flow objective |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 28 | * is made up of a key (typically a PortCriterion) mapped to a set of criteria. |
| 29 | * Using this information, a pipeline aware driver will decide how this objective |
| 30 | * should be mapped to the device specific pipeline-tables in order to satisfy the |
| 31 | * filtering condition. For example, consider the following PERMIT filtering |
| 32 | * objective: |
| 33 | * <p> |
| 34 | * portX -> {MAC1, VLAN1} |
| 35 | * <p> |
| 36 | * The driver could decide to pass packets to the MAC table or VLAN or PORT |
| 37 | * tables to ensure that only those packets arriving with the correct dst MAC |
| 38 | * and VLAN ids from Port X are allowed into the pipeline. |
| 39 | * <p> |
| 40 | * Filtering objectives of type PERMIT allow packets that match the key:criteria |
| 41 | * to enter the pipeline. As a result, the implication is that packets that don't |
| 42 | * match are automatically denied (dropped). |
| 43 | * <p> |
| 44 | * Filtering objectives of type DENY, are used to deny packets that would |
| 45 | * otherwise be permitted and forwarded through the pipeline (ie. those packets |
| 46 | * that make it through the PERMIT filters). |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 47 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 48 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 49 | public interface FilteringObjective extends Objective { |
| 50 | |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 51 | enum Type { |
| 52 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 53 | * Permits packets that match the filtering condition to be processed |
| 54 | * by the rest of the pipeline. Automatically denies packets that don't |
| 55 | * match the criteria. |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 56 | */ |
| 57 | PERMIT, |
| 58 | |
| 59 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 60 | * Denies packets that make it through the permit filters. |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 61 | */ |
| 62 | DENY |
| 63 | } |
| 64 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 65 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 66 | * 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] | 67 | * |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 68 | * @return a criterion, which could be null if no key was provided. |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 69 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 70 | Criterion key(); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 73 | * Obtain this filtering type. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 74 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 75 | * @return the type |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 76 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 77 | Type type(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * The set of conditions the filter must provision at the device. |
| 81 | * |
| 82 | * @return a collection of criteria |
| 83 | */ |
| 84 | Collection<Criterion> conditions(); |
| 85 | |
| 86 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 87 | * Auxiliary optional information provided to the device driver. Typically |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 88 | * conveys information about changes (treatments) to packets that are |
| 89 | * permitted into the pipeline by the PERMIT filtering condition. |
| 90 | * |
| 91 | * @return a treatment on the packets that make it through the PERMIT filters. |
| 92 | * Value may be null if no meta information is provided. |
| 93 | */ |
| 94 | TrafficTreatment meta(); |
| 95 | |
| 96 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 97 | * Returns a new builder set to create a copy of this objective. |
| 98 | * |
| 99 | * @return new builder |
| 100 | */ |
| 101 | @Override |
| 102 | Builder copy(); |
| 103 | |
| 104 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 105 | * Builder of Filtering objective entities. |
| 106 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 107 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 110 | * Specify the key for the filter. |
| 111 | * |
| 112 | * @param key a criterion |
| 113 | * @return a filter objective builder |
| 114 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 115 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 116 | |
| 117 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 118 | * Add a filtering condition. |
| 119 | * |
| 120 | * @param criterion new criterion |
| 121 | * @return a filtering builder |
| 122 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 123 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 126 | * Permit this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 127 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 128 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 129 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 130 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * Deny this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 134 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 135 | * @return a filtering builder |
| 136 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 137 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 138 | |
| 139 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 140 | * Set meta information about this filtering condition set. |
| 141 | * |
Ray Milkey | f64cf41 | 2015-10-28 16:17:30 -0700 | [diff] [blame] | 142 | * @param treatment traffic treatment to use |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 143 | * @return a filtering builder |
| 144 | */ |
Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 145 | Builder withMeta(TrafficTreatment treatment); |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 148 | * Assigns an application id. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 149 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 150 | * @param appId an application id |
| 151 | * @return a filtering builder |
| 152 | */ |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 153 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 154 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 155 | |
| 156 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 157 | * Sets the priority for this objective. |
| 158 | * |
| 159 | * @param priority an integer |
| 160 | * @return an objective builder |
| 161 | */ |
| 162 | @Override |
| 163 | Builder withPriority(int priority); |
| 164 | |
| 165 | /** |
| 166 | * Makes the filtering objective permanent. |
| 167 | * |
| 168 | * @return an objective builder |
| 169 | */ |
| 170 | @Override |
| 171 | public Builder makePermanent(); |
| 172 | |
Andrea Campanella | cbd1694 | 2021-06-01 16:33:14 +0200 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * Adds annotations to the filtering objective. |
| 176 | * |
| 177 | * @param annotations the annotations for the filtering objective |
| 178 | * @return a filtering objective builder |
| 179 | */ |
| 180 | @Override |
| 181 | Builder withAnnotations(Annotations annotations); |
| 182 | |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 183 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 184 | * Builds the filtering objective that will be added. |
| 185 | * |
| 186 | * @return a filtering objective |
| 187 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 188 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 189 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 190 | |
| 191 | /** |
| 192 | * Builds the filtering objective that will be removed. |
| 193 | * |
| 194 | * @return a filtering objective. |
| 195 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 196 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 197 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 198 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 199 | /** |
| 200 | * Builds the filtering objective that will be added. |
| 201 | * The context will be used to notify the calling application. |
| 202 | * |
| 203 | * @param context an objective context |
| 204 | * @return a filtering objective |
| 205 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 206 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 207 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 208 | |
| 209 | /** |
| 210 | * Builds the filtering objective that will be removed. |
| 211 | * The context will be used to notify the calling application. |
| 212 | * |
| 213 | * @param context an objective context |
| 214 | * @return a filtering objective |
| 215 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 216 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 217 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 218 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 219 | |
| 220 | } |
| 221 | |
| 222 | } |