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 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 OFGetConfigRequestVer12 implements OFGetConfigRequest { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFGetConfigRequestVer12.class); |
| 35 | // version: 1.2 |
| 36 | final static byte WIRE_VERSION = 3; |
| 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 OFGetConfigRequestVer12 DEFAULT = new OFGetConfigRequestVer12( |
| 46 | DEFAULT_XID |
| 47 | ); |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFGetConfigRequestVer12(long xid) { |
| 51 | this.xid = xid; |
| 52 | } |
| 53 | |
| 54 | // Accessors for OF message fields |
| 55 | @Override |
| 56 | public OFVersion getVersion() { |
| 57 | return OFVersion.OF_12; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public OFType getType() { |
| 62 | return OFType.GET_CONFIG_REQUEST; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public long getXid() { |
| 67 | return xid; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | public OFGetConfigRequest.Builder createBuilder() { |
| 73 | return new BuilderWithParent(this); |
| 74 | } |
| 75 | |
| 76 | static class BuilderWithParent implements OFGetConfigRequest.Builder { |
| 77 | final OFGetConfigRequestVer12 parentMessage; |
| 78 | |
| 79 | // OF message fields |
| 80 | private boolean xidSet; |
| 81 | private long xid; |
| 82 | |
| 83 | BuilderWithParent(OFGetConfigRequestVer12 parentMessage) { |
| 84 | this.parentMessage = parentMessage; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public OFVersion getVersion() { |
| 89 | return OFVersion.OF_12; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public OFType getType() { |
| 94 | return OFType.GET_CONFIG_REQUEST; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public long getXid() { |
| 99 | return xid; |
| 100 | } |
| 101 | |
| 102 | @Override |
| 103 | public OFGetConfigRequest.Builder setXid(long xid) { |
| 104 | this.xid = xid; |
| 105 | this.xidSet = true; |
| 106 | return this; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | @Override |
| 111 | public OFGetConfigRequest build() { |
| 112 | long xid = this.xidSet ? this.xid : parentMessage.xid; |
| 113 | |
| 114 | // |
| 115 | return new OFGetConfigRequestVer12( |
| 116 | xid |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | |
| 122 | static class Builder implements OFGetConfigRequest.Builder { |
| 123 | // OF message fields |
| 124 | private boolean xidSet; |
| 125 | private long xid; |
| 126 | |
| 127 | @Override |
| 128 | public OFVersion getVersion() { |
| 129 | return OFVersion.OF_12; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public OFType getType() { |
| 134 | return OFType.GET_CONFIG_REQUEST; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public long getXid() { |
| 139 | return xid; |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public OFGetConfigRequest.Builder setXid(long xid) { |
| 144 | this.xid = xid; |
| 145 | this.xidSet = true; |
| 146 | return this; |
| 147 | } |
| 148 | // |
| 149 | @Override |
| 150 | public OFGetConfigRequest build() { |
| 151 | long xid = this.xidSet ? this.xid : DEFAULT_XID; |
| 152 | |
| 153 | |
| 154 | return new OFGetConfigRequestVer12( |
| 155 | xid |
| 156 | ); |
| 157 | } |
| 158 | |
| 159 | } |
| 160 | |
| 161 | |
| 162 | final static Reader READER = new Reader(); |
| 163 | static class Reader implements OFMessageReader<OFGetConfigRequest> { |
| 164 | @Override |
| 165 | public OFGetConfigRequest readFrom(ChannelBuffer bb) throws OFParseError { |
| 166 | int start = bb.readerIndex(); |
| 167 | // fixed value property version == 3 |
| 168 | byte version = bb.readByte(); |
| 169 | if(version != (byte) 0x3) |
| 170 | throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version); |
| 171 | // fixed value property type == 7 |
| 172 | byte type = bb.readByte(); |
| 173 | if(type != (byte) 0x7) |
| 174 | throw new OFParseError("Wrong type: Expected=OFType.GET_CONFIG_REQUEST(7), 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 | OFGetConfigRequestVer12 getConfigRequestVer12 = new OFGetConfigRequestVer12( |
| 188 | xid |
| 189 | ); |
| 190 | if(logger.isTraceEnabled()) |
| 191 | logger.trace("readFrom - read={}", getConfigRequestVer12); |
| 192 | return getConfigRequestVer12; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | public void putTo(PrimitiveSink sink) { |
| 197 | FUNNEL.funnel(this, sink); |
| 198 | } |
| 199 | |
| 200 | final static OFGetConfigRequestVer12Funnel FUNNEL = new OFGetConfigRequestVer12Funnel(); |
| 201 | static class OFGetConfigRequestVer12Funnel implements Funnel<OFGetConfigRequestVer12> { |
| 202 | private static final long serialVersionUID = 1L; |
| 203 | @Override |
| 204 | public void funnel(OFGetConfigRequestVer12 message, PrimitiveSink sink) { |
| 205 | // fixed value property version = 3 |
| 206 | sink.putByte((byte) 0x3); |
| 207 | // fixed value property type = 7 |
| 208 | sink.putByte((byte) 0x7); |
| 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<OFGetConfigRequestVer12> { |
| 222 | @Override |
| 223 | public void write(ChannelBuffer bb, OFGetConfigRequestVer12 message) { |
| 224 | // fixed value property version = 3 |
| 225 | bb.writeByte((byte) 0x3); |
| 226 | // fixed value property type = 7 |
| 227 | bb.writeByte((byte) 0x7); |
| 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("OFGetConfigRequestVer12("); |
| 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 | OFGetConfigRequestVer12 other = (OFGetConfigRequestVer12) 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 | } |