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