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