Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 Open Networking Laboratory |
Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 3 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 4 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 7 | * |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 8 | * 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 Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 18 | import java.util.Set; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 19 | |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.PortNumber; |
| 21 | import org.onosproject.net.flow.criteria.Criterion; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 22 | import org.onlab.packet.IpPrefix; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 23 | import org.onlab.packet.Ip6Address; |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 24 | import org.onlab.packet.MacAddress; |
| 25 | import org.onlab.packet.VlanId; |
alshabib | 7410fea | 2014-09-16 13:48:39 -0700 | [diff] [blame] | 26 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Abstraction of a slice of network traffic. |
| 29 | */ |
| 30 | public interface TrafficSelector { |
| 31 | |
| 32 | /** |
| 33 | * Returns selection criteria as an ordered list. |
| 34 | * |
| 35 | * @return list of criteria |
| 36 | */ |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 37 | Set<Criterion> criteria(); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 38 | |
| 39 | /** |
Jonathan Hart | 936c49d | 2014-10-23 16:38:59 -0700 | [diff] [blame] | 40 | * 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 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 49 | * 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 |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 58 | * @return self |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 59 | */ |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 60 | Builder add(Criterion criterion); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 61 | |
| 62 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 63 | * Matches an inport. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 64 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 65 | * @param port the inport |
| 66 | * @return a selection builder |
| 67 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 68 | public Builder matchInPort(PortNumber port); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 69 | |
| 70 | /** |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 71 | * 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 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 87 | * Matches a l2 dst address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 88 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 89 | * @param addr a l2 address |
| 90 | * @return a selection builder |
| 91 | */ |
| 92 | public Builder matchEthDst(MacAddress addr); |
| 93 | |
| 94 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 95 | * 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 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 103 | * Matches the ethernet type. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 104 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 105 | * @param ethType an ethernet type |
| 106 | * @return a selection builder |
| 107 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 108 | public Builder matchEthType(Short ethType); |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 109 | |
| 110 | /** |
| 111 | * Matches the vlan id. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 112 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 113 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 120 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 121 | * @param vlanPcp a vlan priority |
| 122 | * @return a selection builder |
| 123 | */ |
| 124 | public Builder matchVlanPcp(Byte vlanPcp); |
| 125 | |
| 126 | /** |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 127 | * 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 | /** |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 143 | * Matches the l3 protocol. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 144 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 145 | * @param proto a l3 protocol |
| 146 | * @return a selection builder |
| 147 | */ |
| 148 | public Builder matchIPProtocol(Byte proto); |
| 149 | |
| 150 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 151 | * Matches a l3 IPv4 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 152 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 153 | * @param ip a l3 address |
| 154 | * @return a selection builder |
| 155 | */ |
| 156 | public Builder matchIPSrc(IpPrefix ip); |
| 157 | |
| 158 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 159 | * Matches a l3 IPv4 address. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 160 | * |
alshabib | 010c31d | 2014-09-26 10:01:12 -0700 | [diff] [blame] | 161 | * @param ip a l3 address |
| 162 | * @return a selection builder |
| 163 | */ |
| 164 | public Builder matchIPDst(IpPrefix ip); |
| 165 | |
| 166 | /** |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 167 | * Matches a TCP source port number. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 168 | * |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 169 | * @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 SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 176 | * |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 177 | * @param tcpPort a TCP destination port number |
| 178 | * @return a selection builder |
| 179 | */ |
| 180 | public Builder matchTcpDst(Short tcpPort); |
| 181 | |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 182 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 183 | * 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. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 231 | * 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 Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 245 | |
| 246 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 247 | * Matches an IPv6 flow label. |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 248 | * |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 249 | * @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 Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 258 | * @return a selection builder |
| 259 | */ |
| 260 | public Builder matchIcmpv6Type(Byte icmpv6Type); |
| 261 | |
| 262 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 263 | * Matches an ICMPv6 code. |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 264 | * |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 265 | * @param icmpv6Code an ICMPv6 code |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 266 | * @return a selection builder |
| 267 | */ |
| 268 | public Builder matchIcmpv6Code(Byte icmpv6Code); |
| 269 | |
| 270 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 271 | * 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 Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 297 | * @param mplsLabel a MPLS label. |
| 298 | * @return a selection builder |
| 299 | */ |
| 300 | public Builder matchMplsLabel(Integer mplsLabel); |
| 301 | |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 302 | /** |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 303 | * Matches on IPv6 Extension Header pseudo-field fiags. |
| 304 | * |
| 305 | * @param exthdrFlags the IPv6 Extension Header pseudo-field fiags |
| 306 | * @return a selection builder |
| 307 | */ |
| 308 | public Builder matchIPv6ExthdrFlags(Integer exthdrFlags); |
| 309 | |
| 310 | /** |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 311 | * Matches an optical signal ID or lambda. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 312 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 313 | * @param lambda lamda |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 314 | * @return a selection builder |
| 315 | */ |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 316 | public Builder matchLambda(Short lambda); |
| 317 | |
| 318 | /** |
| 319 | * Matches an optical Signal Type. |
Sho SHIMIZU | bdaea83 | 2014-11-12 11:29:38 -0800 | [diff] [blame] | 320 | * |
Yuta HIGUCHI | 5c94727 | 2014-11-03 21:39:21 -0800 | [diff] [blame] | 321 | * @param signalType signalType |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 322 | * @return a selection builder |
| 323 | */ |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 324 | public Builder matchOpticalSignalType(Short signalType); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 325 | |
| 326 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 327 | * Builds an immutable traffic selector. |
| 328 | * |
| 329 | * @return traffic selector |
| 330 | */ |
| 331 | TrafficSelector build(); |
| 332 | } |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 333 | } |