blob: a0b3416c10b9a5291d91fadea3de7f140c40b495 [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Ray Milkey34c95902015-04-15 09:47:53 -07002 * Copyright 2014-2015 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
alshabibba5ac482014-10-02 17:15:20 -070018import java.util.Set;
tom8bb16062014-09-12 14:47:46 -070019
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070020import org.onlab.packet.Ip6Address;
21import org.onlab.packet.IpPrefix;
22import org.onlab.packet.MacAddress;
23import org.onlab.packet.MplsLabel;
24import org.onlab.packet.TpPort;
25import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.PortNumber;
27import org.onosproject.net.flow.criteria.Criterion;
alshabib7410fea2014-09-16 13:48:39 -070028
tom8bb16062014-09-12 14:47:46 -070029/**
30 * Abstraction of a slice of network traffic.
31 */
32public interface TrafficSelector {
33
34 /**
35 * Returns selection criteria as an ordered list.
36 *
37 * @return list of criteria
38 */
alshabibba5ac482014-10-02 17:15:20 -070039 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070040
41 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070042 * Returns the selection criterion for a particular type, if it exists in
43 * this traffic selector.
44 *
45 * @param type criterion type to look up
46 * @return the criterion of the specified type if one exists, otherwise null
47 */
48 Criterion getCriterion(Criterion.Type type);
49
50 /**
tom8bb16062014-09-12 14:47:46 -070051 * Builder of traffic selector entities.
52 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070053 interface Builder {
tom8bb16062014-09-12 14:47:46 -070054
55 /**
56 * Adds a traffic selection criterion. If a same type criterion has
57 * already been added, it will be replaced by this one.
58 *
59 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070060 * @return self
tom8bb16062014-09-12 14:47:46 -070061 */
alshabib369d2942014-09-12 17:59:35 -070062 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070063
64 /**
alshabib010c31d2014-09-26 10:01:12 -070065 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080066 *
alshabib010c31d2014-09-26 10:01:12 -070067 * @param port the inport
68 * @return a selection builder
69 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070070 Builder matchInPort(PortNumber port);
alshabib010c31d2014-09-26 10:01:12 -070071
72 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080073 * Matches a physical inport.
74 *
75 * @param port the physical inport
76 * @return a selection builder
77 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070078 Builder matchInPhyPort(PortNumber port);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080079
80 /**
81 * Matches a metadata.
82 *
83 * @param metadata the metadata
84 * @return a selection builder
85 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070086 Builder matchMetadata(long metadata);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080087
88 /**
alshabib010c31d2014-09-26 10:01:12 -070089 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080090 *
alshabib010c31d2014-09-26 10:01:12 -070091 * @param addr a l2 address
92 * @return a selection builder
93 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070094 Builder matchEthDst(MacAddress addr);
alshabib010c31d2014-09-26 10:01:12 -070095
96 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080097 * Matches a l2 src address.
98 *
99 * @param addr a l2 address
100 * @return a selection builder
101 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700102 Builder matchEthSrc(MacAddress addr);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800103
104 /**
alshabib010c31d2014-09-26 10:01:12 -0700105 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800106 *
alshabib010c31d2014-09-26 10:01:12 -0700107 * @param ethType an ethernet type
108 * @return a selection builder
109 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700110 Builder matchEthType(short ethType);
alshabib010c31d2014-09-26 10:01:12 -0700111
112 /**
113 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800114 *
alshabib010c31d2014-09-26 10:01:12 -0700115 * @param vlanId a vlan id
116 * @return a selection builder
117 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700118 Builder matchVlanId(VlanId vlanId);
alshabib010c31d2014-09-26 10:01:12 -0700119
120 /**
121 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800122 *
alshabib010c31d2014-09-26 10:01:12 -0700123 * @param vlanPcp a vlan priority
124 * @return a selection builder
125 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700126 Builder matchVlanPcp(byte vlanPcp);
alshabib010c31d2014-09-26 10:01:12 -0700127
128 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800129 * Matches an IP DSCP (6 bits in ToS field).
130 *
131 * @param ipDscp an IP DSCP value
132 * @return a selection builder
133 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700134 Builder matchIPDscp(byte ipDscp);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800135
136 /**
137 * Matches an IP ECN (2 bits in ToS field).
138 *
139 * @param ipEcn an IP ECN value
140 * @return a selection builder
141 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700142 Builder matchIPEcn(byte ipEcn);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800143
144 /**
alshabib010c31d2014-09-26 10:01:12 -0700145 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800146 *
alshabib010c31d2014-09-26 10:01:12 -0700147 * @param proto a l3 protocol
148 * @return a selection builder
149 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700150 Builder matchIPProtocol(byte proto);
alshabib010c31d2014-09-26 10:01:12 -0700151
152 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800153 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800154 *
alshabib010c31d2014-09-26 10:01:12 -0700155 * @param ip a l3 address
156 * @return a selection builder
157 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700158 Builder matchIPSrc(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700159
160 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800161 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800162 *
alshabib010c31d2014-09-26 10:01:12 -0700163 * @param ip a l3 address
164 * @return a selection builder
165 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700166 Builder matchIPDst(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700167
168 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700169 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800170 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700171 * @param tcpPort a TCP source port number
172 * @return a selection builder
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700173 * @deprecated in Drake release
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700174 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700175 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700176 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700177
178 /**
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700179 * Matches a TCP source port number.
180 *
181 * @param tcpPort a TCP source port number
182 * @return a selection builder
183 */
184 Builder matchTcpSrc(TpPort tcpPort);
185
186 /**
187 * Matches a TCP destination port number.
188 *
189 * @param tcpPort a TCP destination port number
190 * @return a selection builder
191 * @deprecated in Drake release
192 */
193 @Deprecated
194 Builder matchTcpDst(short tcpPort);
195
196 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700197 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800198 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700199 * @param tcpPort a TCP destination port number
200 * @return a selection builder
201 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700202 Builder matchTcpDst(TpPort tcpPort);
203
204 /**
205 * Matches an UDP source port number.
206 *
207 * @param udpPort an UDP source port number
208 * @return a selection builder
209 * @deprecated in Drake release
210 */
211 @Deprecated
212 Builder matchUdpSrc(short udpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700213
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800214 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800215 * Matches an UDP source port number.
216 *
217 * @param udpPort an UDP source port number
218 * @return a selection builder
219 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700220 Builder matchUdpSrc(TpPort udpPort);
221
222 /**
223 * Matches an UDP destination port number.
224 *
225 * @param udpPort an UDP destination port number
226 * @return a selection builder
227 * @deprecated in Drake release
228 */
229 @Deprecated
230 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800231
232 /**
233 * Matches an UDP destination port number.
234 *
235 * @param udpPort an UDP destination port number
236 * @return a selection builder
237 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700238 Builder matchUdpDst(TpPort udpPort);
239
240 /**
241 * Matches a SCTP source port number.
242 *
243 * @param sctpPort a SCTP source port number
244 * @return a selection builder
245 * @deprecated in Drake release
246 */
247 @Deprecated
248 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800249
250 /**
251 * Matches a SCTP source port number.
252 *
253 * @param sctpPort a SCTP source port number
254 * @return a selection builder
255 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700256 Builder matchSctpSrc(TpPort sctpPort);
257
258 /**
259 * Matches a SCTP destination port number.
260 *
261 * @param sctpPort a SCTP destination port number
262 * @return a selection builder
263 * @deprecated in Drake release
264 */
265 @Deprecated
266 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800267
268 /**
269 * Matches a SCTP destination port number.
270 *
271 * @param sctpPort a SCTP destination port number
272 * @return a selection builder
273 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700274 Builder matchSctpDst(TpPort sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800275
276 /**
277 * Matches an ICMP type.
278 *
279 * @param icmpType an ICMP type
280 * @return a selection builder
281 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700282 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800283
284 /**
285 * Matches an ICMP code.
286 *
287 * @param icmpCode an ICMP code
288 * @return a selection builder
289 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700290 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800291
292 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800293 * Matches a l3 IPv6 address.
294 *
295 * @param ip a l3 IPv6 address
296 * @return a selection builder
297 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700298 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800299
300 /**
301 * Matches a l3 IPv6 address.
302 *
303 * @param ip a l3 IPv6 address
304 * @return a selection builder
305 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700306 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800307
308 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800309 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800310 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800311 * @param flowLabel an IPv6 flow label
312 * @return a selection builder
313 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700314 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800315
316 /**
317 * Matches an ICMPv6 type.
318 *
319 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800320 * @return a selection builder
321 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700322 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800323
324 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800325 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800326 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800327 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800328 * @return a selection builder
329 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700330 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800331
332 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800333 * Matches an IPv6 Neighbor Discovery target address.
334 *
335 * @param targetAddress an IPv6 Neighbor Discovery target address
336 * @return a selection builder
337 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700338 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800339
340 /**
341 * Matches an IPv6 Neighbor Discovery source link-layer address.
342 *
343 * @param mac an IPv6 Neighbor Discovery source link-layer address
344 * @return a selection builder
345 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700346 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800347
348 /**
349 * Matches an IPv6 Neighbor Discovery target link-layer address.
350 *
351 * @param mac an IPv6 Neighbor Discovery target link-layer address
352 * @return a selection builder
353 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700354 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800355
356 /**
357 * Matches on a MPLS label.
358 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800359 * @param mplsLabel a MPLS label.
360 * @return a selection builder
361 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700362 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800363
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700364 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700365 * Matches on a MPLS Bottom-of-Stack indicator bit.
366 *
367 * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false).
368 * @return a selection builder
369 */
370 Builder matchMplsBos(boolean mplsBos);
371
372 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700373 * Matches a tunnel id.
374 *
375 * @param tunnelId a tunnel id
376 * @return a selection builder
377 */
378 Builder matchTunnelId(long tunnelId);
379
380 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700381 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800382 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700383 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800384 * @return a selection builder
385 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700386 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800387
388 /**
BitOhenry914c7ad2015-11-16 14:58:53 +0800389 * Matches a arp_eth_dst address.
390 *
391 * @param addr a arp_eth_dst address
392 * @return a selection builder
393 */
394 Builder matchArpTha(MacAddress addr);
395
396 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800397 * Matches a arp_eth_src address.
398 *
399 * @param addr a arp_eth_src address
400 * @return a selection builder
401 */
402 Builder matchArpSha(MacAddress addr);
403
404 /**
tom8bb16062014-09-12 14:47:46 -0700405 * Builds an immutable traffic selector.
406 *
407 * @return traffic selector
408 */
409 TrafficSelector build();
410 }
tom8bb16062014-09-12 14:47:46 -0700411}