blob: 6661cb6d2d61120b0c044b9852cbb791045fa1ef [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;
21import org.onosproject.net.flow.criteria.Criterion;
alshabib010c31d2014-09-26 10:01:12 -070022import org.onlab.packet.IpPrefix;
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080023import org.onlab.packet.Ip6Address;
alshabib010c31d2014-09-26 10:01:12 -070024import org.onlab.packet.MacAddress;
Michele Santuari4b6019e2014-12-19 11:31:45 +010025import org.onlab.packet.MplsLabel;
alshabib010c31d2014-09-26 10:01:12 -070026import org.onlab.packet.VlanId;
alshabib7410fea2014-09-16 13:48:39 -070027
tom8bb16062014-09-12 14:47:46 -070028/**
29 * Abstraction of a slice of network traffic.
30 */
31public interface TrafficSelector {
32
33 /**
34 * Returns selection criteria as an ordered list.
35 *
36 * @return list of criteria
37 */
alshabibba5ac482014-10-02 17:15:20 -070038 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070039
40 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070041 * Returns the selection criterion for a particular type, if it exists in
42 * this traffic selector.
43 *
44 * @param type criterion type to look up
45 * @return the criterion of the specified type if one exists, otherwise null
46 */
47 Criterion getCriterion(Criterion.Type type);
48
49 /**
tom8bb16062014-09-12 14:47:46 -070050 * Builder of traffic selector entities.
51 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070052 interface Builder {
tom8bb16062014-09-12 14:47:46 -070053
54 /**
55 * Adds a traffic selection criterion. If a same type criterion has
56 * already been added, it will be replaced by this one.
57 *
58 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070059 * @return self
tom8bb16062014-09-12 14:47:46 -070060 */
alshabib369d2942014-09-12 17:59:35 -070061 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070062
63 /**
alshabib010c31d2014-09-26 10:01:12 -070064 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080065 *
alshabib010c31d2014-09-26 10:01:12 -070066 * @param port the inport
67 * @return a selection builder
68 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070069 Builder matchInPort(PortNumber port);
alshabib010c31d2014-09-26 10:01:12 -070070
71 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080072 * Matches a physical inport.
73 *
74 * @param port the physical inport
75 * @return a selection builder
76 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070077 Builder matchInPhyPort(PortNumber port);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080078
79 /**
80 * Matches a metadata.
81 *
82 * @param metadata the metadata
83 * @return a selection builder
84 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070085 Builder matchMetadata(long metadata);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080086
87 /**
alshabib010c31d2014-09-26 10:01:12 -070088 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080089 *
alshabib010c31d2014-09-26 10:01:12 -070090 * @param addr a l2 address
91 * @return a selection builder
92 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -070093 Builder matchEthDst(MacAddress addr);
alshabib010c31d2014-09-26 10:01:12 -070094
95 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080096 * Matches a l2 src address.
97 *
98 * @param addr a l2 address
99 * @return a selection builder
100 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700101 Builder matchEthSrc(MacAddress addr);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800102
103 /**
alshabib010c31d2014-09-26 10:01:12 -0700104 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800105 *
alshabib010c31d2014-09-26 10:01:12 -0700106 * @param ethType an ethernet type
107 * @return a selection builder
108 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700109 Builder matchEthType(short ethType);
alshabib010c31d2014-09-26 10:01:12 -0700110
111 /**
112 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800113 *
alshabib010c31d2014-09-26 10:01:12 -0700114 * @param vlanId a vlan id
115 * @return a selection builder
116 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700117 Builder matchVlanId(VlanId vlanId);
alshabib010c31d2014-09-26 10:01:12 -0700118
119 /**
120 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800121 *
alshabib010c31d2014-09-26 10:01:12 -0700122 * @param vlanPcp a vlan priority
123 * @return a selection builder
124 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700125 Builder matchVlanPcp(byte vlanPcp);
alshabib010c31d2014-09-26 10:01:12 -0700126
127 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800128 * Matches an IP DSCP (6 bits in ToS field).
129 *
130 * @param ipDscp an IP DSCP value
131 * @return a selection builder
132 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700133 Builder matchIPDscp(byte ipDscp);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800134
135 /**
136 * Matches an IP ECN (2 bits in ToS field).
137 *
138 * @param ipEcn an IP ECN value
139 * @return a selection builder
140 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700141 Builder matchIPEcn(byte ipEcn);
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800142
143 /**
alshabib010c31d2014-09-26 10:01:12 -0700144 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800145 *
alshabib010c31d2014-09-26 10:01:12 -0700146 * @param proto a l3 protocol
147 * @return a selection builder
148 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700149 Builder matchIPProtocol(byte proto);
alshabib010c31d2014-09-26 10:01:12 -0700150
151 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800152 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800153 *
alshabib010c31d2014-09-26 10:01:12 -0700154 * @param ip a l3 address
155 * @return a selection builder
156 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700157 Builder matchIPSrc(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700158
159 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800160 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800161 *
alshabib010c31d2014-09-26 10:01:12 -0700162 * @param ip a l3 address
163 * @return a selection builder
164 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700165 Builder matchIPDst(IpPrefix ip);
alshabib010c31d2014-09-26 10:01:12 -0700166
167 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700168 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800169 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700170 * @param tcpPort a TCP source port number
171 * @return a selection builder
172 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700173 Builder matchTcpSrc(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700174
175 /**
176 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800177 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700178 * @param tcpPort a TCP destination port number
179 * @return a selection builder
180 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700181 Builder matchTcpDst(short tcpPort);
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700182
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800183 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800184 * Matches an UDP source port number.
185 *
186 * @param udpPort an UDP source port number
187 * @return a selection builder
188 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700189 Builder matchUdpSrc(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800190
191 /**
192 * Matches an UDP destination port number.
193 *
194 * @param udpPort an UDP destination port number
195 * @return a selection builder
196 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700197 Builder matchUdpDst(short udpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800198
199 /**
200 * Matches a SCTP source port number.
201 *
202 * @param sctpPort a SCTP source port number
203 * @return a selection builder
204 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700205 Builder matchSctpSrc(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800206
207 /**
208 * Matches a SCTP destination port number.
209 *
210 * @param sctpPort a SCTP destination port number
211 * @return a selection builder
212 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700213 Builder matchSctpDst(short sctpPort);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800214
215 /**
216 * Matches an ICMP type.
217 *
218 * @param icmpType an ICMP type
219 * @return a selection builder
220 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700221 Builder matchIcmpType(byte icmpType);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800222
223 /**
224 * Matches an ICMP code.
225 *
226 * @param icmpCode an ICMP code
227 * @return a selection builder
228 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700229 Builder matchIcmpCode(byte icmpCode);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800230
231 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800232 * Matches a l3 IPv6 address.
233 *
234 * @param ip a l3 IPv6 address
235 * @return a selection builder
236 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700237 Builder matchIPv6Src(IpPrefix ip);
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800238
239 /**
240 * Matches a l3 IPv6 address.
241 *
242 * @param ip a l3 IPv6 address
243 * @return a selection builder
244 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700245 Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800246
247 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800248 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800249 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800250 * @param flowLabel an IPv6 flow label
251 * @return a selection builder
252 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700253 Builder matchIPv6FlowLabel(int flowLabel);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800254
255 /**
256 * Matches an ICMPv6 type.
257 *
258 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800259 * @return a selection builder
260 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700261 Builder matchIcmpv6Type(byte icmpv6Type);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800262
263 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800264 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800265 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800266 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800267 * @return a selection builder
268 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700269 Builder matchIcmpv6Code(byte icmpv6Code);
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800270
271 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800272 * Matches an IPv6 Neighbor Discovery target address.
273 *
274 * @param targetAddress an IPv6 Neighbor Discovery target address
275 * @return a selection builder
276 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700277 Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800278
279 /**
280 * Matches an IPv6 Neighbor Discovery source link-layer address.
281 *
282 * @param mac an IPv6 Neighbor Discovery source link-layer address
283 * @return a selection builder
284 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700285 Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800286
287 /**
288 * Matches an IPv6 Neighbor Discovery target link-layer address.
289 *
290 * @param mac an IPv6 Neighbor Discovery target link-layer address
291 * @return a selection builder
292 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700293 Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800294
295 /**
296 * Matches on a MPLS label.
297 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800298 * @param mplsLabel a MPLS label.
299 * @return a selection builder
300 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700301 Builder matchMplsLabel(MplsLabel mplsLabel);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800302
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700303 /**
Hyunsun Moona08c5d02015-07-14 17:53:00 -0700304 * Matches a tunnel id.
305 *
306 * @param tunnelId a tunnel id
307 * @return a selection builder
308 */
309 Builder matchTunnelId(long tunnelId);
310
311 /**
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700312 * Matches on IPv6 Extension Header pseudo-field flags.
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800313 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700314 * @param exthdrFlags the IPv6 Extension Header pseudo-field flags
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800315 * @return a selection builder
316 */
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700317 Builder matchIPv6ExthdrFlags(short exthdrFlags);
Pavlin Radoslavov5e4f7542015-02-06 18:18:21 -0800318
319 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700320 * Matches an optical signal ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800321 *
Sho SHIMIZU60f12142015-05-06 14:22:03 -0700322 * @param lambda lambda
Marc De Leenheer49087752014-10-23 13:54:09 -0700323 * @return a selection builder
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700324 * @deprecated in Cardinal Release.
325 * Use {@link #add(Criterion)} with an instance created
326 * by {@link org.onosproject.net.flow.criteria.Criteria#matchLambda(org.onosproject.net.Lambda)}.
Marc De Leenheer49087752014-10-23 13:54:09 -0700327 */
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700328 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700329 Builder matchLambda(short lambda);
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700330
331 /**
332 * Matches an optical Signal Type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800333 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800334 * @param signalType signalType
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700335 * @return a selection builder
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700336 * @deprecated in Cardinal Release.
337 * Use {@link #add(Criterion)}} with an instance created
338 * by {@link org.onosproject.net.flow.criteria.Criteria#matchOchSignalType(org.onosproject.net.OchSignalType)}.
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700339 */
Sho SHIMIZUc72c8ea2015-05-06 16:01:47 -0700340 @Deprecated
Sho SHIMIZU15c38002015-04-28 19:00:37 -0700341 Builder matchOpticalSignalType(short signalType);
Marc De Leenheer49087752014-10-23 13:54:09 -0700342
343 /**
tom8bb16062014-09-12 14:47:46 -0700344 * Builds an immutable traffic selector.
345 *
346 * @return traffic selector
347 */
348 TrafficSelector build();
349 }
tom8bb16062014-09-12 14:47:46 -0700350}