blob: ac75147c81999b72fcedc38a4465b2623fcc7c78 [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 */
tom8bb16062014-09-12 14:47:46 -070016package org.onlab.onos.net.flow;
17
alshabibba5ac482014-10-02 17:15:20 -070018import java.util.Set;
tom8bb16062014-09-12 14:47:46 -070019
alshabib010c31d2014-09-26 10:01:12 -070020import org.onlab.onos.net.PortNumber;
alshabib7410fea2014-09-16 13:48:39 -070021import org.onlab.onos.net.flow.criteria.Criterion;
alshabib010c31d2014-09-26 10:01:12 -070022import org.onlab.packet.IpPrefix;
23import org.onlab.packet.MacAddress;
24import org.onlab.packet.VlanId;
alshabib7410fea2014-09-16 13:48:39 -070025
tom8bb16062014-09-12 14:47:46 -070026/**
27 * Abstraction of a slice of network traffic.
28 */
29public interface TrafficSelector {
30
31 /**
32 * Returns selection criteria as an ordered list.
33 *
34 * @return list of criteria
35 */
alshabibba5ac482014-10-02 17:15:20 -070036 Set<Criterion> criteria();
tom8bb16062014-09-12 14:47:46 -070037
38 /**
Jonathan Hart936c49d2014-10-23 16:38:59 -070039 * Returns the selection criterion for a particular type, if it exists in
40 * this traffic selector.
41 *
42 * @param type criterion type to look up
43 * @return the criterion of the specified type if one exists, otherwise null
44 */
45 Criterion getCriterion(Criterion.Type type);
46
47 /**
tom8bb16062014-09-12 14:47:46 -070048 * Builder of traffic selector entities.
49 */
50 public interface Builder {
51
52 /**
53 * Adds a traffic selection criterion. If a same type criterion has
54 * already been added, it will be replaced by this one.
55 *
56 * @param criterion new criterion
alshabib369d2942014-09-12 17:59:35 -070057 * @return self
tom8bb16062014-09-12 14:47:46 -070058 */
alshabib369d2942014-09-12 17:59:35 -070059 Builder add(Criterion criterion);
tom8bb16062014-09-12 14:47:46 -070060
61 /**
alshabib010c31d2014-09-26 10:01:12 -070062 * Matches an inport.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080063 *
alshabib010c31d2014-09-26 10:01:12 -070064 * @param port the inport
65 * @return a selection builder
66 */
67 public Builder matchInport(PortNumber port);
68
69 /**
70 * Matches a l2 src address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080071 *
alshabib010c31d2014-09-26 10:01:12 -070072 * @param addr a l2 address
73 * @return a selection builder
74 */
75 public Builder matchEthSrc(MacAddress addr);
76
77 /**
78 * Matches a l2 dst address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080079 *
alshabib010c31d2014-09-26 10:01:12 -070080 * @param addr a l2 address
81 * @return a selection builder
82 */
83 public Builder matchEthDst(MacAddress addr);
84
85 /**
86 * Matches the ethernet type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080087 *
alshabib010c31d2014-09-26 10:01:12 -070088 * @param ethType an ethernet type
89 * @return a selection builder
90 */
91 public Builder matchEthType(short ethType);
92
93 /**
94 * Matches the vlan id.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -080095 *
alshabib010c31d2014-09-26 10:01:12 -070096 * @param vlanId a vlan id
97 * @return a selection builder
98 */
99 public Builder matchVlanId(VlanId vlanId);
100
101 /**
102 * Matches a vlan priority.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800103 *
alshabib010c31d2014-09-26 10:01:12 -0700104 * @param vlanPcp a vlan priority
105 * @return a selection builder
106 */
107 public Builder matchVlanPcp(Byte vlanPcp);
108
109 /**
110 * Matches the l3 protocol.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800111 *
alshabib010c31d2014-09-26 10:01:12 -0700112 * @param proto a l3 protocol
113 * @return a selection builder
114 */
115 public Builder matchIPProtocol(Byte proto);
116
117 /**
118 * Matches a l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800119 *
alshabib010c31d2014-09-26 10:01:12 -0700120 * @param ip a l3 address
121 * @return a selection builder
122 */
123 public Builder matchIPSrc(IpPrefix ip);
124
125 /**
126 * Matches a l3 address.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800127 *
alshabib010c31d2014-09-26 10:01:12 -0700128 * @param ip a l3 address
129 * @return a selection builder
130 */
131 public Builder matchIPDst(IpPrefix ip);
132
133 /**
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700134 * Matches a TCP source port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800135 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700136 * @param tcpPort a TCP source port number
137 * @return a selection builder
138 */
139 public Builder matchTcpSrc(Short tcpPort);
140
141 /**
142 * Matches a TCP destination port number.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800143 *
Toshio Koide9c44c9a2014-10-09 11:44:36 -0700144 * @param tcpPort a TCP destination port number
145 * @return a selection builder
146 */
147 public Builder matchTcpDst(Short tcpPort);
148
149 /**
Marc De Leenheer49087752014-10-23 13:54:09 -0700150 * Matches an optical signal ID or lambda.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800151 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800152 * @param lambda lamda
Marc De Leenheer49087752014-10-23 13:54:09 -0700153 * @return a selection builder
154 */
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700155 public Builder matchLambda(Short lambda);
156
157 /**
158 * Matches an optical Signal Type.
Sho SHIMIZUbdaea832014-11-12 11:29:38 -0800159 *
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800160 * @param signalType signalType
Praseed Balakrishnan64369da2014-10-23 15:55:20 -0700161 * @return a selection builder
162 */
Praseed Balakrishnan2dd5abd2014-11-03 14:56:28 -0800163 public Builder matchOpticalSignalType(Short signalType);
Marc De Leenheer49087752014-10-23 13:54:09 -0700164
165 /**
tom8bb16062014-09-12 14:47:46 -0700166 * Builds an immutable traffic selector.
167 *
168 * @return traffic selector
169 */
170 TrafficSelector build();
171 }
172
173}