alshabib | 86ac11c | 2014-08-14 16:14:41 -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 OFActionPushPbbVer13 implements OFActionPushPbb { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFActionPushPbbVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 8; |
| 38 | |
| 39 | private final static EthType DEFAULT_ETHERTYPE = EthType.NONE; |
| 40 | |
| 41 | // OF message fields |
| 42 | private final EthType ethertype; |
| 43 | // |
| 44 | // Immutable default instance |
| 45 | final static OFActionPushPbbVer13 DEFAULT = new OFActionPushPbbVer13( |
| 46 | DEFAULT_ETHERTYPE |
| 47 | ); |
| 48 | |
| 49 | // package private constructor - used by readers, builders, and factory |
| 50 | OFActionPushPbbVer13(EthType ethertype) { |
| 51 | this.ethertype = ethertype; |
| 52 | } |
| 53 | |
| 54 | // Accessors for OF message fields |
| 55 | @Override |
| 56 | public OFActionType getType() { |
| 57 | return OFActionType.PUSH_PBB; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public EthType getEthertype() { |
| 62 | return ethertype; |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public OFVersion getVersion() { |
| 67 | return OFVersion.OF_13; |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | public OFActionPushPbb.Builder createBuilder() { |
| 73 | return new BuilderWithParent(this); |
| 74 | } |
| 75 | |
| 76 | static class BuilderWithParent implements OFActionPushPbb.Builder { |
| 77 | final OFActionPushPbbVer13 parentMessage; |
| 78 | |
| 79 | // OF message fields |
| 80 | private boolean ethertypeSet; |
| 81 | private EthType ethertype; |
| 82 | |
| 83 | BuilderWithParent(OFActionPushPbbVer13 parentMessage) { |
| 84 | this.parentMessage = parentMessage; |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public OFActionType getType() { |
| 89 | return OFActionType.PUSH_PBB; |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public EthType getEthertype() { |
| 94 | return ethertype; |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public OFActionPushPbb.Builder setEthertype(EthType ethertype) { |
| 99 | this.ethertype = ethertype; |
| 100 | this.ethertypeSet = true; |
| 101 | return this; |
| 102 | } |
| 103 | @Override |
| 104 | public OFVersion getVersion() { |
| 105 | return OFVersion.OF_13; |
| 106 | } |
| 107 | |
| 108 | |
| 109 | |
| 110 | @Override |
| 111 | public OFActionPushPbb build() { |
| 112 | EthType ethertype = this.ethertypeSet ? this.ethertype : parentMessage.ethertype; |
| 113 | if(ethertype == null) |
| 114 | throw new NullPointerException("Property ethertype must not be null"); |
| 115 | |
| 116 | // |
| 117 | return new OFActionPushPbbVer13( |
| 118 | ethertype |
| 119 | ); |
| 120 | } |
| 121 | |
| 122 | } |
| 123 | |
| 124 | static class Builder implements OFActionPushPbb.Builder { |
| 125 | // OF message fields |
| 126 | private boolean ethertypeSet; |
| 127 | private EthType ethertype; |
| 128 | |
| 129 | @Override |
| 130 | public OFActionType getType() { |
| 131 | return OFActionType.PUSH_PBB; |
| 132 | } |
| 133 | |
| 134 | @Override |
| 135 | public EthType getEthertype() { |
| 136 | return ethertype; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public OFActionPushPbb.Builder setEthertype(EthType ethertype) { |
| 141 | this.ethertype = ethertype; |
| 142 | this.ethertypeSet = true; |
| 143 | return this; |
| 144 | } |
| 145 | @Override |
| 146 | public OFVersion getVersion() { |
| 147 | return OFVersion.OF_13; |
| 148 | } |
| 149 | |
| 150 | // |
| 151 | @Override |
| 152 | public OFActionPushPbb build() { |
| 153 | EthType ethertype = this.ethertypeSet ? this.ethertype : DEFAULT_ETHERTYPE; |
| 154 | if(ethertype == null) |
| 155 | throw new NullPointerException("Property ethertype must not be null"); |
| 156 | |
| 157 | |
| 158 | return new OFActionPushPbbVer13( |
| 159 | ethertype |
| 160 | ); |
| 161 | } |
| 162 | |
| 163 | } |
| 164 | |
| 165 | |
| 166 | final static Reader READER = new Reader(); |
| 167 | static class Reader implements OFMessageReader<OFActionPushPbb> { |
| 168 | @Override |
| 169 | public OFActionPushPbb readFrom(ChannelBuffer bb) throws OFParseError { |
| 170 | int start = bb.readerIndex(); |
| 171 | // fixed value property type == 26 |
| 172 | short type = bb.readShort(); |
| 173 | if(type != (short) 0x1a) |
| 174 | throw new OFParseError("Wrong type: Expected=OFActionType.PUSH_PBB(26), got="+type); |
| 175 | int length = U16.f(bb.readShort()); |
| 176 | if(length != 8) |
| 177 | throw new OFParseError("Wrong length: Expected=8(8), 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 | EthType ethertype = EthType.read2Bytes(bb); |
| 186 | // pad: 2 bytes |
| 187 | bb.skipBytes(2); |
| 188 | |
| 189 | OFActionPushPbbVer13 actionPushPbbVer13 = new OFActionPushPbbVer13( |
| 190 | ethertype |
| 191 | ); |
| 192 | if(logger.isTraceEnabled()) |
| 193 | logger.trace("readFrom - read={}", actionPushPbbVer13); |
| 194 | return actionPushPbbVer13; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | public void putTo(PrimitiveSink sink) { |
| 199 | FUNNEL.funnel(this, sink); |
| 200 | } |
| 201 | |
| 202 | final static OFActionPushPbbVer13Funnel FUNNEL = new OFActionPushPbbVer13Funnel(); |
| 203 | static class OFActionPushPbbVer13Funnel implements Funnel<OFActionPushPbbVer13> { |
| 204 | private static final long serialVersionUID = 1L; |
| 205 | @Override |
| 206 | public void funnel(OFActionPushPbbVer13 message, PrimitiveSink sink) { |
| 207 | // fixed value property type = 26 |
| 208 | sink.putShort((short) 0x1a); |
| 209 | // fixed value property length = 8 |
| 210 | sink.putShort((short) 0x8); |
| 211 | message.ethertype.putTo(sink); |
| 212 | // skip pad (2 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<OFActionPushPbbVer13> { |
| 223 | @Override |
| 224 | public void write(ChannelBuffer bb, OFActionPushPbbVer13 message) { |
| 225 | // fixed value property type = 26 |
| 226 | bb.writeShort((short) 0x1a); |
| 227 | // fixed value property length = 8 |
| 228 | bb.writeShort((short) 0x8); |
| 229 | message.ethertype.write2Bytes(bb); |
| 230 | // pad: 2 bytes |
| 231 | bb.writeZero(2); |
| 232 | |
| 233 | |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | @Override |
| 238 | public String toString() { |
| 239 | StringBuilder b = new StringBuilder("OFActionPushPbbVer13("); |
| 240 | b.append("ethertype=").append(ethertype); |
| 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 | OFActionPushPbbVer13 other = (OFActionPushPbbVer13) obj; |
| 254 | |
| 255 | if (ethertype == null) { |
| 256 | if (other.ethertype != null) |
| 257 | return false; |
| 258 | } else if (!ethertype.equals(other.ethertype)) |
| 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 + ((ethertype == null) ? 0 : ethertype.hashCode()); |
| 269 | return result; |
| 270 | } |
| 271 | |
| 272 | } |