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