alshabib | 86ac11c | 2014-08-14 16:14:41 -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.ver11; |
| 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 OFInstructionWriteMetadataVer11 implements OFInstructionWriteMetadata { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFInstructionWriteMetadataVer11.class); |
| 35 | // version: 1.1 |
| 36 | final static byte WIRE_VERSION = 2; |
| 37 | final static int LENGTH = 24; |
| 38 | |
| 39 | private final static U64 DEFAULT_METADATA = U64.ZERO; |
| 40 | private final static U64 DEFAULT_METADATA_MASK = U64.ZERO; |
| 41 | |
| 42 | // OF message fields |
| 43 | private final U64 metadata; |
| 44 | private final U64 metadataMask; |
| 45 | // |
| 46 | // Immutable default instance |
| 47 | final static OFInstructionWriteMetadataVer11 DEFAULT = new OFInstructionWriteMetadataVer11( |
| 48 | DEFAULT_METADATA, DEFAULT_METADATA_MASK |
| 49 | ); |
| 50 | |
| 51 | // package private constructor - used by readers, builders, and factory |
| 52 | OFInstructionWriteMetadataVer11(U64 metadata, U64 metadataMask) { |
| 53 | this.metadata = metadata; |
| 54 | this.metadataMask = metadataMask; |
| 55 | } |
| 56 | |
| 57 | // Accessors for OF message fields |
| 58 | @Override |
| 59 | public OFInstructionType getType() { |
| 60 | return OFInstructionType.WRITE_METADATA; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public U64 getMetadata() { |
| 65 | return metadata; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public U64 getMetadataMask() { |
| 70 | return metadataMask; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public OFVersion getVersion() { |
| 75 | return OFVersion.OF_11; |
| 76 | } |
| 77 | |
| 78 | |
| 79 | |
| 80 | public OFInstructionWriteMetadata.Builder createBuilder() { |
| 81 | return new BuilderWithParent(this); |
| 82 | } |
| 83 | |
| 84 | static class BuilderWithParent implements OFInstructionWriteMetadata.Builder { |
| 85 | final OFInstructionWriteMetadataVer11 parentMessage; |
| 86 | |
| 87 | // OF message fields |
| 88 | private boolean metadataSet; |
| 89 | private U64 metadata; |
| 90 | private boolean metadataMaskSet; |
| 91 | private U64 metadataMask; |
| 92 | |
| 93 | BuilderWithParent(OFInstructionWriteMetadataVer11 parentMessage) { |
| 94 | this.parentMessage = parentMessage; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public OFInstructionType getType() { |
| 99 | return OFInstructionType.WRITE_METADATA; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public U64 getMetadata() { |
| 104 | return metadata; |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) { |
| 109 | this.metadata = metadata; |
| 110 | this.metadataSet = true; |
| 111 | return this; |
| 112 | } |
| 113 | @Override |
| 114 | public U64 getMetadataMask() { |
| 115 | return metadataMask; |
| 116 | } |
| 117 | |
| 118 | @Override |
| 119 | public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) { |
| 120 | this.metadataMask = metadataMask; |
| 121 | this.metadataMaskSet = true; |
| 122 | return this; |
| 123 | } |
| 124 | @Override |
| 125 | public OFVersion getVersion() { |
| 126 | return OFVersion.OF_11; |
| 127 | } |
| 128 | |
| 129 | |
| 130 | |
| 131 | @Override |
| 132 | public OFInstructionWriteMetadata build() { |
| 133 | U64 metadata = this.metadataSet ? this.metadata : parentMessage.metadata; |
| 134 | if(metadata == null) |
| 135 | throw new NullPointerException("Property metadata must not be null"); |
| 136 | U64 metadataMask = this.metadataMaskSet ? this.metadataMask : parentMessage.metadataMask; |
| 137 | if(metadataMask == null) |
| 138 | throw new NullPointerException("Property metadataMask must not be null"); |
| 139 | |
| 140 | // |
| 141 | return new OFInstructionWriteMetadataVer11( |
| 142 | metadata, |
| 143 | metadataMask |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | } |
| 148 | |
| 149 | static class Builder implements OFInstructionWriteMetadata.Builder { |
| 150 | // OF message fields |
| 151 | private boolean metadataSet; |
| 152 | private U64 metadata; |
| 153 | private boolean metadataMaskSet; |
| 154 | private U64 metadataMask; |
| 155 | |
| 156 | @Override |
| 157 | public OFInstructionType getType() { |
| 158 | return OFInstructionType.WRITE_METADATA; |
| 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public U64 getMetadata() { |
| 163 | return metadata; |
| 164 | } |
| 165 | |
| 166 | @Override |
| 167 | public OFInstructionWriteMetadata.Builder setMetadata(U64 metadata) { |
| 168 | this.metadata = metadata; |
| 169 | this.metadataSet = true; |
| 170 | return this; |
| 171 | } |
| 172 | @Override |
| 173 | public U64 getMetadataMask() { |
| 174 | return metadataMask; |
| 175 | } |
| 176 | |
| 177 | @Override |
| 178 | public OFInstructionWriteMetadata.Builder setMetadataMask(U64 metadataMask) { |
| 179 | this.metadataMask = metadataMask; |
| 180 | this.metadataMaskSet = true; |
| 181 | return this; |
| 182 | } |
| 183 | @Override |
| 184 | public OFVersion getVersion() { |
| 185 | return OFVersion.OF_11; |
| 186 | } |
| 187 | |
| 188 | // |
| 189 | @Override |
| 190 | public OFInstructionWriteMetadata build() { |
| 191 | U64 metadata = this.metadataSet ? this.metadata : DEFAULT_METADATA; |
| 192 | if(metadata == null) |
| 193 | throw new NullPointerException("Property metadata must not be null"); |
| 194 | U64 metadataMask = this.metadataMaskSet ? this.metadataMask : DEFAULT_METADATA_MASK; |
| 195 | if(metadataMask == null) |
| 196 | throw new NullPointerException("Property metadataMask must not be null"); |
| 197 | |
| 198 | |
| 199 | return new OFInstructionWriteMetadataVer11( |
| 200 | metadata, |
| 201 | metadataMask |
| 202 | ); |
| 203 | } |
| 204 | |
| 205 | } |
| 206 | |
| 207 | |
| 208 | final static Reader READER = new Reader(); |
| 209 | static class Reader implements OFMessageReader<OFInstructionWriteMetadata> { |
| 210 | @Override |
| 211 | public OFInstructionWriteMetadata readFrom(ChannelBuffer bb) throws OFParseError { |
| 212 | int start = bb.readerIndex(); |
| 213 | // fixed value property type == 2 |
| 214 | short type = bb.readShort(); |
| 215 | if(type != (short) 0x2) |
| 216 | throw new OFParseError("Wrong type: Expected=OFInstructionType.WRITE_METADATA(2), got="+type); |
| 217 | int length = U16.f(bb.readShort()); |
| 218 | if(length != 24) |
| 219 | throw new OFParseError("Wrong length: Expected=24(24), got="+length); |
| 220 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 221 | // Buffer does not have all data yet |
| 222 | bb.readerIndex(start); |
| 223 | return null; |
| 224 | } |
| 225 | if(logger.isTraceEnabled()) |
| 226 | logger.trace("readFrom - length={}", length); |
| 227 | // pad: 4 bytes |
| 228 | bb.skipBytes(4); |
| 229 | U64 metadata = U64.ofRaw(bb.readLong()); |
| 230 | U64 metadataMask = U64.ofRaw(bb.readLong()); |
| 231 | |
| 232 | OFInstructionWriteMetadataVer11 instructionWriteMetadataVer11 = new OFInstructionWriteMetadataVer11( |
| 233 | metadata, |
| 234 | metadataMask |
| 235 | ); |
| 236 | if(logger.isTraceEnabled()) |
| 237 | logger.trace("readFrom - read={}", instructionWriteMetadataVer11); |
| 238 | return instructionWriteMetadataVer11; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | public void putTo(PrimitiveSink sink) { |
| 243 | FUNNEL.funnel(this, sink); |
| 244 | } |
| 245 | |
| 246 | final static OFInstructionWriteMetadataVer11Funnel FUNNEL = new OFInstructionWriteMetadataVer11Funnel(); |
| 247 | static class OFInstructionWriteMetadataVer11Funnel implements Funnel<OFInstructionWriteMetadataVer11> { |
| 248 | private static final long serialVersionUID = 1L; |
| 249 | @Override |
| 250 | public void funnel(OFInstructionWriteMetadataVer11 message, PrimitiveSink sink) { |
| 251 | // fixed value property type = 2 |
| 252 | sink.putShort((short) 0x2); |
| 253 | // fixed value property length = 24 |
| 254 | sink.putShort((short) 0x18); |
| 255 | // skip pad (4 bytes) |
| 256 | message.metadata.putTo(sink); |
| 257 | message.metadataMask.putTo(sink); |
| 258 | } |
| 259 | } |
| 260 | |
| 261 | |
| 262 | public void writeTo(ChannelBuffer bb) { |
| 263 | WRITER.write(bb, this); |
| 264 | } |
| 265 | |
| 266 | final static Writer WRITER = new Writer(); |
| 267 | static class Writer implements OFMessageWriter<OFInstructionWriteMetadataVer11> { |
| 268 | @Override |
| 269 | public void write(ChannelBuffer bb, OFInstructionWriteMetadataVer11 message) { |
| 270 | // fixed value property type = 2 |
| 271 | bb.writeShort((short) 0x2); |
| 272 | // fixed value property length = 24 |
| 273 | bb.writeShort((short) 0x18); |
| 274 | // pad: 4 bytes |
| 275 | bb.writeZero(4); |
| 276 | bb.writeLong(message.metadata.getValue()); |
| 277 | bb.writeLong(message.metadataMask.getValue()); |
| 278 | |
| 279 | |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | @Override |
| 284 | public String toString() { |
| 285 | StringBuilder b = new StringBuilder("OFInstructionWriteMetadataVer11("); |
| 286 | b.append("metadata=").append(metadata); |
| 287 | b.append(", "); |
| 288 | b.append("metadataMask=").append(metadataMask); |
| 289 | b.append(")"); |
| 290 | return b.toString(); |
| 291 | } |
| 292 | |
| 293 | @Override |
| 294 | public boolean equals(Object obj) { |
| 295 | if (this == obj) |
| 296 | return true; |
| 297 | if (obj == null) |
| 298 | return false; |
| 299 | if (getClass() != obj.getClass()) |
| 300 | return false; |
| 301 | OFInstructionWriteMetadataVer11 other = (OFInstructionWriteMetadataVer11) obj; |
| 302 | |
| 303 | if (metadata == null) { |
| 304 | if (other.metadata != null) |
| 305 | return false; |
| 306 | } else if (!metadata.equals(other.metadata)) |
| 307 | return false; |
| 308 | if (metadataMask == null) { |
| 309 | if (other.metadataMask != null) |
| 310 | return false; |
| 311 | } else if (!metadataMask.equals(other.metadataMask)) |
| 312 | return false; |
| 313 | return true; |
| 314 | } |
| 315 | |
| 316 | @Override |
| 317 | public int hashCode() { |
| 318 | final int prime = 31; |
| 319 | int result = 1; |
| 320 | |
| 321 | result = prime * result + ((metadata == null) ? 0 : metadata.hashCode()); |
| 322 | result = prime * result + ((metadataMask == null) ? 0 : metadataMask.hashCode()); |
| 323 | return result; |
| 324 | } |
| 325 | |
| 326 | } |