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.ver12; |
| 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 OFOxmIcmpv6CodeVer12 implements OFOxmIcmpv6Code { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFOxmIcmpv6CodeVer12.class); |
| 35 | // version: 1.2 |
| 36 | final static byte WIRE_VERSION = 3; |
| 37 | final static int LENGTH = 5; |
| 38 | |
| 39 | private final static U8 DEFAULT_VALUE = U8.ZERO; |
| 40 | |
| 41 | // OF message fields |
| 42 | private final U8 value; |
| 43 | // |
| 44 | // Immutable default instance |
| 45 | final static OFOxmIcmpv6CodeVer12 DEFAULT = new OFOxmIcmpv6CodeVer12( |
| 46 | DEFAULT_VALUE |
| 47 | ); |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFOxmIcmpv6CodeVer12(U8 value) { |
| 51 | this.value = value; |
| 52 | } |
| 53 | |
| 54 | // Accessors for OF message fields |
| 55 | @Override |
| 56 | public long getTypeLen() { |
| 57 | return 0x80003c01L; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public U8 getValue() { |
| 62 | return value; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public MatchField<U8> getMatchField() { |
| 67 | return MatchField.ICMPV6_CODE; |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public boolean isMasked() { |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | public OFOxm<U8> getCanonical() { |
| 76 | // exact match OXM is always canonical |
| 77 | return this; |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public U8 getMask()throws UnsupportedOperationException { |
| 82 | throw new UnsupportedOperationException("Property mask not supported in version 1.2"); |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public OFVersion getVersion() { |
| 87 | return OFVersion.OF_12; |
| 88 | } |
| 89 | |
| 90 | |
| 91 | |
| 92 | public OFOxmIcmpv6Code.Builder createBuilder() { |
| 93 | return new BuilderWithParent(this); |
| 94 | } |
| 95 | |
| 96 | static class BuilderWithParent implements OFOxmIcmpv6Code.Builder { |
| 97 | final OFOxmIcmpv6CodeVer12 parentMessage; |
| 98 | |
| 99 | // OF message fields |
| 100 | private boolean valueSet; |
| 101 | private U8 value; |
| 102 | |
| 103 | BuilderWithParent(OFOxmIcmpv6CodeVer12 parentMessage) { |
| 104 | this.parentMessage = parentMessage; |
| 105 | } |
| 106 | |
| 107 | @Override |
| 108 | public long getTypeLen() { |
| 109 | return 0x80003c01L; |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | public U8 getValue() { |
| 114 | return value; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public OFOxmIcmpv6Code.Builder setValue(U8 value) { |
| 119 | this.value = value; |
| 120 | this.valueSet = true; |
| 121 | return this; |
| 122 | } |
| 123 | @Override |
| 124 | public MatchField<U8> getMatchField() { |
| 125 | return MatchField.ICMPV6_CODE; |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public boolean isMasked() { |
| 130 | return false; |
| 131 | } |
| 132 | |
| 133 | @Override |
| 134 | public OFOxm<U8> getCanonical()throws UnsupportedOperationException { |
| 135 | throw new UnsupportedOperationException("Property canonical not supported in version 1.2"); |
| 136 | } |
| 137 | |
| 138 | @Override |
| 139 | public U8 getMask()throws UnsupportedOperationException { |
| 140 | throw new UnsupportedOperationException("Property mask not supported in version 1.2"); |
| 141 | } |
| 142 | |
| 143 | @Override |
| 144 | public OFVersion getVersion() { |
| 145 | return OFVersion.OF_12; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | |
| 150 | @Override |
| 151 | public OFOxmIcmpv6Code build() { |
| 152 | U8 value = this.valueSet ? this.value : parentMessage.value; |
| 153 | if(value == null) |
| 154 | throw new NullPointerException("Property value must not be null"); |
| 155 | |
| 156 | // |
| 157 | return new OFOxmIcmpv6CodeVer12( |
| 158 | value |
| 159 | ); |
| 160 | } |
| 161 | |
| 162 | } |
| 163 | |
| 164 | static class Builder implements OFOxmIcmpv6Code.Builder { |
| 165 | // OF message fields |
| 166 | private boolean valueSet; |
| 167 | private U8 value; |
| 168 | |
| 169 | @Override |
| 170 | public long getTypeLen() { |
| 171 | return 0x80003c01L; |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public U8 getValue() { |
| 176 | return value; |
| 177 | } |
| 178 | |
| 179 | @Override |
| 180 | public OFOxmIcmpv6Code.Builder setValue(U8 value) { |
| 181 | this.value = value; |
| 182 | this.valueSet = true; |
| 183 | return this; |
| 184 | } |
| 185 | @Override |
| 186 | public MatchField<U8> getMatchField() { |
| 187 | return MatchField.ICMPV6_CODE; |
| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | public boolean isMasked() { |
| 192 | return false; |
| 193 | } |
| 194 | |
| 195 | @Override |
| 196 | public OFOxm<U8> getCanonical()throws UnsupportedOperationException { |
| 197 | throw new UnsupportedOperationException("Property canonical not supported in version 1.2"); |
| 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public U8 getMask()throws UnsupportedOperationException { |
| 202 | throw new UnsupportedOperationException("Property mask not supported in version 1.2"); |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public OFVersion getVersion() { |
| 207 | return OFVersion.OF_12; |
| 208 | } |
| 209 | |
| 210 | // |
| 211 | @Override |
| 212 | public OFOxmIcmpv6Code build() { |
| 213 | U8 value = this.valueSet ? this.value : DEFAULT_VALUE; |
| 214 | if(value == null) |
| 215 | throw new NullPointerException("Property value must not be null"); |
| 216 | |
| 217 | |
| 218 | return new OFOxmIcmpv6CodeVer12( |
| 219 | value |
| 220 | ); |
| 221 | } |
| 222 | |
| 223 | } |
| 224 | |
| 225 | |
| 226 | final static Reader READER = new Reader(); |
| 227 | static class Reader implements OFMessageReader<OFOxmIcmpv6Code> { |
| 228 | @Override |
| 229 | public OFOxmIcmpv6Code readFrom(ChannelBuffer bb) throws OFParseError { |
| 230 | // fixed value property typeLen == 0x80003c01L |
| 231 | int typeLen = bb.readInt(); |
| 232 | if(typeLen != (int) 0x80003c01) |
| 233 | throw new OFParseError("Wrong typeLen: Expected=0x80003c01L(0x80003c01L), got="+typeLen); |
| 234 | U8 value = U8.of(bb.readByte()); |
| 235 | |
| 236 | OFOxmIcmpv6CodeVer12 oxmIcmpv6CodeVer12 = new OFOxmIcmpv6CodeVer12( |
| 237 | value |
| 238 | ); |
| 239 | if(logger.isTraceEnabled()) |
| 240 | logger.trace("readFrom - read={}", oxmIcmpv6CodeVer12); |
| 241 | return oxmIcmpv6CodeVer12; |
| 242 | } |
| 243 | } |
| 244 | |
| 245 | public void putTo(PrimitiveSink sink) { |
| 246 | FUNNEL.funnel(this, sink); |
| 247 | } |
| 248 | |
| 249 | final static OFOxmIcmpv6CodeVer12Funnel FUNNEL = new OFOxmIcmpv6CodeVer12Funnel(); |
| 250 | static class OFOxmIcmpv6CodeVer12Funnel implements Funnel<OFOxmIcmpv6CodeVer12> { |
| 251 | private static final long serialVersionUID = 1L; |
| 252 | @Override |
| 253 | public void funnel(OFOxmIcmpv6CodeVer12 message, PrimitiveSink sink) { |
| 254 | // fixed value property typeLen = 0x80003c01L |
| 255 | sink.putInt((int) 0x80003c01); |
| 256 | message.value.putTo(sink); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | |
| 261 | public void writeTo(ChannelBuffer bb) { |
| 262 | WRITER.write(bb, this); |
| 263 | } |
| 264 | |
| 265 | final static Writer WRITER = new Writer(); |
| 266 | static class Writer implements OFMessageWriter<OFOxmIcmpv6CodeVer12> { |
| 267 | @Override |
| 268 | public void write(ChannelBuffer bb, OFOxmIcmpv6CodeVer12 message) { |
| 269 | // fixed value property typeLen = 0x80003c01L |
| 270 | bb.writeInt((int) 0x80003c01); |
| 271 | bb.writeByte(message.value.getRaw()); |
| 272 | |
| 273 | |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | @Override |
| 278 | public String toString() { |
| 279 | StringBuilder b = new StringBuilder("OFOxmIcmpv6CodeVer12("); |
| 280 | b.append("value=").append(value); |
| 281 | b.append(")"); |
| 282 | return b.toString(); |
| 283 | } |
| 284 | |
| 285 | @Override |
| 286 | public boolean equals(Object obj) { |
| 287 | if (this == obj) |
| 288 | return true; |
| 289 | if (obj == null) |
| 290 | return false; |
| 291 | if (getClass() != obj.getClass()) |
| 292 | return false; |
| 293 | OFOxmIcmpv6CodeVer12 other = (OFOxmIcmpv6CodeVer12) obj; |
| 294 | |
| 295 | if (value == null) { |
| 296 | if (other.value != null) |
| 297 | return false; |
| 298 | } else if (!value.equals(other.value)) |
| 299 | return false; |
| 300 | return true; |
| 301 | } |
| 302 | |
| 303 | @Override |
| 304 | public int hashCode() { |
| 305 | final int prime = 31; |
| 306 | int result = 1; |
| 307 | |
| 308 | result = prime * result + ((value == null) ? 0 : value.hashCode()); |
| 309 | return result; |
| 310 | } |
| 311 | |
| 312 | } |