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.ver11; |
| 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 OFFeaturesRequestVer11 implements OFFeaturesRequest { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFFeaturesRequestVer11.class); |
| 35 | // version: 1.1 |
| 36 | final static byte WIRE_VERSION = 2; |
| 37 | final static int LENGTH = 8; |
| 38 | |
| 39 | private final static long DEFAULT_XID = 0x0L; |
| 40 | |
| 41 | // OF message fields |
| 42 | private final long xid; |
| 43 | // |
| 44 | // Immutable default instance |
| 45 | final static OFFeaturesRequestVer11 DEFAULT = new OFFeaturesRequestVer11( |
| 46 | DEFAULT_XID |
| 47 | ); |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFFeaturesRequestVer11(long xid) { |
| 51 | this.xid = xid; |
| 52 | } |
| 53 | |
| 54 | // Accessors for OF message fields |
| 55 | @Override |
| 56 | public OFVersion getVersion() { |
| 57 | return OFVersion.OF_11; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public OFType getType() { |
| 62 | return OFType.FEATURES_REQUEST; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public long getXid() { |
| 67 | return xid; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | public OFFeaturesRequest.Builder createBuilder() { |
| 73 | return new BuilderWithParent(this); |
| 74 | } |
| 75 | |
| 76 | static class BuilderWithParent implements OFFeaturesRequest.Builder { |
| 77 | final OFFeaturesRequestVer11 parentMessage; |
| 78 | |
| 79 | // OF message fields |
| 80 | private boolean xidSet; |
| 81 | private long xid; |
| 82 | |
| 83 | BuilderWithParent(OFFeaturesRequestVer11 parentMessage) { |
| 84 | this.parentMessage = parentMessage; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public OFVersion getVersion() { |
| 89 | return OFVersion.OF_11; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public OFType getType() { |
| 94 | return OFType.FEATURES_REQUEST; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public long getXid() { |
| 99 | return xid; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public OFFeaturesRequest.Builder setXid(long xid) { |
| 104 | this.xid = xid; |
| 105 | this.xidSet = true; |
| 106 | return this; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | @Override |
| 111 | public OFFeaturesRequest build() { |
| 112 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 113 | |
| 114 | // |
| 115 | return new OFFeaturesRequestVer11( |
| 116 | xid |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | |
| 122 | static class Builder implements OFFeaturesRequest.Builder { |
| 123 | // OF message fields |
| 124 | private boolean xidSet; |
| 125 | private long xid; |
| 126 | |
| 127 | @Override |
| 128 | public OFVersion getVersion() { |
| 129 | return OFVersion.OF_11; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public OFType getType() { |
| 134 | return OFType.FEATURES_REQUEST; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public long getXid() { |
| 139 | return xid; |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public OFFeaturesRequest.Builder setXid(long xid) { |
| 144 | this.xid = xid; |
| 145 | this.xidSet = true; |
| 146 | return this; |
| 147 | } |
| 148 | // |
| 149 | @Override |
| 150 | public OFFeaturesRequest build() { |
| 151 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 152 | |
| 153 | |
| 154 | return new OFFeaturesRequestVer11( |
| 155 | xid |
| 156 | ); |
| 157 | } |
| 158 | |
| 159 | } |
| 160 | |
| 161 | |
| 162 | final static Reader READER = new Reader(); |
| 163 | static class Reader implements OFMessageReader<OFFeaturesRequest> { |
| 164 | @Override |
| 165 | public OFFeaturesRequest readFrom(ChannelBuffer bb) throws OFParseError { |
| 166 | int start = bb.readerIndex(); |
| 167 | // fixed value property version == 2 |
| 168 | byte version = bb.readByte(); |
| 169 | if(version != (byte) 0x2) |
| 170 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_11(2), got="+version); |
| 171 | // fixed value property type == 5 |
| 172 | byte type = bb.readByte(); |
| 173 | if(type != (byte) 0x5) |
| 174 | throw new OFParseError("Wrong type: Expected=OFType.FEATURES_REQUEST(5), got="+type); |
| 175 | int length = U16.f(bb.readShort()); |
| 176 | if(length != 8) |
| 177 | throw new OFParseError("Wrong length: Expected=8(8), got="+length); |
| 178 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 179 | // Buffer does not have all data yet |
| 180 | bb.readerIndex(start); |
| 181 | return null; |
| 182 | } |
| 183 | if(logger.isTraceEnabled()) |
| 184 | logger.trace("readFrom - length={}", length); |
| 185 | long xid = U32.f(bb.readInt()); |
| 186 | |
| 187 | OFFeaturesRequestVer11 featuresRequestVer11 = new OFFeaturesRequestVer11( |
| 188 | xid |
| 189 | ); |
| 190 | if(logger.isTraceEnabled()) |
| 191 | logger.trace("readFrom - read={}", featuresRequestVer11); |
| 192 | return featuresRequestVer11; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | public void putTo(PrimitiveSink sink) { |
| 197 | FUNNEL.funnel(this, sink); |
| 198 | } |
| 199 | |
| 200 | final static OFFeaturesRequestVer11Funnel FUNNEL = new OFFeaturesRequestVer11Funnel(); |
| 201 | static class OFFeaturesRequestVer11Funnel implements Funnel<OFFeaturesRequestVer11> { |
| 202 | private static final long serialVersionUID = 1L; |
| 203 | @Override |
| 204 | public void funnel(OFFeaturesRequestVer11 message, PrimitiveSink sink) { |
| 205 | // fixed value property version = 2 |
| 206 | sink.putByte((byte) 0x2); |
| 207 | // fixed value property type = 5 |
| 208 | sink.putByte((byte) 0x5); |
| 209 | // fixed value property length = 8 |
| 210 | sink.putShort((short) 0x8); |
| 211 | sink.putLong(message.xid); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | |
| 216 | public void writeTo(ChannelBuffer bb) { |
| 217 | WRITER.write(bb, this); |
| 218 | } |
| 219 | |
| 220 | final static Writer WRITER = new Writer(); |
| 221 | static class Writer implements OFMessageWriter<OFFeaturesRequestVer11> { |
| 222 | @Override |
| 223 | public void write(ChannelBuffer bb, OFFeaturesRequestVer11 message) { |
| 224 | // fixed value property version = 2 |
| 225 | bb.writeByte((byte) 0x2); |
| 226 | // fixed value property type = 5 |
| 227 | bb.writeByte((byte) 0x5); |
| 228 | // fixed value property length = 8 |
| 229 | bb.writeShort((short) 0x8); |
| 230 | bb.writeInt(U32.t(message.xid)); |
| 231 | |
| 232 | |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public String toString() { |
| 238 | StringBuilder b = new StringBuilder("OFFeaturesRequestVer11("); |
| 239 | b.append("xid=").append(xid); |
| 240 | b.append(")"); |
| 241 | return b.toString(); |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public boolean equals(Object obj) { |
| 246 | if (this == obj) |
| 247 | return true; |
| 248 | if (obj == null) |
| 249 | return false; |
| 250 | if (getClass() != obj.getClass()) |
| 251 | return false; |
| 252 | OFFeaturesRequestVer11 other = (OFFeaturesRequestVer11) obj; |
| 253 | |
| 254 | if( xid != other.xid) |
| 255 | return false; |
| 256 | return true; |
| 257 | } |
| 258 | |
| 259 | @Override |
| 260 | public int hashCode() { |
| 261 | final int prime = 31; |
| 262 | int result = 1; |
| 263 | |
| 264 | result = prime * (int) (xid ^ (xid >>> 32)); |
| 265 | return result; |
| 266 | } |
| 267 | |
| 268 | } |