blob: 650f3baad0cbd83ab7f9bcc5d71c93b5e7fe6142 [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.ver10;
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 OFActionEnqueueVer10 implements OFActionEnqueue {
34 private static final Logger logger = LoggerFactory.getLogger(OFActionEnqueueVer10.class);
35 // version: 1.0
36 final static byte WIRE_VERSION = 1;
37 final static int LENGTH = 16;
38
39 private final static OFPort DEFAULT_PORT = OFPort.ANY;
40 private final static long DEFAULT_QUEUE_ID = 0x0L;
41
42 // OF message fields
43 private final OFPort port;
44 private final long queueId;
45//
46 // Immutable default instance
47 final static OFActionEnqueueVer10 DEFAULT = new OFActionEnqueueVer10(
48 DEFAULT_PORT, DEFAULT_QUEUE_ID
49 );
50
51 // package private constructor - used by readers, builders, and factory
52 OFActionEnqueueVer10(OFPort port, long queueId) {
53 this.port = port;
54 this.queueId = queueId;
55 }
56
57 // Accessors for OF message fields
58 @Override
59 public OFActionType getType() {
60 return OFActionType.ENQUEUE;
61 }
62
63 @Override
64 public OFPort getPort() {
65 return port;
66 }
67
68 @Override
69 public long getQueueId() {
70 return queueId;
71 }
72
73 @Override
74 public OFVersion getVersion() {
75 return OFVersion.OF_10;
76 }
77
78
79
80 public OFActionEnqueue.Builder createBuilder() {
81 return new BuilderWithParent(this);
82 }
83
84 static class BuilderWithParent implements OFActionEnqueue.Builder {
85 final OFActionEnqueueVer10 parentMessage;
86
87 // OF message fields
88 private boolean portSet;
89 private OFPort port;
90 private boolean queueIdSet;
91 private long queueId;
92
93 BuilderWithParent(OFActionEnqueueVer10 parentMessage) {
94 this.parentMessage = parentMessage;
95 }
96
97 @Override
98 public OFActionType getType() {
99 return OFActionType.ENQUEUE;
100 }
101
102 @Override
103 public OFPort getPort() {
104 return port;
105 }
106
107 @Override
108 public OFActionEnqueue.Builder setPort(OFPort port) {
109 this.port = port;
110 this.portSet = true;
111 return this;
112 }
113 @Override
114 public long getQueueId() {
115 return queueId;
116 }
117
118 @Override
119 public OFActionEnqueue.Builder setQueueId(long queueId) {
120 this.queueId = queueId;
121 this.queueIdSet = true;
122 return this;
123 }
124 @Override
125 public OFVersion getVersion() {
126 return OFVersion.OF_10;
127 }
128
129
130
131 @Override
132 public OFActionEnqueue build() {
133 OFPort port = this.portSet ? this.port : parentMessage.port;
134 if(port == null)
135 throw new NullPointerException("Property port must not be null");
136 long queueId = this.queueIdSet ? this.queueId : parentMessage.queueId;
137
138 //
139 return new OFActionEnqueueVer10(
140 port,
141 queueId
142 );
143 }
144
145 }
146
147 static class Builder implements OFActionEnqueue.Builder {
148 // OF message fields
149 private boolean portSet;
150 private OFPort port;
151 private boolean queueIdSet;
152 private long queueId;
153
154 @Override
155 public OFActionType getType() {
156 return OFActionType.ENQUEUE;
157 }
158
159 @Override
160 public OFPort getPort() {
161 return port;
162 }
163
164 @Override
165 public OFActionEnqueue.Builder setPort(OFPort port) {
166 this.port = port;
167 this.portSet = true;
168 return this;
169 }
170 @Override
171 public long getQueueId() {
172 return queueId;
173 }
174
175 @Override
176 public OFActionEnqueue.Builder setQueueId(long queueId) {
177 this.queueId = queueId;
178 this.queueIdSet = true;
179 return this;
180 }
181 @Override
182 public OFVersion getVersion() {
183 return OFVersion.OF_10;
184 }
185
186//
187 @Override
188 public OFActionEnqueue build() {
189 OFPort port = this.portSet ? this.port : DEFAULT_PORT;
190 if(port == null)
191 throw new NullPointerException("Property port must not be null");
192 long queueId = this.queueIdSet ? this.queueId : DEFAULT_QUEUE_ID;
193
194
195 return new OFActionEnqueueVer10(
196 port,
197 queueId
198 );
199 }
200
201 }
202
203
204 final static Reader READER = new Reader();
205 static class Reader implements OFMessageReader<OFActionEnqueue> {
206 @Override
207 public OFActionEnqueue readFrom(ChannelBuffer bb) throws OFParseError {
208 int start = bb.readerIndex();
209 // fixed value property type == 11
210 short type = bb.readShort();
211 if(type != (short) 0xb)
212 throw new OFParseError("Wrong type: Expected=OFActionType.ENQUEUE(11), got="+type);
213 int length = U16.f(bb.readShort());
214 if(length != 16)
215 throw new OFParseError("Wrong length: Expected=16(16), got="+length);
216 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
217 // Buffer does not have all data yet
218 bb.readerIndex(start);
219 return null;
220 }
221 if(logger.isTraceEnabled())
222 logger.trace("readFrom - length={}", length);
223 OFPort port = OFPort.read2Bytes(bb);
224 // pad: 6 bytes
225 bb.skipBytes(6);
226 long queueId = U32.f(bb.readInt());
227
228 OFActionEnqueueVer10 actionEnqueueVer10 = new OFActionEnqueueVer10(
229 port,
230 queueId
231 );
232 if(logger.isTraceEnabled())
233 logger.trace("readFrom - read={}", actionEnqueueVer10);
234 return actionEnqueueVer10;
235 }
236 }
237
238 public void putTo(PrimitiveSink sink) {
239 FUNNEL.funnel(this, sink);
240 }
241
242 final static OFActionEnqueueVer10Funnel FUNNEL = new OFActionEnqueueVer10Funnel();
243 static class OFActionEnqueueVer10Funnel implements Funnel<OFActionEnqueueVer10> {
244 private static final long serialVersionUID = 1L;
245 @Override
246 public void funnel(OFActionEnqueueVer10 message, PrimitiveSink sink) {
247 // fixed value property type = 11
248 sink.putShort((short) 0xb);
249 // fixed value property length = 16
250 sink.putShort((short) 0x10);
251 message.port.putTo(sink);
252 // skip pad (6 bytes)
253 sink.putLong(message.queueId);
254 }
255 }
256
257
258 public void writeTo(ChannelBuffer bb) {
259 WRITER.write(bb, this);
260 }
261
262 final static Writer WRITER = new Writer();
263 static class Writer implements OFMessageWriter<OFActionEnqueueVer10> {
264 @Override
265 public void write(ChannelBuffer bb, OFActionEnqueueVer10 message) {
266 // fixed value property type = 11
267 bb.writeShort((short) 0xb);
268 // fixed value property length = 16
269 bb.writeShort((short) 0x10);
270 message.port.write2Bytes(bb);
271 // pad: 6 bytes
272 bb.writeZero(6);
273 bb.writeInt(U32.t(message.queueId));
274
275
276 }
277 }
278
279 @Override
280 public String toString() {
281 StringBuilder b = new StringBuilder("OFActionEnqueueVer10(");
282 b.append("port=").append(port);
283 b.append(", ");
284 b.append("queueId=").append(queueId);
285 b.append(")");
286 return b.toString();
287 }
288
289 @Override
290 public boolean equals(Object obj) {
291 if (this == obj)
292 return true;
293 if (obj == null)
294 return false;
295 if (getClass() != obj.getClass())
296 return false;
297 OFActionEnqueueVer10 other = (OFActionEnqueueVer10) obj;
298
299 if (port == null) {
300 if (other.port != null)
301 return false;
302 } else if (!port.equals(other.port))
303 return false;
304 if( queueId != other.queueId)
305 return false;
306 return true;
307 }
308
309 @Override
310 public int hashCode() {
311 final int prime = 31;
312 int result = 1;
313
314 result = prime * result + ((port == null) ? 0 : port.hashCode());
315 result = prime * (int) (queueId ^ (queueId >>> 32));
316 return result;
317 }
318
319}