blob: 6b1720bce47b2e9648df053c263270a54b3358b1 [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
BitOhenryb2f8e812015-11-17 19:19:53 +080020import org.onlab.packet.Ip4Address;
Hyunsun Mooncf732fb2015-08-22 21:04:23 -070021import org.onlab.packet.Ip6Address;
22import org.onlab.packet.IpPrefix;
23import org.onlab.packet.MacAddress;
24import org.onlab.packet.MplsLabel;
25import org.onlab.packet.TpPort;
26import org.onlab.packet.VlanId;
Brian O'Connorabafb502014-12-02 22:26:20 -080027import org.onosproject.net.PortNumber;
28import org.onosproject.net.flow.criteria.Criterion;
alshabib7410fea2014-09-16 13:48:39 -070029
tom8bb16062014-09-12 14:47:46 -070030/**
31 * Abstraction of a slice of network traffic.
32 */
33public interface TrafficSelector {
34
35 /**
36 * Returns selection criteria as an ordered list.
37 *
38 * @return list of criteria
39 */
alshabibba5ac482014-10-02 17:15:20 -070040 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070041
42 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070043 * Returns the selection criterion for a particular type, if it exists in
44 * this traffic selector.
45 *
46 * @param type criterion type to look up
47 * @return the criterion of the specified type if one exists, otherwise null
48 */
49 Criterion getCriterion(Criterion.Type type);
50
51 /**
tom8bb16062014-09-12 14:47:46 -070052 * Builder of traffic selector entities.
53 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070054 interface Builder {
tom8bb16062014-09-12 14:47:46 -070055
56 /**
57 * Adds a traffic selection criterion. If a same type criterion has
58 * already been added, it will be replaced by this one.
59 *
60 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070061 * @return self
tom8bb16062014-09-12 14:47:46 -070062 */
alshabib369d2942014-09-12 17:59:35 -070063 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070064
65 /**
alshabib010c31d2014-09-26 10:01:12 -070066 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080067 *
alshabib010c31d2014-09-26 10:01:12 -070068 * @param port the inport
69 * @return a selection builder
70 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070071 Builder matchInPort(PortNumber port);
alshabib010c31d2014-09-26 10:01:12 -070072
73 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080074 * Matches a physical inport.
75 *
76 * @param port the physical inport
77 * @return a selection builder
78 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070079 Builder matchInPhyPort(PortNumber port);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080080
81 /**
82 * Matches a metadata.
83 *
84 * @param metadata the metadata
85 * @return a selection builder
86 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070087 Builder matchMetadata(long metadata);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080088
89 /**
alshabib010c31d2014-09-26 10:01:12 -070090 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080091 *
alshabib010c31d2014-09-26 10:01:12 -070092 * @param addr a l2 address
93 * @return a selection builder
94 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070095 Builder matchEthDst(MacAddress addr);
alshabib010c31d2014-09-26 10:01:12 -070096
97 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080098 * Matches a l2 src address.
99 *
100 * @param addr a l2 address
101 * @return a selection builder
102 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700103 Builder matchEthSrc(MacAddress addr);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800104
105 /**
alshabib010c31d2014-09-26 10:01:12 -0700106 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800107 *
alshabib010c31d2014-09-26 10:01:12 -0700108 * @param ethType an ethernet type
109 * @return a selection builder
110 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700111 Builder matchEthType(short ethType);
alshabib010c31d2014-09-26 10:01:12 -0700112
113 /**
114 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800115 *
alshabib010c31d2014-09-26 10:01:12 -0700116 * @param vlanId a vlan id
117 * @return a selection builder
118 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700119 Builder matchVlanId(VlanId vlanId);
alshabib010c31d2014-09-26 10:01:12 -0700120
121 /**
122 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800123 *
alshabib010c31d2014-09-26 10:01:12 -0700124 * @param vlanPcp a vlan priority
125 * @return a selection builder
126 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700127 Builder matchVlanPcp(byte vlanPcp);
alshabib010c31d2014-09-26 10:01:12 -0700128
129 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800130 * Matches an IP DSCP (6 bits in ToS field).
131 *
132 * @param ipDscp an IP DSCP value
133 * @return a selection builder
134 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700135 Builder matchIPDscp(byte ipDscp);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800136
137 /**
138 * Matches an IP ECN (2 bits in ToS field).
139 *
140 * @param ipEcn an IP ECN value
141 * @return a selection builder
142 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700143 Builder matchIPEcn(byte ipEcn);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800144
145 /**
alshabib010c31d2014-09-26 10:01:12 -0700146 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800147 *
alshabib010c31d2014-09-26 10:01:12 -0700148 * @param proto a l3 protocol
149 * @return a selection builder
150 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700151 Builder matchIPProtocol(byte proto);
alshabib010c31d2014-09-26 10:01:12 -0700152
153 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800154 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800155 *
alshabib010c31d2014-09-26 10:01:12 -0700156 * @param ip a l3 address
157 * @return a selection builder
158 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700159 Builder matchIPSrc(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700160
161 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800162 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800163 *
alshabib010c31d2014-09-26 10:01:12 -0700164 * @param ip a l3 address
165 * @return a selection builder
166 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700167 Builder matchIPDst(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700168
169 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700170 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800171 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700172 * @param tcpPort a TCP source port number
173 * @return a selection builder
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700174 * @deprecated in Drake release
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700175 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700176 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700177 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700178
179 /**
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700180 * Matches a TCP source port number.
181 *
182 * @param tcpPort a TCP source port number
183 * @return a selection builder
184 */
185 Builder matchTcpSrc(TpPort tcpPort);
186
187 /**
188 * Matches a TCP destination port number.
189 *
190 * @param tcpPort a TCP destination port number
191 * @return a selection builder
192 * @deprecated in Drake release
193 */
194 @Deprecated
195 Builder matchTcpDst(short tcpPort);
196
197 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700198 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800199 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700200 * @param tcpPort a TCP destination port number
201 * @return a selection builder
202 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700203 Builder matchTcpDst(TpPort tcpPort);
204
205 /**
206 * Matches an UDP source port number.
207 *
208 * @param udpPort an UDP source port number
209 * @return a selection builder
210 * @deprecated in Drake release
211 */
212 @Deprecated
213 Builder matchUdpSrc(short udpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700214
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800215 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800216 * Matches an UDP source port number.
217 *
218 * @param udpPort an UDP source port number
219 * @return a selection builder
220 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700221 Builder matchUdpSrc(TpPort udpPort);
222
223 /**
224 * Matches an UDP destination port number.
225 *
226 * @param udpPort an UDP destination port number
227 * @return a selection builder
228 * @deprecated in Drake release
229 */
230 @Deprecated
231 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800232
233 /**
234 * Matches an UDP destination port number.
235 *
236 * @param udpPort an UDP destination port number
237 * @return a selection builder
238 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700239 Builder matchUdpDst(TpPort udpPort);
240
241 /**
242 * Matches a SCTP source port number.
243 *
244 * @param sctpPort a SCTP source port number
245 * @return a selection builder
246 * @deprecated in Drake release
247 */
248 @Deprecated
249 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800250
251 /**
252 * Matches a SCTP source port number.
253 *
254 * @param sctpPort a SCTP source port number
255 * @return a selection builder
256 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700257 Builder matchSctpSrc(TpPort sctpPort);
258
259 /**
260 * Matches a SCTP destination port number.
261 *
262 * @param sctpPort a SCTP destination port number
263 * @return a selection builder
264 * @deprecated in Drake release
265 */
266 @Deprecated
267 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800268
269 /**
270 * Matches a SCTP destination port number.
271 *
272 * @param sctpPort a SCTP destination port number
273 * @return a selection builder
274 */
Hyunsun Mooncf732fb2015-08-22 21:04:23 -0700275 Builder matchSctpDst(TpPort sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800276
277 /**
278 * Matches an ICMP type.
279 *
280 * @param icmpType an ICMP type
281 * @return a selection builder
282 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700283 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800284
285 /**
286 * Matches an ICMP code.
287 *
288 * @param icmpCode an ICMP code
289 * @return a selection builder
290 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700291 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800292
293 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800294 * Matches a l3 IPv6 address.
295 *
296 * @param ip a l3 IPv6 address
297 * @return a selection builder
298 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700299 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800300
301 /**
302 * Matches a l3 IPv6 address.
303 *
304 * @param ip a l3 IPv6 address
305 * @return a selection builder
306 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700307 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800308
309 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800310 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800311 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800312 * @param flowLabel an IPv6 flow label
313 * @return a selection builder
314 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700315 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800316
317 /**
318 * Matches an ICMPv6 type.
319 *
320 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800321 * @return a selection builder
322 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700323 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800324
325 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800326 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800327 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800328 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800329 * @return a selection builder
330 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700331 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800332
333 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800334 * Matches an IPv6 Neighbor Discovery target address.
335 *
336 * @param targetAddress an IPv6 Neighbor Discovery target address
337 * @return a selection builder
338 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700339 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800340
341 /**
342 * Matches an IPv6 Neighbor Discovery source link-layer address.
343 *
344 * @param mac an IPv6 Neighbor Discovery source link-layer address
345 * @return a selection builder
346 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700347 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800348
349 /**
350 * Matches an IPv6 Neighbor Discovery target link-layer address.
351 *
352 * @param mac an IPv6 Neighbor Discovery target link-layer address
353 * @return a selection builder
354 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700355 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800356
357 /**
358 * Matches on a MPLS label.
359 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800360 * @param mplsLabel a MPLS label.
361 * @return a selection builder
362 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700363 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800364
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700365 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700366 * Matches on a MPLS Bottom-of-Stack indicator bit.
367 *
368 * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false).
369 * @return a selection builder
370 */
371 Builder matchMplsBos(boolean mplsBos);
372
373 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700374 * Matches a tunnel id.
375 *
376 * @param tunnelId a tunnel id
377 * @return a selection builder
378 */
379 Builder matchTunnelId(long tunnelId);
380
381 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700382 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800383 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700384 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800385 * @return a selection builder
386 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700387 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800388
389 /**
BitOhenryb2f8e812015-11-17 19:19:53 +0800390 * Matches a arp IPv4 destination address.
391 *
392 * @param addr a arp IPv4 destination address
393 * @return a selection builder
394 */
395 Builder matchArpTpa(Ip4Address addr);
396
397 /**
BitOhenry914c7ad2015-11-16 14:58:53 +0800398 * Matches a arp_eth_dst address.
399 *
400 * @param addr a arp_eth_dst address
401 * @return a selection builder
402 */
403 Builder matchArpTha(MacAddress addr);
404
405 /**
BitOhenrye330cf02015-11-17 18:59:33 +0800406 * Matches a arp_eth_src address.
407 *
408 * @param addr a arp_eth_src address
409 * @return a selection builder
410 */
411 Builder matchArpSha(MacAddress addr);
412
413 /**
tom8bb16062014-09-12 14:47:46 -0700414 * Builds an immutable traffic selector.
415 *
416 * @return traffic selector
417 */
418 TrafficSelector build();
419 }
tom8bb16062014-09-12 14:47:46 -0700420}