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