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