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