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. |
| 68 | * @return the type |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 69 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 70 | Type type(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 71 | |
| 72 | /** |
| 73 | * The set of conditions the filter must provision at the device. |
| 74 | * |
| 75 | * @return a collection of criteria |
| 76 | */ |
| 77 | Collection<Criterion> conditions(); |
| 78 | |
| 79 | /** |
| 80 | * Builder of Filtering objective entities. |
| 81 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 82 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 85 | * Specify the key for the filter. |
| 86 | * |
| 87 | * @param key a criterion |
| 88 | * @return a filter objective builder |
| 89 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 90 | Builder withKey(Criterion key); |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 91 | |
| 92 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 93 | * Add a filtering condition. |
| 94 | * |
| 95 | * @param criterion new criterion |
| 96 | * @return a filtering builder |
| 97 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 98 | Builder addCondition(Criterion criterion); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 99 | |
| 100 | /** |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 101 | * Permit this filtering condition set. |
| 102 | * @return a filtering builder |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 103 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 104 | Builder permit(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
| 107 | * Deny this filtering condition set. |
| 108 | * @return a filtering builder |
| 109 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 110 | Builder deny(); |
alshabib | 910aff1 | 2015-04-09 16:55:57 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Assigns an application id. |
| 114 | * @param appId an application id |
| 115 | * @return a filtering builder |
| 116 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 117 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * Builds the filtering objective that will be added. |
| 121 | * |
| 122 | * @return a filtering objective |
| 123 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 124 | FilteringObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Builds the filtering objective that will be removed. |
| 128 | * |
| 129 | * @return a filtering objective. |
| 130 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 131 | FilteringObjective remove(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 132 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 133 | /** |
| 134 | * Builds the filtering objective that will be added. |
| 135 | * The context will be used to notify the calling application. |
| 136 | * |
| 137 | * @param context an objective context |
| 138 | * @return a filtering objective |
| 139 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 140 | FilteringObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * Builds the filtering objective that will be removed. |
| 144 | * The context will be used to notify the calling application. |
| 145 | * |
| 146 | * @param context an objective context |
| 147 | * @return a filtering objective |
| 148 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 149 | FilteringObjective remove(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 150 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 151 | |
| 152 | } |
| 153 | |
| 154 | } |