Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Ray Milkey | 34c9590 | 2015-04-15 09:47:53 -0700 | [diff] [blame] | 2 | * Copyright 2014-2015 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.criteria; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 17 | |
alshabib | caf1ca2 | 2015-06-25 15:18:16 -0700 | [diff] [blame] | 18 | import org.onlab.packet.EthType; |
lishuai | a72d44d | 2015-10-19 17:27:38 +0800 | [diff] [blame] | 19 | import org.onlab.packet.Ip4Address; |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 20 | import org.onlab.packet.Ip6Address; |
| 21 | import org.onlab.packet.IpPrefix; |
| 22 | import org.onlab.packet.MacAddress; |
| 23 | import org.onlab.packet.MplsLabel; |
| 24 | import org.onlab.packet.TpPort; |
| 25 | import org.onlab.packet.VlanId; |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 26 | import org.onosproject.net.DeviceId; |
Sho SHIMIZU | efc2e28 | 2015-05-04 15:26:23 -0700 | [diff] [blame] | 27 | import org.onosproject.net.IndexedLambda; |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 28 | import org.onosproject.net.Lambda; |
| 29 | import org.onosproject.net.OchSignal; |
lishuai | a72d44d | 2015-10-19 17:27:38 +0800 | [diff] [blame] | 30 | import org.onosproject.net.OchSignalType; |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 31 | import org.onosproject.net.OduSignalId; |
| 32 | import org.onosproject.net.OduSignalType; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 33 | import org.onosproject.net.PortNumber; |
| 34 | import org.onosproject.net.flow.criteria.Criterion.Type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 35 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 36 | /** |
| 37 | * Factory class to create various traffic selection criteria. |
| 38 | */ |
| 39 | public final class Criteria { |
| 40 | |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 41 | //TODO: incomplete type implementation. Need to implement complete list from Criterion |
| 42 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 43 | // Ban construction |
| 44 | private Criteria() { |
| 45 | } |
| 46 | |
| 47 | /** |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 48 | * Creates a match on IN_PORT field using the specified value. |
| 49 | * |
| 50 | * @param port inport value |
| 51 | * @return match criterion |
| 52 | */ |
| 53 | public static Criterion matchInPort(PortNumber port) { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 54 | return new PortCriterion(port, Type.IN_PORT); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Creates a match on IN_PHY_PORT field using the specified value. |
| 59 | * |
| 60 | * @param port inport value |
| 61 | * @return match criterion |
| 62 | */ |
| 63 | public static Criterion matchInPhyPort(PortNumber port) { |
| 64 | return new PortCriterion(port, Type.IN_PHY_PORT); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Creates a match on METADATA field using the specified value. |
| 69 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 70 | * @param metadata metadata value (64 bits data) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 71 | * @return match criterion |
| 72 | */ |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 73 | public static Criterion matchMetadata(long metadata) { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 74 | return new MetadataCriterion(metadata); |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | /** |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 78 | * Creates a match on ETH_DST field using the specified value. This value |
| 79 | * may be a wildcard mask. |
| 80 | * |
tom | c104d28 | 2014-09-19 10:57:55 -0700 | [diff] [blame] | 81 | * @param mac MAC address value or wildcard mask |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 82 | * @return match criterion |
| 83 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 84 | public static Criterion matchEthDst(MacAddress mac) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 85 | return new EthCriterion(mac, Type.ETH_DST); |
| 86 | } |
| 87 | |
| 88 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 89 | * Creates a match on ETH_SRC field using the specified value. This value |
| 90 | * may be a wildcard mask. |
| 91 | * |
| 92 | * @param mac MAC address value or wildcard mask |
| 93 | * @return match criterion |
| 94 | */ |
| 95 | public static Criterion matchEthSrc(MacAddress mac) { |
| 96 | return new EthCriterion(mac, Type.ETH_SRC); |
| 97 | } |
| 98 | |
| 99 | /** |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 100 | * Creates a match on ETH_TYPE field using the specified value. |
| 101 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 102 | * @param ethType eth type value (16 bits unsigned integer) |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 103 | * @return match criterion |
| 104 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 105 | public static Criterion matchEthType(int ethType) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 106 | return new EthTypeCriterion(ethType); |
| 107 | } |
| 108 | |
| 109 | /** |
alshabib | caf1ca2 | 2015-06-25 15:18:16 -0700 | [diff] [blame] | 110 | * Creates a match on ETH_TYPE field using the specified value. |
| 111 | * |
| 112 | * @param ethType eth type value |
| 113 | * @return match criterion |
| 114 | */ |
| 115 | public static Criterion matchEthType(EthType ethType) { |
| 116 | return new EthTypeCriterion(ethType); |
| 117 | } |
| 118 | |
| 119 | /** |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 120 | * Creates a match on VLAN ID field using the specified value. |
| 121 | * |
| 122 | * @param vlanId vlan id value |
| 123 | * @return match criterion |
| 124 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 125 | public static Criterion matchVlanId(VlanId vlanId) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 126 | return new VlanIdCriterion(vlanId); |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Creates a match on VLAN PCP field using the specified value. |
| 131 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 132 | * @param vlanPcp vlan pcp value (3 bits) |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 133 | * @return match criterion |
| 134 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 135 | public static Criterion matchVlanPcp(byte vlanPcp) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 136 | return new VlanPcpCriterion(vlanPcp); |
| 137 | } |
| 138 | |
| 139 | /** |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 140 | * Creates a match on IP DSCP field using the specified value. |
| 141 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 142 | * @param ipDscp ip dscp value (6 bits) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 143 | * @return match criterion |
| 144 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 145 | public static Criterion matchIPDscp(byte ipDscp) { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 146 | return new IPDscpCriterion(ipDscp); |
| 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Creates a match on IP ECN field using the specified value. |
| 151 | * |
Pavlin Radoslavov | ab8553a | 2015-02-20 14:13:50 -0800 | [diff] [blame] | 152 | * @param ipEcn ip ecn value (2 bits) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 153 | * @return match criterion |
| 154 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 155 | public static Criterion matchIPEcn(byte ipEcn) { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 156 | return new IPEcnCriterion(ipEcn); |
| 157 | } |
| 158 | |
| 159 | /** |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 160 | * Creates a match on IP proto field using the specified value. |
| 161 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 162 | * @param proto ip protocol value (8 bits unsigned integer) |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 163 | * @return match criterion |
| 164 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 165 | public static Criterion matchIPProtocol(short proto) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 166 | return new IPProtocolCriterion(proto); |
| 167 | } |
| 168 | |
| 169 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 170 | * Creates a match on IPv4 source field using the specified value. |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 171 | * |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 172 | * @param ip ipv4 source value |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 173 | * @return match criterion |
| 174 | */ |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 175 | public static Criterion matchIPSrc(IpPrefix ip) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 176 | return new IPCriterion(ip, Type.IPV4_SRC); |
| 177 | } |
| 178 | |
| 179 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 180 | * Creates a match on IPv4 destination field using the specified value. |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 181 | * |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 182 | * @param ip ipv4 source value |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 183 | * @return match criterion |
| 184 | */ |
Ayaka Koshibe | 1d56fe4 | 2014-09-19 16:51:58 -0700 | [diff] [blame] | 185 | public static Criterion matchIPDst(IpPrefix ip) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 186 | return new IPCriterion(ip, Type.IPV4_DST); |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 189 | /** |
| 190 | * Creates a match on TCP source port field using the specified value. |
| 191 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 192 | * @param tcpPort TCP source port |
| 193 | * @return match criterion |
| 194 | * @deprecated in Drake release |
| 195 | */ |
| 196 | @Deprecated |
| 197 | public static Criterion matchTcpSrc(short tcpPort) { |
| 198 | return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_SRC); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Creates a match on TCP source port field using the specified value. |
| 203 | * |
| 204 | * @param tcpPort TCP source port |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 205 | * @return match criterion |
| 206 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 207 | public static Criterion matchTcpSrc(TpPort tcpPort) { |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 208 | return new TcpPortCriterion(tcpPort, Type.TCP_SRC); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * Creates a match on TCP destination port field using the specified value. |
| 213 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 214 | * @param tcpPort TCP destination port |
| 215 | * @return match criterion |
| 216 | * @deprecated in Drake release |
| 217 | */ |
| 218 | @Deprecated |
| 219 | public static Criterion matchTcpDst(short tcpPort) { |
| 220 | return new TcpPortCriterion(TpPort.tpPort(tcpPort), Type.TCP_DST); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Creates a match on TCP destination port field using the specified value. |
| 225 | * |
| 226 | * @param tcpPort TCP destination port |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 227 | * @return match criterion |
| 228 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 229 | public static Criterion matchTcpDst(TpPort tcpPort) { |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 230 | return new TcpPortCriterion(tcpPort, Type.TCP_DST); |
| 231 | } |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 232 | |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 233 | /** |
Jian Li | 2748b2c | 2015-11-30 11:43:09 -0800 | [diff] [blame] | 234 | * Creates a match on TCP flags using the specified value. |
| 235 | * |
| 236 | * @param flags TCP flags |
| 237 | * @return match criterion |
| 238 | */ |
| 239 | public static Criterion matchTcpFlags(int flags) { |
| 240 | return new TcpFlagsCriterion(flags); |
| 241 | } |
| 242 | |
| 243 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 244 | * Creates a match on UDP source port field using the specified value. |
| 245 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 246 | * @param udpPort UDP source port |
| 247 | * @return match criterion |
| 248 | * @deprecated in Drake release |
| 249 | */ |
| 250 | @Deprecated |
| 251 | public static Criterion matchUdpSrc(short udpPort) { |
| 252 | return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_SRC); |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * Creates a match on UDP source port field using the specified value. |
| 257 | * |
| 258 | * @param udpPort UDP source port |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 259 | * @return match criterion |
| 260 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 261 | public static Criterion matchUdpSrc(TpPort udpPort) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 262 | return new UdpPortCriterion(udpPort, Type.UDP_SRC); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Creates a match on UDP destination port field using the specified value. |
| 267 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 268 | * @param udpPort UDP destination port |
| 269 | * @return match criterion |
| 270 | * @deprecated in Drake release |
| 271 | */ |
| 272 | @Deprecated |
| 273 | public static Criterion matchUdpDst(short udpPort) { |
| 274 | return new UdpPortCriterion(TpPort.tpPort(udpPort), Type.UDP_DST); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * Creates a match on UDP destination port field using the specified value. |
| 279 | * |
| 280 | * @param udpPort UDP destination port |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 281 | * @return match criterion |
| 282 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 283 | public static Criterion matchUdpDst(TpPort udpPort) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 284 | return new UdpPortCriterion(udpPort, Type.UDP_DST); |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Creates a match on SCTP source port field using the specified value. |
| 289 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 290 | * @param sctpPort SCTP source port |
| 291 | * @return match criterion |
| 292 | * @deprecated in Drake release |
| 293 | */ |
| 294 | @Deprecated |
| 295 | public static Criterion matchSctpSrc(short sctpPort) { |
| 296 | return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_SRC); |
| 297 | } |
| 298 | |
| 299 | /** |
| 300 | * Creates a match on SCTP source port field using the specified value. |
| 301 | * |
| 302 | * @param sctpPort SCTP source port |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 303 | * @return match criterion |
| 304 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 305 | public static Criterion matchSctpSrc(TpPort sctpPort) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 306 | return new SctpPortCriterion(sctpPort, Type.SCTP_SRC); |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Creates a match on SCTP destination port field using the specified |
| 311 | * value. |
| 312 | * |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 313 | * @param sctpPort SCTP destination port |
| 314 | * @return match criterion |
| 315 | * @deprecated in Drake release |
| 316 | */ |
| 317 | @Deprecated |
| 318 | public static Criterion matchSctpDst(short sctpPort) { |
| 319 | return new SctpPortCriterion(TpPort.tpPort(sctpPort), Type.SCTP_DST); |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * Creates a match on SCTP destination port field using the specified |
| 324 | * value. |
| 325 | * |
| 326 | * @param sctpPort SCTP destination port |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 327 | * @return match criterion |
| 328 | */ |
Hyunsun Moon | cf732fb | 2015-08-22 21:04:23 -0700 | [diff] [blame] | 329 | public static Criterion matchSctpDst(TpPort sctpPort) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 330 | return new SctpPortCriterion(sctpPort, Type.SCTP_DST); |
| 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Creates a match on ICMP type field using the specified value. |
| 335 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 336 | * @param icmpType ICMP type (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 337 | * @return match criterion |
| 338 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 339 | public static Criterion matchIcmpType(short icmpType) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 340 | return new IcmpTypeCriterion(icmpType); |
| 341 | } |
| 342 | |
| 343 | /** |
| 344 | * Creates a match on ICMP code field using the specified value. |
| 345 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 346 | * @param icmpCode ICMP code (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 347 | * @return match criterion |
| 348 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 349 | public static Criterion matchIcmpCode(short icmpCode) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 350 | return new IcmpCodeCriterion(icmpCode); |
| 351 | } |
| 352 | |
| 353 | /** |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 354 | * Creates a match on IPv6 source field using the specified value. |
| 355 | * |
| 356 | * @param ip ipv6 source value |
| 357 | * @return match criterion |
| 358 | */ |
| 359 | public static Criterion matchIPv6Src(IpPrefix ip) { |
| 360 | return new IPCriterion(ip, Type.IPV6_SRC); |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Creates a match on IPv6 destination field using the specified value. |
| 365 | * |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 366 | * @param ip ipv6 destination value |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 367 | * @return match criterion |
| 368 | */ |
| 369 | public static Criterion matchIPv6Dst(IpPrefix ip) { |
| 370 | return new IPCriterion(ip, Type.IPV6_DST); |
| 371 | } |
| 372 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 373 | /** |
| 374 | * Creates a match on IPv6 flow label field using the specified value. |
| 375 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 376 | * @param flowLabel IPv6 flow label (20 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 377 | * @return match criterion |
| 378 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 379 | public static Criterion matchIPv6FlowLabel(int flowLabel) { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 380 | return new IPv6FlowLabelCriterion(flowLabel); |
| 381 | } |
| 382 | |
| 383 | /** |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 384 | * Creates a match on ICMPv6 type field using the specified value. |
| 385 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 386 | * @param icmpv6Type ICMPv6 type (8 bits unsigned integer) |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 387 | * @return match criterion |
| 388 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 389 | public static Criterion matchIcmpv6Type(short icmpv6Type) { |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 390 | return new Icmpv6TypeCriterion(icmpv6Type); |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * Creates a match on ICMPv6 code field using the specified value. |
| 395 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 396 | * @param icmpv6Code ICMPv6 code (8 bits unsigned integer) |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 397 | * @return match criterion |
| 398 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 399 | public static Criterion matchIcmpv6Code(short icmpv6Code) { |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 400 | return new Icmpv6CodeCriterion(icmpv6Code); |
| 401 | } |
| 402 | |
Charles M.C. Chan | 52fae7d | 2015-01-17 00:35:53 +0800 | [diff] [blame] | 403 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 404 | * Creates a match on IPv6 Neighbor Discovery target address using the |
| 405 | * specified value. |
| 406 | * |
| 407 | * @param targetAddress IPv6 Neighbor Discovery target address |
| 408 | * @return match criterion |
| 409 | */ |
| 410 | public static Criterion matchIPv6NDTargetAddress(Ip6Address targetAddress) { |
| 411 | return new IPv6NDTargetAddressCriterion(targetAddress); |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Creates a match on IPv6 Neighbor Discovery source link-layer address |
| 416 | * using the specified value. |
| 417 | * |
| 418 | * @param mac IPv6 Neighbor Discovery source link-layer address |
| 419 | * @return match criterion |
| 420 | */ |
| 421 | public static Criterion matchIPv6NDSourceLinkLayerAddress(MacAddress mac) { |
| 422 | return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_SLL); |
| 423 | } |
| 424 | |
| 425 | /** |
| 426 | * Creates a match on IPv6 Neighbor Discovery target link-layer address |
| 427 | * using the specified value. |
| 428 | * |
| 429 | * @param mac IPv6 Neighbor Discovery target link-layer address |
| 430 | * @return match criterion |
| 431 | */ |
| 432 | public static Criterion matchIPv6NDTargetLinkLayerAddress(MacAddress mac) { |
| 433 | return new IPv6NDLinkLayerAddressCriterion(mac, Type.IPV6_ND_TLL); |
| 434 | } |
| 435 | |
| 436 | /** |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 437 | * Creates a match on MPLS label. |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 438 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 439 | * @param mplsLabel MPLS label (20 bits) |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 440 | * @return match criterion |
| 441 | */ |
Michele Santuari | 4b6019e | 2014-12-19 11:31:45 +0100 | [diff] [blame] | 442 | public static Criterion matchMplsLabel(MplsLabel mplsLabel) { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 443 | return new MplsCriterion(mplsLabel); |
| 444 | } |
| 445 | |
| 446 | /** |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 447 | * Creates a match on MPLS Bottom-of-Stack indicator bit. |
| 448 | * |
| 449 | * @param mplsBos boolean value indicating true (BOS=1) or false (BOS=0) |
| 450 | * @return match criterion |
| 451 | */ |
Jian Li | 5c4cf1e | 2015-11-30 13:10:46 -0800 | [diff] [blame] | 452 | public static Criterion matchMplsBos(boolean mplsBos) { |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 453 | return new MplsBosCriterion(mplsBos); |
| 454 | } |
| 455 | |
| 456 | /** |
Jian Li | fd44dc9 | 2015-11-26 16:32:32 -0800 | [diff] [blame] | 457 | * Creates a match on MPLS TC. |
| 458 | * |
| 459 | * @param mplsTc MPLS TC (3 bits) |
| 460 | * @return match criterion |
| 461 | */ |
| 462 | public static Criterion matchMplsTc(byte mplsTc) { |
| 463 | return new MplsTcCriterion(mplsTc); |
| 464 | } |
| 465 | |
| 466 | /** |
Hyunsun Moon | a08c5d0 | 2015-07-14 17:53:00 -0700 | [diff] [blame] | 467 | * Creates a match on Tunnel ID. |
| 468 | * |
| 469 | * @param tunnelId Tunnel ID (64 bits) |
| 470 | * @return match criterion |
| 471 | */ |
| 472 | public static Criterion matchTunnelId(long tunnelId) { |
| 473 | return new TunnelIdCriterion(tunnelId); |
| 474 | } |
| 475 | |
| 476 | /** |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame] | 477 | * Creates a match on IPv6 Extension Header pseudo-field fiags. |
| 478 | * Those are defined in Criterion.IPv6ExthdrFlags. |
| 479 | * |
| 480 | * @param exthdrFlags IPv6 Extension Header pseudo-field flags (16 bits) |
| 481 | * @return match criterion |
| 482 | */ |
| 483 | public static Criterion matchIPv6ExthdrFlags(int exthdrFlags) { |
| 484 | return new IPv6ExthdrFlagsCriterion(exthdrFlags); |
| 485 | } |
| 486 | |
| 487 | /** |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 488 | * Creates a match on lambda using the specified value. |
| 489 | * |
| 490 | * @param lambda lambda |
| 491 | * @return match criterion |
| 492 | */ |
| 493 | public static Criterion matchLambda(Lambda lambda) { |
Sho SHIMIZU | efc2e28 | 2015-05-04 15:26:23 -0700 | [diff] [blame] | 494 | if (lambda instanceof IndexedLambda) { |
| 495 | return new IndexedLambdaCriterion((IndexedLambda) lambda); |
| 496 | } else if (lambda instanceof OchSignal) { |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 497 | return new OchSignalCriterion((OchSignal) lambda); |
| 498 | } else { |
| 499 | throw new UnsupportedOperationException(String.format("Unsupported type of Lambda: %s", lambda)); |
| 500 | } |
| 501 | } |
| 502 | |
| 503 | /** |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 504 | * Create a match on OCh (Optical Channel) signal type. |
| 505 | * |
| 506 | * @param signalType OCh signal type |
| 507 | * @return match criterion |
| 508 | */ |
| 509 | public static Criterion matchOchSignalType(OchSignalType signalType) { |
| 510 | return new OchSignalTypeCriterion(signalType); |
| 511 | } |
| 512 | |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 513 | /** |
| 514 | * Creates a match on ODU (Optical channel Data Unit) signal ID using the specified value. |
| 515 | * |
| 516 | * @param oduSignalId ODU Signal Id |
| 517 | * @return match criterion |
| 518 | */ |
| 519 | public static Criterion matchOduSignalId(OduSignalId oduSignalId) { |
| 520 | return new OduSignalIdCriterion(oduSignalId); |
| 521 | } |
| 522 | |
| 523 | /** |
| 524 | * Creates a match on ODU (Optical channel Data Unit) signal Type using the specified value. |
| 525 | * |
| 526 | * @param signalType ODU Signal Type |
| 527 | * @return match criterion |
| 528 | */ |
| 529 | public static Criterion matchOduSignalType(OduSignalType signalType) { |
| 530 | return new OduSignalTypeCriterion(signalType); |
| 531 | } |
| 532 | |
lishuai | a72d44d | 2015-10-19 17:27:38 +0800 | [diff] [blame] | 533 | /** |
BitOhenry | e330cf0 | 2015-11-17 18:59:33 +0800 | [diff] [blame] | 534 | * Creates a match on IPv4 destination field using the specified value. |
lishuai | a72d44d | 2015-10-19 17:27:38 +0800 | [diff] [blame] | 535 | * |
BitOhenry | e330cf0 | 2015-11-17 18:59:33 +0800 | [diff] [blame] | 536 | * @param ip ipv4 destination value |
lishuai | a72d44d | 2015-10-19 17:27:38 +0800 | [diff] [blame] | 537 | * @return match criterion |
| 538 | */ |
| 539 | public static Criterion matchArpTpa(Ip4Address ip) { |
| 540 | return new ArpPaCriterion(ip, Type.ARP_TPA); |
| 541 | } |
| 542 | |
BitOhenry | cc024eb | 2015-11-10 17:17:36 +0800 | [diff] [blame] | 543 | /** |
BitOhenry | 08c7294 | 2015-11-18 14:44:29 +0800 | [diff] [blame] | 544 | * Creates a match on IPv4 source field using the specified value. |
| 545 | * |
| 546 | * @param ip ipv4 source value |
| 547 | * @return match criterion |
| 548 | */ |
| 549 | public static Criterion matchArpSpa(Ip4Address ip) { |
| 550 | return new ArpPaCriterion(ip, Type.ARP_SPA); |
| 551 | } |
| 552 | |
| 553 | /** |
BitOhenry | e330cf0 | 2015-11-17 18:59:33 +0800 | [diff] [blame] | 554 | * Creates a match on MAC destination field using the specified value. |
| 555 | * |
| 556 | * @param mac MAC destination value |
| 557 | * @return match criterion |
| 558 | */ |
| 559 | public static Criterion matchArpTha(MacAddress mac) { |
| 560 | return new ArpHaCriterion(mac, Type.ARP_THA); |
| 561 | } |
| 562 | |
| 563 | /** |
BitOhenry | cc024eb | 2015-11-10 17:17:36 +0800 | [diff] [blame] | 564 | * Creates a match on MAC source field using the specified value. |
| 565 | * |
| 566 | * @param mac MAC source value |
| 567 | * @return match criterion |
| 568 | */ |
BitOhenry | e330cf0 | 2015-11-17 18:59:33 +0800 | [diff] [blame] | 569 | public static Criterion matchArpSha(MacAddress mac) { |
| 570 | return new ArpHaCriterion(mac, Type.ARP_SHA); |
BitOhenry | cc024eb | 2015-11-10 17:17:36 +0800 | [diff] [blame] | 571 | } |
| 572 | |
BitOhenry | 11620c9 | 2015-11-27 08:42:36 +0800 | [diff] [blame] | 573 | /** |
| 574 | * Creates a match on arp operation type field using the specified value. |
| 575 | * |
| 576 | * @param arpOp arp operation type value |
| 577 | * @return match criterion |
| 578 | */ |
| 579 | public static Criterion matchArpOp(int arpOp) { |
| 580 | return new ArpOpCriterion(arpOp, Type.ARP_OP); |
| 581 | } |
| 582 | |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 583 | /** |
Jian Li | f1ecf99 | 2015-12-02 17:48:54 -0800 | [diff] [blame] | 584 | * Creates a match on PBB I-SID field using the specific value. |
| 585 | * |
| 586 | * @param pbbIsid PBB I-SID |
| 587 | * @return match criterion |
| 588 | */ |
| 589 | public static Criterion matchPbbIsid(int pbbIsid) { |
| 590 | return new PbbIsidCriterion(pbbIsid); |
| 591 | } |
| 592 | |
| 593 | /** |
Jonathan Hart | 26a8d95 | 2015-12-02 15:16:35 -0800 | [diff] [blame] | 594 | * Creates an extension criterion for the specified extension selector. |
| 595 | * |
| 596 | * @param extensionSelector extension selector |
| 597 | * @param deviceId device ID |
| 598 | * @return match criterion |
| 599 | */ |
| 600 | public static Criterion extension(ExtensionSelector extensionSelector, |
| 601 | DeviceId deviceId) { |
| 602 | return new ExtensionCriterion(extensionSelector, deviceId); |
| 603 | } |
| 604 | |
| 605 | /** |
| 606 | * Creates a dummy criterion. |
| 607 | * |
| 608 | * @return match criterion |
| 609 | */ |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 610 | public static Criterion dummy() { |
| 611 | return new DummyCriterion(); |
| 612 | } |
| 613 | |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 614 | /** |
alshabib | a3a476d | 2015-04-10 14:35:38 -0700 | [diff] [blame] | 615 | * Dummy Criterion used with @see{FilteringObjective}. |
| 616 | */ |
| 617 | private static class DummyCriterion implements Criterion { |
| 618 | |
| 619 | @Override |
| 620 | public Type type() { |
| 621 | return Type.DUMMY; |
| 622 | } |
| 623 | } |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 624 | } |