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