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 | 2a441c6 | 2015-04-13 18:39:38 -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.TrafficTreatment; |
| 21 | |
| 22 | import java.util.Collection; |
| 23 | |
| 24 | /** |
| 25 | * Represents a nexthop which will be translated by a driver |
| 26 | * into the appropriate group or actions needed to implement |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 27 | * the egress function. |
| 28 | * |
Sho SHIMIZU | fee286d | 2015-07-01 10:19:10 -0700 | [diff] [blame] | 29 | * A next objective is made up of a collection of traffic treatments |
alshabib | 9d9e3a3 | 2015-06-25 18:33:50 -0700 | [diff] [blame] | 30 | * associated with a type. These types are: |
| 31 | * |
| 32 | * - Hashed |
| 33 | * - Broadcast |
| 34 | * - Failover |
| 35 | * - Simple |
| 36 | * |
| 37 | * These types will indicate to the driver what the intended behaviour is. |
| 38 | * For example, a broadcast next objective with a collection of output |
| 39 | * treatments will indicate to a driver that all output actions are expected |
| 40 | * to be executed simultaneously. The driver is then free to implement this |
| 41 | * as a group or a simple action list. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 42 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 43 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 44 | public interface NextObjective extends Objective { |
| 45 | |
| 46 | /** |
| 47 | * Represents the type of next phase to build. |
| 48 | */ |
| 49 | enum Type { |
| 50 | /** |
| 51 | * A hashed packet processing. |
| 52 | */ |
| 53 | HASHED, |
| 54 | |
| 55 | /** |
| 56 | * Broadcast packet process. |
| 57 | */ |
| 58 | BROADCAST, |
| 59 | |
| 60 | /** |
| 61 | * Failover handling. |
| 62 | */ |
| 63 | FAILOVER, |
| 64 | |
| 65 | /** |
| 66 | * Simple processing. Could be a group or a treatment. |
| 67 | */ |
| 68 | SIMPLE |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * The collection of treatments that need to be applied to a set of traffic. |
| 73 | * |
| 74 | * @return a collection of traffic treatments |
| 75 | */ |
| 76 | Collection<TrafficTreatment> next(); |
| 77 | |
| 78 | /** |
| 79 | * The type of operation that will be applied to the traffic using the collection |
| 80 | * of treatments. |
| 81 | * |
| 82 | * @return a type |
| 83 | */ |
| 84 | Type type(); |
| 85 | |
| 86 | /** |
| 87 | * A next step builder. |
| 88 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 89 | interface Builder extends Objective.Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
| 92 | * Specifies the id for this next objective. |
| 93 | * |
| 94 | * @param nextId an integer |
| 95 | * @return a next objective builder |
| 96 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 97 | Builder withId(int nextId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * Sets the type of next step. |
| 101 | * |
| 102 | * @param type a type |
| 103 | * @return a next step builder |
| 104 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 105 | Builder withType(Type type); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 106 | |
| 107 | /** |
| 108 | * Adds a treatment to this next step. |
| 109 | * |
| 110 | * @param treatment a traffic treatment |
| 111 | * @return a next step builder |
| 112 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 113 | Builder addTreatment(TrafficTreatment treatment); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 114 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 115 | @Override |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 116 | Builder fromApp(ApplicationId appId); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 117 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 118 | /** |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 119 | * Builds the next objective that will be added. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 120 | * |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 121 | * @return a next objective |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 122 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 123 | NextObjective add(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * Builds the next objective that will be removed. |
| 127 | * |
| 128 | * @return a next objective. |
| 129 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 130 | NextObjective remove(); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * Builds the next objective that will be added. |
| 134 | * The context will be used to notify the calling application. |
| 135 | * |
| 136 | * @param context an objective context |
| 137 | * @return a next objective |
| 138 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 139 | NextObjective add(ObjectiveContext context); |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * Builds the next objective that will be removed. |
| 143 | * The context will be used to notify the calling application. |
| 144 | * |
| 145 | * @param context an objective context |
| 146 | * @return a next objective |
| 147 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 148 | NextObjective remove(ObjectiveContext context); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 149 | |
| 150 | } |
| 151 | |
| 152 | } |