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