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.ver13; |
| 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 OFBsnTimeReplyVer13 implements OFBsnTimeReply { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFBsnTimeReplyVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 24; |
| 38 | |
| 39 | private final static long DEFAULT_XID = 0x0L; |
| 40 | private final static U64 DEFAULT_TIME_MS = U64.ZERO; |
| 41 | |
| 42 | // OF message fields |
| 43 | private final long xid; |
| 44 | private final U64 timeMs; |
| 45 | // |
| 46 | // Immutable default instance |
| 47 | final static OFBsnTimeReplyVer13 DEFAULT = new OFBsnTimeReplyVer13( |
| 48 | DEFAULT_XID, DEFAULT_TIME_MS |
| 49 | ); |
| 50 | |
| 51 | // package private constructor - used by readers, builders, and factory |
| 52 | OFBsnTimeReplyVer13(long xid, U64 timeMs) { |
| 53 | this.xid = xid; |
| 54 | this.timeMs = timeMs; |
| 55 | } |
| 56 | |
| 57 | // Accessors for OF message fields |
| 58 | @Override |
| 59 | public OFVersion getVersion() { |
| 60 | return OFVersion.OF_13; |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public OFType getType() { |
| 65 | return OFType.EXPERIMENTER; |
| 66 | } |
| 67 | |
| 68 | @Override |
| 69 | public long getXid() { |
| 70 | return xid; |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public long getExperimenter() { |
| 75 | return 0x5c16c7L; |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public long getSubtype() { |
| 80 | return 0x2dL; |
| 81 | } |
| 82 | |
| 83 | @Override |
| 84 | public U64 getTimeMs() { |
| 85 | return timeMs; |
| 86 | } |
| 87 | |
| 88 | |
| 89 | |
| 90 | public OFBsnTimeReply.Builder createBuilder() { |
| 91 | return new BuilderWithParent(this); |
| 92 | } |
| 93 | |
| 94 | static class BuilderWithParent implements OFBsnTimeReply.Builder { |
| 95 | final OFBsnTimeReplyVer13 parentMessage; |
| 96 | |
| 97 | // OF message fields |
| 98 | private boolean xidSet; |
| 99 | private long xid; |
| 100 | private boolean timeMsSet; |
| 101 | private U64 timeMs; |
| 102 | |
| 103 | BuilderWithParent(OFBsnTimeReplyVer13 parentMessage) { |
| 104 | this.parentMessage = parentMessage; |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public OFVersion getVersion() { |
| 109 | return OFVersion.OF_13; |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | public OFType getType() { |
| 114 | return OFType.EXPERIMENTER; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public long getXid() { |
| 119 | return xid; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public OFBsnTimeReply.Builder setXid(long xid) { |
| 124 | this.xid = xid; |
| 125 | this.xidSet = true; |
| 126 | return this; |
| 127 | } |
| 128 | @Override |
| 129 | public long getExperimenter() { |
| 130 | return 0x5c16c7L; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public long getSubtype() { |
| 135 | return 0x2dL; |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public U64 getTimeMs() { |
| 140 | return timeMs; |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public OFBsnTimeReply.Builder setTimeMs(U64 timeMs) { |
| 145 | this.timeMs = timeMs; |
| 146 | this.timeMsSet = true; |
| 147 | return this; |
| 148 | } |
| 149 | |
| 150 | |
| 151 | @Override |
| 152 | public OFBsnTimeReply build() { |
| 153 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 154 | U64 timeMs = this.timeMsSet ? this.timeMs : parentMessage.timeMs; |
| 155 | if(timeMs == null) |
| 156 | throw new NullPointerException("Property timeMs must not be null"); |
| 157 | |
| 158 | // |
| 159 | return new OFBsnTimeReplyVer13( |
| 160 | xid, |
| 161 | timeMs |
| 162 | ); |
| 163 | } |
| 164 | |
| 165 | } |
| 166 | |
| 167 | static class Builder implements OFBsnTimeReply.Builder { |
| 168 | // OF message fields |
| 169 | private boolean xidSet; |
| 170 | private long xid; |
| 171 | private boolean timeMsSet; |
| 172 | private U64 timeMs; |
| 173 | |
| 174 | @Override |
| 175 | public OFVersion getVersion() { |
| 176 | return OFVersion.OF_13; |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public OFType getType() { |
| 181 | return OFType.EXPERIMENTER; |
| 182 | } |
| 183 | |
| 184 | @Override |
| 185 | public long getXid() { |
| 186 | return xid; |
| 187 | } |
| 188 | |
| 189 | @Override |
| 190 | public OFBsnTimeReply.Builder setXid(long xid) { |
| 191 | this.xid = xid; |
| 192 | this.xidSet = true; |
| 193 | return this; |
| 194 | } |
| 195 | @Override |
| 196 | public long getExperimenter() { |
| 197 | return 0x5c16c7L; |
| 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public long getSubtype() { |
| 202 | return 0x2dL; |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public U64 getTimeMs() { |
| 207 | return timeMs; |
| 208 | } |
| 209 | |
| 210 | @Override |
| 211 | public OFBsnTimeReply.Builder setTimeMs(U64 timeMs) { |
| 212 | this.timeMs = timeMs; |
| 213 | this.timeMsSet = true; |
| 214 | return this; |
| 215 | } |
| 216 | // |
| 217 | @Override |
| 218 | public OFBsnTimeReply build() { |
| 219 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 220 | U64 timeMs = this.timeMsSet ? this.timeMs : DEFAULT_TIME_MS; |
| 221 | if(timeMs == null) |
| 222 | throw new NullPointerException("Property timeMs must not be null"); |
| 223 | |
| 224 | |
| 225 | return new OFBsnTimeReplyVer13( |
| 226 | xid, |
| 227 | timeMs |
| 228 | ); |
| 229 | } |
| 230 | |
| 231 | } |
| 232 | |
| 233 | |
| 234 | final static Reader READER = new Reader(); |
| 235 | static class Reader implements OFMessageReader<OFBsnTimeReply> { |
| 236 | @Override |
| 237 | public OFBsnTimeReply readFrom(ChannelBuffer bb) throws OFParseError { |
| 238 | int start = bb.readerIndex(); |
| 239 | // fixed value property version == 4 |
| 240 | byte version = bb.readByte(); |
| 241 | if(version != (byte) 0x4) |
| 242 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version); |
| 243 | // fixed value property type == 4 |
| 244 | byte type = bb.readByte(); |
| 245 | if(type != (byte) 0x4) |
| 246 | throw new OFParseError("Wrong type: Expected=OFType.EXPERIMENTER(4), got="+type); |
| 247 | int length = U16.f(bb.readShort()); |
| 248 | if(length != 24) |
| 249 | throw new OFParseError("Wrong length: Expected=24(24), got="+length); |
| 250 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 251 | // Buffer does not have all data yet |
| 252 | bb.readerIndex(start); |
| 253 | return null; |
| 254 | } |
| 255 | if(logger.isTraceEnabled()) |
| 256 | logger.trace("readFrom - length={}", length); |
| 257 | long xid = U32.f(bb.readInt()); |
| 258 | // fixed value property experimenter == 0x5c16c7L |
| 259 | int experimenter = bb.readInt(); |
| 260 | if(experimenter != 0x5c16c7) |
| 261 | throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter); |
| 262 | // fixed value property subtype == 0x2dL |
| 263 | int subtype = bb.readInt(); |
| 264 | if(subtype != 0x2d) |
| 265 | throw new OFParseError("Wrong subtype: Expected=0x2dL(0x2dL), got="+subtype); |
| 266 | U64 timeMs = U64.ofRaw(bb.readLong()); |
| 267 | |
| 268 | OFBsnTimeReplyVer13 bsnTimeReplyVer13 = new OFBsnTimeReplyVer13( |
| 269 | xid, |
| 270 | timeMs |
| 271 | ); |
| 272 | if(logger.isTraceEnabled()) |
| 273 | logger.trace("readFrom - read={}", bsnTimeReplyVer13); |
| 274 | return bsnTimeReplyVer13; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | public void putTo(PrimitiveSink sink) { |
| 279 | FUNNEL.funnel(this, sink); |
| 280 | } |
| 281 | |
| 282 | final static OFBsnTimeReplyVer13Funnel FUNNEL = new OFBsnTimeReplyVer13Funnel(); |
| 283 | static class OFBsnTimeReplyVer13Funnel implements Funnel<OFBsnTimeReplyVer13> { |
| 284 | private static final long serialVersionUID = 1L; |
| 285 | @Override |
| 286 | public void funnel(OFBsnTimeReplyVer13 message, PrimitiveSink sink) { |
| 287 | // fixed value property version = 4 |
| 288 | sink.putByte((byte) 0x4); |
| 289 | // fixed value property type = 4 |
| 290 | sink.putByte((byte) 0x4); |
| 291 | // fixed value property length = 24 |
| 292 | sink.putShort((short) 0x18); |
| 293 | sink.putLong(message.xid); |
| 294 | // fixed value property experimenter = 0x5c16c7L |
| 295 | sink.putInt(0x5c16c7); |
| 296 | // fixed value property subtype = 0x2dL |
| 297 | sink.putInt(0x2d); |
| 298 | message.timeMs.putTo(sink); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | |
| 303 | public void writeTo(ChannelBuffer bb) { |
| 304 | WRITER.write(bb, this); |
| 305 | } |
| 306 | |
| 307 | final static Writer WRITER = new Writer(); |
| 308 | static class Writer implements OFMessageWriter<OFBsnTimeReplyVer13> { |
| 309 | @Override |
| 310 | public void write(ChannelBuffer bb, OFBsnTimeReplyVer13 message) { |
| 311 | // fixed value property version = 4 |
| 312 | bb.writeByte((byte) 0x4); |
| 313 | // fixed value property type = 4 |
| 314 | bb.writeByte((byte) 0x4); |
| 315 | // fixed value property length = 24 |
| 316 | bb.writeShort((short) 0x18); |
| 317 | bb.writeInt(U32.t(message.xid)); |
| 318 | // fixed value property experimenter = 0x5c16c7L |
| 319 | bb.writeInt(0x5c16c7); |
| 320 | // fixed value property subtype = 0x2dL |
| 321 | bb.writeInt(0x2d); |
| 322 | bb.writeLong(message.timeMs.getValue()); |
| 323 | |
| 324 | |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public String toString() { |
| 330 | StringBuilder b = new StringBuilder("OFBsnTimeReplyVer13("); |
| 331 | b.append("xid=").append(xid); |
| 332 | b.append(", "); |
| 333 | b.append("timeMs=").append(timeMs); |
| 334 | b.append(")"); |
| 335 | return b.toString(); |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public boolean equals(Object obj) { |
| 340 | if (this == obj) |
| 341 | return true; |
| 342 | if (obj == null) |
| 343 | return false; |
| 344 | if (getClass() != obj.getClass()) |
| 345 | return false; |
| 346 | OFBsnTimeReplyVer13 other = (OFBsnTimeReplyVer13) obj; |
| 347 | |
| 348 | if( xid != other.xid) |
| 349 | return false; |
| 350 | if (timeMs == null) { |
| 351 | if (other.timeMs != null) |
| 352 | return false; |
| 353 | } else if (!timeMs.equals(other.timeMs)) |
| 354 | return false; |
| 355 | return true; |
| 356 | } |
| 357 | |
| 358 | @Override |
| 359 | public int hashCode() { |
| 360 | final int prime = 31; |
| 361 | int result = 1; |
| 362 | |
| 363 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 364 | result = prime * result + ((timeMs == null) ? 0 : timeMs.hashCode()); |
| 365 | return result; |
| 366 | } |
| 367 | |
| 368 | } |