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 OFBsnInterfaceVer13 implements OFBsnInterface { |
| 34 | private static final Logger logger = LoggerFactory.getLogger(OFBsnInterfaceVer13.class); |
| 35 | // version: 1.3 |
| 36 | final static byte WIRE_VERSION = 4; |
| 37 | final static int LENGTH = 32; |
| 38 | |
| 39 | private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE; |
| 40 | private final static String DEFAULT_NAME = ""; |
| 41 | private final static IPv4Address DEFAULT_IPV4_ADDR = IPv4Address.NONE; |
| 42 | private final static IPv4Address DEFAULT_IPV4_NETMASK = IPv4Address.NONE; |
| 43 | |
| 44 | // OF message fields |
| 45 | private final MacAddress hwAddr; |
| 46 | private final String name; |
| 47 | private final IPv4Address ipv4Addr; |
| 48 | private final IPv4Address ipv4Netmask; |
| 49 | // |
| 50 | // Immutable default instance |
| 51 | final static OFBsnInterfaceVer13 DEFAULT = new OFBsnInterfaceVer13( |
| 52 | DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_IPV4_ADDR, DEFAULT_IPV4_NETMASK |
| 53 | ); |
| 54 | |
| 55 | // package private constructor - used by readers, builders, and factory |
| 56 | OFBsnInterfaceVer13(MacAddress hwAddr, String name, IPv4Address ipv4Addr, IPv4Address ipv4Netmask) { |
| 57 | this.hwAddr = hwAddr; |
| 58 | this.name = name; |
| 59 | this.ipv4Addr = ipv4Addr; |
| 60 | this.ipv4Netmask = ipv4Netmask; |
| 61 | } |
| 62 | |
| 63 | // Accessors for OF message fields |
| 64 | @Override |
| 65 | public MacAddress getHwAddr() { |
| 66 | return hwAddr; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public String getName() { |
| 71 | return name; |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public IPv4Address getIpv4Addr() { |
| 76 | return ipv4Addr; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public IPv4Address getIpv4Netmask() { |
| 81 | return ipv4Netmask; |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public OFVersion getVersion() { |
| 86 | return OFVersion.OF_13; |
| 87 | } |
| 88 | |
| 89 | |
| 90 | |
| 91 | public OFBsnInterface.Builder createBuilder() { |
| 92 | return new BuilderWithParent(this); |
| 93 | } |
| 94 | |
| 95 | static class BuilderWithParent implements OFBsnInterface.Builder { |
| 96 | final OFBsnInterfaceVer13 parentMessage; |
| 97 | |
| 98 | // OF message fields |
| 99 | private boolean hwAddrSet; |
| 100 | private MacAddress hwAddr; |
| 101 | private boolean nameSet; |
| 102 | private String name; |
| 103 | private boolean ipv4AddrSet; |
| 104 | private IPv4Address ipv4Addr; |
| 105 | private boolean ipv4NetmaskSet; |
| 106 | private IPv4Address ipv4Netmask; |
| 107 | |
| 108 | BuilderWithParent(OFBsnInterfaceVer13 parentMessage) { |
| 109 | this.parentMessage = parentMessage; |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | public MacAddress getHwAddr() { |
| 114 | return hwAddr; |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) { |
| 119 | this.hwAddr = hwAddr; |
| 120 | this.hwAddrSet = true; |
| 121 | return this; |
| 122 | } |
| 123 | @Override |
| 124 | public String getName() { |
| 125 | return name; |
| 126 | } |
| 127 | |
| 128 | @Override |
| 129 | public OFBsnInterface.Builder setName(String name) { |
| 130 | this.name = name; |
| 131 | this.nameSet = true; |
| 132 | return this; |
| 133 | } |
| 134 | @Override |
| 135 | public IPv4Address getIpv4Addr() { |
| 136 | return ipv4Addr; |
| 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) { |
| 141 | this.ipv4Addr = ipv4Addr; |
| 142 | this.ipv4AddrSet = true; |
| 143 | return this; |
| 144 | } |
| 145 | @Override |
| 146 | public IPv4Address getIpv4Netmask() { |
| 147 | return ipv4Netmask; |
| 148 | } |
| 149 | |
| 150 | @Override |
| 151 | public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) { |
| 152 | this.ipv4Netmask = ipv4Netmask; |
| 153 | this.ipv4NetmaskSet = true; |
| 154 | return this; |
| 155 | } |
| 156 | @Override |
| 157 | public OFVersion getVersion() { |
| 158 | return OFVersion.OF_13; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | |
| 163 | @Override |
| 164 | public OFBsnInterface build() { |
| 165 | MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr; |
| 166 | if(hwAddr == null) |
| 167 | throw new NullPointerException("Property hwAddr must not be null"); |
| 168 | String name = this.nameSet ? this.name : parentMessage.name; |
| 169 | if(name == null) |
| 170 | throw new NullPointerException("Property name must not be null"); |
| 171 | IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : parentMessage.ipv4Addr; |
| 172 | if(ipv4Addr == null) |
| 173 | throw new NullPointerException("Property ipv4Addr must not be null"); |
| 174 | IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : parentMessage.ipv4Netmask; |
| 175 | if(ipv4Netmask == null) |
| 176 | throw new NullPointerException("Property ipv4Netmask must not be null"); |
| 177 | |
| 178 | // |
| 179 | return new OFBsnInterfaceVer13( |
| 180 | hwAddr, |
| 181 | name, |
| 182 | ipv4Addr, |
| 183 | ipv4Netmask |
| 184 | ); |
| 185 | } |
| 186 | |
| 187 | } |
| 188 | |
| 189 | static class Builder implements OFBsnInterface.Builder { |
| 190 | // OF message fields |
| 191 | private boolean hwAddrSet; |
| 192 | private MacAddress hwAddr; |
| 193 | private boolean nameSet; |
| 194 | private String name; |
| 195 | private boolean ipv4AddrSet; |
| 196 | private IPv4Address ipv4Addr; |
| 197 | private boolean ipv4NetmaskSet; |
| 198 | private IPv4Address ipv4Netmask; |
| 199 | |
| 200 | @Override |
| 201 | public MacAddress getHwAddr() { |
| 202 | return hwAddr; |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public OFBsnInterface.Builder setHwAddr(MacAddress hwAddr) { |
| 207 | this.hwAddr = hwAddr; |
| 208 | this.hwAddrSet = true; |
| 209 | return this; |
| 210 | } |
| 211 | @Override |
| 212 | public String getName() { |
| 213 | return name; |
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public OFBsnInterface.Builder setName(String name) { |
| 218 | this.name = name; |
| 219 | this.nameSet = true; |
| 220 | return this; |
| 221 | } |
| 222 | @Override |
| 223 | public IPv4Address getIpv4Addr() { |
| 224 | return ipv4Addr; |
| 225 | } |
| 226 | |
| 227 | @Override |
| 228 | public OFBsnInterface.Builder setIpv4Addr(IPv4Address ipv4Addr) { |
| 229 | this.ipv4Addr = ipv4Addr; |
| 230 | this.ipv4AddrSet = true; |
| 231 | return this; |
| 232 | } |
| 233 | @Override |
| 234 | public IPv4Address getIpv4Netmask() { |
| 235 | return ipv4Netmask; |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public OFBsnInterface.Builder setIpv4Netmask(IPv4Address ipv4Netmask) { |
| 240 | this.ipv4Netmask = ipv4Netmask; |
| 241 | this.ipv4NetmaskSet = true; |
| 242 | return this; |
| 243 | } |
| 244 | @Override |
| 245 | public OFVersion getVersion() { |
| 246 | return OFVersion.OF_13; |
| 247 | } |
| 248 | |
| 249 | // |
| 250 | @Override |
| 251 | public OFBsnInterface build() { |
| 252 | MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR; |
| 253 | if(hwAddr == null) |
| 254 | throw new NullPointerException("Property hwAddr must not be null"); |
| 255 | String name = this.nameSet ? this.name : DEFAULT_NAME; |
| 256 | if(name == null) |
| 257 | throw new NullPointerException("Property name must not be null"); |
| 258 | IPv4Address ipv4Addr = this.ipv4AddrSet ? this.ipv4Addr : DEFAULT_IPV4_ADDR; |
| 259 | if(ipv4Addr == null) |
| 260 | throw new NullPointerException("Property ipv4Addr must not be null"); |
| 261 | IPv4Address ipv4Netmask = this.ipv4NetmaskSet ? this.ipv4Netmask : DEFAULT_IPV4_NETMASK; |
| 262 | if(ipv4Netmask == null) |
| 263 | throw new NullPointerException("Property ipv4Netmask must not be null"); |
| 264 | |
| 265 | |
| 266 | return new OFBsnInterfaceVer13( |
| 267 | hwAddr, |
| 268 | name, |
| 269 | ipv4Addr, |
| 270 | ipv4Netmask |
| 271 | ); |
| 272 | } |
| 273 | |
| 274 | } |
| 275 | |
| 276 | |
| 277 | final static Reader READER = new Reader(); |
| 278 | static class Reader implements OFMessageReader<OFBsnInterface> { |
| 279 | @Override |
| 280 | public OFBsnInterface readFrom(ChannelBuffer bb) throws OFParseError { |
| 281 | MacAddress hwAddr = MacAddress.read6Bytes(bb); |
| 282 | // pad: 2 bytes |
| 283 | bb.skipBytes(2); |
| 284 | String name = ChannelUtils.readFixedLengthString(bb, 16); |
| 285 | IPv4Address ipv4Addr = IPv4Address.read4Bytes(bb); |
| 286 | IPv4Address ipv4Netmask = IPv4Address.read4Bytes(bb); |
| 287 | |
| 288 | OFBsnInterfaceVer13 bsnInterfaceVer13 = new OFBsnInterfaceVer13( |
| 289 | hwAddr, |
| 290 | name, |
| 291 | ipv4Addr, |
| 292 | ipv4Netmask |
| 293 | ); |
| 294 | if(logger.isTraceEnabled()) |
| 295 | logger.trace("readFrom - read={}", bsnInterfaceVer13); |
| 296 | return bsnInterfaceVer13; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | public void putTo(PrimitiveSink sink) { |
| 301 | FUNNEL.funnel(this, sink); |
| 302 | } |
| 303 | |
| 304 | final static OFBsnInterfaceVer13Funnel FUNNEL = new OFBsnInterfaceVer13Funnel(); |
| 305 | static class OFBsnInterfaceVer13Funnel implements Funnel<OFBsnInterfaceVer13> { |
| 306 | private static final long serialVersionUID = 1L; |
| 307 | @Override |
| 308 | public void funnel(OFBsnInterfaceVer13 message, PrimitiveSink sink) { |
| 309 | message.hwAddr.putTo(sink); |
| 310 | // skip pad (2 bytes) |
| 311 | sink.putUnencodedChars(message.name); |
| 312 | message.ipv4Addr.putTo(sink); |
| 313 | message.ipv4Netmask.putTo(sink); |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | |
| 318 | public void writeTo(ChannelBuffer bb) { |
| 319 | WRITER.write(bb, this); |
| 320 | } |
| 321 | |
| 322 | final static Writer WRITER = new Writer(); |
| 323 | static class Writer implements OFMessageWriter<OFBsnInterfaceVer13> { |
| 324 | @Override |
| 325 | public void write(ChannelBuffer bb, OFBsnInterfaceVer13 message) { |
| 326 | message.hwAddr.write6Bytes(bb); |
| 327 | // pad: 2 bytes |
| 328 | bb.writeZero(2); |
| 329 | ChannelUtils.writeFixedLengthString(bb, message.name, 16); |
| 330 | message.ipv4Addr.write4Bytes(bb); |
| 331 | message.ipv4Netmask.write4Bytes(bb); |
| 332 | |
| 333 | |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public String toString() { |
| 339 | StringBuilder b = new StringBuilder("OFBsnInterfaceVer13("); |
| 340 | b.append("hwAddr=").append(hwAddr); |
| 341 | b.append(", "); |
| 342 | b.append("name=").append(name); |
| 343 | b.append(", "); |
| 344 | b.append("ipv4Addr=").append(ipv4Addr); |
| 345 | b.append(", "); |
| 346 | b.append("ipv4Netmask=").append(ipv4Netmask); |
| 347 | b.append(")"); |
| 348 | return b.toString(); |
| 349 | } |
| 350 | |
| 351 | @Override |
| 352 | public boolean equals(Object obj) { |
| 353 | if (this == obj) |
| 354 | return true; |
| 355 | if (obj == null) |
| 356 | return false; |
| 357 | if (getClass() != obj.getClass()) |
| 358 | return false; |
| 359 | OFBsnInterfaceVer13 other = (OFBsnInterfaceVer13) obj; |
| 360 | |
| 361 | if (hwAddr == null) { |
| 362 | if (other.hwAddr != null) |
| 363 | return false; |
| 364 | } else if (!hwAddr.equals(other.hwAddr)) |
| 365 | return false; |
| 366 | if (name == null) { |
| 367 | if (other.name != null) |
| 368 | return false; |
| 369 | } else if (!name.equals(other.name)) |
| 370 | return false; |
| 371 | if (ipv4Addr == null) { |
| 372 | if (other.ipv4Addr != null) |
| 373 | return false; |
| 374 | } else if (!ipv4Addr.equals(other.ipv4Addr)) |
| 375 | return false; |
| 376 | if (ipv4Netmask == null) { |
| 377 | if (other.ipv4Netmask != null) |
| 378 | return false; |
| 379 | } else if (!ipv4Netmask.equals(other.ipv4Netmask)) |
| 380 | return false; |
| 381 | return true; |
| 382 | } |
| 383 | |
| 384 | @Override |
| 385 | public int hashCode() { |
| 386 | final int prime = 31; |
| 387 | int result = 1; |
| 388 | |
| 389 | result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode()); |
| 390 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 391 | result = prime * result + ((ipv4Addr == null) ? 0 : ipv4Addr.hashCode()); |
| 392 | result = prime * result + ((ipv4Netmask == null) ? 0 : ipv4Netmask.hashCode()); |
| 393 | return result; |
| 394 | } |
| 395 | |
| 396 | } |