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