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