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