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