Jonathan Hart | 23701d1 | 2014-04-03 10:45:48 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.util; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 2 | |
| 3 | import net.floodlightcontroller.util.MACAddress; |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 4 | |
| 5 | import org.codehaus.jackson.annotate.JsonProperty; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 6 | |
| 7 | /** |
| 8 | * The class representing the Flow Entry Matching filter. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 9 | * <p/> |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 10 | * The Flow Entry matching filter that is used to specify |
| 11 | * the network data that would be forwarded on the data path from |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 12 | * the source to the destination. Examples: source or destination MAC address, |
| 13 | * IP prefix that includes the destination's IP address, etc. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 14 | */ |
| 15 | public class FlowEntryMatch { |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 16 | /** |
| 17 | * A class for storing a value to match. |
| 18 | */ |
Pavlin Radoslavov | a2d35f1 | 2013-10-17 16:46:39 -0700 | [diff] [blame] | 19 | public static class Field<T> { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 20 | /** |
| 21 | * Default constructor. |
| 22 | */ |
| 23 | public Field() { |
| 24 | this.enabled = false; |
| 25 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 26 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 27 | /** |
| 28 | * Constructor for a given value to match. |
| 29 | * |
| 30 | * @param value the value to match. |
| 31 | */ |
| 32 | public Field(T value) { |
| 33 | this.value = value; |
| 34 | this.enabled = true; |
| 35 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 36 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 37 | /** |
| 38 | * Get the value. |
| 39 | * |
| 40 | * @return the value. |
| 41 | */ |
| 42 | public T value() { |
| 43 | return this.value; |
| 44 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 45 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Enable the matching for a given value. |
| 48 | * |
| 49 | * @param value the value to set. |
| 50 | */ |
| 51 | public void enableMatch(T value) { |
| 52 | this.value = value; |
| 53 | this.enabled = true; |
| 54 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 55 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Disable the matching. |
| 58 | */ |
| 59 | public void disableMatch() { |
| 60 | this.enabled = false; |
| 61 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 62 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Test whether matching is enabled. |
| 65 | * |
| 66 | * @return true if matching is enabled, otherwise false. |
| 67 | */ |
| 68 | public boolean enabled() { |
| 69 | return this.enabled; |
| 70 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 71 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 72 | private T value; // The value to match |
| 73 | private boolean enabled; // Set to true, if matching is enabled |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 74 | } |
| 75 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 76 | private Field<Port> inPort; // Matching input switch port |
| 77 | private Field<MACAddress> srcMac; // Matching source MAC address |
| 78 | private Field<MACAddress> dstMac; // Matching destination MAC address |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 79 | private Field<Short> ethernetFrameType; // Matching Ethernet frame type |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 80 | private Field<Short> vlanId; // Matching VLAN ID |
| 81 | private Field<Byte> vlanPriority; // Matching VLAN priority |
| 82 | private Field<IPv4Net> srcIPv4Net; // Matching source IPv4 prefix |
| 83 | private Field<IPv4Net> dstIPv4Net; // Matching destination IPv4 prefix |
| 84 | private Field<Byte> ipProto; // Matching IP protocol |
| 85 | private Field<Byte> ipToS; // Matching IP ToS (DSCP field, 6 bits) |
| 86 | private Field<Short> srcTcpUdpPort; // Matching source TCP/UDP port |
| 87 | private Field<Short> dstTcpUdpPort; // Matching destination TCP/UDP port |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * Default constructor. |
| 91 | */ |
| 92 | public FlowEntryMatch() { |
| 93 | } |
| 94 | |
| 95 | /** |
Pavlin Radoslavov | b9fe6b4 | 2013-03-27 16:25:05 -0700 | [diff] [blame] | 96 | * Copy constructor. |
| 97 | * |
| 98 | * @param other the object to copy from. |
| 99 | */ |
| 100 | public FlowEntryMatch(FlowEntryMatch other) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 101 | if ((other.inPort != null) && other.inPort.enabled()) |
| 102 | this.enableInPort(other.inPort.value()); |
| 103 | if ((other.srcMac != null) && other.srcMac.enabled()) |
| 104 | this.enableSrcMac(other.srcMac.value()); |
| 105 | if ((other.dstMac != null) && other.dstMac.enabled()) |
| 106 | this.enableDstMac(other.dstMac.value()); |
| 107 | if ((other.ethernetFrameType != null) && other.ethernetFrameType.enabled()) |
| 108 | this.enableEthernetFrameType(other.ethernetFrameType.value()); |
| 109 | if ((other.vlanId != null) && other.vlanId.enabled()) |
| 110 | this.enableVlanId(other.vlanId.value()); |
| 111 | if ((other.vlanPriority != null) && other.vlanPriority.enabled()) |
| 112 | this.enableVlanPriority(other.vlanPriority.value()); |
| 113 | if ((other.srcIPv4Net != null) && other.srcIPv4Net.enabled()) |
| 114 | this.enableSrcIPv4Net(other.srcIPv4Net.value()); |
| 115 | if ((other.dstIPv4Net != null) && other.dstIPv4Net.enabled()) |
| 116 | this.enableDstIPv4Net(other.dstIPv4Net.value()); |
| 117 | if ((other.ipProto != null) && other.ipProto.enabled()) |
| 118 | this.enableIpProto(other.ipProto.value()); |
| 119 | if ((other.ipToS != null) && other.ipToS.enabled()) |
| 120 | this.enableIpToS(other.ipToS.value()); |
| 121 | if ((other.srcTcpUdpPort != null) && other.srcTcpUdpPort.enabled()) |
| 122 | this.enableSrcTcpUdpPort(other.srcTcpUdpPort.value()); |
| 123 | if ((other.dstTcpUdpPort != null) && other.dstTcpUdpPort.enabled()) |
| 124 | this.enableDstTcpUdpPort(other.dstTcpUdpPort.value()); |
Pavlin Radoslavov | b9fe6b4 | 2013-03-27 16:25:05 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 128 | * Get the matching input switch port. |
| 129 | * |
| 130 | * @return the matching input switch port. |
| 131 | */ |
| 132 | @JsonProperty("inPort") |
| 133 | public Port inPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 134 | if (inPort != null) |
| 135 | return inPort.value(); |
| 136 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Enable the matching on input switch port. |
| 141 | * |
| 142 | * @param inPort the input switch port value to enable for matching. |
| 143 | */ |
| 144 | @JsonProperty("inPort") |
| 145 | public void enableInPort(Port inPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 146 | this.inPort = new Field<Port>(inPort); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | /** |
| 150 | * Disable the matching on input switch port. |
| 151 | */ |
| 152 | public void disableInPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 153 | this.inPort = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Test if matching on input switch port is enabled. |
| 158 | * |
| 159 | * @return true if matching on input switch port is enabled. |
| 160 | */ |
| 161 | @JsonProperty("matchInPort") |
| 162 | public boolean matchInPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 163 | if (inPort != null) |
| 164 | return inPort.enabled(); |
| 165 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 169 | * Get the matching source MAC address. |
| 170 | * |
| 171 | * @return the matching source MAC address. |
| 172 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 173 | @JsonProperty("srcMac") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 174 | public MACAddress srcMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 175 | if (srcMac != null) |
| 176 | return srcMac.value(); |
| 177 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 178 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 179 | |
| 180 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 181 | * Enable the matching on source MAC address. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 182 | * |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 183 | * @param srcMac the source MAC address value to enable for matching. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 184 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 185 | @JsonProperty("srcMac") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 186 | public void enableSrcMac(MACAddress srcMac) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 187 | this.srcMac = new Field<MACAddress>(srcMac); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Disable the matching on source MAC address. |
| 192 | */ |
| 193 | public void disableSrcMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 194 | this.srcMac = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | /** |
| 198 | * Test if matching on source MAC address is enabled. |
| 199 | * |
| 200 | * @return true if matching on source MAC address is enabled. |
| 201 | */ |
| 202 | @JsonProperty("matchSrcMac") |
| 203 | public boolean matchSrcMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 204 | if (srcMac != null) |
| 205 | return srcMac.enabled(); |
| 206 | return false; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | /** |
| 210 | * Get the matching destination MAC address. |
| 211 | * |
| 212 | * @return the matching destination MAC address. |
| 213 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 214 | @JsonProperty("dstMac") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 215 | public MACAddress dstMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 216 | if (dstMac != null) |
| 217 | return dstMac.value(); |
| 218 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 219 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 220 | |
| 221 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 222 | * Enable the matching on destination MAC address. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 223 | * |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 224 | * @param dstMac the destination MAC address value to enable for matching. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 225 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 226 | @JsonProperty("dstMac") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 227 | public void enableDstMac(MACAddress dstMac) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 228 | this.dstMac = new Field<MACAddress>(dstMac); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Disable the matching on destination MAC address. |
| 233 | */ |
| 234 | public void disableDstMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 235 | this.dstMac = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | /** |
| 239 | * Test if matching on destination MAC address is enabled. |
| 240 | * |
| 241 | * @return true if matching on destination MAC address is enabled. |
| 242 | */ |
| 243 | @JsonProperty("matchDstMac") |
| 244 | public boolean matchDstMac() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 245 | if (dstMac != null) |
| 246 | return dstMac.enabled(); |
| 247 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | /** |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 251 | * Get the matching Ethernet frame type. |
| 252 | * |
| 253 | * @return the matching Ethernet frame type. |
| 254 | */ |
| 255 | @JsonProperty("ethernetFrameType") |
| 256 | public Short ethernetFrameType() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 257 | if (ethernetFrameType != null) |
| 258 | return ethernetFrameType.value(); |
| 259 | return null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | /** |
| 263 | * Enable the matching on Ethernet frame type. |
| 264 | * |
| 265 | * @param ethernetFrameType the Ethernet frame type value to enable for |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 266 | * matching. |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 267 | */ |
| 268 | @JsonProperty("ethernetFrameType") |
| 269 | public void enableEthernetFrameType(Short ethernetFrameType) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 270 | this.ethernetFrameType = new Field<Short>(ethernetFrameType); |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Disable the matching on Ethernet frame type. |
| 275 | */ |
| 276 | public void disableEthernetFrameType() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 277 | this.ethernetFrameType = null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 278 | } |
| 279 | |
| 280 | /** |
| 281 | * Test if matching on Ethernet frame type is enabled. |
| 282 | * |
| 283 | * @return true if matching on Ethernet frame type is enabled. |
| 284 | */ |
| 285 | @JsonProperty("matchEthernetFrameType") |
| 286 | public boolean matchEthernetFrameType() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 287 | if (ethernetFrameType != null) |
| 288 | return ethernetFrameType.enabled(); |
| 289 | return false; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 293 | * Get the matching VLAN ID. |
| 294 | * |
| 295 | * @return the matching VLAN ID. |
| 296 | */ |
| 297 | @JsonProperty("vlanId") |
| 298 | public Short vlanId() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 299 | if (vlanId != null) |
| 300 | return vlanId.value(); |
| 301 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Enable the matching on VLAN ID. |
| 306 | * |
| 307 | * @param vlanId the VLAN ID value to enable for matching. |
| 308 | */ |
| 309 | @JsonProperty("vlanId") |
| 310 | public void enableVlanId(Short vlanId) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 311 | this.vlanId = new Field<Short>(vlanId); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Disable the matching on VLAN ID. |
| 316 | */ |
| 317 | public void disableVlanId() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 318 | this.vlanId = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Test if matching on VLAN ID is enabled. |
| 323 | * |
| 324 | * @return true if matching on VLAN ID is enabled. |
| 325 | */ |
| 326 | @JsonProperty("matchVlanId") |
| 327 | public boolean matchVlanId() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 328 | if (vlanId != null) |
| 329 | return vlanId.enabled(); |
| 330 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | /** |
| 334 | * Get the matching VLAN priority. |
| 335 | * |
| 336 | * @return the matching VLAN priority. |
| 337 | */ |
| 338 | @JsonProperty("vlanPriority") |
| 339 | public Byte vlanPriority() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 340 | if (vlanPriority != null) |
| 341 | return vlanPriority.value(); |
| 342 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Enable the matching on VLAN priority. |
| 347 | * |
| 348 | * @param vlanPriority the VLAN priority value to enable for matching. |
| 349 | */ |
| 350 | @JsonProperty("vlanPriority") |
| 351 | public void enableVlanPriority(Byte vlanPriority) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 352 | this.vlanPriority = new Field<Byte>(vlanPriority); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | /** |
| 356 | * Disable the matching on VLAN priority. |
| 357 | */ |
| 358 | public void disableVlanPriority() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 359 | this.vlanPriority = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | /** |
| 363 | * Test if matching on VLAN priority is enabled. |
| 364 | * |
| 365 | * @return true if matching on VLAN priority is enabled. |
| 366 | */ |
| 367 | @JsonProperty("matchVlanPriority") |
| 368 | public boolean matchVlanPriority() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 369 | if (vlanPriority != null) |
| 370 | return vlanPriority.enabled(); |
| 371 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 372 | } |
| 373 | |
| 374 | /** |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 375 | * Get the matching source IPv4 prefix. |
| 376 | * |
| 377 | * @return the matching source IPv4 prefix. |
| 378 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 379 | @JsonProperty("srcIPv4Net") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 380 | public IPv4Net srcIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 381 | if (srcIPv4Net != null) |
| 382 | return srcIPv4Net.value(); |
| 383 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 384 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 385 | |
| 386 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 387 | * Enable the matching on source IPv4 prefix. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 388 | * |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 389 | * @param srcIPv4Net the source IPv4 prefix value to enable for matching. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 390 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 391 | @JsonProperty("srcIPv4Net") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 392 | public void enableSrcIPv4Net(IPv4Net srcIPv4Net) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 393 | this.srcIPv4Net = new Field<IPv4Net>(srcIPv4Net); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Disable the matching on source IPv4 prefix. |
| 398 | */ |
| 399 | public void disableSrcIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 400 | this.srcIPv4Net = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /** |
| 404 | * Test if matching on source IPv4 prefix is enabled. |
| 405 | * |
| 406 | * @return true if matching on source IPv4 prefix is enabled. |
| 407 | */ |
| 408 | @JsonProperty("matchSrcIPv4Net") |
| 409 | public boolean matchSrcIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 410 | if (srcIPv4Net != null) |
| 411 | return srcIPv4Net.enabled(); |
| 412 | return false; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | /** |
| 416 | * Get the matching destination IPv4 prefix. |
| 417 | * |
| 418 | * @return the matching destination IPv4 prefix. |
| 419 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 420 | @JsonProperty("dstIPv4Net") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 421 | public IPv4Net dstIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 422 | if (dstIPv4Net != null) |
| 423 | return dstIPv4Net.value(); |
| 424 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 425 | } |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 426 | |
| 427 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 428 | * Enable the matching on destination IPv4 prefix. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 429 | * |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 430 | * @param dstIPv4Net the destination IPv4 prefix value to enable for |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 431 | * matching. |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 432 | */ |
Pavlin Radoslavov | 2013cbb | 2013-02-26 10:15:18 -0800 | [diff] [blame] | 433 | @JsonProperty("dstIPv4Net") |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 434 | public void enableDstIPv4Net(IPv4Net dstIPv4Net) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 435 | this.dstIPv4Net = new Field<IPv4Net>(dstIPv4Net); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | /** |
| 439 | * Disable the matching on destination IPv4 prefix. |
| 440 | */ |
| 441 | public void disableDstIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 442 | this.dstIPv4Net = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Test if matching on destination IPv4 prefix is enabled. |
| 447 | * |
| 448 | * @return true if matching on destination IPv4 prefix is enabled. |
| 449 | */ |
| 450 | @JsonProperty("matchDstIPv4Net") |
| 451 | public boolean matchDstIPv4Net() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 452 | if (dstIPv4Net != null) |
| 453 | return dstIPv4Net.enabled(); |
| 454 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | /** |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 458 | * Get the matching IP protocol. |
| 459 | * |
| 460 | * @return the matching IP protocol. |
| 461 | */ |
| 462 | @JsonProperty("ipProto") |
| 463 | public Byte ipProto() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 464 | if (ipProto != null) |
| 465 | return ipProto.value(); |
| 466 | return null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 467 | } |
| 468 | |
| 469 | /** |
| 470 | * Enable the matching on IP protocol. |
| 471 | * |
| 472 | * @param ipProto the IP protocol value to enable for matching. |
| 473 | */ |
| 474 | @JsonProperty("ipProto") |
| 475 | public void enableIpProto(Byte ipProto) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 476 | this.ipProto = new Field<Byte>(ipProto); |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 477 | } |
| 478 | |
| 479 | /** |
| 480 | * Disable the matching on IP protocol. |
| 481 | */ |
| 482 | public void disableIpProto() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 483 | this.ipProto = null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | /** |
| 487 | * Test if matching on IP protocol is enabled. |
| 488 | * |
| 489 | * @return true if matching on IP protocol is enabled. |
| 490 | */ |
| 491 | @JsonProperty("matchIpProto") |
| 492 | public boolean matchIpProto() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 493 | if (ipProto != null) |
| 494 | return ipProto.enabled(); |
| 495 | return false; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 496 | } |
| 497 | |
| 498 | /** |
| 499 | * Get the matching IP ToS (DSCP field, 6 bits) |
| 500 | * |
| 501 | * @return the matching IP ToS. |
| 502 | */ |
| 503 | @JsonProperty("ipToS") |
| 504 | public Byte ipToS() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 505 | if (ipToS != null) |
| 506 | return ipToS.value(); |
| 507 | return null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | /** |
| 511 | * Enable the matching on IP ToS (DSCP field, 6 bits). |
| 512 | * |
| 513 | * @param ipToS the IP ToS value to enable for matching. |
| 514 | */ |
| 515 | @JsonProperty("ipToS") |
| 516 | public void enableIpToS(Byte ipToS) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 517 | this.ipToS = new Field<Byte>(ipToS); |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | /** |
| 521 | * Disable the matching on IP ToS (DSCP field, 6 bits). |
| 522 | */ |
| 523 | public void disableIpToS() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 524 | this.ipToS = null; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Test if matching on IP ToS (DSCP field, 6 bits) is enabled. |
| 529 | * |
| 530 | * @return true if matching on IP ToS is enabled. |
| 531 | */ |
| 532 | @JsonProperty("matchIpToS") |
| 533 | public boolean matchIpToS() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 534 | if (ipToS != null) |
| 535 | return ipToS.enabled(); |
| 536 | return false; |
Pavlin Radoslavov | ad3a1e6 | 2013-07-09 13:30:16 -0700 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | /** |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 540 | * Get the matching source TCP/UDP port. |
| 541 | * |
| 542 | * @return the matching source TCP/UDP port. |
| 543 | */ |
| 544 | @JsonProperty("srcTcpUdpPort") |
| 545 | public Short srcTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 546 | if (srcTcpUdpPort != null) |
| 547 | return srcTcpUdpPort.value(); |
| 548 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Enable the matching on source TCP/UDP port. |
| 553 | * |
| 554 | * @param srcTcpUdpPort the source TCP/UDP port to enable for matching. |
| 555 | */ |
| 556 | @JsonProperty("srcTcpUdpPort") |
| 557 | public void enableSrcTcpUdpPort(Short srcTcpUdpPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 558 | this.srcTcpUdpPort = new Field<Short>(srcTcpUdpPort); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | /** |
| 562 | * Disable the matching on source TCP/UDP port. |
| 563 | */ |
| 564 | public void disableSrcTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 565 | this.srcTcpUdpPort = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | /** |
| 569 | * Test if matching on source TCP/UDP port is enabled. |
| 570 | * |
| 571 | * @return true if matching on source TCP/UDP port is enabled. |
| 572 | */ |
| 573 | @JsonProperty("matchSrcTcpUdpPort") |
| 574 | public boolean matchSrcTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 575 | if (srcTcpUdpPort != null) |
| 576 | return srcTcpUdpPort.enabled(); |
| 577 | return false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | /** |
| 581 | * Get the matching destination TCP/UDP port. |
| 582 | * |
| 583 | * @return the matching destination TCP/UDP port. |
| 584 | */ |
| 585 | @JsonProperty("dstTcpUdpPort") |
| 586 | public Short dstTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 587 | if (dstTcpUdpPort != null) |
| 588 | return dstTcpUdpPort.value(); |
| 589 | return null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | /** |
| 593 | * Enable the matching on destination TCP/UDP port. |
| 594 | * |
| 595 | * @param dstTcpUdpPort the destination TCP/UDP port to enable for |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 596 | * matching. |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 597 | */ |
| 598 | @JsonProperty("dstTcpUdpPort") |
| 599 | public void enableDstTcpUdpPort(Short dstTcpUdpPort) { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 600 | this.dstTcpUdpPort = new Field<Short>(dstTcpUdpPort); |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | /** |
| 604 | * Disable the matching on destination TCP/UDP port. |
| 605 | */ |
| 606 | public void disableDstTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 607 | this.dstTcpUdpPort = null; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Test if matching on destination TCP/UDP port is enabled. |
| 612 | * |
| 613 | * @return true if matching on destination TCP/UDP port is enabled. |
| 614 | */ |
| 615 | @JsonProperty("matchDstTcpUdpPort") |
| 616 | public boolean matchDstTcpUdpPort() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 617 | if (dstTcpUdpPort != null) |
| 618 | return dstTcpUdpPort.enabled(); |
| 619 | return false; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 620 | } |
| 621 | |
| 622 | /** |
| 623 | * Convert the matching filter to a string. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 624 | * <p/> |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 625 | * The string has the following form: |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 626 | * [srcMac=XXX dstMac=XXX srcIPv4Net=XXX dstIPv4Net=XXX] |
Pavlin Radoslavov | ad008e0 | 2013-02-21 18:42:42 -0800 | [diff] [blame] | 627 | * |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 628 | * @return the matching filter as a string. |
| 629 | */ |
| 630 | @Override |
| 631 | public String toString() { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 632 | String ret = "["; |
| 633 | boolean addSpace = false; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 634 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 635 | // |
| 636 | // Conditionally add only those matching fields that are enabled |
| 637 | // |
| 638 | if (matchInPort()) { |
| 639 | if (addSpace) |
| 640 | ret += " "; |
| 641 | addSpace = true; |
| 642 | ret += "inPort=" + this.inPort().toString(); |
| 643 | } |
| 644 | if (matchSrcMac()) { |
| 645 | if (addSpace) |
| 646 | ret += " "; |
| 647 | addSpace = true; |
| 648 | ret += "srcMac=" + this.srcMac().toString(); |
| 649 | } |
| 650 | if (matchDstMac()) { |
| 651 | if (addSpace) |
| 652 | ret += " "; |
| 653 | addSpace = true; |
| 654 | ret += "dstMac=" + this.dstMac().toString(); |
| 655 | } |
| 656 | if (matchEthernetFrameType()) { |
| 657 | if (addSpace) |
| 658 | ret += " "; |
| 659 | addSpace = true; |
| 660 | ret += "ethernetFrameType=" + this.ethernetFrameType().toString(); |
| 661 | } |
| 662 | if (matchVlanId()) { |
| 663 | if (addSpace) |
| 664 | ret += " "; |
| 665 | addSpace = true; |
| 666 | ret += "vlanId=" + this.vlanId().toString(); |
| 667 | } |
| 668 | if (matchVlanPriority()) { |
| 669 | if (addSpace) |
| 670 | ret += " "; |
| 671 | addSpace = true; |
| 672 | ret += "vlanPriority=" + this.vlanPriority().toString(); |
| 673 | } |
| 674 | if (matchSrcIPv4Net()) { |
| 675 | if (addSpace) |
| 676 | ret += " "; |
| 677 | addSpace = true; |
| 678 | ret += "srcIPv4Net=" + this.srcIPv4Net().toString(); |
| 679 | } |
| 680 | if (matchDstIPv4Net()) { |
| 681 | if (addSpace) |
| 682 | ret += " "; |
| 683 | addSpace = true; |
| 684 | ret += "dstIPv4Net=" + this.dstIPv4Net().toString(); |
| 685 | } |
| 686 | if (matchIpProto()) { |
| 687 | if (addSpace) |
| 688 | ret += " "; |
| 689 | addSpace = true; |
| 690 | ret += "ipProto=" + this.ipProto().toString(); |
| 691 | } |
| 692 | if (matchIpToS()) { |
| 693 | if (addSpace) |
| 694 | ret += " "; |
| 695 | addSpace = true; |
| 696 | ret += "ipToS=" + this.ipToS().toString(); |
| 697 | } |
| 698 | if (matchSrcTcpUdpPort()) { |
| 699 | if (addSpace) |
| 700 | ret += " "; |
| 701 | addSpace = true; |
| 702 | ret += "srcTcpUdpPort=" + this.srcTcpUdpPort().toString(); |
| 703 | } |
| 704 | if (matchDstTcpUdpPort()) { |
| 705 | if (addSpace) |
| 706 | ret += " "; |
| 707 | addSpace = true; |
| 708 | ret += "dstTcpUdpPort=" + this.dstTcpUdpPort().toString(); |
| 709 | } |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 710 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 711 | ret += "]"; |
Pavlin Radoslavov | ede9758 | 2013-03-08 18:57:28 -0800 | [diff] [blame] | 712 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 713 | return ret; |
Pavlin Radoslavov | 5363c2a | 2013-02-18 09:55:42 -0800 | [diff] [blame] | 714 | } |
| 715 | } |