tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 1 | // 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 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver10; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.slf4j.Logger; |
| 27 | import org.slf4j.LoggerFactory; |
| 28 | import java.util.Set; |
| 29 | import org.jboss.netty.buffer.ChannelBuffer; |
| 30 | import com.google.common.hash.PrimitiveSink; |
| 31 | import com.google.common.hash.Funnel; |
| 32 | |
| 33 | class OFActionBsnMirrorVer10 implements OFActionBsnMirror { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFActionBsnMirrorVer10.class); |
| 35 | // version: 1.0 |
| 36 | final static byte WIRE_VERSION = 1; |
| 37 | final static int LENGTH = 24; |
| 38 | |
| 39 | private final static OFPort DEFAULT_DEST_PORT = OFPort.ANY; |
| 40 | private final static long DEFAULT_VLAN_TAG = 0x0L; |
| 41 | private final static short DEFAULT_COPY_STAGE = (short) 0x0; |
| 42 | |
| 43 | // OF message fields |
| 44 | private final OFPort destPort; |
| 45 | private final long vlanTag; |
| 46 | private final short copyStage; |
| 47 | // |
| 48 | // Immutable default instance |
| 49 | final static OFActionBsnMirrorVer10 DEFAULT = new OFActionBsnMirrorVer10( |
| 50 | DEFAULT_DEST_PORT, DEFAULT_VLAN_TAG, DEFAULT_COPY_STAGE |
| 51 | ); |
| 52 | |
| 53 | // package private constructor - used by readers, builders, and factory |
| 54 | OFActionBsnMirrorVer10(OFPort destPort, long vlanTag, short copyStage) { |
| 55 | this.destPort = destPort; |
| 56 | this.vlanTag = vlanTag; |
| 57 | this.copyStage = copyStage; |
| 58 | } |
| 59 | |
| 60 | // Accessors for OF message fields |
| 61 | @Override |
| 62 | public OFActionType getType() { |
| 63 | return OFActionType.EXPERIMENTER; |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public long getExperimenter() { |
| 68 | return 0x5c16c7L; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public long getSubtype() { |
| 73 | return 0x1L; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public OFPort getDestPort() { |
| 78 | return destPort; |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public long getVlanTag() { |
| 83 | return vlanTag; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public short getCopyStage() { |
| 88 | return copyStage; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public OFVersion getVersion() { |
| 93 | return OFVersion.OF_10; |
| 94 | } |
| 95 | |
| 96 | |
| 97 | |
| 98 | public OFActionBsnMirror.Builder createBuilder() { |
| 99 | return new BuilderWithParent(this); |
| 100 | } |
| 101 | |
| 102 | static class BuilderWithParent implements OFActionBsnMirror.Builder { |
| 103 | final OFActionBsnMirrorVer10 parentMessage; |
| 104 | |
| 105 | // OF message fields |
| 106 | private boolean destPortSet; |
| 107 | private OFPort destPort; |
| 108 | private boolean vlanTagSet; |
| 109 | private long vlanTag; |
| 110 | private boolean copyStageSet; |
| 111 | private short copyStage; |
| 112 | |
| 113 | BuilderWithParent(OFActionBsnMirrorVer10 parentMessage) { |
| 114 | this.parentMessage = parentMessage; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public OFActionType getType() { |
| 119 | return OFActionType.EXPERIMENTER; |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public long getExperimenter() { |
| 124 | return 0x5c16c7L; |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public long getSubtype() { |
| 129 | return 0x1L; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public OFPort getDestPort() { |
| 134 | return destPort; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public OFActionBsnMirror.Builder setDestPort(OFPort destPort) { |
| 139 | this.destPort = destPort; |
| 140 | this.destPortSet = true; |
| 141 | return this; |
| 142 | } |
| 143 | @Override |
| 144 | public long getVlanTag() { |
| 145 | return vlanTag; |
| 146 | } |
| 147 | |
| 148 | @Override |
| 149 | public OFActionBsnMirror.Builder setVlanTag(long vlanTag) { |
| 150 | this.vlanTag = vlanTag; |
| 151 | this.vlanTagSet = true; |
| 152 | return this; |
| 153 | } |
| 154 | @Override |
| 155 | public short getCopyStage() { |
| 156 | return copyStage; |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public OFActionBsnMirror.Builder setCopyStage(short copyStage) { |
| 161 | this.copyStage = copyStage; |
| 162 | this.copyStageSet = true; |
| 163 | return this; |
| 164 | } |
| 165 | @Override |
| 166 | public OFVersion getVersion() { |
| 167 | return OFVersion.OF_10; |
| 168 | } |
| 169 | |
| 170 | |
| 171 | |
| 172 | @Override |
| 173 | public OFActionBsnMirror build() { |
| 174 | OFPort destPort = this.destPortSet ? this.destPort : parentMessage.destPort; |
| 175 | if(destPort == null) |
| 176 | throw new NullPointerException("Property destPort must not be null"); |
| 177 | long vlanTag = this.vlanTagSet ? this.vlanTag : parentMessage.vlanTag; |
| 178 | short copyStage = this.copyStageSet ? this.copyStage : parentMessage.copyStage; |
| 179 | |
| 180 | // |
| 181 | return new OFActionBsnMirrorVer10( |
| 182 | destPort, |
| 183 | vlanTag, |
| 184 | copyStage |
| 185 | ); |
| 186 | } |
| 187 | |
| 188 | } |
| 189 | |
| 190 | static class Builder implements OFActionBsnMirror.Builder { |
| 191 | // OF message fields |
| 192 | private boolean destPortSet; |
| 193 | private OFPort destPort; |
| 194 | private boolean vlanTagSet; |
| 195 | private long vlanTag; |
| 196 | private boolean copyStageSet; |
| 197 | private short copyStage; |
| 198 | |
| 199 | @Override |
| 200 | public OFActionType getType() { |
| 201 | return OFActionType.EXPERIMENTER; |
| 202 | } |
| 203 | |
| 204 | @Override |
| 205 | public long getExperimenter() { |
| 206 | return 0x5c16c7L; |
| 207 | } |
| 208 | |
| 209 | @Override |
| 210 | public long getSubtype() { |
| 211 | return 0x1L; |
| 212 | } |
| 213 | |
| 214 | @Override |
| 215 | public OFPort getDestPort() { |
| 216 | return destPort; |
| 217 | } |
| 218 | |
| 219 | @Override |
| 220 | public OFActionBsnMirror.Builder setDestPort(OFPort destPort) { |
| 221 | this.destPort = destPort; |
| 222 | this.destPortSet = true; |
| 223 | return this; |
| 224 | } |
| 225 | @Override |
| 226 | public long getVlanTag() { |
| 227 | return vlanTag; |
| 228 | } |
| 229 | |
| 230 | @Override |
| 231 | public OFActionBsnMirror.Builder setVlanTag(long vlanTag) { |
| 232 | this.vlanTag = vlanTag; |
| 233 | this.vlanTagSet = true; |
| 234 | return this; |
| 235 | } |
| 236 | @Override |
| 237 | public short getCopyStage() { |
| 238 | return copyStage; |
| 239 | } |
| 240 | |
| 241 | @Override |
| 242 | public OFActionBsnMirror.Builder setCopyStage(short copyStage) { |
| 243 | this.copyStage = copyStage; |
| 244 | this.copyStageSet = true; |
| 245 | return this; |
| 246 | } |
| 247 | @Override |
| 248 | public OFVersion getVersion() { |
| 249 | return OFVersion.OF_10; |
| 250 | } |
| 251 | |
| 252 | // |
| 253 | @Override |
| 254 | public OFActionBsnMirror build() { |
| 255 | OFPort destPort = this.destPortSet ? this.destPort : DEFAULT_DEST_PORT; |
| 256 | if(destPort == null) |
| 257 | throw new NullPointerException("Property destPort must not be null"); |
| 258 | long vlanTag = this.vlanTagSet ? this.vlanTag : DEFAULT_VLAN_TAG; |
| 259 | short copyStage = this.copyStageSet ? this.copyStage : DEFAULT_COPY_STAGE; |
| 260 | |
| 261 | |
| 262 | return new OFActionBsnMirrorVer10( |
| 263 | destPort, |
| 264 | vlanTag, |
| 265 | copyStage |
| 266 | ); |
| 267 | } |
| 268 | |
| 269 | } |
| 270 | |
| 271 | |
| 272 | final static Reader READER = new Reader(); |
| 273 | static class Reader implements OFMessageReader<OFActionBsnMirror> { |
| 274 | @Override |
| 275 | public OFActionBsnMirror readFrom(ChannelBuffer bb) throws OFParseError { |
| 276 | int start = bb.readerIndex(); |
| 277 | // fixed value property type == 65535 |
| 278 | short type = bb.readShort(); |
| 279 | if(type != (short) 0xffff) |
| 280 | throw new OFParseError("Wrong type: Expected=OFActionType.EXPERIMENTER(65535), got="+type); |
| 281 | int length = U16.f(bb.readShort()); |
| 282 | if(length != 24) |
| 283 | throw new OFParseError("Wrong length: Expected=24(24), got="+length); |
| 284 | if(bb.readableBytes() + (bb.readerIndex() - start) < length) { |
| 285 | // Buffer does not have all data yet |
| 286 | bb.readerIndex(start); |
| 287 | return null; |
| 288 | } |
| 289 | if(logger.isTraceEnabled()) |
| 290 | logger.trace("readFrom - length={}", length); |
| 291 | // fixed value property experimenter == 0x5c16c7L |
| 292 | int experimenter = bb.readInt(); |
| 293 | if(experimenter != 0x5c16c7) |
| 294 | throw new OFParseError("Wrong experimenter: Expected=0x5c16c7L(0x5c16c7L), got="+experimenter); |
| 295 | // fixed value property subtype == 0x1L |
| 296 | int subtype = bb.readInt(); |
| 297 | if(subtype != 0x1) |
| 298 | throw new OFParseError("Wrong subtype: Expected=0x1L(0x1L), got="+subtype); |
| 299 | OFPort destPort = OFPort.read2Bytes(bb); |
| 300 | long vlanTag = U32.f(bb.readInt()); |
| 301 | short copyStage = U8.f(bb.readByte()); |
| 302 | // pad: 3 bytes |
| 303 | bb.skipBytes(3); |
| 304 | |
| 305 | OFActionBsnMirrorVer10 actionBsnMirrorVer10 = new OFActionBsnMirrorVer10( |
| 306 | destPort, |
| 307 | vlanTag, |
| 308 | copyStage |
| 309 | ); |
| 310 | if(logger.isTraceEnabled()) |
| 311 | logger.trace("readFrom - read={}", actionBsnMirrorVer10); |
| 312 | return actionBsnMirrorVer10; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | public void putTo(PrimitiveSink sink) { |
| 317 | FUNNEL.funnel(this, sink); |
| 318 | } |
| 319 | |
| 320 | final static OFActionBsnMirrorVer10Funnel FUNNEL = new OFActionBsnMirrorVer10Funnel(); |
| 321 | static class OFActionBsnMirrorVer10Funnel implements Funnel<OFActionBsnMirrorVer10> { |
| 322 | private static final long serialVersionUID = 1L; |
| 323 | @Override |
| 324 | public void funnel(OFActionBsnMirrorVer10 message, PrimitiveSink sink) { |
| 325 | // fixed value property type = 65535 |
| 326 | sink.putShort((short) 0xffff); |
| 327 | // fixed value property length = 24 |
| 328 | sink.putShort((short) 0x18); |
| 329 | // fixed value property experimenter = 0x5c16c7L |
| 330 | sink.putInt(0x5c16c7); |
| 331 | // fixed value property subtype = 0x1L |
| 332 | sink.putInt(0x1); |
| 333 | message.destPort.putTo(sink); |
| 334 | sink.putLong(message.vlanTag); |
| 335 | sink.putShort(message.copyStage); |
| 336 | // skip pad (3 bytes) |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | |
| 341 | public void writeTo(ChannelBuffer bb) { |
| 342 | WRITER.write(bb, this); |
| 343 | } |
| 344 | |
| 345 | final static Writer WRITER = new Writer(); |
| 346 | static class Writer implements OFMessageWriter<OFActionBsnMirrorVer10> { |
| 347 | @Override |
| 348 | public void write(ChannelBuffer bb, OFActionBsnMirrorVer10 message) { |
| 349 | // fixed value property type = 65535 |
| 350 | bb.writeShort((short) 0xffff); |
| 351 | // fixed value property length = 24 |
| 352 | bb.writeShort((short) 0x18); |
| 353 | // fixed value property experimenter = 0x5c16c7L |
| 354 | bb.writeInt(0x5c16c7); |
| 355 | // fixed value property subtype = 0x1L |
| 356 | bb.writeInt(0x1); |
| 357 | message.destPort.write2Bytes(bb); |
| 358 | bb.writeInt(U32.t(message.vlanTag)); |
| 359 | bb.writeByte(U8.t(message.copyStage)); |
| 360 | // pad: 3 bytes |
| 361 | bb.writeZero(3); |
| 362 | |
| 363 | |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | @Override |
| 368 | public String toString() { |
| 369 | StringBuilder b = new StringBuilder("OFActionBsnMirrorVer10("); |
| 370 | b.append("destPort=").append(destPort); |
| 371 | b.append(", "); |
| 372 | b.append("vlanTag=").append(vlanTag); |
| 373 | b.append(", "); |
| 374 | b.append("copyStage=").append(copyStage); |
| 375 | b.append(")"); |
| 376 | return b.toString(); |
| 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public boolean equals(Object obj) { |
| 381 | if (this == obj) |
| 382 | return true; |
| 383 | if (obj == null) |
| 384 | return false; |
| 385 | if (getClass() != obj.getClass()) |
| 386 | return false; |
| 387 | OFActionBsnMirrorVer10 other = (OFActionBsnMirrorVer10) obj; |
| 388 | |
| 389 | if (destPort == null) { |
| 390 | if (other.destPort != null) |
| 391 | return false; |
| 392 | } else if (!destPort.equals(other.destPort)) |
| 393 | return false; |
| 394 | if( vlanTag != other.vlanTag) |
| 395 | return false; |
| 396 | if( copyStage != other.copyStage) |
| 397 | return false; |
| 398 | return true; |
| 399 | } |
| 400 | |
| 401 | @Override |
| 402 | public int hashCode() { |
| 403 | final int prime = 31; |
| 404 | int result = 1; |
| 405 | |
| 406 | result = prime * result + ((destPort == null) ? 0 : destPort.hashCode()); |
| 407 | result = prime * (int) (vlanTag ^ (vlanTag >>> 32)); |
| 408 | result = prime * result + copyStage; |
| 409 | return result; |
| 410 | } |
| 411 | |
| 412 | } |