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 | |
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; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 20 | import org.onosproject.net.flow.criteria.Criterion; |
| 21 | |
| 22 | import java.util.Collection; |
| 23 | |
| 24 | /** |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 25 | * Represents a filtering flow objective. Each filtering flow objective |
| 26 | * is made up of a key (criterion) to a set of criteria. Using this information |
| 27 | * a pipeline aware driver will decide how this objective should be mapped |
| 28 | * to the specific device pipeline. For example, consider the following |
| 29 | * filtering objective: |
| 30 | * |
| 31 | * portX -> {MAC1, IP1, MAC2} |
| 32 | * |
| 33 | * The driver could decide to pass L3 packet to the L3 table and L2 packets to |
| 34 | * the L2 table for packets arriving on portX. |
| 35 | * |
| 36 | * Filtering objectives do not only represent what should be permitted into the |
| 37 | * pipeline but can also be used to deny or drop unwanted packets by specifying |
| 38 | * the appropriate type of filtering objective. It is also important to note |
| 39 | * that submitting a filtering objective does not necessarily result in rules |
| 40 | * programmed at the switch, the driver is free to decide when these rules are |
| 41 | * programmed. For example, a filtering rule may only be programmed once a |
| 42 | * corresponding forwarding objective has been received. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 43 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 44 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 45 | public interface FilteringObjective extends Objective { |
| 46 | |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 47 | enum Type { |
| 48 | /** |
| 49 | * Enables the filtering condition. |
| 50 | */ |
| 51 | PERMIT, |
| 52 | |
| 53 | /** |
| 54 | * Disables the filtering condition. |
| 55 | */ |
| 56 | DENY |
| 57 | } |
| 58 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 59 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 60 | * Obtain the key for this filter. |
| 61 | * |
| 62 | * @return a criterion |
| 63 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 64 | Criterion key(); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 65 | |
| 66 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 67 | * Obtain this filtering type. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 68 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 69 | * @return the type |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 70 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 71 | Type type(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 72 | |
| 73 | /** |
| 74 | * The set of conditions the filter must provision at the device. |
| 75 | * |
| 76 | * @return a collection of criteria |
| 77 | */ |
| 78 | Collection<Criterion> conditions(); |
| 79 | |
| 80 | /** |
| 81 | * Builder of Filtering objective entities. |
| 82 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 83 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 84 | |
| 85 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 86 | * Specify the key for the filter. |
| 87 | * |
| 88 | * @param key a criterion |
| 89 | * @return a filter objective builder |
| 90 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 91 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 92 | |
| 93 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 94 | * Add a filtering condition. |
| 95 | * |
| 96 | * @param criterion new criterion |
| 97 | * @return a filtering builder |
| 98 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 99 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 100 | |
| 101 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 102 | * Permit this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 103 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 104 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 105 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 106 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Deny this filtering condition set. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 110 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 111 | * @return a filtering builder |
| 112 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 113 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 114 | |
| 115 | /** |
| 116 | * Assigns an application id. |
Sho SHIMIZU | f3ae3fb | 2015-07-01 09:52:35 -0700 | [diff] [blame] | 117 | * |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 118 | * @param appId an application id |
| 119 | * @return a filtering builder |
| 120 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 121 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 122 | |
| 123 | /** |
| 124 | * Builds the filtering objective that will be added. |
| 125 | * |
| 126 | * @return a filtering objective |
| 127 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 128 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Builds the filtering objective that will be removed. |
| 132 | * |
| 133 | * @return a filtering objective. |
| 134 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 135 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 136 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 137 | /** |
| 138 | * Builds the filtering objective that will be added. |
| 139 | * The context will be used to notify the calling application. |
| 140 | * |
| 141 | * @param context an objective context |
| 142 | * @return a filtering objective |
| 143 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 144 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 145 | |
| 146 | /** |
| 147 | * Builds the filtering objective that will be removed. |
| 148 | * The context will be used to notify the calling application. |
| 149 | * |
| 150 | * @param context an objective context |
| 151 | * @return a filtering objective |
| 152 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 153 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 154 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 155 | |
| 156 | } |
| 157 | |
| 158 | } |