blob: 542294ef346b57d946644dfc5ccbb415ccf0c7e2 [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 org.jboss.netty.buffer.ChannelBuffer;
30import com.google.common.hash.PrimitiveSink;
31import com.google.common.hash.Funnel;
32
33class OFBarrierRequestVer13 implements OFBarrierRequest {
34 private static final Logger logger = LoggerFactory.getLogger(OFBarrierRequestVer13.class);
35 // version: 1.3
36 final static byte WIRE_VERSION = 4;
37 final static int LENGTH = 8;
38
39 private final static long DEFAULT_XID = 0x0L;
40
41 // OF message fields
42 private final long xid;
43//
44 // Immutable default instance
45 final static OFBarrierRequestVer13 DEFAULT = new OFBarrierRequestVer13(
46 DEFAULT_XID
47 );
48
49 // package private constructor - used by readers, builders, and factory
50 OFBarrierRequestVer13(long xid) {
51 this.xid = xid;
52 }
53
54 // Accessors for OF message fields
55 @Override
56 public OFVersion getVersion() {
57 return OFVersion.OF_13;
58 }
59
60 @Override
61 public OFType getType() {
62 return OFType.BARRIER_REQUEST;
63 }
64
65 @Override
66 public long getXid() {
67 return xid;
68 }
69
70
71
72 public OFBarrierRequest.Builder createBuilder() {
73 return new BuilderWithParent(this);
74 }
75
76 static class BuilderWithParent implements OFBarrierRequest.Builder {
77 final OFBarrierRequestVer13 parentMessage;
78
79 // OF message fields
80 private boolean xidSet;
81 private long xid;
82
83 BuilderWithParent(OFBarrierRequestVer13 parentMessage) {
84 this.parentMessage = parentMessage;
85 }
86
87 @Override
88 public OFVersion getVersion() {
89 return OFVersion.OF_13;
90 }
91
92 @Override
93 public OFType getType() {
94 return OFType.BARRIER_REQUEST;
95 }
96
97 @Override
98 public long getXid() {
99 return xid;
100 }
101
102 @Override
103 public OFBarrierRequest.Builder setXid(long xid) {
104 this.xid = xid;
105 this.xidSet = true;
106 return this;
107 }
108
109
110 @Override
111 public OFBarrierRequest build() {
112 long xid = this.xidSet ? this.xid : parentMessage.xid;
113
114 //
115 return new OFBarrierRequestVer13(
116 xid
117 );
118 }
119
120 }
121
122 static class Builder implements OFBarrierRequest.Builder {
123 // OF message fields
124 private boolean xidSet;
125 private long xid;
126
127 @Override
128 public OFVersion getVersion() {
129 return OFVersion.OF_13;
130 }
131
132 @Override
133 public OFType getType() {
134 return OFType.BARRIER_REQUEST;
135 }
136
137 @Override
138 public long getXid() {
139 return xid;
140 }
141
142 @Override
143 public OFBarrierRequest.Builder setXid(long xid) {
144 this.xid = xid;
145 this.xidSet = true;
146 return this;
147 }
148//
149 @Override
150 public OFBarrierRequest build() {
151 long xid = this.xidSet ? this.xid : DEFAULT_XID;
152
153
154 return new OFBarrierRequestVer13(
155 xid
156 );
157 }
158
159 }
160
161
162 final static Reader READER = new Reader();
163 static class Reader implements OFMessageReader<OFBarrierRequest> {
164 @Override
165 public OFBarrierRequest readFrom(ChannelBuffer bb) throws OFParseError {
166 int start = bb.readerIndex();
167 // fixed value property version == 4
168 byte version = bb.readByte();
169 if(version != (byte) 0x4)
170 throw new OFParseError("Wrong version: Expected=OFVersion.OF_13(4), got="+version);
171 // fixed value property type == 20
172 byte type = bb.readByte();
173 if(type != (byte) 0x14)
174 throw new OFParseError("Wrong type: Expected=OFType.BARRIER_REQUEST(20), got="+type);
175 int length = U16.f(bb.readShort());
176 if(length != 8)
177 throw new OFParseError("Wrong length: Expected=8(8), got="+length);
178 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
179 // Buffer does not have all data yet
180 bb.readerIndex(start);
181 return null;
182 }
183 if(logger.isTraceEnabled())
184 logger.trace("readFrom - length={}", length);
185 long xid = U32.f(bb.readInt());
186
187 OFBarrierRequestVer13 barrierRequestVer13 = new OFBarrierRequestVer13(
188 xid
189 );
190 if(logger.isTraceEnabled())
191 logger.trace("readFrom - read={}", barrierRequestVer13);
192 return barrierRequestVer13;
193 }
194 }
195
196 public void putTo(PrimitiveSink sink) {
197 FUNNEL.funnel(this, sink);
198 }
199
200 final static OFBarrierRequestVer13Funnel FUNNEL = new OFBarrierRequestVer13Funnel();
201 static class OFBarrierRequestVer13Funnel implements Funnel<OFBarrierRequestVer13> {
202 private static final long serialVersionUID = 1L;
203 @Override
204 public void funnel(OFBarrierRequestVer13 message, PrimitiveSink sink) {
205 // fixed value property version = 4
206 sink.putByte((byte) 0x4);
207 // fixed value property type = 20
208 sink.putByte((byte) 0x14);
209 // fixed value property length = 8
210 sink.putShort((short) 0x8);
211 sink.putLong(message.xid);
212 }
213 }
214
215
216 public void writeTo(ChannelBuffer bb) {
217 WRITER.write(bb, this);
218 }
219
220 final static Writer WRITER = new Writer();
221 static class Writer implements OFMessageWriter<OFBarrierRequestVer13> {
222 @Override
223 public void write(ChannelBuffer bb, OFBarrierRequestVer13 message) {
224 // fixed value property version = 4
225 bb.writeByte((byte) 0x4);
226 // fixed value property type = 20
227 bb.writeByte((byte) 0x14);
228 // fixed value property length = 8
229 bb.writeShort((short) 0x8);
230 bb.writeInt(U32.t(message.xid));
231
232
233 }
234 }
235
236 @Override
237 public String toString() {
238 StringBuilder b = new StringBuilder("OFBarrierRequestVer13(");
239 b.append("xid=").append(xid);
240 b.append(")");
241 return b.toString();
242 }
243
244 @Override
245 public boolean equals(Object obj) {
246 if (this == obj)
247 return true;
248 if (obj == null)
249 return false;
250 if (getClass() != obj.getClass())
251 return false;
252 OFBarrierRequestVer13 other = (OFBarrierRequestVer13) obj;
253
254 if( xid != other.xid)
255 return false;
256 return true;
257 }
258
259 @Override
260 public int hashCode() {
261 final int prime = 31;
262 int result = 1;
263
264 result = prime * (int) (xid ^ (xid >>> 32));
265 return result;
266 }
267
268}