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