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