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