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