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