blob: d5fedf2ed20dd26d2fd71cc0e1bae7a55d211ed1 [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
alshabibfaa1e362015-04-02 15:01:54 -07003 *
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 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabibfaa1e362015-04-02 15:01:54 -070019import org.onosproject.net.flow.TrafficSelector;
20import 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
alshabib9d9e3a32015-06-25 18:33:50 -070025 * 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.
alshabibfaa1e362015-04-02 15:01:54 -070039 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070040@Beta
alshabibfaa1e362015-04-02 15:01:54 -070041public 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 Chan4ca2f7f2016-03-25 13:40:16 -070090 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -0700100 * A forwarding objective builder.
101 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700102 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700103
104 /**
105 * Assigns a selector to the forwarding objective.
106 *
107 * @param selector a traffic selector
108 * @return a forwarding objective builder
109 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700110 Builder withSelector(TrafficSelector selector);
alshabibfaa1e362015-04-02 15:01:54 -0700111
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 SHIMIZU3310a342015-05-13 12:14:05 -0700118 Builder nextStep(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700119
120 /**
121 * Assigns the treatment for this forwarding objective.
122 *
123 * @param treatment a traffic treatment
124 * @return a forwarding objective
125 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700126 Builder withTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700127
128 /**
129 * Assigns the flag to the forwarding objective.
130 *
131 * @param flag a flag
132 * @return a forwarding objective builder
133 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700134 Builder withFlag(Flag flag);
alshabibfaa1e362015-04-02 15:01:54 -0700135
136 /**
Charles Chan4ca2f7f2016-03-25 13:40:16 -0700137 * 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 /**
alshabibfaa1e362015-04-02 15:01:54 -0700145 * Builds the forwarding objective that will be added.
146 *
147 * @return a forwarding objective
148 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800149 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700150 ForwardingObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700151
152 /**
153 * Builds the forwarding objective that will be removed.
154 *
155 * @return a forwarding objective.
156 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800157 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700158 ForwardingObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700159
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 Vachuska00f48162016-02-29 17:07:23 -0800167 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700168 ForwardingObjective add(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700169
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 Vachuska00f48162016-02-29 17:07:23 -0800177 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700178 ForwardingObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700179 }
180}