tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 1 | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University |
| 2 | // Copyright (c) 2011, 2012 Open Networking Foundation |
| 3 | // Copyright (c) 2012, 2013 Big Switch Networks, Inc. |
| 4 | // This library was generated by the LoxiGen Compiler. |
| 5 | // See the file LICENSE.txt which should have been included in the source distribution |
| 6 | |
| 7 | // Automatically generated by LOXI from template of_class.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver12; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | import java.util.Set; |
| 29 | import org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import com.google.common.hash.PrimitiveSink; |
| 31 | import com.google.common.hash.Funnel; |
| 32 | |
| 33 | class OFOxmArpThaMaskedVer12 implements OFOxmArpThaMasked { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFOxmArpThaMaskedVer12.class); |
| 35 | // version: 1.2 |
| 36 | final static byte WIRE_VERSION = 3; |
| 37 | final static int LENGTH = 16; |
| 38 | |
| 39 | private final static MacAddress DEFAULT_VALUE = MacAddress.NONE; |
| 40 | private final static MacAddress DEFAULT_VALUE_MASK = MacAddress.NONE; |
| 41 | |
| 42 | // OF message fields |
| 43 | private final MacAddress value; |
| 44 | private final MacAddress mask; |
| 45 | // |
| 46 | // Immutable default instance |
| 47 | final static OFOxmArpThaMaskedVer12 DEFAULT = new OFOxmArpThaMaskedVer12( |
| 48 | DEFAULT_VALUE, DEFAULT_VALUE_MASK |
| 49 | ); |
| 50 | |
| 51 | // package private constructor - used by readers, builders, and factory |
| 52 | OFOxmArpThaMaskedVer12(MacAddress value, MacAddress mask) { |
| 53 | this.value = value; |
| 54 | this.mask = mask; |
| 55 | } |
| 56 | |
| 57 | // Accessors for OF message fields |
| 58 | @Override |
| 59 | public long getTypeLen() { |
| 60 | return 0x8000330cL; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public MacAddress getValue() { |
| 65 | return value; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public MacAddress getMask() { |
| 70 | return mask; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public MatchField<MacAddress> getMatchField() { |
| 75 | return MatchField.ARP_THA; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public boolean isMasked() { |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | public OFOxm<MacAddress> getCanonical() { |
| 84 | if (MacAddress.NO_MASK.equals(mask)) { |
| 85 | return new OFOxmArpThaVer12(value); |
| 86 | } else if(MacAddress.FULL_MASK.equals(mask)) { |
| 87 | return null; |
| 88 | } else { |
| 89 | return this; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public OFVersion getVersion() { |
| 95 | return OFVersion.OF_12; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | |
| 100 | public OFOxmArpThaMasked.Builder createBuilder() { |
| 101 | return new BuilderWithParent(this); |
| 102 | } |
| 103 | |
| 104 | static class BuilderWithParent implements OFOxmArpThaMasked.Builder { |
| 105 | final OFOxmArpThaMaskedVer12 parentMessage; |
| 106 | |
| 107 | // OF message fields |
| 108 | private boolean valueSet; |
| 109 | private MacAddress value; |
| 110 | private boolean maskSet; |
| 111 | private MacAddress mask; |
| 112 | |
| 113 | BuilderWithParent(OFOxmArpThaMaskedVer12 parentMessage) { |
| 114 | this.parentMessage = parentMessage; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public long getTypeLen() { |
| 119 | return 0x8000330cL; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public MacAddress getValue() { |
| 124 | return value; |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public OFOxmArpThaMasked.Builder setValue(MacAddress value) { |
| 129 | this.value = value; |
| 130 | this.valueSet = true; |
| 131 | return this; |
| 132 | } |
| 133 | @Override |
| 134 | public MacAddress getMask() { |
| 135 | return mask; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public OFOxmArpThaMasked.Builder setMask(MacAddress mask) { |
| 140 | this.mask = mask; |
| 141 | this.maskSet = true; |
| 142 | return this; |
| 143 | } |
| 144 | @Override |
| 145 | public MatchField<MacAddress> getMatchField() { |
| 146 | return MatchField.ARP_THA; |
| 147 | } |
| 148 | |
| 149 | @Override |
| 150 | public boolean isMasked() { |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | @Override |
| 155 | public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException { |
| 156 | throw new UnsupportedOperationException("Property canonical not supported in version 1.2"); |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public OFVersion getVersion() { |
| 161 | return OFVersion.OF_12; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | |
| 166 | @Override |
| 167 | public OFOxmArpThaMasked build() { |
| 168 | MacAddress value = this.valueSet ? this.value : parentMessage.value; |
| 169 | if(value == null) |
| 170 | throw new NullPointerException("Property value must not be null"); |
| 171 | MacAddress mask = this.maskSet ? this.mask : parentMessage.mask; |
| 172 | if(mask == null) |
| 173 | throw new NullPointerException("Property mask must not be null"); |
| 174 | |
| 175 | // |
| 176 | return new OFOxmArpThaMaskedVer12( |
| 177 | value, |
| 178 | mask |
| 179 | ); |
| 180 | } |
| 181 | |
| 182 | } |
| 183 | |
| 184 | static class Builder implements OFOxmArpThaMasked.Builder { |
| 185 | // OF message fields |
| 186 | private boolean valueSet; |
| 187 | private MacAddress value; |
| 188 | private boolean maskSet; |
| 189 | private MacAddress mask; |
| 190 | |
| 191 | @Override |
| 192 | public long getTypeLen() { |
| 193 | return 0x8000330cL; |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public MacAddress getValue() { |
| 198 | return value; |
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public OFOxmArpThaMasked.Builder setValue(MacAddress value) { |
| 203 | this.value = value; |
| 204 | this.valueSet = true; |
| 205 | return this; |
| 206 | } |
| 207 | @Override |
| 208 | public MacAddress getMask() { |
| 209 | return mask; |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public OFOxmArpThaMasked.Builder setMask(MacAddress mask) { |
| 214 | this.mask = mask; |
| 215 | this.maskSet = true; |
| 216 | return this; |
| 217 | } |
| 218 | @Override |
| 219 | public MatchField<MacAddress> getMatchField() { |
| 220 | return MatchField.ARP_THA; |
| 221 | } |
| 222 | |
| 223 | @Override |
| 224 | public boolean isMasked() { |
| 225 | return true; |
| 226 | } |
| 227 | |
| 228 | @Override |
| 229 | public OFOxm<MacAddress> getCanonical()throws UnsupportedOperationException { |
| 230 | throw new UnsupportedOperationException("Property canonical not supported in version 1.2"); |
| 231 | } |
| 232 | |
| 233 | @Override |
| 234 | public OFVersion getVersion() { |
| 235 | return OFVersion.OF_12; |
| 236 | } |
| 237 | |
| 238 | // |
| 239 | @Override |
| 240 | public OFOxmArpThaMasked build() { |
| 241 | MacAddress value = this.valueSet ? this.value : DEFAULT_VALUE; |
| 242 | if(value == null) |
| 243 | throw new NullPointerException("Property value must not be null"); |
| 244 | MacAddress mask = this.maskSet ? this.mask : DEFAULT_VALUE_MASK; |
| 245 | if(mask == null) |
| 246 | throw new NullPointerException("Property mask must not be null"); |
| 247 | |
| 248 | |
| 249 | return new OFOxmArpThaMaskedVer12( |
| 250 | value, |
| 251 | mask |
| 252 | ); |
| 253 | } |
| 254 | |
| 255 | } |
| 256 | |
| 257 | |
| 258 | final static Reader READER = new Reader(); |
| 259 | static class Reader implements OFMessageReader<OFOxmArpThaMasked> { |
| 260 | @Override |
| 261 | public OFOxmArpThaMasked readFrom(ChannelBuffer bb) throws OFParseError { |
| 262 | // fixed value property typeLen == 0x8000330cL |
| 263 | int typeLen = bb.readInt(); |
| 264 | if(typeLen != (int) 0x8000330c) |
| 265 | throw new OFParseError("Wrong typeLen: Expected=0x8000330cL(0x8000330cL), got="+typeLen); |
| 266 | MacAddress value = MacAddress.read6Bytes(bb); |
| 267 | MacAddress mask = MacAddress.read6Bytes(bb); |
| 268 | |
| 269 | OFOxmArpThaMaskedVer12 oxmArpThaMaskedVer12 = new OFOxmArpThaMaskedVer12( |
| 270 | value, |
| 271 | mask |
| 272 | ); |
| 273 | if(logger.isTraceEnabled()) |
| 274 | logger.trace("readFrom - read={}", oxmArpThaMaskedVer12); |
| 275 | return oxmArpThaMaskedVer12; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | public void putTo(PrimitiveSink sink) { |
| 280 | FUNNEL.funnel(this, sink); |
| 281 | } |
| 282 | |
| 283 | final static OFOxmArpThaMaskedVer12Funnel FUNNEL = new OFOxmArpThaMaskedVer12Funnel(); |
| 284 | static class OFOxmArpThaMaskedVer12Funnel implements Funnel<OFOxmArpThaMaskedVer12> { |
| 285 | private static final long serialVersionUID = 1L; |
| 286 | @Override |
| 287 | public void funnel(OFOxmArpThaMaskedVer12 message, PrimitiveSink sink) { |
| 288 | // fixed value property typeLen = 0x8000330cL |
| 289 | sink.putInt((int) 0x8000330c); |
| 290 | message.value.putTo(sink); |
| 291 | message.mask.putTo(sink); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | |
| 296 | public void writeTo(ChannelBuffer bb) { |
| 297 | WRITER.write(bb, this); |
| 298 | } |
| 299 | |
| 300 | final static Writer WRITER = new Writer(); |
| 301 | static class Writer implements OFMessageWriter<OFOxmArpThaMaskedVer12> { |
| 302 | @Override |
| 303 | public void write(ChannelBuffer bb, OFOxmArpThaMaskedVer12 message) { |
| 304 | // fixed value property typeLen = 0x8000330cL |
| 305 | bb.writeInt((int) 0x8000330c); |
| 306 | message.value.write6Bytes(bb); |
| 307 | message.mask.write6Bytes(bb); |
| 308 | |
| 309 | |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | @Override |
| 314 | public String toString() { |
| 315 | StringBuilder b = new StringBuilder("OFOxmArpThaMaskedVer12("); |
| 316 | b.append("value=").append(value); |
| 317 | b.append(", "); |
| 318 | b.append("mask=").append(mask); |
| 319 | b.append(")"); |
| 320 | return b.toString(); |
| 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public boolean equals(Object obj) { |
| 325 | if (this == obj) |
| 326 | return true; |
| 327 | if (obj == null) |
| 328 | return false; |
| 329 | if (getClass() != obj.getClass()) |
| 330 | return false; |
| 331 | OFOxmArpThaMaskedVer12 other = (OFOxmArpThaMaskedVer12) obj; |
| 332 | |
| 333 | if (value == null) { |
| 334 | if (other.value != null) |
| 335 | return false; |
| 336 | } else if (!value.equals(other.value)) |
| 337 | return false; |
| 338 | if (mask == null) { |
| 339 | if (other.mask != null) |
| 340 | return false; |
| 341 | } else if (!mask.equals(other.mask)) |
| 342 | return false; |
| 343 | return true; |
| 344 | } |
| 345 | |
| 346 | @Override |
| 347 | public int hashCode() { |
| 348 | final int prime = 31; |
| 349 | int result = 1; |
| 350 | |
| 351 | result = prime * result + ((value == null) ? 0 : value.hashCode()); |
| 352 | result = prime * result + ((mask == null) ? 0 : mask.hashCode()); |
| 353 | return result; |
| 354 | } |
| 355 | |
| 356 | } |