blob: b45dc45a1df32b14c164add92a3297fc7e2536fa [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
BitOhenryb2f8e812015-11-17 19:19:53 +080018import org.onlab.packet.Ip4Address;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070019import org.onlab.packet.Ip6Address;
20import org.onlab.packet.IpPrefix;
21import org.onlab.packet.MacAddress;
22import org.onlab.packet.MplsLabel;
23import org.onlab.packet.TpPort;
24import org.onlab.packet.VlanId;
Jonathan Hart26a8d952015-12-02 15:16:35 -080025import org.onosproject.net.DeviceId;
Brian O'Connorabafb502014-12-02 22:26:20 -080026import org.onosproject.net.PortNumber;
27import org.onosproject.net.flow.criteria.Criterion;
Jonathan Hart26a8d952015-12-02 15:16:35 -080028import org.onosproject.net.flow.criteria.ExtensionSelector;
29
30import java.util.Set;
alshabib7410fea2014-09-16 13:48:39 -070031
tom8bb16062014-09-12 14:47:46 -070032/**
33 * Abstraction of a slice of network traffic.
34 */
35public interface TrafficSelector {
36
37 /**
38 * Returns selection criteria as an ordered list.
39 *
40 * @return list of criteria
41 */
alshabibba5ac482014-10-02 17:15:20 -070042 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070043
44 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070045 * Returns the selection criterion for a particular type, if it exists in
46 * this traffic selector.
47 *
48 * @param type criterion type to look up
49 * @return the criterion of the specified type if one exists, otherwise null
50 */
51 Criterion getCriterion(Criterion.Type type);
52
53 /**
tom8bb16062014-09-12 14:47:46 -070054 * Builder of traffic selector entities.
55 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070056 interface Builder {
tom8bb16062014-09-12 14:47:46 -070057
58 /**
59 * Adds a traffic selection criterion. If a same type criterion has
60 * already been added, it will be replaced by this one.
61 *
62 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070063 * @return self
tom8bb16062014-09-12 14:47:46 -070064 */
alshabib369d2942014-09-12 17:59:35 -070065 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070066
67 /**
alshabib010c31d2014-09-26 10:01:12 -070068 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080069 *
alshabib010c31d2014-09-26 10:01:12 -070070 * @param port the inport
71 * @return a selection builder
72 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070073 Builder matchInPort(PortNumber port);
alshabib010c31d2014-09-26 10:01:12 -070074
75 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080076 * Matches a physical inport.
77 *
78 * @param port the physical inport
79 * @return a selection builder
80 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070081 Builder matchInPhyPort(PortNumber port);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080082
83 /**
84 * Matches a metadata.
85 *
86 * @param metadata the metadata
87 * @return a selection builder
88 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070089 Builder matchMetadata(long metadata);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080090
91 /**
alshabib010c31d2014-09-26 10:01:12 -070092 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080093 *
alshabib010c31d2014-09-26 10:01:12 -070094 * @param addr a l2 address
95 * @return a selection builder
96 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070097 Builder matchEthDst(MacAddress addr);
alshabib010c31d2014-09-26 10:01:12 -070098
99 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800100 * Matches a l2 src address.
101 *
102 * @param addr a l2 address
103 * @return a selection builder
104 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700105 Builder matchEthSrc(MacAddress addr);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800106
107 /**
alshabib010c31d2014-09-26 10:01:12 -0700108 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800109 *
alshabib010c31d2014-09-26 10:01:12 -0700110 * @param ethType an ethernet type
111 * @return a selection builder
112 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700113 Builder matchEthType(short ethType);
alshabib010c31d2014-09-26 10:01:12 -0700114
115 /**
116 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800117 *
alshabib010c31d2014-09-26 10:01:12 -0700118 * @param vlanId a vlan id
119 * @return a selection builder
120 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700121 Builder matchVlanId(VlanId vlanId);
alshabib010c31d2014-09-26 10:01:12 -0700122
123 /**
124 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800125 *
alshabib010c31d2014-09-26 10:01:12 -0700126 * @param vlanPcp a vlan priority
127 * @return a selection builder
128 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700129 Builder matchVlanPcp(byte vlanPcp);
alshabib010c31d2014-09-26 10:01:12 -0700130
131 /**
alshabibfa0dc662016-01-13 11:23:53 -0800132 * Matches the inner vlan id.
133 *
134 * @param vlanId a vlan id
135 * @return a selection builder
136 */
137 Builder matchInnerVlanId(VlanId vlanId);
138
139 /**
140 * Matches a vlan priority.
141 *
142 * @param vlanPcp a vlan priority
143 * @return a selection builder
144 */
145 Builder matchInnerVlanPcp(byte vlanPcp);
146
147 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800148 * Matches an IP DSCP (6 bits in ToS field).
149 *
150 * @param ipDscp an IP DSCP value
151 * @return a selection builder
152 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700153 Builder matchIPDscp(byte ipDscp);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800154
155 /**
156 * Matches an IP ECN (2 bits in ToS field).
157 *
158 * @param ipEcn an IP ECN value
159 * @return a selection builder
160 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700161 Builder matchIPEcn(byte ipEcn);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800162
163 /**
alshabib010c31d2014-09-26 10:01:12 -0700164 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800165 *
alshabib010c31d2014-09-26 10:01:12 -0700166 * @param proto a l3 protocol
167 * @return a selection builder
168 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700169 Builder matchIPProtocol(byte proto);
alshabib010c31d2014-09-26 10:01:12 -0700170
171 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800172 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800173 *
alshabib010c31d2014-09-26 10:01:12 -0700174 * @param ip a l3 address
175 * @return a selection builder
176 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700177 Builder matchIPSrc(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700178
179 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800180 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800181 *
alshabib010c31d2014-09-26 10:01:12 -0700182 * @param ip a l3 address
183 * @return a selection builder
184 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700185 Builder matchIPDst(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700186
187 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700188 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800189 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700190 * @param tcpPort a TCP source port number
191 * @return a selection builder
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700192 * @deprecated in Drake release
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700193 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700194 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700195 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700196
197 /**
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700198 * Matches a TCP source port number.
199 *
200 * @param tcpPort a TCP source port number
201 * @return a selection builder
202 */
203 Builder matchTcpSrc(TpPort tcpPort);
204
205 /**
206 * Matches a TCP destination port number.
207 *
208 * @param tcpPort a TCP destination port number
209 * @return a selection builder
210 * @deprecated in Drake release
211 */
212 @Deprecated
213 Builder matchTcpDst(short tcpPort);
214
215 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700216 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800217 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700218 * @param tcpPort a TCP destination port number
219 * @return a selection builder
220 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700221 Builder matchTcpDst(TpPort tcpPort);
222
223 /**
224 * Matches an UDP source port number.
225 *
226 * @param udpPort an UDP source port number
227 * @return a selection builder
228 * @deprecated in Drake release
229 */
230 @Deprecated
231 Builder matchUdpSrc(short udpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700232
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800233 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800234 * Matches an UDP source port number.
235 *
236 * @param udpPort an UDP source port number
237 * @return a selection builder
238 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700239 Builder matchUdpSrc(TpPort udpPort);
240
241 /**
242 * Matches an UDP destination port number.
243 *
244 * @param udpPort an UDP destination port number
245 * @return a selection builder
246 * @deprecated in Drake release
247 */
248 @Deprecated
249 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800250
251 /**
252 * Matches an UDP destination port number.
253 *
254 * @param udpPort an UDP destination port number
255 * @return a selection builder
256 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700257 Builder matchUdpDst(TpPort udpPort);
258
259 /**
260 * Matches a SCTP source port number.
261 *
262 * @param sctpPort a SCTP source port number
263 * @return a selection builder
264 * @deprecated in Drake release
265 */
266 @Deprecated
267 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800268
269 /**
270 * Matches a SCTP source port number.
271 *
272 * @param sctpPort a SCTP source port number
273 * @return a selection builder
274 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700275 Builder matchSctpSrc(TpPort sctpPort);
276
277 /**
278 * Matches a SCTP destination port number.
279 *
280 * @param sctpPort a SCTP destination port number
281 * @return a selection builder
282 * @deprecated in Drake release
283 */
284 @Deprecated
285 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800286
287 /**
288 * Matches a SCTP destination port number.
289 *
290 * @param sctpPort a SCTP destination port number
291 * @return a selection builder
292 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700293 Builder matchSctpDst(TpPort sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800294
295 /**
296 * Matches an ICMP type.
297 *
298 * @param icmpType an ICMP type
299 * @return a selection builder
300 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700301 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800302
303 /**
304 * Matches an ICMP code.
305 *
306 * @param icmpCode an ICMP code
307 * @return a selection builder
308 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700309 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800310
311 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800312 * Matches a l3 IPv6 address.
313 *
314 * @param ip a l3 IPv6 address
315 * @return a selection builder
316 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700317 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800318
319 /**
320 * Matches a l3 IPv6 address.
321 *
322 * @param ip a l3 IPv6 address
323 * @return a selection builder
324 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700325 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800326
327 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800328 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800329 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800330 * @param flowLabel an IPv6 flow label
331 * @return a selection builder
332 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700333 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800334
335 /**
336 * Matches an ICMPv6 type.
337 *
338 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800339 * @return a selection builder
340 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700341 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800342
343 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800344 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800345 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800346 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800347 * @return a selection builder
348 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700349 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800350
351 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800352 * Matches an IPv6 Neighbor Discovery target address.
353 *
354 * @param targetAddress an IPv6 Neighbor Discovery target address
355 * @return a selection builder
356 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700357 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800358
359 /**
360 * Matches an IPv6 Neighbor Discovery source link-layer address.
361 *
362 * @param mac an IPv6 Neighbor Discovery source link-layer address
363 * @return a selection builder
364 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700365 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800366
367 /**
368 * Matches an IPv6 Neighbor Discovery target link-layer address.
369 *
370 * @param mac an IPv6 Neighbor Discovery target link-layer address
371 * @return a selection builder
372 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700373 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800374
375 /**
376 * Matches on a MPLS label.
377 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800378 * @param mplsLabel a MPLS label.
379 * @return a selection builder
380 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700381 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800382
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700383 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700384 * Matches on a MPLS Bottom-of-Stack indicator bit.
385 *
386 * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false).
387 * @return a selection builder
388 */
389 Builder matchMplsBos(boolean mplsBos);
390
391 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700392 * Matches a tunnel id.
393 *
394 * @param tunnelId a tunnel id
395 * @return a selection builder
396 */
397 Builder matchTunnelId(long tunnelId);
398
399 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700400 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800401 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700402 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800403 * @return a selection builder
404 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700405 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800406
407 /**
BitOhenryb2f8e812015-11-17 19:19:53 +0800408 * Matches a arp IPv4 destination address.
409 *
410 * @param addr a arp IPv4 destination address
411 * @return a selection builder
412 */
413 Builder matchArpTpa(Ip4Address addr);
414
415 /**
BitOhenry08c72942015-11-18 14:44:29 +0800416 * Matches a arp IPv4 source address.
417 *
418 * @param addr a arp IPv4 source address
419 * @return a selection builder
420 */
421 Builder matchArpSpa(Ip4Address addr);
422
423 /**
BitOhenry914c7ad2015-11-16 14:58:53 +0800424 * Matches a arp_eth_dst address.
425 *
426 * @param addr a arp_eth_dst address
427 * @return a selection builder
428 */
429 Builder matchArpTha(MacAddress addr);
430
431 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800432 * Matches a arp_eth_src address.
433 *
434 * @param addr a arp_eth_src address
435 * @return a selection builder
436 */
437 Builder matchArpSha(MacAddress addr);
438
439 /**
BitOhenryb40129a2015-11-30 12:41:18 +0800440 * Matches a arp operation type.
441 *
442 * @param arpOp a arp operation type
443 * @return a selection builder
444 */
445 Builder matchArpOp(int arpOp);
446
447 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800448 * Uses an extension selector.
449 *
450 * @param extensionSelector extension selector
451 * @param deviceId device ID
452 * @return a selection builder
453 */
454 Builder extension(ExtensionSelector extensionSelector, DeviceId deviceId);
455
456 /**
tom8bb16062014-09-12 14:47:46 -0700457 * Builds an immutable traffic selector.
458 *
459 * @return traffic selector
460 */
461 TrafficSelector build();
462 }
tom8bb16062014-09-12 14:47:46 -0700463}