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