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 | 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 | /** |
| 90 | * A forwarding objective builder. |
| 91 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 92 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * Assigns a selector to the forwarding objective. |
| 96 | * |
| 97 | * @param selector a traffic selector |
| 98 | * @return a forwarding objective builder |
| 99 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 100 | Builder withSelector(TrafficSelector selector); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 101 | |
| 102 | /** |
| 103 | * Assigns a next step to the forwarding objective. |
| 104 | * |
| 105 | * @param nextId a next objective id. |
| 106 | * @return a forwarding objective builder |
| 107 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 108 | Builder nextStep(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Assigns the treatment for this forwarding objective. |
| 112 | * |
| 113 | * @param treatment a traffic treatment |
| 114 | * @return a forwarding objective |
| 115 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 116 | Builder withTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
| 119 | * Assigns the flag to the forwarding objective. |
| 120 | * |
| 121 | * @param flag a flag |
| 122 | * @return a forwarding objective builder |
| 123 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 124 | Builder withFlag(Flag flag); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Builds the forwarding objective that will be added. |
| 128 | * |
| 129 | * @return a forwarding objective |
| 130 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 131 | ForwardingObjective add(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Builds the forwarding objective that will be removed. |
| 135 | * |
| 136 | * @return a forwarding objective. |
| 137 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 138 | ForwardingObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 139 | |
| 140 | /** |
| 141 | * Builds the forwarding objective that will be added. |
| 142 | * The context will be used to notify the calling application. |
| 143 | * |
| 144 | * @param context an objective context |
| 145 | * @return a forwarding objective |
| 146 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 147 | ForwardingObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Builds the forwarding objective that will be removed. |
| 151 | * The context will be used to notify the calling application. |
| 152 | * |
| 153 | * @param context an objective context |
| 154 | * @return a forwarding objective |
| 155 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 156 | ForwardingObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 157 | } |
| 158 | } |