blob: a2254fa8ccc6e437a98ce9c76c2816923d7294d6 [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 /**
alshabib346b5b32015-03-06 00:42:16 -080035 * Returns the list of treatment instructions that will be applied
36 * further down the pipeline.
37 * @return list of treatment instructions
38 */
39 List<Instruction> deferred();
40
41 /**
42 * Returns the list of treatment instructions that will be applied
43 * immediately.
44 * @return list of treatment instructions
45 */
46 List<Instruction> immediate();
47
48 /**
Jonathan Hart8ef6d3b2015-03-08 21:21:27 -070049 * Returns the list of all instructions in the treatment, both immediate and
50 * deferred.
51 *
52 * @return list of treatment instructions
53 */
54 List<Instruction> allInstructions();
55
56 /**
alshabib346b5b32015-03-06 00:42:16 -080057 * Returns the next table in the pipeline.
58 * @return a table transition; may be null.
59 */
60 Instructions.TableTypeTransition tableTransition();
61
62 /**
63 * Whether the deferred treatment instructions will be cleared
64 * by the device.
65 * @return a boolean
66 */
67 Boolean clearedDeferred();
68
69 /**
tom8bb16062014-09-12 14:47:46 -070070 * Builder of traffic treatment entities.
71 */
72 public interface Builder {
73
74 /**
alshabib010c31d2014-09-26 10:01:12 -070075 * Adds an instruction to the builder.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080076 *
alshabib010c31d2014-09-26 10:01:12 -070077 * @param instruction an instruction
78 * @return a treatment builder
tom8bb16062014-09-12 14:47:46 -070079 */
alshabib369d2942014-09-12 17:59:35 -070080 Builder add(Instruction instruction);
tom8bb16062014-09-12 14:47:46 -070081
82 /**
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080083 * Adds a drop instruction.
84 *
85 * @return a treatment builder
alshabib010c31d2014-09-26 10:01:12 -070086 */
Thomas Vachuskaf4df0052015-01-06 12:30:11 -080087 public Builder drop();
88
89 /**
90 * Adds a punt-to-controller instruction.
91 *
92 * @return a treatment builder
93 */
94 public Builder punt();
alshabib010c31d2014-09-26 10:01:12 -070095
96 /**
97 * Set the output port.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080098 *
alshabib010c31d2014-09-26 10:01:12 -070099 * @param number the out port
100 * @return a treatment builder
101 */
102 public Builder setOutput(PortNumber number);
103
104 /**
105 * Sets the src l2 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800106 *
alshabib010c31d2014-09-26 10:01:12 -0700107 * @param addr a macaddress
108 * @return a treatment builder
109 */
110 public Builder setEthSrc(MacAddress addr);
111
112 /**
113 * Sets the dst 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 setEthDst(MacAddress addr);
119
120 /**
121 * Sets the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800122 *
alshabib010c31d2014-09-26 10:01:12 -0700123 * @param id a vlanid
124 * @return a treatment builder
125 */
126 public Builder setVlanId(VlanId id);
127
128 /**
129 * Sets the vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800130 *
alshabib010c31d2014-09-26 10:01:12 -0700131 * @param pcp a vlan priority
132 * @return a treatment builder
133 */
134 public Builder setVlanPcp(Byte pcp);
135
136 /**
137 * Sets the src l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800138 *
alshabib010c31d2014-09-26 10:01:12 -0700139 * @param addr an ip
140 * @return a treatment builder
141 */
Pavlin Radoslavov855ea2d2014-10-30 15:32:39 -0700142 public Builder setIpSrc(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700143
144 /**
145 * Sets the dst 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 setIpDst(IpAddress addr);
alshabib010c31d2014-09-26 10:01:12 -0700151
152 /**
Pavlin Radoslavovfebe82c2015-02-11 19:08:15 -0800153 * Decrement the TTL in IP header by one.
sangho3f97a17d2015-01-29 22:56:29 -0800154 *
155 * @return a treatment builder
156 */
157 public Builder decNwTtl();
158
159 /**
160 * Copy the TTL to outer protocol layer.
161 *
162 * @return a treatment builder
163 */
164 public Builder copyTtlOut();
165
166 /**
167 * Copy the TTL to inner protocol layer.
168 *
169 * @return a treatment builder
170 */
171 public Builder copyTtlIn();
172
173 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800174 * Push MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800175 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800176 * @return a treatment builder.
177 */
178 public Builder pushMpls();
179
180 /**
181 * Pops MPLS ether type.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800182 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800183 * @return a treatment builder.
184 */
185 public Builder popMpls();
186
187 /**
Michele Santuari4b6019e2014-12-19 11:31:45 +0100188 * Pops MPLS ether type and set the new ethertype.
sangho3f97a17d2015-01-29 22:56:29 -0800189 *
Michele Santuari4b6019e2014-12-19 11:31:45 +0100190 * @param etherType an ether type
sangho3f97a17d2015-01-29 22:56:29 -0800191 * @return a treatment builder.
192 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100193 public Builder popMpls(Short etherType);
sangho3f97a17d2015-01-29 22:56:29 -0800194
195 /**
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800196 * Sets the mpls label.
Thomas Vachuskaf4df0052015-01-06 12:30:11 -0800197 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800198 * @param mplsLabel MPLS label.
199 * @return a treatment builder.
200 */
Michele Santuari4b6019e2014-12-19 11:31:45 +0100201 public Builder setMpls(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800202
203 /**
sangho3f97a17d2015-01-29 22:56:29 -0800204 * Decrement MPLS TTL.
205 *
206 * @return a treatment builder
207 */
208 public Builder decMplsTtl();
209
210 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700211 * Sets the optical channel ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800212 *
Marc De Leenheer49087752014-10-23 13:54:09 -0700213 * @param lambda optical channel ID
214 * @return a treatment builder
215 */
216 public Builder setLambda(short lambda);
217
218 /**
sangho8995ac52015-02-04 11:29:03 -0800219 * Sets the group ID.
220 *
221 * @param groupId group ID
222 * @return a treatment builder
223 */
224 public Builder group(GroupId groupId);
225
alshabib9af70072015-02-09 14:34:16 -0800226
227 /**
228 * Sets the next table type to transition to.
229 *
230 * @param type the table type
231 * @return a treatement builder
232 */
233 public Builder transition(FlowRule.Type type);
234
sangho8995ac52015-02-04 11:29:03 -0800235 /**
Saurav Dasfbe25c52015-03-04 11:12:00 -0800236 * Pops outermost VLAN tag.
237 *
238 * @return a treatment builder.
239 */
240 public Builder popVlan();
241
242 /**
Jonathan Hart54b406b2015-03-06 16:24:14 -0800243 * Pushes a new VLAN tag.
244 *
245 * @return a treatment builder.
246 */
247 public Builder pushVlan();
248
249 /**
alshabib346b5b32015-03-06 00:42:16 -0800250 * Any instructions preceded by this method call will be deferred.
251 * @return a treatment builder
252 */
253 public Builder deferred();
254
255 /**
256 * Any instructions preceded by this method call will be immediate.
257 * @return a treatment builder
258 */
259 public Builder immediate();
260
261
262 /**
263 * Instructs the device to clear the deferred instructions set.
264 * @return a treatment builder
265 */
266 public Builder wipeDeferred();
267
268 /**
tom8bb16062014-09-12 14:47:46 -0700269 * Builds an immutable traffic treatment descriptor.
Brian O'Connor6b528132015-03-10 16:39:52 -0700270 * <p>
271 * If the treatment is empty when build() is called, it will add a default
272 * drop rule automatically. For a treatment that is actually empty, use
273 * {@link org.onosproject.net.flow.DefaultTrafficTreatment#emptyTreatment}.
274 * </p>
tom8bb16062014-09-12 14:47:46 -0700275 *
276 * @return traffic treatment
277 */
278 TrafficTreatment build();
tom8bb16062014-09-12 14:47:46 -0700279 }
tom8bb16062014-09-12 14:47:46 -0700280}