blob: bf1bd39bea3d3c064266a072df93c59fd94ee4bc [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
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 */
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 /**
90 * A forwarding objective builder.
91 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -070092 interface Builder extends Objective.Builder {
alshabibfaa1e362015-04-02 15:01:54 -070093
94 /**
95 * Assigns a selector to the forwarding objective.
96 *
97 * @param selector a traffic selector
98 * @return a forwarding objective builder
99 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700100 Builder withSelector(TrafficSelector selector);
alshabibfaa1e362015-04-02 15:01:54 -0700101
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 SHIMIZU3310a342015-05-13 12:14:05 -0700108 Builder nextStep(int nextId);
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Assigns the treatment for this forwarding objective.
112 *
113 * @param treatment a traffic treatment
114 * @return a forwarding objective
115 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700116 Builder withTreatment(TrafficTreatment treatment);
alshabibfaa1e362015-04-02 15:01:54 -0700117
118 /**
119 * Assigns the flag to the forwarding objective.
120 *
121 * @param flag a flag
122 * @return a forwarding objective builder
123 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700124 Builder withFlag(Flag flag);
alshabibfaa1e362015-04-02 15:01:54 -0700125
126 /**
127 * Builds the forwarding objective that will be added.
128 *
129 * @return a forwarding objective
130 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800131 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700132 ForwardingObjective add();
alshabibfaa1e362015-04-02 15:01:54 -0700133
134 /**
135 * Builds the forwarding objective that will be removed.
136 *
137 * @return a forwarding objective.
138 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800139 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700140 ForwardingObjective remove();
alshabib2a441c62015-04-13 18:39:38 -0700141
142 /**
143 * Builds the forwarding objective that will be added.
144 * The context will be used to notify the calling application.
145 *
146 * @param context an objective context
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(ObjectiveContext context);
alshabib2a441c62015-04-13 18:39:38 -0700151
152 /**
153 * Builds the forwarding objective that will be removed.
154 * The context will be used to notify the calling application.
155 *
156 * @param context an objective context
157 * @return a forwarding objective
158 */
Thomas Vachuska00f48162016-02-29 17:07:23 -0800159 @Override
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700160 ForwardingObjective remove(ObjectiveContext context);
alshabibfaa1e362015-04-02 15:01:54 -0700161 }
162}