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