blob: eb59186a66aa9b5b91de6fc46aeea3ecf79ad90d [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.ver12;
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 OFGroupModFailedErrorMsgVer12 implements OFGroupModFailedErrorMsg {
34 private static final Logger logger = LoggerFactory.getLogger(OFGroupModFailedErrorMsgVer12.class);
35 // version: 1.2
36 final static byte WIRE_VERSION = 3;
37 final static int MINIMUM_LENGTH = 12;
38
39 private final static long DEFAULT_XID = 0x0L;
40 private final static OFErrorCauseData DEFAULT_DATA = OFErrorCauseData.NONE;
41
42 // OF message fields
43 private final long xid;
44 private final OFGroupModFailedCode code;
45 private final OFErrorCauseData data;
46//
47
48 // package private constructor - used by readers, builders, and factory
49 OFGroupModFailedErrorMsgVer12(long xid, OFGroupModFailedCode code, OFErrorCauseData data) {
50 this.xid = xid;
51 this.code = code;
52 this.data = data;
53 }
54
55 // Accessors for OF message fields
56 @Override
57 public OFVersion getVersion() {
58 return OFVersion.OF_12;
59 }
60
61 @Override
62 public OFType getType() {
63 return OFType.ERROR;
64 }
65
66 @Override
67 public long getXid() {
68 return xid;
69 }
70
71 @Override
72 public OFErrorType getErrType() {
73 return OFErrorType.GROUP_MOD_FAILED;
74 }
75
76 @Override
77 public OFGroupModFailedCode getCode() {
78 return code;
79 }
80
81 @Override
82 public OFErrorCauseData getData() {
83 return data;
84 }
85
86
87
88 public OFGroupModFailedErrorMsg.Builder createBuilder() {
89 return new BuilderWithParent(this);
90 }
91
92 static class BuilderWithParent implements OFGroupModFailedErrorMsg.Builder {
93 final OFGroupModFailedErrorMsgVer12 parentMessage;
94
95 // OF message fields
96 private boolean xidSet;
97 private long xid;
98 private boolean codeSet;
99 private OFGroupModFailedCode code;
100 private boolean dataSet;
101 private OFErrorCauseData data;
102
103 BuilderWithParent(OFGroupModFailedErrorMsgVer12 parentMessage) {
104 this.parentMessage = parentMessage;
105 }
106
107 @Override
108 public OFVersion getVersion() {
109 return OFVersion.OF_12;
110 }
111
112 @Override
113 public OFType getType() {
114 return OFType.ERROR;
115 }
116
117 @Override
118 public long getXid() {
119 return xid;
120 }
121
122 @Override
123 public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
124 this.xid = xid;
125 this.xidSet = true;
126 return this;
127 }
128 @Override
129 public OFErrorType getErrType() {
130 return OFErrorType.GROUP_MOD_FAILED;
131 }
132
133 @Override
134 public OFGroupModFailedCode getCode() {
135 return code;
136 }
137
138 @Override
139 public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
140 this.code = code;
141 this.codeSet = true;
142 return this;
143 }
144 @Override
145 public OFErrorCauseData getData() {
146 return data;
147 }
148
149 @Override
150 public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
151 this.data = data;
152 this.dataSet = true;
153 return this;
154 }
155
156
157 @Override
158 public OFGroupModFailedErrorMsg build() {
159 long xid = this.xidSet ? this.xid : parentMessage.xid;
160 OFGroupModFailedCode code = this.codeSet ? this.code : parentMessage.code;
161 if(code == null)
162 throw new NullPointerException("Property code must not be null");
163 OFErrorCauseData data = this.dataSet ? this.data : parentMessage.data;
164 if(data == null)
165 throw new NullPointerException("Property data must not be null");
166
167 //
168 return new OFGroupModFailedErrorMsgVer12(
169 xid,
170 code,
171 data
172 );
173 }
174
175 }
176
177 static class Builder implements OFGroupModFailedErrorMsg.Builder {
178 // OF message fields
179 private boolean xidSet;
180 private long xid;
181 private boolean codeSet;
182 private OFGroupModFailedCode code;
183 private boolean dataSet;
184 private OFErrorCauseData data;
185
186 @Override
187 public OFVersion getVersion() {
188 return OFVersion.OF_12;
189 }
190
191 @Override
192 public OFType getType() {
193 return OFType.ERROR;
194 }
195
196 @Override
197 public long getXid() {
198 return xid;
199 }
200
201 @Override
202 public OFGroupModFailedErrorMsg.Builder setXid(long xid) {
203 this.xid = xid;
204 this.xidSet = true;
205 return this;
206 }
207 @Override
208 public OFErrorType getErrType() {
209 return OFErrorType.GROUP_MOD_FAILED;
210 }
211
212 @Override
213 public OFGroupModFailedCode getCode() {
214 return code;
215 }
216
217 @Override
218 public OFGroupModFailedErrorMsg.Builder setCode(OFGroupModFailedCode code) {
219 this.code = code;
220 this.codeSet = true;
221 return this;
222 }
223 @Override
224 public OFErrorCauseData getData() {
225 return data;
226 }
227
228 @Override
229 public OFGroupModFailedErrorMsg.Builder setData(OFErrorCauseData data) {
230 this.data = data;
231 this.dataSet = true;
232 return this;
233 }
234//
235 @Override
236 public OFGroupModFailedErrorMsg build() {
237 long xid = this.xidSet ? this.xid : DEFAULT_XID;
238 if(!this.codeSet)
239 throw new IllegalStateException("Property code doesn't have default value -- must be set");
240 if(code == null)
241 throw new NullPointerException("Property code must not be null");
242 OFErrorCauseData data = this.dataSet ? this.data : DEFAULT_DATA;
243 if(data == null)
244 throw new NullPointerException("Property data must not be null");
245
246
247 return new OFGroupModFailedErrorMsgVer12(
248 xid,
249 code,
250 data
251 );
252 }
253
254 }
255
256
257 final static Reader READER = new Reader();
258 static class Reader implements OFMessageReader<OFGroupModFailedErrorMsg> {
259 @Override
260 public OFGroupModFailedErrorMsg readFrom(ChannelBuffer bb) throws OFParseError {
261 int start = bb.readerIndex();
262 // fixed value property version == 3
263 byte version = bb.readByte();
264 if(version != (byte) 0x3)
265 throw new OFParseError("Wrong version: Expected=OFVersion.OF_12(3), got="+version);
266 // fixed value property type == 1
267 byte type = bb.readByte();
268 if(type != (byte) 0x1)
269 throw new OFParseError("Wrong type: Expected=OFType.ERROR(1), got="+type);
270 int length = U16.f(bb.readShort());
271 if(length < MINIMUM_LENGTH)
272 throw new OFParseError("Wrong length: Expected to be >= " + MINIMUM_LENGTH + ", was: " + length);
273 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
274 // Buffer does not have all data yet
275 bb.readerIndex(start);
276 return null;
277 }
278 if(logger.isTraceEnabled())
279 logger.trace("readFrom - length={}", length);
280 long xid = U32.f(bb.readInt());
281 // fixed value property errType == 6
282 short errType = bb.readShort();
283 if(errType != (short) 0x6)
284 throw new OFParseError("Wrong errType: Expected=OFErrorType.GROUP_MOD_FAILED(6), got="+errType);
285 OFGroupModFailedCode code = OFGroupModFailedCodeSerializerVer12.readFrom(bb);
286 OFErrorCauseData data = OFErrorCauseData.read(bb, length - (bb.readerIndex() - start), OFVersion.OF_12);
287
288 OFGroupModFailedErrorMsgVer12 groupModFailedErrorMsgVer12 = new OFGroupModFailedErrorMsgVer12(
289 xid,
290 code,
291 data
292 );
293 if(logger.isTraceEnabled())
294 logger.trace("readFrom - read={}", groupModFailedErrorMsgVer12);
295 return groupModFailedErrorMsgVer12;
296 }
297 }
298
299 public void putTo(PrimitiveSink sink) {
300 FUNNEL.funnel(this, sink);
301 }
302
303 final static OFGroupModFailedErrorMsgVer12Funnel FUNNEL = new OFGroupModFailedErrorMsgVer12Funnel();
304 static class OFGroupModFailedErrorMsgVer12Funnel implements Funnel<OFGroupModFailedErrorMsgVer12> {
305 private static final long serialVersionUID = 1L;
306 @Override
307 public void funnel(OFGroupModFailedErrorMsgVer12 message, PrimitiveSink sink) {
308 // fixed value property version = 3
309 sink.putByte((byte) 0x3);
310 // fixed value property type = 1
311 sink.putByte((byte) 0x1);
312 // FIXME: skip funnel of length
313 sink.putLong(message.xid);
314 // fixed value property errType = 6
315 sink.putShort((short) 0x6);
316 OFGroupModFailedCodeSerializerVer12.putTo(message.code, sink);
317 message.data.putTo(sink);
318 }
319 }
320
321
322 public void writeTo(ChannelBuffer bb) {
323 WRITER.write(bb, this);
324 }
325
326 final static Writer WRITER = new Writer();
327 static class Writer implements OFMessageWriter<OFGroupModFailedErrorMsgVer12> {
328 @Override
329 public void write(ChannelBuffer bb, OFGroupModFailedErrorMsgVer12 message) {
330 int startIndex = bb.writerIndex();
331 // fixed value property version = 3
332 bb.writeByte((byte) 0x3);
333 // fixed value property type = 1
334 bb.writeByte((byte) 0x1);
335 // length is length of variable message, will be updated at the end
336 int lengthIndex = bb.writerIndex();
337 bb.writeShort(U16.t(0));
338
339 bb.writeInt(U32.t(message.xid));
340 // fixed value property errType = 6
341 bb.writeShort((short) 0x6);
342 OFGroupModFailedCodeSerializerVer12.writeTo(bb, message.code);
343 message.data.writeTo(bb);
344
345 // update length field
346 int length = bb.writerIndex() - startIndex;
347 bb.setShort(lengthIndex, length);
348
349 }
350 }
351
352 @Override
353 public String toString() {
354 StringBuilder b = new StringBuilder("OFGroupModFailedErrorMsgVer12(");
355 b.append("xid=").append(xid);
356 b.append(", ");
357 b.append("code=").append(code);
358 b.append(", ");
359 b.append("data=").append(data);
360 b.append(")");
361 return b.toString();
362 }
363
364 @Override
365 public boolean equals(Object obj) {
366 if (this == obj)
367 return true;
368 if (obj == null)
369 return false;
370 if (getClass() != obj.getClass())
371 return false;
372 OFGroupModFailedErrorMsgVer12 other = (OFGroupModFailedErrorMsgVer12) obj;
373
374 if( xid != other.xid)
375 return false;
376 if (code == null) {
377 if (other.code != null)
378 return false;
379 } else if (!code.equals(other.code))
380 return false;
381 if (data == null) {
382 if (other.data != null)
383 return false;
384 } else if (!data.equals(other.data))
385 return false;
386 return true;
387 }
388
389 @Override
390 public int hashCode() {
391 final int prime = 31;
392 int result = 1;
393
394 result = prime * (int) (xid ^ (xid >>> 32));
395 result = prime * result + ((code == null) ? 0 : code.hashCode());
396 result = prime * result + ((data == null) ? 0 : data.hashCode());
397 return result;
398 }
399
400}