blob: 9f4b8249e65ba8ffc210ab9a5e4069e195ca375e [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.ver13;
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 OFQueuePropMaxRateVer13 implements OFQueuePropMaxRate {
34 private static final Logger logger = LoggerFactory.getLogger(OFQueuePropMaxRateVer13.class);
35 // version: 1.3
36 final static byte WIRE_VERSION = 4;
37 final static int LENGTH = 16;
38
39 private final static int DEFAULT_RATE = 0x0;
40
41 // OF message fields
42 private final int rate;
43//
44 // Immutable default instance
45 final static OFQueuePropMaxRateVer13 DEFAULT = new OFQueuePropMaxRateVer13(
46 DEFAULT_RATE
47 );
48
49 // package private constructor - used by readers, builders, and factory
50 OFQueuePropMaxRateVer13(int rate) {
51 this.rate = rate;
52 }
53
54 // Accessors for OF message fields
55 @Override
56 public int getType() {
57 return 0x2;
58 }
59
60 @Override
61 public int getRate() {
62 return rate;
63 }
64
65 @Override
66 public OFVersion getVersion() {
67 return OFVersion.OF_13;
68 }
69
70
71
72 public OFQueuePropMaxRate.Builder createBuilder() {
73 return new BuilderWithParent(this);
74 }
75
76 static class BuilderWithParent implements OFQueuePropMaxRate.Builder {
77 final OFQueuePropMaxRateVer13 parentMessage;
78
79 // OF message fields
80 private boolean rateSet;
81 private int rate;
82
83 BuilderWithParent(OFQueuePropMaxRateVer13 parentMessage) {
84 this.parentMessage = parentMessage;
85 }
86
87 @Override
88 public int getType() {
89 return 0x2;
90 }
91
92 @Override
93 public int getRate() {
94 return rate;
95 }
96
97 @Override
98 public OFQueuePropMaxRate.Builder setRate(int rate) {
99 this.rate = rate;
100 this.rateSet = true;
101 return this;
102 }
103 @Override
104 public OFVersion getVersion() {
105 return OFVersion.OF_13;
106 }
107
108
109
110 @Override
111 public OFQueuePropMaxRate build() {
112 int rate = this.rateSet ? this.rate : parentMessage.rate;
113
114 //
115 return new OFQueuePropMaxRateVer13(
116 rate
117 );
118 }
119
120 }
121
122 static class Builder implements OFQueuePropMaxRate.Builder {
123 // OF message fields
124 private boolean rateSet;
125 private int rate;
126
127 @Override
128 public int getType() {
129 return 0x2;
130 }
131
132 @Override
133 public int getRate() {
134 return rate;
135 }
136
137 @Override
138 public OFQueuePropMaxRate.Builder setRate(int rate) {
139 this.rate = rate;
140 this.rateSet = true;
141 return this;
142 }
143 @Override
144 public OFVersion getVersion() {
145 return OFVersion.OF_13;
146 }
147
148//
149 @Override
150 public OFQueuePropMaxRate build() {
151 int rate = this.rateSet ? this.rate : DEFAULT_RATE;
152
153
154 return new OFQueuePropMaxRateVer13(
155 rate
156 );
157 }
158
159 }
160
161
162 final static Reader READER = new Reader();
163 static class Reader implements OFMessageReader<OFQueuePropMaxRate> {
164 @Override
165 public OFQueuePropMaxRate readFrom(ChannelBuffer bb) throws OFParseError {
166 int start = bb.readerIndex();
167 // fixed value property type == 0x2
168 short type = bb.readShort();
169 if(type != (short) 0x2)
170 throw new OFParseError("Wrong type: Expected=0x2(0x2), got="+type);
171 int length = U16.f(bb.readShort());
172 if(length != 16)
173 throw new OFParseError("Wrong length: Expected=16(16), got="+length);
174 if(bb.readableBytes() + (bb.readerIndex() - start) < length) {
175 // Buffer does not have all data yet
176 bb.readerIndex(start);
177 return null;
178 }
179 if(logger.isTraceEnabled())
180 logger.trace("readFrom - length={}", length);
181 // pad: 4 bytes
182 bb.skipBytes(4);
183 int rate = U16.f(bb.readShort());
184 // pad: 6 bytes
185 bb.skipBytes(6);
186
187 OFQueuePropMaxRateVer13 queuePropMaxRateVer13 = new OFQueuePropMaxRateVer13(
188 rate
189 );
190 if(logger.isTraceEnabled())
191 logger.trace("readFrom - read={}", queuePropMaxRateVer13);
192 return queuePropMaxRateVer13;
193 }
194 }
195
196 public void putTo(PrimitiveSink sink) {
197 FUNNEL.funnel(this, sink);
198 }
199
200 final static OFQueuePropMaxRateVer13Funnel FUNNEL = new OFQueuePropMaxRateVer13Funnel();
201 static class OFQueuePropMaxRateVer13Funnel implements Funnel<OFQueuePropMaxRateVer13> {
202 private static final long serialVersionUID = 1L;
203 @Override
204 public void funnel(OFQueuePropMaxRateVer13 message, PrimitiveSink sink) {
205 // fixed value property type = 0x2
206 sink.putShort((short) 0x2);
207 // fixed value property length = 16
208 sink.putShort((short) 0x10);
209 // skip pad (4 bytes)
210 sink.putInt(message.rate);
211 // skip pad (6 bytes)
212 }
213 }
214
215
216 public void writeTo(ChannelBuffer bb) {
217 WRITER.write(bb, this);
218 }
219
220 final static Writer WRITER = new Writer();
221 static class Writer implements OFMessageWriter<OFQueuePropMaxRateVer13> {
222 @Override
223 public void write(ChannelBuffer bb, OFQueuePropMaxRateVer13 message) {
224 // fixed value property type = 0x2
225 bb.writeShort((short) 0x2);
226 // fixed value property length = 16
227 bb.writeShort((short) 0x10);
228 // pad: 4 bytes
229 bb.writeZero(4);
230 bb.writeShort(U16.t(message.rate));
231 // pad: 6 bytes
232 bb.writeZero(6);
233
234
235 }
236 }
237
238 @Override
239 public String toString() {
240 StringBuilder b = new StringBuilder("OFQueuePropMaxRateVer13(");
241 b.append("rate=").append(rate);
242 b.append(")");
243 return b.toString();
244 }
245
246 @Override
247 public boolean equals(Object obj) {
248 if (this == obj)
249 return true;
250 if (obj == null)
251 return false;
252 if (getClass() != obj.getClass())
253 return false;
254 OFQueuePropMaxRateVer13 other = (OFQueuePropMaxRateVer13) obj;
255
256 if( rate != other.rate)
257 return false;
258 return true;
259 }
260
261 @Override
262 public int hashCode() {
263 final int prime = 31;
264 int result = 1;
265
266 result = prime * result + rate;
267 return result;
268 }
269
270}