Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 2 | * Copyright 2014 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 | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 20 | import java.util.Objects; |
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; |
| 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 | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 134 | * @param ipEcn ip ecn value (3 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 | */ |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 341 | public static Criterion matchMplsLabel(int 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 | a66cb12 | 2014-12-02 18:11:15 -0800 | [diff] [blame] | 367 | * Creates a match on optical signal type using the specified value. |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 368 | * |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 369 | * @param sigType optical signal type (8 bits unsigned integer) |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 370 | * @return match criterion |
| 371 | */ |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 372 | public static Criterion matchOpticalSignalType(short sigType) { |
Praseed Balakrishnan | 2dd5abd | 2014-11-03 14:56:28 -0800 | [diff] [blame] | 373 | return new OpticalSignalTypeCriterion(sigType, Type.OCH_SIGTYPE); |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 376 | /** |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 377 | * Implementation of input port criterion. |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 378 | */ |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 379 | public static final class PortCriterion implements Criterion { |
| 380 | private final PortNumber port; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 381 | private final Type type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 382 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 383 | /** |
| 384 | * Constructor. |
| 385 | * |
| 386 | * @param port the input port number to match |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 387 | * @param type the match type. Should be either Type.IN_PORT or |
| 388 | * Type.IN_PHY_PORT |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 389 | */ |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 390 | public PortCriterion(PortNumber port, Type type) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 391 | this.port = port; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 392 | this.type = type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 393 | } |
| 394 | |
| 395 | @Override |
| 396 | public Type type() { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 397 | return this.type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 398 | } |
| 399 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 400 | /** |
| 401 | * Gets the input port number to match. |
| 402 | * |
| 403 | * @return the input port number to match |
| 404 | */ |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 405 | public PortNumber port() { |
| 406 | return this.port; |
| 407 | } |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 408 | |
| 409 | @Override |
| 410 | public String toString() { |
| 411 | return toStringHelper(type().toString()) |
| 412 | .add("port", port).toString(); |
| 413 | } |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 414 | |
| 415 | @Override |
| 416 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 417 | return Objects.hash(type(), port); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | @Override |
| 421 | public boolean equals(Object obj) { |
| 422 | if (this == obj) { |
| 423 | return true; |
| 424 | } |
| 425 | if (obj instanceof PortCriterion) { |
| 426 | PortCriterion that = (PortCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 427 | return Objects.equals(port, that.port) && |
| 428 | Objects.equals(this.type(), that.type()); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 429 | } |
| 430 | return false; |
| 431 | } |
| 432 | } |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 433 | |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 434 | /** |
| 435 | * Implementation of Metadata criterion. |
| 436 | */ |
| 437 | public static final class MetadataCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 438 | private final long metadata; |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 439 | |
| 440 | /** |
| 441 | * Constructor. |
| 442 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 443 | * @param metadata the metadata to match (64 bits data) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 444 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 445 | public MetadataCriterion(long metadata) { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 446 | this.metadata = metadata; |
| 447 | } |
| 448 | |
| 449 | @Override |
| 450 | public Type type() { |
| 451 | return Type.METADATA; |
| 452 | } |
| 453 | |
| 454 | /** |
| 455 | * Gets the metadata to match. |
| 456 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 457 | * @return the metadata to match (64 bits data) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 458 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 459 | public long metadata() { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 460 | return metadata; |
| 461 | } |
| 462 | |
| 463 | @Override |
| 464 | public String toString() { |
| 465 | return toStringHelper(type().toString()) |
| 466 | .add("metadata", Long.toHexString(metadata)) |
| 467 | .toString(); |
| 468 | } |
| 469 | |
| 470 | @Override |
| 471 | public int hashCode() { |
| 472 | return Objects.hash(type(), metadata); |
| 473 | } |
| 474 | |
| 475 | @Override |
| 476 | public boolean equals(Object obj) { |
| 477 | if (this == obj) { |
| 478 | return true; |
| 479 | } |
| 480 | if (obj instanceof MetadataCriterion) { |
| 481 | MetadataCriterion that = (MetadataCriterion) obj; |
| 482 | return Objects.equals(metadata, that.metadata) && |
| 483 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 484 | } |
| 485 | return false; |
| 486 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 487 | } |
| 488 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 489 | /** |
| 490 | * Implementation of MAC address criterion. |
| 491 | */ |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 492 | public static final class EthCriterion implements Criterion { |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 493 | private final MacAddress mac; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 494 | private final Type type; |
| 495 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 496 | /** |
| 497 | * Constructor. |
| 498 | * |
| 499 | * @param mac the source or destination MAC address to match |
| 500 | * @param type the match type. Should be either Type.ETH_DST or |
| 501 | * Type.ETH_SRC |
| 502 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 503 | public EthCriterion(MacAddress mac, Type type) { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 504 | this.mac = mac; |
| 505 | this.type = type; |
| 506 | } |
| 507 | |
| 508 | @Override |
| 509 | public Type type() { |
| 510 | return this.type; |
| 511 | } |
| 512 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 513 | /** |
| 514 | * Gets the MAC address to match. |
| 515 | * |
| 516 | * @return the MAC address to match |
| 517 | */ |
Ayaka Koshibe | a9c199f | 2014-09-16 16:21:40 -0700 | [diff] [blame] | 518 | public MacAddress mac() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 519 | return this.mac; |
| 520 | } |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 521 | |
| 522 | @Override |
| 523 | public String toString() { |
| 524 | return toStringHelper(type().toString()) |
| 525 | .add("mac", mac).toString(); |
| 526 | } |
| 527 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 528 | @Override |
| 529 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 530 | return Objects.hash(type, mac); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | @Override |
| 534 | public boolean equals(Object obj) { |
| 535 | if (this == obj) { |
| 536 | return true; |
| 537 | } |
| 538 | if (obj instanceof EthCriterion) { |
| 539 | EthCriterion that = (EthCriterion) obj; |
| 540 | return Objects.equals(mac, that.mac) && |
| 541 | Objects.equals(type, that.type); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 542 | } |
| 543 | return false; |
| 544 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 545 | } |
| 546 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 547 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 548 | * Implementation of Ethernet type criterion (16 bits unsigned integer). |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 549 | */ |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 550 | public static final class EthTypeCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 551 | private static final int MASK = 0xffff; |
| 552 | private final int ethType; // Ethernet type value: 16 bits |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 553 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 554 | /** |
| 555 | * Constructor. |
| 556 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 557 | * @param ethType the Ethernet frame type to match (16 bits unsigned |
| 558 | * integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 559 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 560 | public EthTypeCriterion(int ethType) { |
| 561 | this.ethType = ethType & MASK; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | @Override |
| 565 | public Type type() { |
| 566 | return Type.ETH_TYPE; |
| 567 | } |
| 568 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 569 | /** |
| 570 | * Gets the Ethernet frame type to match. |
| 571 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 572 | * @return the Ethernet frame type to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 573 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 574 | public int ethType() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 575 | return ethType; |
| 576 | } |
| 577 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 578 | @Override |
| 579 | public String toString() { |
| 580 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 581 | .add("ethType", Long.toHexString(ethType)) |
Charles M.C. Chan | 36eb6e1 | 2015-01-06 17:12:27 +0800 | [diff] [blame] | 582 | .toString(); |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 583 | } |
| 584 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 585 | @Override |
| 586 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 587 | return Objects.hash(type(), ethType); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 588 | } |
| 589 | |
| 590 | @Override |
| 591 | public boolean equals(Object obj) { |
| 592 | if (this == obj) { |
| 593 | return true; |
| 594 | } |
| 595 | if (obj instanceof EthTypeCriterion) { |
| 596 | EthTypeCriterion that = (EthTypeCriterion) obj; |
alshabib | 2020b89 | 2014-10-20 15:47:08 -0700 | [diff] [blame] | 597 | return Objects.equals(ethType, that.ethType) && |
| 598 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 599 | } |
| 600 | return false; |
| 601 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 602 | } |
| 603 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 604 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 605 | * Implementation of VLAN ID criterion. |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 606 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 607 | public static final class VlanIdCriterion implements Criterion { |
| 608 | private final VlanId vlanId; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 609 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 610 | /** |
| 611 | * Constructor. |
| 612 | * |
| 613 | * @param vlanId the VLAN ID to match |
| 614 | */ |
| 615 | public VlanIdCriterion(VlanId vlanId) { |
| 616 | this.vlanId = vlanId; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | @Override |
| 620 | public Type type() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 621 | return Type.VLAN_VID; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 622 | } |
| 623 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 624 | /** |
| 625 | * Gets the VLAN ID to match. |
| 626 | * |
| 627 | * @return the VLAN ID to match |
| 628 | */ |
| 629 | public VlanId vlanId() { |
| 630 | return vlanId; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 631 | } |
| 632 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 633 | @Override |
| 634 | public String toString() { |
| 635 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 636 | .add("vlanId", vlanId).toString(); |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 637 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 638 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 639 | @Override |
| 640 | public int hashCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 641 | return Objects.hash(type(), vlanId); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | @Override |
| 645 | public boolean equals(Object obj) { |
| 646 | if (this == obj) { |
| 647 | return true; |
| 648 | } |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 649 | if (obj instanceof VlanIdCriterion) { |
| 650 | VlanIdCriterion that = (VlanIdCriterion) obj; |
| 651 | return Objects.equals(vlanId, that.vlanId) && |
| 652 | Objects.equals(this.type(), that.type()); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 653 | } |
| 654 | return false; |
| 655 | } |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 656 | } |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 657 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 658 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 659 | * Implementation of VLAN priority criterion (3 bits). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 660 | */ |
| 661 | public static final class VlanPcpCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 662 | private static final byte MASK = 0x7; |
| 663 | private final byte vlanPcp; // VLAN pcp value: 3 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 664 | |
| 665 | /** |
| 666 | * Constructor. |
| 667 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 668 | * @param vlanPcp the VLAN priority to match (3 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 669 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 670 | public VlanPcpCriterion(byte vlanPcp) { |
| 671 | this.vlanPcp = (byte) (vlanPcp & MASK); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 672 | } |
| 673 | |
| 674 | @Override |
| 675 | public Type type() { |
| 676 | return Type.VLAN_PCP; |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * Gets the VLAN priority to match. |
| 681 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 682 | * @return the VLAN priority to match (3 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 683 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 684 | public byte priority() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 685 | return vlanPcp; |
| 686 | } |
| 687 | |
| 688 | @Override |
| 689 | public String toString() { |
| 690 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 691 | .add("priority", Long.toHexString(vlanPcp)).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 692 | } |
| 693 | |
| 694 | @Override |
| 695 | public int hashCode() { |
| 696 | return Objects.hash(type(), vlanPcp); |
| 697 | } |
| 698 | |
| 699 | @Override |
| 700 | public boolean equals(Object obj) { |
| 701 | if (this == obj) { |
| 702 | return true; |
| 703 | } |
| 704 | if (obj instanceof VlanPcpCriterion) { |
| 705 | VlanPcpCriterion that = (VlanPcpCriterion) obj; |
| 706 | return Objects.equals(vlanPcp, that.vlanPcp) && |
| 707 | Objects.equals(this.type(), that.type()); |
| 708 | } |
| 709 | return false; |
| 710 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 711 | } |
| 712 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 713 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 714 | * Implementation of IP DSCP (Differentiated Services Code Point) |
| 715 | * criterion (6 bits). |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 716 | */ |
| 717 | public static final class IPDscpCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 718 | private static final byte MASK = 0x3f; |
| 719 | private final byte ipDscp; // IP DSCP value: 6 bits |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 720 | |
| 721 | /** |
| 722 | * Constructor. |
| 723 | * |
| 724 | * @param ipDscp the IP DSCP value to match |
| 725 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 726 | public IPDscpCriterion(byte ipDscp) { |
| 727 | this.ipDscp = (byte) (ipDscp & MASK); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | @Override |
| 731 | public Type type() { |
| 732 | return Type.IP_DSCP; |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * Gets the IP DSCP value to match. |
| 737 | * |
| 738 | * @return the IP DSCP value to match |
| 739 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 740 | public byte ipDscp() { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 741 | return ipDscp; |
| 742 | } |
| 743 | |
| 744 | @Override |
| 745 | public String toString() { |
| 746 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 747 | .add("ipDscp", Long.toHexString(ipDscp)).toString(); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | @Override |
| 751 | public int hashCode() { |
| 752 | return Objects.hash(type(), ipDscp); |
| 753 | } |
| 754 | |
| 755 | @Override |
| 756 | public boolean equals(Object obj) { |
| 757 | if (this == obj) { |
| 758 | return true; |
| 759 | } |
| 760 | if (obj instanceof IPDscpCriterion) { |
| 761 | IPDscpCriterion that = (IPDscpCriterion) obj; |
| 762 | return Objects.equals(ipDscp, that.ipDscp) && |
| 763 | Objects.equals(this.type(), that.type()); |
| 764 | } |
| 765 | return false; |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 770 | * Implementation of IP ECN (Explicit Congestion Notification) criterion |
| 771 | * (3 bits). |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 772 | */ |
| 773 | public static final class IPEcnCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 774 | private static final byte MASK = 0x7; |
| 775 | private final byte ipEcn; // IP ECN value: 3 bits |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 776 | |
| 777 | /** |
| 778 | * Constructor. |
| 779 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 780 | * @param ipEcn the IP ECN value to match (3 bits) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 781 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 782 | public IPEcnCriterion(byte ipEcn) { |
| 783 | this.ipEcn = (byte) (ipEcn & MASK); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 784 | } |
| 785 | |
| 786 | @Override |
| 787 | public Type type() { |
| 788 | return Type.IP_ECN; |
| 789 | } |
| 790 | |
| 791 | /** |
| 792 | * Gets the IP ECN value to match. |
| 793 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 794 | * @return the IP ECN value to match (3 bits) |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 795 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 796 | public byte ipEcn() { |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 797 | return ipEcn; |
| 798 | } |
| 799 | |
| 800 | @Override |
| 801 | public String toString() { |
| 802 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 803 | .add("ipEcn", Long.toHexString(ipEcn)).toString(); |
Pavlin Radoslavov | d0fd841 | 2015-02-04 13:57:00 -0800 | [diff] [blame] | 804 | } |
| 805 | |
| 806 | @Override |
| 807 | public int hashCode() { |
| 808 | return Objects.hash(type(), ipEcn); |
| 809 | } |
| 810 | |
| 811 | @Override |
| 812 | public boolean equals(Object obj) { |
| 813 | if (this == obj) { |
| 814 | return true; |
| 815 | } |
| 816 | if (obj instanceof IPEcnCriterion) { |
| 817 | IPEcnCriterion that = (IPEcnCriterion) obj; |
| 818 | return Objects.equals(ipEcn, that.ipEcn) && |
| 819 | Objects.equals(this.type(), that.type()); |
| 820 | } |
| 821 | return false; |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 826 | * Implementation of Internet Protocol Number criterion (8 bits unsigned) |
| 827 | * integer. |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 828 | */ |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 829 | public static final class IPProtocolCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 830 | private static final short MASK = 0xff; |
| 831 | private final short proto; // IP protocol number: 8 bits |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 832 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 833 | /** |
| 834 | * Constructor. |
| 835 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 836 | * @param protocol the IP protocol (e.g., TCP=6, UDP=17) to match |
| 837 | * (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 838 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 839 | public IPProtocolCriterion(short protocol) { |
| 840 | this.proto = (short) (protocol & MASK); |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | @Override |
| 844 | public Type type() { |
| 845 | return Type.IP_PROTO; |
| 846 | } |
| 847 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 848 | /** |
| 849 | * Gets the IP protocol to match. |
| 850 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 851 | * @return the IP protocol to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 852 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 853 | public short protocol() { |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 854 | return proto; |
| 855 | } |
| 856 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 857 | @Override |
| 858 | public String toString() { |
| 859 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 860 | .add("protocol", proto).toString(); |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 861 | } |
| 862 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 863 | @Override |
| 864 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 865 | return Objects.hash(type(), proto); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 866 | } |
| 867 | |
| 868 | @Override |
| 869 | public boolean equals(Object obj) { |
| 870 | if (this == obj) { |
| 871 | return true; |
| 872 | } |
| 873 | if (obj instanceof IPProtocolCriterion) { |
| 874 | IPProtocolCriterion that = (IPProtocolCriterion) obj; |
| 875 | return Objects.equals(proto, that.proto); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 876 | } |
| 877 | return false; |
| 878 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 879 | } |
| 880 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 881 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 882 | * Implementation of IP address criterion. |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 883 | */ |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 884 | public static final class IPCriterion implements Criterion { |
| 885 | private final IpPrefix ip; |
| 886 | private final Type type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 887 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 888 | /** |
| 889 | * Constructor. |
| 890 | * |
| 891 | * @param ip the IP prefix to match. Could be either IPv4 or IPv6 |
| 892 | * @param type the match type. Should be one of the following: |
| 893 | * Type.IPV4_SRC, Type.IPV4_DST, Type.IPV6_SRC, Type.IPV6_DST |
| 894 | */ |
| 895 | public IPCriterion(IpPrefix ip, Type type) { |
| 896 | this.ip = ip; |
| 897 | this.type = type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | @Override |
| 901 | public Type type() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 902 | return this.type; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 903 | } |
| 904 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 905 | /** |
| 906 | * Gets the IP prefix to match. |
| 907 | * |
| 908 | * @return the IP prefix to match |
| 909 | */ |
| 910 | public IpPrefix ip() { |
| 911 | return this.ip; |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 912 | } |
| 913 | |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 914 | @Override |
| 915 | public String toString() { |
| 916 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 917 | .add("ip", ip).toString(); |
alshabib | 99b8fdc | 2014-09-25 14:30:22 -0700 | [diff] [blame] | 918 | } |
| 919 | |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 920 | @Override |
| 921 | public int hashCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 922 | return Objects.hash(type, ip); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 923 | } |
| 924 | |
| 925 | @Override |
| 926 | public boolean equals(Object obj) { |
| 927 | if (this == obj) { |
| 928 | return true; |
| 929 | } |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 930 | if (obj instanceof IPCriterion) { |
| 931 | IPCriterion that = (IPCriterion) obj; |
| 932 | return Objects.equals(ip, that.ip) && |
| 933 | Objects.equals(type, that.type); |
alshabib | ba5ac48 | 2014-10-02 17:15:20 -0700 | [diff] [blame] | 934 | } |
| 935 | return false; |
| 936 | } |
alshabib | 7b79549 | 2014-09-16 14:38:39 -0700 | [diff] [blame] | 937 | } |
| 938 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 939 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 940 | * Implementation of TCP port criterion (16 bits unsigned integer). |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 941 | */ |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 942 | public static final class TcpPortCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 943 | private static final int MASK = 0xffff; |
| 944 | private final int tcpPort; // Port value: 16 bits |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 945 | private final Type type; |
| 946 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 947 | /** |
| 948 | * Constructor. |
| 949 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 950 | * @param tcpPort the TCP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 951 | * @param type the match type. Should be either Type.TCP_SRC or |
| 952 | * Type.TCP_DST |
| 953 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 954 | public TcpPortCriterion(int tcpPort, Type type) { |
| 955 | this.tcpPort = tcpPort & MASK; |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 956 | this.type = type; |
| 957 | } |
| 958 | |
| 959 | @Override |
| 960 | public Type type() { |
| 961 | return this.type; |
| 962 | } |
| 963 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 964 | /** |
| 965 | * Gets the TCP port to match. |
| 966 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 967 | * @return the TCP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 968 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 969 | public int tcpPort() { |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 970 | return this.tcpPort; |
| 971 | } |
| 972 | |
| 973 | @Override |
| 974 | public String toString() { |
| 975 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 976 | .add("tcpPort", tcpPort).toString(); |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | @Override |
| 980 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 981 | return Objects.hash(type, tcpPort); |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 982 | } |
| 983 | |
| 984 | @Override |
| 985 | public boolean equals(Object obj) { |
| 986 | if (this == obj) { |
| 987 | return true; |
| 988 | } |
| 989 | if (obj instanceof TcpPortCriterion) { |
| 990 | TcpPortCriterion that = (TcpPortCriterion) obj; |
| 991 | return Objects.equals(tcpPort, that.tcpPort) && |
| 992 | Objects.equals(type, that.type); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 993 | } |
| 994 | return false; |
| 995 | } |
| 996 | } |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 997 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 998 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 999 | * Implementation of UDP port criterion (16 bits unsigned integer). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1000 | */ |
| 1001 | public static final class UdpPortCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1002 | private static final int MASK = 0xffff; |
| 1003 | private final int udpPort; // Port value: 16 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1004 | private final Type type; |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 1005 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1006 | /** |
| 1007 | * Constructor. |
| 1008 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1009 | * @param udpPort the UDP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1010 | * @param type the match type. Should be either Type.UDP_SRC or |
| 1011 | * Type.UDP_DST |
| 1012 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1013 | public UdpPortCriterion(int udpPort, Type type) { |
| 1014 | this.udpPort = udpPort & MASK; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1015 | this.type = type; |
| 1016 | } |
| 1017 | |
| 1018 | @Override |
| 1019 | public Type type() { |
| 1020 | return this.type; |
| 1021 | } |
| 1022 | |
| 1023 | /** |
| 1024 | * Gets the UDP port to match. |
| 1025 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1026 | * @return the UDP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1027 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1028 | public int udpPort() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1029 | return this.udpPort; |
| 1030 | } |
| 1031 | |
| 1032 | @Override |
| 1033 | public String toString() { |
| 1034 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1035 | .add("udpPort", udpPort).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1036 | } |
| 1037 | |
| 1038 | @Override |
| 1039 | public int hashCode() { |
| 1040 | return Objects.hash(type, udpPort); |
| 1041 | } |
| 1042 | |
| 1043 | @Override |
| 1044 | public boolean equals(Object obj) { |
| 1045 | if (this == obj) { |
| 1046 | return true; |
| 1047 | } |
| 1048 | if (obj instanceof UdpPortCriterion) { |
| 1049 | UdpPortCriterion that = (UdpPortCriterion) obj; |
| 1050 | return Objects.equals(udpPort, that.udpPort) && |
| 1051 | Objects.equals(type, that.type); |
| 1052 | } |
| 1053 | return false; |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1058 | * Implementation of SCTP port criterion (16 bits unsigned integer). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1059 | */ |
| 1060 | public static final class SctpPortCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1061 | private static final int MASK = 0xffff; |
| 1062 | private final int sctpPort; // Port value: 16 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1063 | private final Type type; |
| 1064 | |
| 1065 | /** |
| 1066 | * Constructor. |
| 1067 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1068 | * @param sctpPort the SCTP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1069 | * @param type the match type. Should be either Type.SCTP_SRC or |
| 1070 | * Type.SCTP_DST |
| 1071 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1072 | public SctpPortCriterion(int sctpPort, Type type) { |
| 1073 | this.sctpPort = sctpPort & MASK; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1074 | this.type = type; |
| 1075 | } |
| 1076 | |
| 1077 | @Override |
| 1078 | public Type type() { |
| 1079 | return this.type; |
| 1080 | } |
| 1081 | |
| 1082 | /** |
| 1083 | * Gets the SCTP port to match. |
| 1084 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1085 | * @return the SCTP port to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1086 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1087 | public int sctpPort() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1088 | return this.sctpPort; |
| 1089 | } |
| 1090 | |
| 1091 | @Override |
| 1092 | public String toString() { |
| 1093 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1094 | .add("sctpPort", sctpPort).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | @Override |
| 1098 | public int hashCode() { |
| 1099 | return Objects.hash(type, sctpPort); |
| 1100 | } |
| 1101 | |
| 1102 | @Override |
| 1103 | public boolean equals(Object obj) { |
| 1104 | if (this == obj) { |
| 1105 | return true; |
| 1106 | } |
| 1107 | if (obj instanceof SctpPortCriterion) { |
| 1108 | SctpPortCriterion that = (SctpPortCriterion) obj; |
| 1109 | return Objects.equals(sctpPort, that.sctpPort) && |
| 1110 | Objects.equals(type, that.type); |
| 1111 | } |
| 1112 | return false; |
| 1113 | } |
| 1114 | } |
| 1115 | |
| 1116 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1117 | * Implementation of ICMP type criterion (8 bits unsigned integer). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1118 | */ |
| 1119 | public static final class IcmpTypeCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1120 | private static final short MASK = 0xff; |
| 1121 | private final short icmpType; // The ICMP type: 8 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1122 | |
| 1123 | /** |
| 1124 | * Constructor. |
| 1125 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1126 | * @param icmpType the ICMP type to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1127 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1128 | public IcmpTypeCriterion(short icmpType) { |
| 1129 | this.icmpType = (short) (icmpType & MASK); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1130 | } |
| 1131 | |
| 1132 | @Override |
| 1133 | public Type type() { |
| 1134 | return Type.ICMPV4_TYPE; |
| 1135 | } |
| 1136 | |
| 1137 | /** |
| 1138 | * Gets the ICMP type to match. |
| 1139 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1140 | * @return the ICMP type to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1141 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1142 | public short icmpType() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1143 | return icmpType; |
| 1144 | } |
| 1145 | |
| 1146 | @Override |
| 1147 | public String toString() { |
| 1148 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1149 | .add("icmpType", icmpType).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1150 | } |
| 1151 | |
| 1152 | @Override |
| 1153 | public int hashCode() { |
| 1154 | return Objects.hash(type(), icmpType); |
| 1155 | } |
| 1156 | |
| 1157 | @Override |
| 1158 | public boolean equals(Object obj) { |
| 1159 | if (this == obj) { |
| 1160 | return true; |
| 1161 | } |
| 1162 | if (obj instanceof IcmpTypeCriterion) { |
| 1163 | IcmpTypeCriterion that = (IcmpTypeCriterion) obj; |
| 1164 | return Objects.equals(icmpType, that.icmpType) && |
| 1165 | Objects.equals(this.type(), that.type()); |
| 1166 | } |
| 1167 | return false; |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1172 | * Implementation of ICMP code criterion (8 bits unsigned integer). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1173 | */ |
| 1174 | public static final class IcmpCodeCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1175 | private static final short MASK = 0xff; |
| 1176 | private final short icmpCode; // The ICMP code: 8 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1177 | |
| 1178 | /** |
| 1179 | * Constructor. |
| 1180 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1181 | * @param icmpCode the ICMP code to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1182 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1183 | public IcmpCodeCriterion(short icmpCode) { |
| 1184 | this.icmpCode = (short) (icmpCode & MASK); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | @Override |
| 1188 | public Type type() { |
| 1189 | return Type.ICMPV4_CODE; |
| 1190 | } |
| 1191 | |
| 1192 | /** |
| 1193 | * Gets the ICMP code to match. |
| 1194 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1195 | * @return the ICMP code to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1196 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1197 | public short icmpCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1198 | return icmpCode; |
| 1199 | } |
| 1200 | |
| 1201 | @Override |
| 1202 | public String toString() { |
| 1203 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1204 | .add("icmpCode", icmpCode).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1205 | } |
| 1206 | |
| 1207 | @Override |
| 1208 | public int hashCode() { |
| 1209 | return Objects.hash(type(), icmpCode); |
| 1210 | } |
| 1211 | |
| 1212 | @Override |
| 1213 | public boolean equals(Object obj) { |
| 1214 | if (this == obj) { |
| 1215 | return true; |
| 1216 | } |
| 1217 | if (obj instanceof IcmpCodeCriterion) { |
| 1218 | IcmpCodeCriterion that = (IcmpCodeCriterion) obj; |
| 1219 | return Objects.equals(icmpCode, that.icmpCode) && |
| 1220 | Objects.equals(this.type(), that.type()); |
| 1221 | } |
| 1222 | return false; |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1227 | * Implementation of IPv6 Flow Label (RFC 6437) criterion (20 bits unsigned |
| 1228 | * integer). |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1229 | */ |
| 1230 | public static final class IPv6FlowLabelCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1231 | private static final int MASK = 0xfffff; |
| 1232 | private final int flowLabel; // IPv6 flow label: 20 bits |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1233 | |
| 1234 | /** |
| 1235 | * Constructor. |
| 1236 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1237 | * @param flowLabel the IPv6 flow label to match (20 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1238 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1239 | public IPv6FlowLabelCriterion(int flowLabel) { |
| 1240 | this.flowLabel = flowLabel & MASK; |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1241 | } |
| 1242 | |
| 1243 | @Override |
| 1244 | public Type type() { |
| 1245 | return Type.IPV6_FLABEL; |
| 1246 | } |
| 1247 | |
| 1248 | /** |
| 1249 | * Gets the IPv6 flow label to match. |
| 1250 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1251 | * @return the IPv6 flow label to match (20 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1252 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1253 | public int flowLabel() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1254 | return flowLabel; |
| 1255 | } |
| 1256 | |
| 1257 | @Override |
| 1258 | public String toString() { |
| 1259 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1260 | .add("flowLabel", Long.toHexString(flowLabel)).toString(); |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | @Override |
| 1264 | public int hashCode() { |
| 1265 | return Objects.hash(type(), flowLabel); |
| 1266 | } |
| 1267 | |
| 1268 | @Override |
| 1269 | public boolean equals(Object obj) { |
| 1270 | if (this == obj) { |
| 1271 | return true; |
| 1272 | } |
| 1273 | if (obj instanceof IPv6FlowLabelCriterion) { |
| 1274 | IPv6FlowLabelCriterion that = (IPv6FlowLabelCriterion) obj; |
| 1275 | return Objects.equals(flowLabel, that.flowLabel) && |
| 1276 | Objects.equals(this.type(), that.type()); |
Toshio Koide | 9c44c9a | 2014-10-09 11:44:36 -0700 | [diff] [blame] | 1277 | } |
| 1278 | return false; |
| 1279 | } |
| 1280 | } |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1281 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1282 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1283 | * Implementation of ICMPv6 type criterion (8 bits unsigned integer). |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1284 | */ |
| 1285 | public static final class Icmpv6TypeCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1286 | private static final short MASK = 0xff; |
| 1287 | private final short icmpv6Type; // ICMPv6 type: 8 bits |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1288 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1289 | /** |
| 1290 | * Constructor. |
| 1291 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1292 | * @param icmpv6Type the ICMPv6 type to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1293 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1294 | public Icmpv6TypeCriterion(short icmpv6Type) { |
| 1295 | this.icmpv6Type = (short) (icmpv6Type & MASK); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1296 | } |
| 1297 | |
| 1298 | @Override |
| 1299 | public Type type() { |
| 1300 | return Type.ICMPV6_TYPE; |
| 1301 | } |
| 1302 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1303 | /** |
| 1304 | * Gets the ICMPv6 type to match. |
| 1305 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1306 | * @return the ICMPv6 type to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1307 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1308 | public short icmpv6Type() { |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1309 | return icmpv6Type; |
| 1310 | } |
| 1311 | |
| 1312 | @Override |
| 1313 | public String toString() { |
| 1314 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1315 | .add("icmpv6Type", icmpv6Type).toString(); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1316 | } |
| 1317 | |
| 1318 | @Override |
| 1319 | public int hashCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1320 | return Objects.hash(type(), icmpv6Type); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1321 | } |
| 1322 | |
| 1323 | @Override |
| 1324 | public boolean equals(Object obj) { |
| 1325 | if (this == obj) { |
| 1326 | return true; |
| 1327 | } |
| 1328 | if (obj instanceof Icmpv6TypeCriterion) { |
| 1329 | Icmpv6TypeCriterion that = (Icmpv6TypeCriterion) obj; |
| 1330 | return Objects.equals(icmpv6Type, that.icmpv6Type) && |
| 1331 | Objects.equals(this.type(), that.type()); |
| 1332 | } |
| 1333 | return false; |
| 1334 | } |
| 1335 | } |
| 1336 | |
| 1337 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1338 | * Implementation of ICMPv6 code criterion (8 bits unsigned integer). |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1339 | */ |
| 1340 | public static final class Icmpv6CodeCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1341 | private static final short MASK = 0xff; |
| 1342 | private final short icmpv6Code; // ICMPv6 code: 8 bits |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1343 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1344 | /** |
| 1345 | * Constructor. |
| 1346 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1347 | * @param icmpv6Code the ICMPv6 code to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1348 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1349 | public Icmpv6CodeCriterion(short icmpv6Code) { |
| 1350 | this.icmpv6Code = (short) (icmpv6Code & MASK); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1351 | } |
| 1352 | |
| 1353 | @Override |
| 1354 | public Type type() { |
| 1355 | return Type.ICMPV6_CODE; |
| 1356 | } |
| 1357 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1358 | /** |
| 1359 | * Gets the ICMPv6 code to match. |
| 1360 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1361 | * @return the ICMPv6 code to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1362 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1363 | public short icmpv6Code() { |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1364 | return icmpv6Code; |
| 1365 | } |
| 1366 | |
| 1367 | @Override |
| 1368 | public String toString() { |
| 1369 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1370 | .add("icmpv6Code", icmpv6Code).toString(); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | @Override |
| 1374 | public int hashCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1375 | return Objects.hash(type(), icmpv6Code); |
Kunihiro Ishiguro | 0f9aba8 | 2015-01-15 17:14:17 -0800 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | @Override |
| 1379 | public boolean equals(Object obj) { |
| 1380 | if (this == obj) { |
| 1381 | return true; |
| 1382 | } |
| 1383 | if (obj instanceof Icmpv6CodeCriterion) { |
| 1384 | Icmpv6CodeCriterion that = (Icmpv6CodeCriterion) obj; |
| 1385 | return Objects.equals(icmpv6Code, that.icmpv6Code) && |
| 1386 | Objects.equals(this.type(), that.type()); |
| 1387 | } |
| 1388 | return false; |
| 1389 | } |
| 1390 | } |
| 1391 | |
| 1392 | /** |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1393 | * Implementation of IPv6 Neighbor Discovery target address criterion. |
| 1394 | */ |
| 1395 | public static final class IPv6NDTargetAddressCriterion |
| 1396 | implements Criterion { |
| 1397 | private final Ip6Address targetAddress; |
| 1398 | |
| 1399 | /** |
| 1400 | * Constructor. |
| 1401 | * |
| 1402 | * @param targetAddress the IPv6 target address to match |
| 1403 | */ |
| 1404 | public IPv6NDTargetAddressCriterion(Ip6Address targetAddress) { |
| 1405 | this.targetAddress = targetAddress; |
| 1406 | } |
| 1407 | |
| 1408 | @Override |
| 1409 | public Type type() { |
| 1410 | return Type.IPV6_ND_TARGET; |
| 1411 | } |
| 1412 | |
| 1413 | /** |
| 1414 | * Gets the IPv6 target address to match. |
| 1415 | * |
| 1416 | * @return the IPv6 target address to match |
| 1417 | */ |
| 1418 | public Ip6Address targetAddress() { |
| 1419 | return this.targetAddress; |
| 1420 | } |
| 1421 | |
| 1422 | @Override |
| 1423 | public String toString() { |
| 1424 | return toStringHelper(type().toString()) |
| 1425 | .add("targetAddress", targetAddress).toString(); |
| 1426 | } |
| 1427 | |
| 1428 | @Override |
| 1429 | public int hashCode() { |
| 1430 | return Objects.hash(type(), targetAddress); |
| 1431 | } |
| 1432 | |
| 1433 | @Override |
| 1434 | public boolean equals(Object obj) { |
| 1435 | if (this == obj) { |
| 1436 | return true; |
| 1437 | } |
| 1438 | if (obj instanceof IPv6NDTargetAddressCriterion) { |
| 1439 | IPv6NDTargetAddressCriterion that = |
| 1440 | (IPv6NDTargetAddressCriterion) obj; |
| 1441 | return Objects.equals(targetAddress, that.targetAddress) && |
| 1442 | Objects.equals(type(), that.type()); |
| 1443 | } |
| 1444 | return false; |
| 1445 | } |
| 1446 | } |
| 1447 | |
| 1448 | /** |
| 1449 | * Implementation of IPv6 Neighbor Discovery link-layer address criterion. |
| 1450 | */ |
| 1451 | public static final class IPv6NDLinkLayerAddressCriterion |
| 1452 | implements Criterion { |
| 1453 | private final MacAddress mac; |
| 1454 | private final Type type; |
| 1455 | |
| 1456 | /** |
| 1457 | * Constructor. |
| 1458 | * |
| 1459 | * @param mac the source or destination link-layer address to match |
| 1460 | * @param type the match type. Should be either Type.IPV6_ND_SLL or |
| 1461 | * Type.IPV6_ND_TLL |
| 1462 | */ |
| 1463 | public IPv6NDLinkLayerAddressCriterion(MacAddress mac, Type type) { |
| 1464 | this.mac = mac; |
| 1465 | this.type = type; |
| 1466 | } |
| 1467 | |
| 1468 | @Override |
| 1469 | public Type type() { |
| 1470 | return this.type; |
| 1471 | } |
| 1472 | |
| 1473 | /** |
| 1474 | * Gets the MAC link-layer address to match. |
| 1475 | * |
| 1476 | * @return the MAC link-layer address to match |
| 1477 | */ |
| 1478 | public MacAddress mac() { |
| 1479 | return this.mac; |
| 1480 | } |
| 1481 | |
| 1482 | @Override |
| 1483 | public String toString() { |
| 1484 | return toStringHelper(type().toString()) |
| 1485 | .add("mac", mac).toString(); |
| 1486 | } |
| 1487 | |
| 1488 | @Override |
| 1489 | public int hashCode() { |
| 1490 | return Objects.hash(type, mac); |
| 1491 | } |
| 1492 | |
| 1493 | @Override |
| 1494 | public boolean equals(Object obj) { |
| 1495 | if (this == obj) { |
| 1496 | return true; |
| 1497 | } |
| 1498 | if (obj instanceof IPv6NDLinkLayerAddressCriterion) { |
| 1499 | IPv6NDLinkLayerAddressCriterion that = |
| 1500 | (IPv6NDLinkLayerAddressCriterion) obj; |
| 1501 | return Objects.equals(mac, that.mac) && |
| 1502 | Objects.equals(type, that.type); |
| 1503 | } |
| 1504 | return false; |
| 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1509 | * Implementation of MPLS tag criterion (20 bits). |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1510 | */ |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1511 | public static final class MplsCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1512 | private static final int MASK = 0xfffff; |
| 1513 | private final int mplsLabel; // MPLS label: 20 bits |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1514 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1515 | /** |
| 1516 | * Constructor. |
| 1517 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1518 | * @param mplsLabel the MPLS label to match (20 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1519 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1520 | public MplsCriterion(int mplsLabel) { |
| 1521 | this.mplsLabel = mplsLabel & MASK; |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1522 | } |
| 1523 | |
| 1524 | @Override |
| 1525 | public Type type() { |
| 1526 | return Type.MPLS_LABEL; |
| 1527 | } |
| 1528 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1529 | /** |
| 1530 | * Gets the MPLS label to match. |
| 1531 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1532 | * @return the MPLS label to match (20 bits) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1533 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1534 | public int label() { |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1535 | return mplsLabel; |
| 1536 | } |
| 1537 | |
| 1538 | @Override |
| 1539 | public String toString() { |
| 1540 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1541 | .add("label", Long.toHexString(mplsLabel)).toString(); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1542 | } |
| 1543 | |
| 1544 | @Override |
| 1545 | public int hashCode() { |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1546 | return Objects.hash(type(), mplsLabel); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1547 | } |
| 1548 | |
| 1549 | @Override |
| 1550 | public boolean equals(Object obj) { |
| 1551 | if (this == obj) { |
| 1552 | return true; |
| 1553 | } |
| 1554 | if (obj instanceof MplsCriterion) { |
| 1555 | MplsCriterion that = (MplsCriterion) obj; |
| 1556 | return Objects.equals(mplsLabel, that.mplsLabel) && |
| 1557 | Objects.equals(this.type(), that.type()); |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1558 | } |
| 1559 | return false; |
| 1560 | } |
Praseed Balakrishnan | 8c67d17 | 2014-11-10 10:15:41 -0800 | [diff] [blame] | 1561 | } |
| 1562 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1563 | /** |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1564 | * Implementation of IPv6 Extension Header pseudo-field criterion |
| 1565 | * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags. |
| 1566 | */ |
| 1567 | public static final class IPv6ExthdrFlagsCriterion implements Criterion { |
| 1568 | private static final int MASK = 0xffff; |
| 1569 | private final int exthdrFlags; // IPv6 Exthdr flags: 16 bits |
| 1570 | |
| 1571 | /** |
| 1572 | * Constructor. |
| 1573 | * |
| 1574 | * @param exthdrFlags the IPv6 Extension Header pseudo-field flags |
| 1575 | * to match (16 bits). Those are defined in Criterion.IPv6ExthdrFlags |
| 1576 | */ |
| 1577 | public IPv6ExthdrFlagsCriterion(int exthdrFlags) { |
| 1578 | this.exthdrFlags = exthdrFlags & MASK; |
| 1579 | } |
| 1580 | |
| 1581 | @Override |
| 1582 | public Type type() { |
| 1583 | return Type.IPV6_EXTHDR; |
| 1584 | } |
| 1585 | |
| 1586 | /** |
| 1587 | * Gets the IPv6 Extension Header pseudo-field flags to match. |
| 1588 | * |
| 1589 | * @return the IPv6 Extension Header pseudo-field flags to match |
| 1590 | * (16 bits). Those are defined in Criterion.IPv6ExthdrFlags |
| 1591 | */ |
| 1592 | public int exthdrFlags() { |
| 1593 | return exthdrFlags; |
| 1594 | } |
| 1595 | |
| 1596 | @Override |
| 1597 | public String toString() { |
| 1598 | return toStringHelper(type().toString()) |
| 1599 | .add("exthdrFlags", Long.toHexString(exthdrFlags)).toString(); |
| 1600 | } |
| 1601 | |
| 1602 | @Override |
| 1603 | public int hashCode() { |
| 1604 | return Objects.hash(type(), exthdrFlags); |
| 1605 | } |
| 1606 | |
| 1607 | @Override |
| 1608 | public boolean equals(Object obj) { |
| 1609 | if (this == obj) { |
| 1610 | return true; |
| 1611 | } |
| 1612 | if (obj instanceof IPv6ExthdrFlagsCriterion) { |
| 1613 | IPv6ExthdrFlagsCriterion that = (IPv6ExthdrFlagsCriterion) obj; |
| 1614 | return Objects.equals(exthdrFlags, that.exthdrFlags) && |
| 1615 | Objects.equals(this.type(), that.type()); |
| 1616 | } |
| 1617 | return false; |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | /** |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1622 | * Implementation of lambda (wavelength) criterion (16 bits unsigned |
| 1623 | * integer). |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1624 | */ |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1625 | public static final class LambdaCriterion implements Criterion { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1626 | private static final int MASK = 0xffff; |
| 1627 | private final int lambda; // Lambda value: 16 bits |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1628 | private final Type type; |
| 1629 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1630 | /** |
| 1631 | * Constructor. |
| 1632 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1633 | * @param lambda the lambda (wavelength) to match (16 bits unsigned |
| 1634 | * integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1635 | * @param type the match type. Should be Type.OCH_SIGID |
| 1636 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1637 | public LambdaCriterion(int lambda, Type type) { |
| 1638 | this.lambda = lambda & MASK; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1639 | this.type = type; |
| 1640 | } |
| 1641 | |
| 1642 | @Override |
| 1643 | public Type type() { |
| 1644 | return this.type; |
| 1645 | } |
| 1646 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1647 | /** |
| 1648 | * Gets the lambda (wavelength) to match. |
| 1649 | * |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1650 | * @return the lambda (wavelength) to match (16 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1651 | */ |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1652 | public int lambda() { |
| 1653 | return lambda; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | @Override |
| 1657 | public String toString() { |
| 1658 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1659 | .add("lambda", lambda).toString(); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | @Override |
| 1663 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 1664 | return Objects.hash(type, lambda); |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 1665 | } |
| 1666 | |
| 1667 | @Override |
| 1668 | public boolean equals(Object obj) { |
| 1669 | if (this == obj) { |
| 1670 | return true; |
| 1671 | } |
| 1672 | if (obj instanceof LambdaCriterion) { |
| 1673 | LambdaCriterion that = (LambdaCriterion) obj; |
| 1674 | return Objects.equals(lambda, that.lambda) && |
| 1675 | Objects.equals(type, that.type); |
| 1676 | } |
| 1677 | return false; |
| 1678 | } |
| 1679 | } |
| 1680 | |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1681 | /** |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1682 | * Implementation of optical signal type criterion (8 bits unsigned |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1683 | * integer). |
Sho SHIMIZU | 06596e3 | 2014-12-02 18:07:50 -0800 | [diff] [blame] | 1684 | */ |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1685 | public static final class OpticalSignalTypeCriterion implements Criterion { |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1686 | private static final short MASK = 0xff; |
| 1687 | private final short signalType; // Signal type value: 8 bits |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1688 | private final Type type; |
| 1689 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1690 | /** |
| 1691 | * Constructor. |
| 1692 | * |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1693 | * @param signalType the optical signal type to match (8 bits unsigned |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1694 | * integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1695 | * @param type the match type. Should be Type.OCH_SIGTYPE |
| 1696 | */ |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1697 | public OpticalSignalTypeCriterion(short signalType, Type type) { |
| 1698 | this.signalType = (short) (signalType & MASK); |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1699 | this.type = type; |
| 1700 | } |
| 1701 | |
| 1702 | @Override |
| 1703 | public Type type() { |
| 1704 | return this.type; |
| 1705 | } |
| 1706 | |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1707 | /** |
| 1708 | * Gets the optical signal type to match. |
| 1709 | * |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1710 | * @return the optical signal type to match (8 bits unsigned integer) |
Pavlin Radoslavov | 320e6c9 | 2015-02-02 16:51:58 -0800 | [diff] [blame] | 1711 | */ |
Pavlin Radoslavov | 5e4f754 | 2015-02-06 18:18:21 -0800 | [diff] [blame^] | 1712 | public short signalType() { |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1713 | return signalType; |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1714 | } |
| 1715 | |
| 1716 | @Override |
| 1717 | public String toString() { |
| 1718 | return toStringHelper(type().toString()) |
Pavlin Radoslavov | f3b6933 | 2015-02-06 15:47:05 -0800 | [diff] [blame] | 1719 | .add("signalType", signalType).toString(); |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1720 | } |
| 1721 | |
| 1722 | @Override |
| 1723 | public int hashCode() { |
Thomas Vachuska | 9b2da21 | 2014-11-10 19:30:25 -0800 | [diff] [blame] | 1724 | return Objects.hash(type, signalType); |
Praseed Balakrishnan | 64369da | 2014-10-23 15:55:20 -0700 | [diff] [blame] | 1725 | } |
| 1726 | |
| 1727 | @Override |
| 1728 | public boolean equals(Object obj) { |
| 1729 | if (this == obj) { |
| 1730 | return true; |
| 1731 | } |
| 1732 | if (obj instanceof OpticalSignalTypeCriterion) { |
| 1733 | OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj; |
| 1734 | return Objects.equals(signalType, that.signalType) && |
| 1735 | Objects.equals(type, that.type); |
| 1736 | } |
| 1737 | return false; |
| 1738 | } |
| 1739 | } |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 1740 | } |