blob: 4343d37651a9dccf680bed52098f456622bfdd21 [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 OFDescStatsReplyVer13 implements OFDescStatsReply {
35 private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer13.class);
36 // version: 1.3
37 final static byte WIRE_VERSION = 4;
38 final static int LENGTH = 1072;
39
40 private final static long DEFAULT_XID = 0x0L;
41 private final static Set<OFStatsReplyFlags> DEFAULT_FLAGS = ImmutableSet.<OFStatsReplyFlags>of();
42 private final static String DEFAULT_MFR_DESC = "";
43 private final static String DEFAULT_HW_DESC = "";
44 private final static String DEFAULT_SW_DESC = "";
45 private final static String DEFAULT_SERIAL_NUM = "";
46 private final static String DEFAULT_DP_DESC = "";
47
48 // OF message fields
49 private final long xid;
50 private final Set<OFStatsReplyFlags> flags;
51 private final String mfrDesc;
52 private final String hwDesc;
53 private final String swDesc;
54 private final String serialNum;
55 private final String dpDesc;
56//
57 // Immutable default instance
58 final static OFDescStatsReplyVer13 DEFAULT = new OFDescStatsReplyVer13(
59 DEFAULT_XID, DEFAULT_FLAGS, DEFAULT_MFR_DESC, DEFAULT_HW_DESC, DEFAULT_SW_DESC, DEFAULT_SERIAL_NUM, DEFAULT_DP_DESC
60 );
61
62 // package private constructor - used by readers, builders, and factory
63 OFDescStatsReplyVer13(long xid, Set<OFStatsReplyFlags> flags, String mfrDesc, String hwDesc, String swDesc, String serialNum, String dpDesc) {
64 this.xid = xid;
65 this.flags = flags;
66 this.mfrDesc = mfrDesc;
67 this.hwDesc = hwDesc;
68 this.swDesc = swDesc;
69 this.serialNum = serialNum;
70 this.dpDesc = dpDesc;
71 }
72
73 // Accessors for OF message fields
74 @Override
75 public OFVersion getVersion() {
76 return OFVersion.OF_13;
77 }
78
79 @Override
80 public OFType getType() {
81 return OFType.STATS_REPLY;
82 }
83
84 @Override
85 public long getXid() {
86 return xid;
87 }
88
89 @Override
90 public OFStatsType getStatsType() {
91 return OFStatsType.DESC;
92 }
93
94 @Override
95 public Set<OFStatsReplyFlags> getFlags() {
96 return flags;
97 }
98
99 @Override
100 public String getMfrDesc() {
101 return mfrDesc;
102 }
103
104 @Override
105 public String getHwDesc() {
106 return hwDesc;
107 }
108
109 @Override
110 public String getSwDesc() {
111 return swDesc;
112 }
113
114 @Override
115 public String getSerialNum() {
116 return serialNum;
117 }
118
119 @Override
120 public String getDpDesc() {
121 return dpDesc;
122 }
123
124
125
126 public OFDescStatsReply.Builder createBuilder() {
127 return new BuilderWithParent(this);
128 }
129
130 static class BuilderWithParent implements OFDescStatsReply.Builder {
131 final OFDescStatsReplyVer13 parentMessage;
132
133 // OF message fields
134 private boolean xidSet;
135 private long xid;
136 private boolean flagsSet;
137 private Set<OFStatsReplyFlags> flags;
138 private boolean mfrDescSet;
139 private String mfrDesc;
140 private boolean hwDescSet;
141 private String hwDesc;
142 private boolean swDescSet;
143 private String swDesc;
144 private boolean serialNumSet;
145 private String serialNum;
146 private boolean dpDescSet;
147 private String dpDesc;
148
149 BuilderWithParent(OFDescStatsReplyVer13 parentMessage) {
150 this.parentMessage = parentMessage;
151 }
152
153 @Override
154 public OFVersion getVersion() {
155 return OFVersion.OF_13;
156 }
157
158 @Override
159 public OFType getType() {
160 return OFType.STATS_REPLY;
161 }
162
163 @Override
164 public long getXid() {
165 return xid;
166 }
167
168 @Override
169 public OFDescStatsReply.Builder setXid(long xid) {
170 this.xid = xid;
171 this.xidSet = true;
172 return this;
173 }
174 @Override
175 public OFStatsType getStatsType() {
176 return OFStatsType.DESC;
177 }
178
179 @Override
180 public Set<OFStatsReplyFlags> getFlags() {
181 return flags;
182 }
183
184 @Override
185 public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
186 this.flags = flags;
187 this.flagsSet = true;
188 return this;
189 }
190 @Override
191 public String getMfrDesc() {
192 return mfrDesc;
193 }
194
195 @Override
196 public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
197 this.mfrDesc = mfrDesc;
198 this.mfrDescSet = true;
199 return this;
200 }
201 @Override
202 public String getHwDesc() {
203 return hwDesc;
204 }
205
206 @Override
207 public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
208 this.hwDesc = hwDesc;
209 this.hwDescSet = true;
210 return this;
211 }
212 @Override
213 public String getSwDesc() {
214 return swDesc;
215 }
216
217 @Override
218 public OFDescStatsReply.Builder setSwDesc(String swDesc) {
219 this.swDesc = swDesc;
220 this.swDescSet = true;
221 return this;
222 }
223 @Override
224 public String getSerialNum() {
225 return serialNum;
226 }
227
228 @Override
229 public OFDescStatsReply.Builder setSerialNum(String serialNum) {
230 this.serialNum = serialNum;
231 this.serialNumSet = true;
232 return this;
233 }
234 @Override
235 public String getDpDesc() {
236 return dpDesc;
237 }
238
239 @Override
240 public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
241 this.dpDesc = dpDesc;
242 this.dpDescSet = true;
243 return this;
244 }
245
246
247 @Override
248 public OFDescStatsReply build() {
249 long xid = this.xidSet ? this.xid : parentMessage.xid;
250 Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : parentMessage.flags;
251 if(flags == null)
252 throw new NullPointerException("Property flags must not be null");
253 String mfrDesc = this.mfrDescSet ? this.mfrDesc : parentMessage.mfrDesc;
254 if(mfrDesc == null)
255 throw new NullPointerException("Property mfrDesc must not be null");
256 String hwDesc = this.hwDescSet ? this.hwDesc : parentMessage.hwDesc;
257 if(hwDesc == null)
258 throw new NullPointerException("Property hwDesc must not be null");
259 String swDesc = this.swDescSet ? this.swDesc : parentMessage.swDesc;
260 if(swDesc == null)
261 throw new NullPointerException("Property swDesc must not be null");
262 String serialNum = this.serialNumSet ? this.serialNum : parentMessage.serialNum;
263 if(serialNum == null)
264 throw new NullPointerException("Property serialNum must not be null");
265 String dpDesc = this.dpDescSet ? this.dpDesc : parentMessage.dpDesc;
266 if(dpDesc == null)
267 throw new NullPointerException("Property dpDesc must not be null");
268
269 //
270 return new OFDescStatsReplyVer13(
271 xid,
272 flags,
273 mfrDesc,
274 hwDesc,
275 swDesc,
276 serialNum,
277 dpDesc
278 );
279 }
280
281 }
282
283 static class Builder implements OFDescStatsReply.Builder {
284 // OF message fields
285 private boolean xidSet;
286 private long xid;
287 private boolean flagsSet;
288 private Set<OFStatsReplyFlags> flags;
289 private boolean mfrDescSet;
290 private String mfrDesc;
291 private boolean hwDescSet;
292 private String hwDesc;
293 private boolean swDescSet;
294 private String swDesc;
295 private boolean serialNumSet;
296 private String serialNum;
297 private boolean dpDescSet;
298 private String dpDesc;
299
300 @Override
301 public OFVersion getVersion() {
302 return OFVersion.OF_13;
303 }
304
305 @Override
306 public OFType getType() {
307 return OFType.STATS_REPLY;
308 }
309
310 @Override
311 public long getXid() {
312 return xid;
313 }
314
315 @Override
316 public OFDescStatsReply.Builder setXid(long xid) {
317 this.xid = xid;
318 this.xidSet = true;
319 return this;
320 }
321 @Override
322 public OFStatsType getStatsType() {
323 return OFStatsType.DESC;
324 }
325
326 @Override
327 public Set<OFStatsReplyFlags> getFlags() {
328 return flags;
329 }
330
331 @Override
332 public OFDescStatsReply.Builder setFlags(Set<OFStatsReplyFlags> flags) {
333 this.flags = flags;
334 this.flagsSet = true;
335 return this;
336 }
337 @Override
338 public String getMfrDesc() {
339 return mfrDesc;
340 }
341
342 @Override
343 public OFDescStatsReply.Builder setMfrDesc(String mfrDesc) {
344 this.mfrDesc = mfrDesc;
345 this.mfrDescSet = true;
346 return this;
347 }
348 @Override
349 public String getHwDesc() {
350 return hwDesc;
351 }
352
353 @Override
354 public OFDescStatsReply.Builder setHwDesc(String hwDesc) {
355 this.hwDesc = hwDesc;
356 this.hwDescSet = true;
357 return this;
358 }
359 @Override
360 public String getSwDesc() {
361 return swDesc;
362 }
363
364 @Override
365 public OFDescStatsReply.Builder setSwDesc(String swDesc) {
366 this.swDesc = swDesc;
367 this.swDescSet = true;
368 return this;
369 }
370 @Override
371 public String getSerialNum() {
372 return serialNum;
373 }
374
375 @Override
376 public OFDescStatsReply.Builder setSerialNum(String serialNum) {
377 this.serialNum = serialNum;
378 this.serialNumSet = true;
379 return this;
380 }
381 @Override
382 public String getDpDesc() {
383 return dpDesc;
384 }
385
386 @Override
387 public OFDescStatsReply.Builder setDpDesc(String dpDesc) {
388 this.dpDesc = dpDesc;
389 this.dpDescSet = true;
390 return this;
391 }
392//
393 @Override
394 public OFDescStatsReply build() {
395 long xid = this.xidSet ? this.xid : DEFAULT_XID;
396 Set<OFStatsReplyFlags> flags = this.flagsSet ? this.flags : DEFAULT_FLAGS;
397 if(flags == null)
398 throw new NullPointerException("Property flags must not be null");
399 String mfrDesc = this.mfrDescSet ? this.mfrDesc : DEFAULT_MFR_DESC;
400 if(mfrDesc == null)
401 throw new NullPointerException("Property mfrDesc must not be null");
402 String hwDesc = this.hwDescSet ? this.hwDesc : DEFAULT_HW_DESC;
403 if(hwDesc == null)
404 throw new NullPointerException("Property hwDesc must not be null");
405 String swDesc = this.swDescSet ? this.swDesc : DEFAULT_SW_DESC;
406 if(swDesc == null)
407 throw new NullPointerException("Property swDesc must not be null");
408 String serialNum = this.serialNumSet ? this.serialNum : DEFAULT_SERIAL_NUM;
409 if(serialNum == null)
410 throw new NullPointerException("Property serialNum must not be null");
411 String dpDesc = this.dpDescSet ? this.dpDesc : DEFAULT_DP_DESC;
412 if(dpDesc == null)
413 throw new NullPointerException("Property dpDesc must not be null");
414
415
416 return new OFDescStatsReplyVer13(
417 xid,
418 flags,
419 mfrDesc,
420 hwDesc,
421 swDesc,
422 serialNum,
423 dpDesc
424 );
425 }
426
427 }
428
429
430 final static Reader READER = new Reader();
431 static class Reader implements OFMessageReader<OFDescStatsReply> {
432 @Override
433 public OFDescStatsReply readFrom(ChannelBuffer bb) throws OFParseError {
434 int start = bb.readerIndex();
435 // fixed value property version == 4
436 byte version = bb.readByte();
437 if(version != (byte) 0x4)
438 throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
439 // fixed value property type == 19
440 byte type = bb.readByte();
441 if(type != (byte) 0x13)
442 throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(19), got="+type);
443 int length = U16.f(bb.readShort());
444 if(length != 1072)
445 throw new OFParseError("Wrong length: Expected=1072(1072), got="+length);
446 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
447 // Buffer does not have all data yet
448 bb.readerIndex(start);
449 return null;
450 }
451 if(logger.isTraceEnabled())
452 logger.trace("readFrom - length={}", length);
453 long xid = U32.f(bb.readInt());
454 // fixed value property statsType == 0
455 short statsType = bb.readShort();
456 if(statsType != (short) 0x0)
457 throw new OFParseError("Wrong statsType: Expected=OFStatsType.DESC(0), got="+statsType);
458 Set<OFStatsReplyFlags> flags = OFStatsReplyFlagsSerializerVer13.readFrom(bb);
459 // pad: 4 bytes
460 bb.skipBytes(4);
461 String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
462 String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
463 String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
464 String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
465 String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
466
467 OFDescStatsReplyVer13 descStatsReplyVer13 = new OFDescStatsReplyVer13(
468 xid,
469 flags,
470 mfrDesc,
471 hwDesc,
472 swDesc,
473 serialNum,
474 dpDesc
475 );
476 if(logger.isTraceEnabled())
477 logger.trace("readFrom - read={}", descStatsReplyVer13);
478 return descStatsReplyVer13;
479 }
480 }
481
482 public void putTo(PrimitiveSink sink) {
483 FUNNEL.funnel(this, sink);
484 }
485
486 final static OFDescStatsReplyVer13Funnel FUNNEL = new OFDescStatsReplyVer13Funnel();
487 static class OFDescStatsReplyVer13Funnel implements Funnel<OFDescStatsReplyVer13> {
488 private static final long serialVersionUID = 1L;
489 @Override
490 public void funnel(OFDescStatsReplyVer13 message, PrimitiveSink sink) {
491 // fixed value property version = 4
492 sink.putByte((byte) 0x4);
493 // fixed value property type = 19
494 sink.putByte((byte) 0x13);
495 // fixed value property length = 1072
496 sink.putShort((short) 0x430);
497 sink.putLong(message.xid);
498 // fixed value property statsType = 0
499 sink.putShort((short) 0x0);
500 OFStatsReplyFlagsSerializerVer13.putTo(message.flags, sink);
501 // skip pad (4 bytes)
502 sink.putUnencodedChars(message.mfrDesc);
503 sink.putUnencodedChars(message.hwDesc);
504 sink.putUnencodedChars(message.swDesc);
505 sink.putUnencodedChars(message.serialNum);
506 sink.putUnencodedChars(message.dpDesc);
507 }
508 }
509
510
511 public void writeTo(ChannelBuffer bb) {
512 WRITER.write(bb, this);
513 }
514
515 final static Writer WRITER = new Writer();
516 static class Writer implements OFMessageWriter<OFDescStatsReplyVer13> {
517 @Override
518 public void write(ChannelBuffer bb, OFDescStatsReplyVer13 message) {
519 // fixed value property version = 4
520 bb.writeByte((byte) 0x4);
521 // fixed value property type = 19
522 bb.writeByte((byte) 0x13);
523 // fixed value property length = 1072
524 bb.writeShort((short) 0x430);
525 bb.writeInt(U32.t(message.xid));
526 // fixed value property statsType = 0
527 bb.writeShort((short) 0x0);
528 OFStatsReplyFlagsSerializerVer13.writeTo(bb, message.flags);
529 // pad: 4 bytes
530 bb.writeZero(4);
531 ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
532 ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
533 ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
534 ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
535 ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
536
537
538 }
539 }
540
541 @Override
542 public String toString() {
543 StringBuilder b = new StringBuilder("OFDescStatsReplyVer13(");
544 b.append("xid=").append(xid);
545 b.append(", ");
546 b.append("flags=").append(flags);
547 b.append(", ");
548 b.append("mfrDesc=").append(mfrDesc);
549 b.append(", ");
550 b.append("hwDesc=").append(hwDesc);
551 b.append(", ");
552 b.append("swDesc=").append(swDesc);
553 b.append(", ");
554 b.append("serialNum=").append(serialNum);
555 b.append(", ");
556 b.append("dpDesc=").append(dpDesc);
557 b.append(")");
558 return b.toString();
559 }
560
561 @Override
562 public boolean equals(Object obj) {
563 if (this == obj)
564 return true;
565 if (obj == null)
566 return false;
567 if (getClass() != obj.getClass())
568 return false;
569 OFDescStatsReplyVer13 other = (OFDescStatsReplyVer13) obj;
570
571 if( xid != other.xid)
572 return false;
573 if (flags == null) {
574 if (other.flags != null)
575 return false;
576 } else if (!flags.equals(other.flags))
577 return false;
578 if (mfrDesc == null) {
579 if (other.mfrDesc != null)
580 return false;
581 } else if (!mfrDesc.equals(other.mfrDesc))
582 return false;
583 if (hwDesc == null) {
584 if (other.hwDesc != null)
585 return false;
586 } else if (!hwDesc.equals(other.hwDesc))
587 return false;
588 if (swDesc == null) {
589 if (other.swDesc != null)
590 return false;
591 } else if (!swDesc.equals(other.swDesc))
592 return false;
593 if (serialNum == null) {
594 if (other.serialNum != null)
595 return false;
596 } else if (!serialNum.equals(other.serialNum))
597 return false;
598 if (dpDesc == null) {
599 if (other.dpDesc != null)
600 return false;
601 } else if (!dpDesc.equals(other.dpDesc))
602 return false;
603 return true;
604 }
605
606 @Override
607 public int hashCode() {
608 final int prime = 31;
609 int result = 1;
610
611 result = prime * (int) (xid ^ (xid >>> 32));
612 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
613 result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
614 result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
615 result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
616 result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
617 result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
618 return result;
619 }
620
621}