blob: 0732e3539cc92872a21c6f2fa0193dedda097409 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 Open Networking Laboratory
Thomas Vachuska83e090e2014-10-22 14:25:35 -07003 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07004 * 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
Thomas Vachuska83e090e2014-10-22 14:25:35 -07007 *
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07008 * 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.
Thomas Vachuska83e090e2014-10-22 14:25:35 -070015 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow;
tom8bb16062014-09-12 14:47:46 -070017
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -070018import org.onlab.packet.IpAddress;
alshabib010c31d2014-09-26 10:01:12 -070019import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010020import org.onlab.packet.MplsLabel;
alshabib010c31d2014-09-26 10:01:12 -070021import org.onlab.packet.VlanId;
Jonathan Hart54b406b2015-03-06 16:24:14 -080022import org.onosproject.core.GroupId;
23import org.onosproject.net.PortNumber;
24import org.onosproject.net.flow.instructions.Instruction;
alshabib346b5b32015-03-06 00:42:16 -080025import org.onosproject.net.flow.instructions.Instructions;
alshabib55a55d92014-09-16 11:59:31 -070026
Jonathan Hart54b406b2015-03-06 16:24:14 -080027import java.util.List;
28
tom8bb16062014-09-12 14:47:46 -070029/**
30 * Abstraction of network traffic treatment.
31 */
32public interface TrafficTreatment {
33
34 /**
35 * Returns list of instructions on how to treat traffic.
36 *
37 * @return list of treatment instructions
38 */
alshabib346b5b32015-03-06 00:42:16 -080039 @Deprecated
tom8bb16062014-09-12 14:47:46 -070040 List<Instruction> instructions();
41
42 /**
alshabib346b5b32015-03-06 00:42:16 -080043 * Returns the list of treatment instructions that will be applied
44 * further down the pipeline.
45 * @return list of treatment instructions
46 */
47 List<Instruction> deferred();
48
49 /**
50 * Returns the list of treatment instructions that will be applied
51 * immediately.
52 * @return list of treatment instructions
53 */
54 List<Instruction> immediate();
55
56 /**
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070057 * Returns the list of all instructions in the treatment, both immediate and
58 * deferred.
59 *
60 * @return list of treatment instructions
61 */
62 List<Instruction> allInstructions();
63
64 /**
alshabib346b5b32015-03-06 00:42:16 -080065 * Returns the next table in the pipeline.
66 * @return a table transition; may be null.
67 */
68 Instructions.TableTypeTransition tableTransition();
69
70 /**
71 * Whether the deferred treatment instructions will be cleared
72 * by the device.
73 * @return a boolean
74 */
75 Boolean clearedDeferred();
76
77 /**
tom8bb16062014-09-12 14:47:46 -070078 * Builder of traffic treatment entities.
79 */
80 public interface Builder {
81
82 /**
alshabib010c31d2014-09-26 10:01:12 -070083 * Adds an instruction to the builder.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080084 *
alshabib010c31d2014-09-26 10:01:12 -070085 * @param instruction an instruction
86 * @return a treatment builder
tom8bb16062014-09-12 14:47:46 -070087 */
alshabib369d2942014-09-12 17:59:35 -070088 Builder add(Instruction instruction);
tom8bb16062014-09-12 14:47:46 -070089
90 /**
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080091 * Adds a drop instruction.
92 *
93 * @return a treatment builder
alshabib010c31d2014-09-26 10:01:12 -070094 */
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080095 public Builder drop();
96
97 /**
98 * Adds a punt-to-controller instruction.
99 *
100 * @return a treatment builder
101 */
102 public Builder punt();
alshabib010c31d2014-09-26 10:01:12 -0700103
104 /**
105 * Set the output port.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800106 *
alshabib010c31d2014-09-26 10:01:12 -0700107 * @param number the out port
108 * @return a treatment builder
109 */
110 public Builder setOutput(PortNumber number);
111
112 /**
113 * Sets the src l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800114 *
alshabib010c31d2014-09-26 10:01:12 -0700115 * @param addr a macaddress
116 * @return a treatment builder
117 */
118 public Builder setEthSrc(MacAddress addr);
119
120 /**
121 * Sets the dst l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800122 *
alshabib010c31d2014-09-26 10:01:12 -0700123 * @param addr a macaddress
124 * @return a treatment builder
125 */
126 public Builder setEthDst(MacAddress addr);
127
128 /**
129 * Sets the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800130 *
alshabib010c31d2014-09-26 10:01:12 -0700131 * @param id a vlanid
132 * @return a treatment builder
133 */
134 public Builder setVlanId(VlanId id);
135
136 /**
137 * Sets the vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800138 *
alshabib010c31d2014-09-26 10:01:12 -0700139 * @param pcp a vlan priority
140 * @return a treatment builder
141 */
142 public Builder setVlanPcp(Byte pcp);
143
144 /**
145 * Sets the src l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800146 *
alshabib010c31d2014-09-26 10:01:12 -0700147 * @param addr an ip
148 * @return a treatment builder
149 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700150 public Builder setIpSrc(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700151
152 /**
153 * Sets the dst l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800154 *
alshabib010c31d2014-09-26 10:01:12 -0700155 * @param addr an ip
156 * @return a treatment builder
157 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700158 public Builder setIpDst(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700159
160 /**
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800161 * Decrement the TTL in IP header by one.
sangho3f97a17d2015-01-29 22:56:29 -0800162 *
163 * @return a treatment builder
164 */
165 public Builder decNwTtl();
166
167 /**
168 * Copy the TTL to outer protocol layer.
169 *
170 * @return a treatment builder
171 */
172 public Builder copyTtlOut();
173
174 /**
175 * Copy the TTL to inner protocol layer.
176 *
177 * @return a treatment builder
178 */
179 public Builder copyTtlIn();
180
181 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800182 * Push MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800183 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800184 * @return a treatment builder.
185 */
186 public Builder pushMpls();
187
188 /**
189 * Pops MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800190 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800191 * @return a treatment builder.
192 */
193 public Builder popMpls();
194
195 /**
Michele Santuari4b6019e2014-12-19 11:31:45 +0100196 * Pops MPLS ether type and set the new ethertype.
sangho3f97a17d2015-01-29 22:56:29 -0800197 *
Michele Santuari4b6019e2014-12-19 11:31:45 +0100198 * @param etherType an ether type
sangho3f97a17d2015-01-29 22:56:29 -0800199 * @return a treatment builder.
200 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100201 public Builder popMpls(Short etherType);
sangho3f97a17d2015-01-29 22:56:29 -0800202
203 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800204 * Sets the mpls label.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800205 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800206 * @param mplsLabel MPLS label.
207 * @return a treatment builder.
208 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100209 public Builder setMpls(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800210
211 /**
sangho3f97a17d2015-01-29 22:56:29 -0800212 * Decrement MPLS TTL.
213 *
214 * @return a treatment builder
215 */
216 public Builder decMplsTtl();
217
218 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700219 * Sets the optical channel ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800220 *
Marc De Leenheer49087752014-10-23 13:54:09 -0700221 * @param lambda optical channel ID
222 * @return a treatment builder
223 */
224 public Builder setLambda(short lambda);
225
226 /**
sangho8995ac52015-02-04 11:29:03 -0800227 * Sets the group ID.
228 *
229 * @param groupId group ID
230 * @return a treatment builder
231 */
232 public Builder group(GroupId groupId);
233
alshabib9af70072015-02-09 14:34:16 -0800234
235 /**
236 * Sets the next table type to transition to.
237 *
238 * @param type the table type
239 * @return a treatement builder
240 */
241 public Builder transition(FlowRule.Type type);
242
sangho8995ac52015-02-04 11:29:03 -0800243 /**
Saurav Dasfbe25c52015-03-04 11:12:00 -0800244 * Pops outermost VLAN tag.
245 *
246 * @return a treatment builder.
247 */
248 public Builder popVlan();
249
250 /**
Jonathan Hart54b406b2015-03-06 16:24:14 -0800251 * Pushes a new VLAN tag.
252 *
253 * @return a treatment builder.
254 */
255 public Builder pushVlan();
256
257 /**
alshabib346b5b32015-03-06 00:42:16 -0800258 * Any instructions preceded by this method call will be deferred.
259 * @return a treatment builder
260 */
261 public Builder deferred();
262
263 /**
264 * Any instructions preceded by this method call will be immediate.
265 * @return a treatment builder
266 */
267 public Builder immediate();
268
269
270 /**
271 * Instructs the device to clear the deferred instructions set.
272 * @return a treatment builder
273 */
274 public Builder wipeDeferred();
275
276 /**
tom8bb16062014-09-12 14:47:46 -0700277 * Builds an immutable traffic treatment descriptor.
Brian O'Connor6b528132015-03-10 16:39:52 -0700278 * <p>
279 * If the treatment is empty when build() is called, it will add a default
280 * drop rule automatically. For a treatment that is actually empty, use
281 * {@link org.onosproject.net.flow.DefaultTrafficTreatment#emptyTreatment}.
282 * </p>
tom8bb16062014-09-12 14:47:46 -0700283 *
284 * @return traffic treatment
285 */
286 TrafficTreatment build();
tom8bb16062014-09-12 14:47:46 -0700287 }
tom8bb16062014-09-12 14:47:46 -0700288}