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; |
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 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 96 | * Returns a new builder set to create a copy of this objective. |
| 97 | * |
| 98 | * @return new builder |
| 99 | */ |
| 100 | @Override |
| 101 | Builder copy(); |
| 102 | |
| 103 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 104 | * Builder of Filtering objective entities. |
| 105 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 106 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 109 | * Specify the key for the filter. |
| 110 | * |
| 111 | * @param key a criterion |
| 112 | * @return a filter objective builder |
| 113 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 114 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 115 | |
| 116 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 117 | * Add a filtering condition. |
| 118 | * |
| 119 | * @param criterion new criterion |
| 120 | * @return a filtering builder |
| 121 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 122 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 125 | * Permit this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 126 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 127 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 128 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 129 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * Deny this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 133 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 134 | * @return a filtering builder |
| 135 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 136 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 137 | |
| 138 | /** |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 139 | * Set meta information about this filtering condition set. |
| 140 | * |
Ray Milkey | f64cf41 | 2015-10-28 16:17:30 -0700 | [diff] [blame] | 141 | * @param treatment traffic treatment to use |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 142 | * @return a filtering builder |
| 143 | */ |
Saurav Das | 4ce4596 | 2015-11-24 23:21:05 -0800 | [diff] [blame] | 144 | Builder withMeta(TrafficTreatment treatment); |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 145 | |
| 146 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 147 | * Assigns an application id. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 148 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 149 | * @param appId an application id |
| 150 | * @return a filtering builder |
| 151 | */ |
Saurav Das | 88f4c84 | 2015-10-27 13:13:19 -0700 | [diff] [blame] | 152 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 153 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 154 | |
| 155 | /** |
Ray Milkey | 3004c7d | 2017-12-13 09:43:20 -0800 | [diff] [blame] | 156 | * Sets the priority for this objective. |
| 157 | * |
| 158 | * @param priority an integer |
| 159 | * @return an objective builder |
| 160 | */ |
| 161 | @Override |
| 162 | Builder withPriority(int priority); |
| 163 | |
| 164 | /** |
| 165 | * Makes the filtering objective permanent. |
| 166 | * |
| 167 | * @return an objective builder |
| 168 | */ |
| 169 | @Override |
| 170 | public Builder makePermanent(); |
| 171 | |
| 172 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 173 | * Builds the filtering objective that will be added. |
| 174 | * |
| 175 | * @return a filtering objective |
| 176 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 177 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 178 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 179 | |
| 180 | /** |
| 181 | * Builds the filtering objective that will be removed. |
| 182 | * |
| 183 | * @return a filtering objective. |
| 184 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 185 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 186 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 187 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 188 | /** |
| 189 | * Builds the filtering objective that will be added. |
| 190 | * The context will be used to notify the calling application. |
| 191 | * |
| 192 | * @param context an objective context |
| 193 | * @return a filtering objective |
| 194 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 195 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 196 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 197 | |
| 198 | /** |
| 199 | * Builds the filtering objective that will be removed. |
| 200 | * The context will be used to notify the calling application. |
| 201 | * |
| 202 | * @param context an objective context |
| 203 | * @return a filtering objective |
| 204 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 205 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 206 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 207 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 208 | |
| 209 | } |
| 210 | |
| 211 | } |