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.ver13; |
| 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 OFBsnTlvVrfVer13 implements OFBsnTlvVrf { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFBsnTlvVrfVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 8; |
| 38 | |
| 39 | private final static long DEFAULT_VALUE = 0x0L; |
| 40 | |
| 41 | // OF message fields |
| 42 | private final long value; |
| 43 | // |
| 44 | // Immutable default instance |
| 45 | final static OFBsnTlvVrfVer13 DEFAULT = new OFBsnTlvVrfVer13( |
| 46 | DEFAULT_VALUE |
| 47 | ); |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFBsnTlvVrfVer13(long value) { |
| 51 | this.value = value; |
| 52 | } |
| 53 | |
| 54 | // Accessors for OF message fields |
| 55 | @Override |
| 56 | public int getType() { |
| 57 | return 0x13; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public long getValue() { |
| 62 | return value; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public OFVersion getVersion() { |
| 67 | return OFVersion.OF_13; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | public OFBsnTlvVrf.Builder createBuilder() { |
| 73 | return new BuilderWithParent(this); |
| 74 | } |
| 75 | |
| 76 | static class BuilderWithParent implements OFBsnTlvVrf.Builder { |
| 77 | final OFBsnTlvVrfVer13 parentMessage; |
| 78 | |
| 79 | // OF message fields |
| 80 | private boolean valueSet; |
| 81 | private long value; |
| 82 | |
| 83 | BuilderWithParent(OFBsnTlvVrfVer13 parentMessage) { |
| 84 | this.parentMessage = parentMessage; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public int getType() { |
| 89 | return 0x13; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public long getValue() { |
| 94 | return value; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public OFBsnTlvVrf.Builder setValue(long value) { |
| 99 | this.value = value; |
| 100 | this.valueSet = true; |
| 101 | return this; |
| 102 | } |
| 103 | @Override |
| 104 | public OFVersion getVersion() { |
| 105 | return OFVersion.OF_13; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | |
| 110 | @Override |
| 111 | public OFBsnTlvVrf build() { |
| 112 | long value = this.valueSet ? this.value : parentMessage.value; |
| 113 | |
| 114 | // |
| 115 | return new OFBsnTlvVrfVer13( |
| 116 | value |
| 117 | ); |
| 118 | } |
| 119 | |
| 120 | } |
| 121 | |
| 122 | static class Builder implements OFBsnTlvVrf.Builder { |
| 123 | // OF message fields |
| 124 | private boolean valueSet; |
| 125 | private long value; |
| 126 | |
| 127 | @Override |
| 128 | public int getType() { |
| 129 | return 0x13; |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public long getValue() { |
| 134 | return value; |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public OFBsnTlvVrf.Builder setValue(long value) { |
| 139 | this.value = value; |
| 140 | this.valueSet = true; |
| 141 | return this; |
| 142 | } |
| 143 | @Override |
| 144 | public OFVersion getVersion() { |
| 145 | return OFVersion.OF_13; |
| 146 | } |
| 147 | |
| 148 | // |
| 149 | @Override |
| 150 | public OFBsnTlvVrf build() { |
| 151 | long value = this.valueSet ? this.value : DEFAULT_VALUE; |
| 152 | |
| 153 | |
| 154 | return new OFBsnTlvVrfVer13( |
| 155 | value |
| 156 | ); |
| 157 | } |
| 158 | |
| 159 | } |
| 160 | |
| 161 | |
| 162 | final static Reader READER = new Reader(); |
| 163 | static class Reader implements OFMessageReader<OFBsnTlvVrf> { |
| 164 | @Override |
| 165 | public OFBsnTlvVrf readFrom(ChannelBuffer bb) throws OFParseError { |
| 166 | int start = bb.readerIndex(); |
| 167 | // fixed value property type == 0x13 |
| 168 | short type = bb.readShort(); |
| 169 | if(type != (short) 0x13) |
| 170 | throw new OFParseError("Wrong type: Expected=0x13(0x13), 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 | long value = U32.f(bb.readInt()); |
| 182 | |
| 183 | OFBsnTlvVrfVer13 bsnTlvVrfVer13 = new OFBsnTlvVrfVer13( |
| 184 | value |
| 185 | ); |
| 186 | if(logger.isTraceEnabled()) |
| 187 | logger.trace("readFrom - read={}", bsnTlvVrfVer13); |
| 188 | return bsnTlvVrfVer13; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | public void putTo(PrimitiveSink sink) { |
| 193 | FUNNEL.funnel(this, sink); |
| 194 | } |
| 195 | |
| 196 | final static OFBsnTlvVrfVer13Funnel FUNNEL = new OFBsnTlvVrfVer13Funnel(); |
| 197 | static class OFBsnTlvVrfVer13Funnel implements Funnel<OFBsnTlvVrfVer13> { |
| 198 | private static final long serialVersionUID = 1L; |
| 199 | @Override |
| 200 | public void funnel(OFBsnTlvVrfVer13 message, PrimitiveSink sink) { |
| 201 | // fixed value property type = 0x13 |
| 202 | sink.putShort((short) 0x13); |
| 203 | // fixed value property length = 8 |
| 204 | sink.putShort((short) 0x8); |
| 205 | sink.putLong(message.value); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | |
| 210 | public void writeTo(ChannelBuffer bb) { |
| 211 | WRITER.write(bb, this); |
| 212 | } |
| 213 | |
| 214 | final static Writer WRITER = new Writer(); |
| 215 | static class Writer implements OFMessageWriter<OFBsnTlvVrfVer13> { |
| 216 | @Override |
| 217 | public void write(ChannelBuffer bb, OFBsnTlvVrfVer13 message) { |
| 218 | // fixed value property type = 0x13 |
| 219 | bb.writeShort((short) 0x13); |
| 220 | // fixed value property length = 8 |
| 221 | bb.writeShort((short) 0x8); |
| 222 | bb.writeInt(U32.t(message.value)); |
| 223 | |
| 224 | |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | @Override |
| 229 | public String toString() { |
| 230 | StringBuilder b = new StringBuilder("OFBsnTlvVrfVer13("); |
| 231 | b.append("value=").append(value); |
| 232 | b.append(")"); |
| 233 | return b.toString(); |
| 234 | } |
| 235 | |
| 236 | @Override |
| 237 | public boolean equals(Object obj) { |
| 238 | if (this == obj) |
| 239 | return true; |
| 240 | if (obj == null) |
| 241 | return false; |
| 242 | if (getClass() != obj.getClass()) |
| 243 | return false; |
| 244 | OFBsnTlvVrfVer13 other = (OFBsnTlvVrfVer13) obj; |
| 245 | |
| 246 | if( value != other.value) |
| 247 | return false; |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | @Override |
| 252 | public int hashCode() { |
| 253 | final int prime = 31; |
| 254 | int result = 1; |
| 255 | |
| 256 | result = prime * (int) (value ^ (value >>> 32)); |
| 257 | return result; |
| 258 | } |
| 259 | |
| 260 | } |