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