blob: 1ecab716ae1137522838ee9fe6ec0bbc6f777ffa [file] [log] [blame]
Thomas Vachuska83e090e2014-10-22 14:25:35 -07001/*
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07002 * Copyright 2014 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;
25import org.onlab.packet.VlanId;
alshabib7410fea2014-09-16 13:48:39 -070026
tom8bb16062014-09-12 14:47:46 -070027/**
28 * Abstraction of a slice of network traffic.
29 */
30public interface TrafficSelector {
31
32 /**
33 * Returns selection criteria as an ordered list.
34 *
35 * @return list of criteria
36 */
alshabibba5ac482014-10-02 17:15:20 -070037 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070038
39 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070040 * Returns the selection criterion for a particular type, if it exists in
41 * this traffic selector.
42 *
43 * @param type criterion type to look up
44 * @return the criterion of the specified type if one exists, otherwise null
45 */
46 Criterion getCriterion(Criterion.Type type);
47
48 /**
tom8bb16062014-09-12 14:47:46 -070049 * Builder of traffic selector entities.
50 */
51 public interface Builder {
52
53 /**
54 * Adds a traffic selection criterion. If a same type criterion has
55 * already been added, it will be replaced by this one.
56 *
57 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070058 * @return self
tom8bb16062014-09-12 14:47:46 -070059 */
alshabib369d2942014-09-12 17:59:35 -070060 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070061
62 /**
alshabib010c31d2014-09-26 10:01:12 -070063 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080064 *
alshabib010c31d2014-09-26 10:01:12 -070065 * @param port the inport
66 * @return a selection builder
67 */
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080068 public Builder matchInPort(PortNumber port);
alshabib010c31d2014-09-26 10:01:12 -070069
70 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -080071 * Matches a physical inport.
72 *
73 * @param port the physical inport
74 * @return a selection builder
75 */
76 public Builder matchInPhyPort(PortNumber port);
77
78 /**
79 * Matches a metadata.
80 *
81 * @param metadata the metadata
82 * @return a selection builder
83 */
84 public Builder matchMetadata(Long metadata);
85
86 /**
alshabib010c31d2014-09-26 10:01:12 -070087 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080088 *
alshabib010c31d2014-09-26 10:01:12 -070089 * @param addr a l2 address
90 * @return a selection builder
91 */
92 public Builder matchEthDst(MacAddress addr);
93
94 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -080095 * Matches a l2 src address.
96 *
97 * @param addr a l2 address
98 * @return a selection builder
99 */
100 public Builder matchEthSrc(MacAddress addr);
101
102 /**
alshabib010c31d2014-09-26 10:01:12 -0700103 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800104 *
alshabib010c31d2014-09-26 10:01:12 -0700105 * @param ethType an ethernet type
106 * @return a selection builder
107 */
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800108 public Builder matchEthType(Short ethType);
alshabib010c31d2014-09-26 10:01:12 -0700109
110 /**
111 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800112 *
alshabib010c31d2014-09-26 10:01:12 -0700113 * @param vlanId a vlan id
114 * @return a selection builder
115 */
116 public Builder matchVlanId(VlanId vlanId);
117
118 /**
119 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800120 *
alshabib010c31d2014-09-26 10:01:12 -0700121 * @param vlanPcp a vlan priority
122 * @return a selection builder
123 */
124 public Builder matchVlanPcp(Byte vlanPcp);
125
126 /**
Pavlin Radoslavovd0fd8412015-02-04 13:57:00 -0800127 * Matches an IP DSCP (6 bits in ToS field).
128 *
129 * @param ipDscp an IP DSCP value
130 * @return a selection builder
131 */
132 public Builder matchIPDscp(Byte ipDscp);
133
134 /**
135 * Matches an IP ECN (2 bits in ToS field).
136 *
137 * @param ipEcn an IP ECN value
138 * @return a selection builder
139 */
140 public Builder matchIPEcn(Byte ipEcn);
141
142 /**
alshabib010c31d2014-09-26 10:01:12 -0700143 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800144 *
alshabib010c31d2014-09-26 10:01:12 -0700145 * @param proto a l3 protocol
146 * @return a selection builder
147 */
148 public Builder matchIPProtocol(Byte proto);
149
150 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800151 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800152 *
alshabib010c31d2014-09-26 10:01:12 -0700153 * @param ip a l3 address
154 * @return a selection builder
155 */
156 public Builder matchIPSrc(IpPrefix ip);
157
158 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800159 * Matches a l3 IPv4 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800160 *
alshabib010c31d2014-09-26 10:01:12 -0700161 * @param ip a l3 address
162 * @return a selection builder
163 */
164 public Builder matchIPDst(IpPrefix ip);
165
166 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700167 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800168 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700169 * @param tcpPort a TCP source port number
170 * @return a selection builder
171 */
172 public Builder matchTcpSrc(Short tcpPort);
173
174 /**
175 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800176 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700177 * @param tcpPort a TCP destination port number
178 * @return a selection builder
179 */
180 public Builder matchTcpDst(Short tcpPort);
181
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800182 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800183 * Matches an UDP source port number.
184 *
185 * @param udpPort an UDP source port number
186 * @return a selection builder
187 */
188 public Builder matchUdpSrc(Short udpPort);
189
190 /**
191 * Matches an UDP destination port number.
192 *
193 * @param udpPort an UDP destination port number
194 * @return a selection builder
195 */
196 public Builder matchUdpDst(Short udpPort);
197
198 /**
199 * Matches a SCTP source port number.
200 *
201 * @param sctpPort a SCTP source port number
202 * @return a selection builder
203 */
204 public Builder matchSctpSrc(Short sctpPort);
205
206 /**
207 * Matches a SCTP destination port number.
208 *
209 * @param sctpPort a SCTP destination port number
210 * @return a selection builder
211 */
212 public Builder matchSctpDst(Short sctpPort);
213
214 /**
215 * Matches an ICMP type.
216 *
217 * @param icmpType an ICMP type
218 * @return a selection builder
219 */
220 public Builder matchIcmpType(Byte icmpType);
221
222 /**
223 * Matches an ICMP code.
224 *
225 * @param icmpCode an ICMP code
226 * @return a selection builder
227 */
228 public Builder matchIcmpCode(Byte icmpCode);
229
230 /**
Charles M.C. Chan52fae7d2015-01-17 00:35:53 +0800231 * Matches a l3 IPv6 address.
232 *
233 * @param ip a l3 IPv6 address
234 * @return a selection builder
235 */
236 public Builder matchIPv6Src(IpPrefix ip);
237
238 /**
239 * Matches a l3 IPv6 address.
240 *
241 * @param ip a l3 IPv6 address
242 * @return a selection builder
243 */
244 public Builder matchIPv6Dst(IpPrefix ip);
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800245
246 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800247 * Matches an IPv6 flow label.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800248 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800249 * @param flowLabel an IPv6 flow label
250 * @return a selection builder
251 */
252 public Builder matchIPv6FlowLabel(Integer flowLabel);
253
254 /**
255 * Matches an ICMPv6 type.
256 *
257 * @param icmpv6Type an ICMPv6 type
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800258 * @return a selection builder
259 */
260 public Builder matchIcmpv6Type(Byte icmpv6Type);
261
262 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800263 * Matches an ICMPv6 code.
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800264 *
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800265 * @param icmpv6Code an ICMPv6 code
Kunihiro Ishiguro0f9aba82015-01-15 17:14:17 -0800266 * @return a selection builder
267 */
268 public Builder matchIcmpv6Code(Byte icmpv6Code);
269
270 /**
Pavlin Radoslavov320e6c92015-02-02 16:51:58 -0800271 * Matches an IPv6 Neighbor Discovery target address.
272 *
273 * @param targetAddress an IPv6 Neighbor Discovery target address
274 * @return a selection builder
275 */
276 public Builder matchIPv6NDTargetAddress(Ip6Address targetAddress);
277
278 /**
279 * Matches an IPv6 Neighbor Discovery source link-layer address.
280 *
281 * @param mac an IPv6 Neighbor Discovery source link-layer address
282 * @return a selection builder
283 */
284 public Builder matchIPv6NDSourceLinkLayerAddress(MacAddress mac);
285
286 /**
287 * Matches an IPv6 Neighbor Discovery target link-layer address.
288 *
289 * @param mac an IPv6 Neighbor Discovery target link-layer address
290 * @return a selection builder
291 */
292 public Builder matchIPv6NDTargetLinkLayerAddress(MacAddress mac);
293
294 /**
295 * Matches on a MPLS label.
296 *
Praseed Balakrishnan8c67d172014-11-10 10:15:41 -0800297 * @param mplsLabel a MPLS label.
298 * @return a selection builder
299 */
300 public Builder matchMplsLabel(Integer mplsLabel);
301
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700302 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700303 * Matches an optical signal ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800304 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800305 * @param lambda lamda
Marc De Leenheer49087752014-10-23 13:54:09 -0700306 * @return a selection builder
307 */
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700308 public Builder matchLambda(Short lambda);
309
310 /**
311 * Matches an optical Signal Type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800312 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800313 * @param signalType signalType
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700314 * @return a selection builder
315 */
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800316 public Builder matchOpticalSignalType(Short signalType);
Marc De Leenheer49087752014-10-23 13:54:09 -0700317
318 /**
tom8bb16062014-09-12 14:47:46 -0700319 * Builds an immutable traffic selector.
320 *
321 * @return traffic selector
322 */
323 TrafficSelector build();
324 }
tom8bb16062014-09-12 14:47:46 -0700325}