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