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