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 | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 19 | import org.onosproject.net.flow.TrafficSelector; |
| 20 | import org.onosproject.net.flow.TrafficTreatment; |
| 21 | |
| 22 | /** |
| 23 | * Represents a description of which types of traffic need to |
| 24 | * be forwarded through the device. A forwarding objective may |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 25 | * result in multiple rules at the device. There are two main types |
| 26 | * of forwarding objectives: |
| 27 | * |
| 28 | * - Versatile |
| 29 | * - Specific |
| 30 | * |
| 31 | * A versatile forwarding objective represents a composite rule that matches |
| 32 | * two or more header fields. The use of versatile usually indicates that this |
| 33 | * rule should be inserted in its entirety into the ACL table. Although, |
| 34 | * drivers for some devices are free to implement this differently. |
| 35 | * |
| 36 | * A specific forwarding objective represents a specific rule matching one or |
| 37 | * more header fields. The installation of this rule may result in several rules |
| 38 | * at the device. For example, one per table type. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 39 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 40 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 41 | public interface ForwardingObjective extends Objective { |
| 42 | |
| 43 | /** |
| 44 | * Represents whether this objective is monolithic or |
| 45 | * may be broken down into parts. |
| 46 | */ |
| 47 | enum Flag { |
| 48 | /** |
| 49 | * A decomposable objective. |
| 50 | */ |
| 51 | SPECIFIC, |
| 52 | |
| 53 | /** |
| 54 | * A monolithic objective. |
| 55 | */ |
| 56 | VERSATILE |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Obtain the selector for this objective. |
| 61 | * |
| 62 | * @return a traffic selector |
| 63 | */ |
| 64 | TrafficSelector selector(); |
| 65 | |
| 66 | /** |
| 67 | * Obtain the traffic treatment for this objective. Mutually exclusive with |
| 68 | * 'treatment'. |
| 69 | * |
| 70 | * @return an integer |
| 71 | */ |
| 72 | Integer nextId(); |
| 73 | |
| 74 | /** |
| 75 | * A traffic treatment for this forwarding objective. Mutually exclusive |
| 76 | * with a nextId. |
| 77 | * |
| 78 | * @return a traffic treatment |
| 79 | */ |
| 80 | TrafficTreatment treatment(); |
| 81 | |
| 82 | /** |
| 83 | * Obtain the type of this objective. |
| 84 | * |
| 85 | * @return a flag type |
| 86 | */ |
| 87 | Flag flag(); |
| 88 | |
| 89 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 90 | * Auxiliary optional information provided to the device driver. Typically |
| 91 | * conveys information about selectors (matches) that are intended to |
| 92 | * use this Forwarding Objective. |
| 93 | * |
| 94 | * @return a selector intended to pass meta information to the device driver. |
| 95 | * Value may be null if no meta information is provided. |
| 96 | */ |
| 97 | TrafficSelector meta(); |
| 98 | |
| 99 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 100 | * A forwarding objective builder. |
| 101 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 102 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Assigns a selector to the forwarding objective. |
| 106 | * |
| 107 | * @param selector a traffic selector |
| 108 | * @return a forwarding objective builder |
| 109 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 110 | Builder withSelector(TrafficSelector selector); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 111 | |
| 112 | /** |
| 113 | * Assigns a next step to the forwarding objective. |
| 114 | * |
| 115 | * @param nextId a next objective id. |
| 116 | * @return a forwarding objective builder |
| 117 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 118 | Builder nextStep(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * Assigns the treatment for this forwarding objective. |
| 122 | * |
| 123 | * @param treatment a traffic treatment |
| 124 | * @return a forwarding objective |
| 125 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 126 | Builder withTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
| 129 | * Assigns the flag to the forwarding objective. |
| 130 | * |
| 131 | * @param flag a flag |
| 132 | * @return a forwarding objective builder |
| 133 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 134 | Builder withFlag(Flag flag); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 135 | |
| 136 | /** |
Charles Chan | 4ca2f7f | 2016-03-25 13:40:16 -0700 | [diff] [blame] | 137 | * Set meta information related to this forwarding objective. |
| 138 | * |
| 139 | * @param selector match conditions |
| 140 | * @return an objective builder |
| 141 | */ |
| 142 | Builder withMeta(TrafficSelector selector); |
| 143 | |
| 144 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 145 | * Builds the forwarding objective that will be added. |
| 146 | * |
| 147 | * @return a forwarding objective |
| 148 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 149 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 150 | ForwardingObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
| 153 | * Builds the forwarding objective that will be removed. |
| 154 | * |
| 155 | * @return a forwarding objective. |
| 156 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 157 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 158 | ForwardingObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 159 | |
| 160 | /** |
| 161 | * Builds the forwarding objective that will be added. |
| 162 | * The context will be used to notify the calling application. |
| 163 | * |
| 164 | * @param context an objective context |
| 165 | * @return a forwarding objective |
| 166 | */ |
Thomas Vachuska | 00f4816 | 2016-02-29 17:07:23 -0800 | [diff] [blame] | 167 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 168 | ForwardingObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 169 | |
| 170 | /** |
| 171 | * Builds the forwarding objective that will be removed. |
| 172 | * The context will be used to notify the calling application. |
| 173 | * |
| 174 | * @param context an objective context |
| 175 | * @return a forwarding 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 | ForwardingObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 179 | } |
| 180 | } |