blob: 0d055addccaeb6b9284fbc37560b9d491df99dee [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 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800132 * Matches an IP DSCP (6 bits in ToS field).
133 *
134 * @param ipDscp an IP DSCP value
135 * @return a selection builder
136 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700137 Builder matchIPDscp(byte ipDscp);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800138
139 /**
140 * Matches an IP ECN (2 bits in ToS field).
141 *
142 * @param ipEcn an IP ECN value
143 * @return a selection builder
144 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700145 Builder matchIPEcn(byte ipEcn);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800146
147 /**
alshabib010c31d2014-09-26 10:01:12 -0700148 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800149 *
alshabib010c31d2014-09-26 10:01:12 -0700150 * @param proto a l3 protocol
151 * @return a selection builder
152 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700153 Builder matchIPProtocol(byte proto);
alshabib010c31d2014-09-26 10:01:12 -0700154
155 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800156 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800157 *
alshabib010c31d2014-09-26 10:01:12 -0700158 * @param ip a l3 address
159 * @return a selection builder
160 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700161 Builder matchIPSrc(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700162
163 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800164 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800165 *
alshabib010c31d2014-09-26 10:01:12 -0700166 * @param ip a l3 address
167 * @return a selection builder
168 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700169 Builder matchIPDst(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700170
171 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700172 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800173 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700174 * @param tcpPort a TCP source port number
175 * @return a selection builder
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700176 * @deprecated in Drake release
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700177 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700178 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700179 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700180
181 /**
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700182 * Matches a TCP source port number.
183 *
184 * @param tcpPort a TCP source port number
185 * @return a selection builder
186 */
187 Builder matchTcpSrc(TpPort tcpPort);
188
189 /**
190 * Matches a TCP destination port number.
191 *
192 * @param tcpPort a TCP destination port number
193 * @return a selection builder
194 * @deprecated in Drake release
195 */
196 @Deprecated
197 Builder matchTcpDst(short tcpPort);
198
199 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700200 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800201 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700202 * @param tcpPort a TCP destination port number
203 * @return a selection builder
204 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700205 Builder matchTcpDst(TpPort tcpPort);
206
207 /**
208 * Matches an UDP source port number.
209 *
210 * @param udpPort an UDP source port number
211 * @return a selection builder
212 * @deprecated in Drake release
213 */
214 @Deprecated
215 Builder matchUdpSrc(short udpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700216
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800217 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800218 * Matches an UDP source port number.
219 *
220 * @param udpPort an UDP source port number
221 * @return a selection builder
222 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700223 Builder matchUdpSrc(TpPort udpPort);
224
225 /**
226 * Matches an UDP destination port number.
227 *
228 * @param udpPort an UDP destination port number
229 * @return a selection builder
230 * @deprecated in Drake release
231 */
232 @Deprecated
233 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800234
235 /**
236 * Matches an UDP destination port number.
237 *
238 * @param udpPort an UDP destination port number
239 * @return a selection builder
240 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700241 Builder matchUdpDst(TpPort udpPort);
242
243 /**
244 * Matches a SCTP source port number.
245 *
246 * @param sctpPort a SCTP source port number
247 * @return a selection builder
248 * @deprecated in Drake release
249 */
250 @Deprecated
251 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800252
253 /**
254 * Matches a SCTP source port number.
255 *
256 * @param sctpPort a SCTP source port number
257 * @return a selection builder
258 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700259 Builder matchSctpSrc(TpPort sctpPort);
260
261 /**
262 * Matches a SCTP destination port number.
263 *
264 * @param sctpPort a SCTP destination port number
265 * @return a selection builder
266 * @deprecated in Drake release
267 */
268 @Deprecated
269 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800270
271 /**
272 * Matches a SCTP destination port number.
273 *
274 * @param sctpPort a SCTP destination port number
275 * @return a selection builder
276 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700277 Builder matchSctpDst(TpPort sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800278
279 /**
280 * Matches an ICMP type.
281 *
282 * @param icmpType an ICMP type
283 * @return a selection builder
284 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700285 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800286
287 /**
288 * Matches an ICMP code.
289 *
290 * @param icmpCode an ICMP code
291 * @return a selection builder
292 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700293 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800294
295 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800296 * Matches a l3 IPv6 address.
297 *
298 * @param ip a l3 IPv6 address
299 * @return a selection builder
300 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700301 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800302
303 /**
304 * Matches a l3 IPv6 address.
305 *
306 * @param ip a l3 IPv6 address
307 * @return a selection builder
308 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700309 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800310
311 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800312 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800313 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800314 * @param flowLabel an IPv6 flow label
315 * @return a selection builder
316 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700317 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800318
319 /**
320 * Matches an ICMPv6 type.
321 *
322 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800323 * @return a selection builder
324 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700325 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800326
327 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800328 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800329 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800330 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800331 * @return a selection builder
332 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700333 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800334
335 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800336 * Matches an IPv6 Neighbor Discovery target address.
337 *
338 * @param targetAddress an IPv6 Neighbor Discovery target address
339 * @return a selection builder
340 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700341 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800342
343 /**
344 * Matches an IPv6 Neighbor Discovery source link-layer address.
345 *
346 * @param mac an IPv6 Neighbor Discovery source link-layer address
347 * @return a selection builder
348 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700349 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800350
351 /**
352 * Matches an IPv6 Neighbor Discovery target link-layer address.
353 *
354 * @param mac an IPv6 Neighbor Discovery target link-layer address
355 * @return a selection builder
356 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700357 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800358
359 /**
360 * Matches on a MPLS label.
361 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800362 * @param mplsLabel a MPLS label.
363 * @return a selection builder
364 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700365 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800366
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700367 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700368 * Matches on a MPLS Bottom-of-Stack indicator bit.
369 *
370 * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false).
371 * @return a selection builder
372 */
373 Builder matchMplsBos(boolean mplsBos);
374
375 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700376 * Matches a tunnel id.
377 *
378 * @param tunnelId a tunnel id
379 * @return a selection builder
380 */
381 Builder matchTunnelId(long tunnelId);
382
383 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700384 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800385 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700386 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800387 * @return a selection builder
388 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700389 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800390
391 /**
BitOhenryb2f8e812015-11-17 19:19:53 +0800392 * Matches a arp IPv4 destination address.
393 *
394 * @param addr a arp IPv4 destination address
395 * @return a selection builder
396 */
397 Builder matchArpTpa(Ip4Address addr);
398
399 /**
BitOhenry08c72942015-11-18 14:44:29 +0800400 * Matches a arp IPv4 source address.
401 *
402 * @param addr a arp IPv4 source address
403 * @return a selection builder
404 */
405 Builder matchArpSpa(Ip4Address addr);
406
407 /**
BitOhenry914c7ad2015-11-16 14:58:53 +0800408 * Matches a arp_eth_dst address.
409 *
410 * @param addr a arp_eth_dst address
411 * @return a selection builder
412 */
413 Builder matchArpTha(MacAddress addr);
414
415 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800416 * Matches a arp_eth_src address.
417 *
418 * @param addr a arp_eth_src address
419 * @return a selection builder
420 */
421 Builder matchArpSha(MacAddress addr);
422
423 /**
BitOhenryb40129a2015-11-30 12:41:18 +0800424 * Matches a arp operation type.
425 *
426 * @param arpOp a arp operation type
427 * @return a selection builder
428 */
429 Builder matchArpOp(int arpOp);
430
431 /**
Jonathan Hart26a8d952015-12-02 15:16:35 -0800432 * Uses an extension selector.
433 *
434 * @param extensionSelector extension selector
435 * @param deviceId device ID
436 * @return a selection builder
437 */
438 Builder extension(ExtensionSelector extensionSelector, DeviceId deviceId);
439
440 /**
tom8bb16062014-09-12 14:47:46 -0700441 * Builds an immutable traffic selector.
442 *
443 * @return traffic selector
444 */
445 TrafficSelector build();
446 }
tom8bb16062014-09-12 14:47:46 -0700447}