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