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