blob: 8ccc53110e9643387bf753e5187ba86b18e4388d [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
Brian O'Connorabafb502014-12-02 22:26:20 -080020import org.onosproject.net.PortNumber;
Saurav Dasffc5bbc2015-08-18 23:30:19 -070021import org.onosproject.net.flow.DefaultTrafficSelector.Builder;
Brian O'Connorabafb502014-12-02 22:26:20 -080022import org.onosproject.net.flow.criteria.Criterion;
alshabib010c31d2014-09-26 10:01:12 -070023import org.onlab.packet.IpPrefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080024import org.onlab.packet.Ip6Address;
alshabib010c31d2014-09-26 10:01:12 -070025import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010026import org.onlab.packet.MplsLabel;
alshabib010c31d2014-09-26 10:01:12 -070027import org.onlab.packet.VlanId;
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
173 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700174 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700175
176 /**
177 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800178 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700179 * @param tcpPort a TCP destination port number
180 * @return a selection builder
181 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700182 Builder matchTcpDst(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700183
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800184 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800185 * Matches an UDP source port number.
186 *
187 * @param udpPort an UDP source port number
188 * @return a selection builder
189 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700190 Builder matchUdpSrc(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800191
192 /**
193 * Matches an UDP destination port number.
194 *
195 * @param udpPort an UDP destination port number
196 * @return a selection builder
197 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700198 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800199
200 /**
201 * Matches a SCTP source port number.
202 *
203 * @param sctpPort a SCTP source port number
204 * @return a selection builder
205 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700206 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800207
208 /**
209 * Matches a SCTP destination port number.
210 *
211 * @param sctpPort a SCTP destination port number
212 * @return a selection builder
213 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700214 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800215
216 /**
217 * Matches an ICMP type.
218 *
219 * @param icmpType an ICMP type
220 * @return a selection builder
221 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700222 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800223
224 /**
225 * Matches an ICMP code.
226 *
227 * @param icmpCode an ICMP code
228 * @return a selection builder
229 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700230 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800231
232 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800233 * Matches a l3 IPv6 address.
234 *
235 * @param ip a l3 IPv6 address
236 * @return a selection builder
237 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700238 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800239
240 /**
241 * Matches a l3 IPv6 address.
242 *
243 * @param ip a l3 IPv6 address
244 * @return a selection builder
245 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700246 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800247
248 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800249 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800250 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800251 * @param flowLabel an IPv6 flow label
252 * @return a selection builder
253 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700254 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800255
256 /**
257 * Matches an ICMPv6 type.
258 *
259 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800260 * @return a selection builder
261 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700262 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800263
264 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800265 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800266 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800267 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800268 * @return a selection builder
269 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700270 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800271
272 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800273 * Matches an IPv6 Neighbor Discovery target address.
274 *
275 * @param targetAddress an IPv6 Neighbor Discovery target address
276 * @return a selection builder
277 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700278 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800279
280 /**
281 * Matches an IPv6 Neighbor Discovery source link-layer address.
282 *
283 * @param mac an IPv6 Neighbor Discovery source link-layer address
284 * @return a selection builder
285 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700286 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800287
288 /**
289 * Matches an IPv6 Neighbor Discovery target link-layer address.
290 *
291 * @param mac an IPv6 Neighbor Discovery target link-layer address
292 * @return a selection builder
293 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700294 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800295
296 /**
297 * Matches on a MPLS label.
298 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800299 * @param mplsLabel a MPLS label.
300 * @return a selection builder
301 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700302 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800303
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700304 /**
Saurav Dasffc5bbc2015-08-18 23:30:19 -0700305 * Matches on a MPLS Bottom-of-Stack indicator bit.
306 *
307 * @param mplsBos boolean value indicating BOS=1 (true) or BOS=0 (false).
308 * @return a selection builder
309 */
310 Builder matchMplsBos(boolean mplsBos);
311
312 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700313 * Matches a tunnel id.
314 *
315 * @param tunnelId a tunnel id
316 * @return a selection builder
317 */
318 Builder matchTunnelId(long tunnelId);
319
320 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700321 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800322 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700323 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800324 * @return a selection builder
325 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700326 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800327
328 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700329 * Matches an optical signal ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800330 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700331 * @param lambda lambda
Marc De Leenheer49087752014-10-23 13:54:09 -0700332 * @return a selection builder
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700333 * @deprecated in Cardinal Release.
334 * Use {@link #add(Criterion)} with an instance created
335 * by {@link org.onosproject.net.flow.criteria.Criteria#matchLambda(org.onosproject.net.Lambda)}.
Marc De Leenheer49087752014-10-23 13:54:09 -0700336 */
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700337 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700338 Builder matchLambda(short lambda);
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700339
340 /**
341 * Matches an optical Signal Type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800342 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800343 * @param signalType signalType
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700344 * @return a selection builder
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700345 * @deprecated in Cardinal Release.
346 * Use {@link #add(Criterion)}} with an instance created
347 * by {@link org.onosproject.net.flow.criteria.Criteria#matchOchSignalType(org.onosproject.net.OchSignalType)}.
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700348 */
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700349 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700350 Builder matchOpticalSignalType(short signalType);
Marc De Leenheer49087752014-10-23 13:54:09 -0700351
352 /**
tom8bb16062014-09-12 14:47:46 -0700353 * Builds an immutable traffic selector.
354 *
355 * @return traffic selector
356 */
357 TrafficSelector build();
358 }
tom8bb16062014-09-12 14:47:46 -0700359}