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