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