blob: ed1bf76ec42ba079b915199fc037e9d201b9854a [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.ver10;
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 OFDescStatsReplyVer10 implements OFDescStatsReply {
35 private static final Logger logger = LoggerFactory.getLogger(OFDescStatsReplyVer10.class);
36 // version: 1.0
37 final static byte WIRE_VERSION = 1;
38 final static int LENGTH = 1068;
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 OFDescStatsReplyVer10 DEFAULT = new OFDescStatsReplyVer10(
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 OFDescStatsReplyVer10(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_10;
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 OFDescStatsReplyVer10 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(OFDescStatsReplyVer10 parentMessage) {
150 this.parentMessage = parentMessage;
151 }
152
153 @Override
154 public OFVersion getVersion() {
155 return OFVersion.OF_10;
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 OFDescStatsReplyVer10(
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_10;
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 OFDescStatsReplyVer10(
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 == 1
436 byte version = bb.readByte();
437 if(version != (byte) 0x1)
438 throw new OFParseError("Wrong version: Expected=OFVersion.OF_10(1), got="+version);
439 // fixed value property type == 17
440 byte type = bb.readByte();
441 if(type != (byte) 0x11)
442 throw new OFParseError("Wrong type: Expected=OFType.STATS_REPLY(17), got="+type);
443 int length = U16.f(bb.readShort());
444 if(length != 1068)
445 throw new OFParseError("Wrong length: Expected=1068(1068), 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 = OFStatsReplyFlagsSerializerVer10.readFrom(bb);
459 String mfrDesc = ChannelUtils.readFixedLengthString(bb, 256);
460 String hwDesc = ChannelUtils.readFixedLengthString(bb, 256);
461 String swDesc = ChannelUtils.readFixedLengthString(bb, 256);
462 String serialNum = ChannelUtils.readFixedLengthString(bb, 32);
463 String dpDesc = ChannelUtils.readFixedLengthString(bb, 256);
464
465 OFDescStatsReplyVer10 descStatsReplyVer10 = new OFDescStatsReplyVer10(
466 xid,
467 flags,
468 mfrDesc,
469 hwDesc,
470 swDesc,
471 serialNum,
472 dpDesc
473 );
474 if(logger.isTraceEnabled())
475 logger.trace("readFrom - read={}", descStatsReplyVer10);
476 return descStatsReplyVer10;
477 }
478 }
479
480 public void putTo(PrimitiveSink sink) {
481 FUNNEL.funnel(this, sink);
482 }
483
484 final static OFDescStatsReplyVer10Funnel FUNNEL = new OFDescStatsReplyVer10Funnel();
485 static class OFDescStatsReplyVer10Funnel implements Funnel<OFDescStatsReplyVer10> {
486 private static final long serialVersionUID = 1L;
487 @Override
488 public void funnel(OFDescStatsReplyVer10 message, PrimitiveSink sink) {
489 // fixed value property version = 1
490 sink.putByte((byte) 0x1);
491 // fixed value property type = 17
492 sink.putByte((byte) 0x11);
493 // fixed value property length = 1068
494 sink.putShort((short) 0x42c);
495 sink.putLong(message.xid);
496 // fixed value property statsType = 0
497 sink.putShort((short) 0x0);
498 OFStatsReplyFlagsSerializerVer10.putTo(message.flags, sink);
499 sink.putUnencodedChars(message.mfrDesc);
500 sink.putUnencodedChars(message.hwDesc);
501 sink.putUnencodedChars(message.swDesc);
502 sink.putUnencodedChars(message.serialNum);
503 sink.putUnencodedChars(message.dpDesc);
504 }
505 }
506
507
508 public void writeTo(ChannelBuffer bb) {
509 WRITER.write(bb, this);
510 }
511
512 final static Writer WRITER = new Writer();
513 static class Writer implements OFMessageWriter<OFDescStatsReplyVer10> {
514 @Override
515 public void write(ChannelBuffer bb, OFDescStatsReplyVer10 message) {
516 // fixed value property version = 1
517 bb.writeByte((byte) 0x1);
518 // fixed value property type = 17
519 bb.writeByte((byte) 0x11);
520 // fixed value property length = 1068
521 bb.writeShort((short) 0x42c);
522 bb.writeInt(U32.t(message.xid));
523 // fixed value property statsType = 0
524 bb.writeShort((short) 0x0);
525 OFStatsReplyFlagsSerializerVer10.writeTo(bb, message.flags);
526 ChannelUtils.writeFixedLengthString(bb, message.mfrDesc, 256);
527 ChannelUtils.writeFixedLengthString(bb, message.hwDesc, 256);
528 ChannelUtils.writeFixedLengthString(bb, message.swDesc, 256);
529 ChannelUtils.writeFixedLengthString(bb, message.serialNum, 32);
530 ChannelUtils.writeFixedLengthString(bb, message.dpDesc, 256);
531
532
533 }
534 }
535
536 @Override
537 public String toString() {
538 StringBuilder b = new StringBuilder("OFDescStatsReplyVer10(");
539 b.append("xid=").append(xid);
540 b.append(", ");
541 b.append("flags=").append(flags);
542 b.append(", ");
543 b.append("mfrDesc=").append(mfrDesc);
544 b.append(", ");
545 b.append("hwDesc=").append(hwDesc);
546 b.append(", ");
547 b.append("swDesc=").append(swDesc);
548 b.append(", ");
549 b.append("serialNum=").append(serialNum);
550 b.append(", ");
551 b.append("dpDesc=").append(dpDesc);
552 b.append(")");
553 return b.toString();
554 }
555
556 @Override
557 public boolean equals(Object obj) {
558 if (this == obj)
559 return true;
560 if (obj == null)
561 return false;
562 if (getClass() != obj.getClass())
563 return false;
564 OFDescStatsReplyVer10 other = (OFDescStatsReplyVer10) obj;
565
566 if( xid != other.xid)
567 return false;
568 if (flags == null) {
569 if (other.flags != null)
570 return false;
571 } else if (!flags.equals(other.flags))
572 return false;
573 if (mfrDesc == null) {
574 if (other.mfrDesc != null)
575 return false;
576 } else if (!mfrDesc.equals(other.mfrDesc))
577 return false;
578 if (hwDesc == null) {
579 if (other.hwDesc != null)
580 return false;
581 } else if (!hwDesc.equals(other.hwDesc))
582 return false;
583 if (swDesc == null) {
584 if (other.swDesc != null)
585 return false;
586 } else if (!swDesc.equals(other.swDesc))
587 return false;
588 if (serialNum == null) {
589 if (other.serialNum != null)
590 return false;
591 } else if (!serialNum.equals(other.serialNum))
592 return false;
593 if (dpDesc == null) {
594 if (other.dpDesc != null)
595 return false;
596 } else if (!dpDesc.equals(other.dpDesc))
597 return false;
598 return true;
599 }
600
601 @Override
602 public int hashCode() {
603 final int prime = 31;
604 int result = 1;
605
606 result = prime * (int) (xid ^ (xid >>> 32));
607 result = prime * result + ((flags == null) ? 0 : flags.hashCode());
608 result = prime * result + ((mfrDesc == null) ? 0 : mfrDesc.hashCode());
609 result = prime * result + ((hwDesc == null) ? 0 : hwDesc.hashCode());
610 result = prime * result + ((swDesc == null) ? 0 : swDesc.hashCode());
611 result = prime * result + ((serialNum == null) ? 0 : serialNum.hashCode());
612 result = prime * result + ((dpDesc == null) ? 0 : dpDesc.hashCode());
613 return result;
614 }
615
616}