org.projectfloodlight.openflow.protocol.ver11.OFPortDescVer11 Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openflowj Show documentation
Show all versions of openflowj Show documentation
OpenFlowJ API supporting OpenFlow versions 1.0 through 1.5.1, generated by LoxiGen
The newest version!
// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
// Copyright (c) 2011, 2012 Open Networking Foundation
// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
// This library was generated by the LoxiGen Compiler.
// See the file LICENSE.txt which should have been included in the source distribution
// Automatically generated by LOXI from template of_class.java
// Do not modify
package org.projectfloodlight.openflow.protocol.ver11;
import org.projectfloodlight.openflow.protocol.*;
import org.projectfloodlight.openflow.protocol.action.*;
import org.projectfloodlight.openflow.protocol.actionid.*;
import org.projectfloodlight.openflow.protocol.bsntlv.*;
import org.projectfloodlight.openflow.protocol.errormsg.*;
import org.projectfloodlight.openflow.protocol.meterband.*;
import org.projectfloodlight.openflow.protocol.instruction.*;
import org.projectfloodlight.openflow.protocol.instructionid.*;
import org.projectfloodlight.openflow.protocol.match.*;
import org.projectfloodlight.openflow.protocol.stat.*;
import org.projectfloodlight.openflow.protocol.oxm.*;
import org.projectfloodlight.openflow.protocol.oxs.*;
import org.projectfloodlight.openflow.protocol.queueprop.*;
import org.projectfloodlight.openflow.types.*;
import org.projectfloodlight.openflow.util.*;
import org.projectfloodlight.openflow.exceptions.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Set;
import com.google.common.collect.ImmutableSet;
import java.util.List;
import javax.annotation.Nonnull;
import io.netty.buffer.ByteBuf;
import com.google.common.hash.PrimitiveSink;
import com.google.common.hash.Funnel;
class OFPortDescVer11 implements OFPortDesc {
private static final Logger logger = LoggerFactory.getLogger(OFPortDescVer11.class);
// version: 1.1
final static byte WIRE_VERSION = 2;
final static int LENGTH = 64;
private final static OFPort DEFAULT_PORT_NO = OFPort.ANY;
private final static MacAddress DEFAULT_HW_ADDR = MacAddress.NONE;
private final static String DEFAULT_NAME = "";
private final static Set DEFAULT_CONFIG = ImmutableSet.of();
private final static Set DEFAULT_STATE = ImmutableSet.of();
private final static Set DEFAULT_CURR = ImmutableSet.of();
private final static Set DEFAULT_ADVERTISED = ImmutableSet.of();
private final static Set DEFAULT_SUPPORTED = ImmutableSet.of();
private final static Set DEFAULT_PEER = ImmutableSet.of();
private final static long DEFAULT_CURR_SPEED = 0x0L;
private final static long DEFAULT_MAX_SPEED = 0x0L;
// OF message fields
private final OFPort portNo;
private final MacAddress hwAddr;
private final String name;
private final Set config;
private final Set state;
private final Set curr;
private final Set advertised;
private final Set supported;
private final Set peer;
private final long currSpeed;
private final long maxSpeed;
//
// Immutable default instance
final static OFPortDescVer11 DEFAULT = new OFPortDescVer11(
DEFAULT_PORT_NO, DEFAULT_HW_ADDR, DEFAULT_NAME, DEFAULT_CONFIG, DEFAULT_STATE, DEFAULT_CURR, DEFAULT_ADVERTISED, DEFAULT_SUPPORTED, DEFAULT_PEER, DEFAULT_CURR_SPEED, DEFAULT_MAX_SPEED
);
// package private constructor - used by readers, builders, and factory
OFPortDescVer11(OFPort portNo, MacAddress hwAddr, String name, Set config, Set state, Set curr, Set advertised, Set supported, Set peer, long currSpeed, long maxSpeed) {
if(portNo == null) {
throw new NullPointerException("OFPortDescVer11: property portNo cannot be null");
}
if(hwAddr == null) {
throw new NullPointerException("OFPortDescVer11: property hwAddr cannot be null");
}
if(name == null) {
throw new NullPointerException("OFPortDescVer11: property name cannot be null");
}
if(config == null) {
throw new NullPointerException("OFPortDescVer11: property config cannot be null");
}
if(state == null) {
throw new NullPointerException("OFPortDescVer11: property state cannot be null");
}
if(curr == null) {
throw new NullPointerException("OFPortDescVer11: property curr cannot be null");
}
if(advertised == null) {
throw new NullPointerException("OFPortDescVer11: property advertised cannot be null");
}
if(supported == null) {
throw new NullPointerException("OFPortDescVer11: property supported cannot be null");
}
if(peer == null) {
throw new NullPointerException("OFPortDescVer11: property peer cannot be null");
}
this.portNo = portNo;
this.hwAddr = hwAddr;
this.name = name;
this.config = config;
this.state = state;
this.curr = curr;
this.advertised = advertised;
this.supported = supported;
this.peer = peer;
this.currSpeed = U32.normalize(currSpeed);
this.maxSpeed = U32.normalize(maxSpeed);
}
// Accessors for OF message fields
@Override
public OFPort getPortNo() {
return portNo;
}
@Override
public MacAddress getHwAddr() {
return hwAddr;
}
@Override
public String getName() {
return name;
}
@Override
public Set getConfig() {
return config;
}
@Override
public Set getState() {
return state;
}
@Override
public Set getCurr() {
return curr;
}
@Override
public Set getAdvertised() {
return advertised;
}
@Override
public Set getSupported() {
return supported;
}
@Override
public Set getPeer() {
return peer;
}
@Override
public long getCurrSpeed() {
return currSpeed;
}
@Override
public long getMaxSpeed() {
return maxSpeed;
}
@Override
public List getProperties()throws UnsupportedOperationException {
throw new UnsupportedOperationException("Property properties not supported in version 1.1");
}
@Override
public OFVersion getVersion() {
return OFVersion.OF_11;
}
/**
* Returns true if the port is up, i.e., it's neither administratively
* down nor link down. It currently does NOT take STP state into
* consideration
* @return whether the port is up
*/
public boolean isEnabled() {
return (!state.contains(OFPortState.LINK_DOWN) && !config.contains(OFPortConfig.PORT_DOWN));
}
/**
* Returns the current generation ID of this port.
*
* The generationId is reported by the switch as a @{link OFPortDescProp} in
* {@link OFPortDescStatsReply} and {@link OFPortStatus} messages. If the
* current OFPortDesc does not contain a generation Id, returns U64.ZERO;
*
* For OpenFlow versions earlier than 1.4, always returns U64.ZERO;
*
* @return the generation ID or U64.NULL if not reported
* @since 1.4
*/
@Nonnull
public U64 getBsnGenerationId() {
return U64.ZERO;
}
public OFPortDesc.Builder createBuilder() {
return new BuilderWithParent(this);
}
static class BuilderWithParent implements OFPortDesc.Builder {
final OFPortDescVer11 parentMessage;
// OF message fields
private boolean portNoSet;
private OFPort portNo;
private boolean hwAddrSet;
private MacAddress hwAddr;
private boolean nameSet;
private String name;
private boolean configSet;
private Set config;
private boolean stateSet;
private Set state;
private boolean currSet;
private Set curr;
private boolean advertisedSet;
private Set advertised;
private boolean supportedSet;
private Set supported;
private boolean peerSet;
private Set peer;
private boolean currSpeedSet;
private long currSpeed;
private boolean maxSpeedSet;
private long maxSpeed;
BuilderWithParent(OFPortDescVer11 parentMessage) {
this.parentMessage = parentMessage;
}
@Override
public OFPort getPortNo() {
return portNo;
}
@Override
public OFPortDesc.Builder setPortNo(OFPort portNo) {
this.portNo = portNo;
this.portNoSet = true;
return this;
}
@Override
public MacAddress getHwAddr() {
return hwAddr;
}
@Override
public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
this.hwAddr = hwAddr;
this.hwAddrSet = true;
return this;
}
@Override
public String getName() {
return name;
}
@Override
public OFPortDesc.Builder setName(String name) {
this.name = name;
this.nameSet = true;
return this;
}
@Override
public Set getConfig() {
return config;
}
@Override
public OFPortDesc.Builder setConfig(Set config) {
this.config = config;
this.configSet = true;
return this;
}
@Override
public Set getState() {
return state;
}
@Override
public OFPortDesc.Builder setState(Set state) {
this.state = state;
this.stateSet = true;
return this;
}
@Override
public Set getCurr() {
return curr;
}
@Override
public OFPortDesc.Builder setCurr(Set curr) {
this.curr = curr;
this.currSet = true;
return this;
}
@Override
public Set getAdvertised() {
return advertised;
}
@Override
public OFPortDesc.Builder setAdvertised(Set advertised) {
this.advertised = advertised;
this.advertisedSet = true;
return this;
}
@Override
public Set getSupported() {
return supported;
}
@Override
public OFPortDesc.Builder setSupported(Set supported) {
this.supported = supported;
this.supportedSet = true;
return this;
}
@Override
public Set getPeer() {
return peer;
}
@Override
public OFPortDesc.Builder setPeer(Set peer) {
this.peer = peer;
this.peerSet = true;
return this;
}
@Override
public long getCurrSpeed() {
return currSpeed;
}
@Override
public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
this.currSpeed = currSpeed;
this.currSpeedSet = true;
return this;
}
@Override
public long getMaxSpeed() {
return maxSpeed;
}
@Override
public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
this.maxSpeed = maxSpeed;
this.maxSpeedSet = true;
return this;
}
@Override
public List getProperties()throws UnsupportedOperationException {
throw new UnsupportedOperationException("Property properties not supported in version 1.1");
}
@Override
public OFPortDesc.Builder setProperties(List properties) throws UnsupportedOperationException {
throw new UnsupportedOperationException("Property properties not supported in version 1.1");
}
@Override
public OFVersion getVersion() {
return OFVersion.OF_11;
}
@Override
public OFPortDesc build() {
OFPort portNo = this.portNoSet ? this.portNo : parentMessage.portNo;
if(portNo == null)
throw new NullPointerException("Property portNo must not be null");
MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : parentMessage.hwAddr;
if(hwAddr == null)
throw new NullPointerException("Property hwAddr must not be null");
String name = this.nameSet ? this.name : parentMessage.name;
if(name == null)
throw new NullPointerException("Property name must not be null");
Set config = this.configSet ? this.config : parentMessage.config;
if(config == null)
throw new NullPointerException("Property config must not be null");
Set state = this.stateSet ? this.state : parentMessage.state;
if(state == null)
throw new NullPointerException("Property state must not be null");
Set curr = this.currSet ? this.curr : parentMessage.curr;
if(curr == null)
throw new NullPointerException("Property curr must not be null");
Set advertised = this.advertisedSet ? this.advertised : parentMessage.advertised;
if(advertised == null)
throw new NullPointerException("Property advertised must not be null");
Set supported = this.supportedSet ? this.supported : parentMessage.supported;
if(supported == null)
throw new NullPointerException("Property supported must not be null");
Set peer = this.peerSet ? this.peer : parentMessage.peer;
if(peer == null)
throw new NullPointerException("Property peer must not be null");
long currSpeed = this.currSpeedSet ? this.currSpeed : parentMessage.currSpeed;
long maxSpeed = this.maxSpeedSet ? this.maxSpeed : parentMessage.maxSpeed;
//
return new OFPortDescVer11(
portNo,
hwAddr,
name,
config,
state,
curr,
advertised,
supported,
peer,
currSpeed,
maxSpeed
);
}
}
static class Builder implements OFPortDesc.Builder {
// OF message fields
private boolean portNoSet;
private OFPort portNo;
private boolean hwAddrSet;
private MacAddress hwAddr;
private boolean nameSet;
private String name;
private boolean configSet;
private Set config;
private boolean stateSet;
private Set state;
private boolean currSet;
private Set curr;
private boolean advertisedSet;
private Set advertised;
private boolean supportedSet;
private Set supported;
private boolean peerSet;
private Set peer;
private boolean currSpeedSet;
private long currSpeed;
private boolean maxSpeedSet;
private long maxSpeed;
@Override
public OFPort getPortNo() {
return portNo;
}
@Override
public OFPortDesc.Builder setPortNo(OFPort portNo) {
this.portNo = portNo;
this.portNoSet = true;
return this;
}
@Override
public MacAddress getHwAddr() {
return hwAddr;
}
@Override
public OFPortDesc.Builder setHwAddr(MacAddress hwAddr) {
this.hwAddr = hwAddr;
this.hwAddrSet = true;
return this;
}
@Override
public String getName() {
return name;
}
@Override
public OFPortDesc.Builder setName(String name) {
this.name = name;
this.nameSet = true;
return this;
}
@Override
public Set getConfig() {
return config;
}
@Override
public OFPortDesc.Builder setConfig(Set config) {
this.config = config;
this.configSet = true;
return this;
}
@Override
public Set getState() {
return state;
}
@Override
public OFPortDesc.Builder setState(Set state) {
this.state = state;
this.stateSet = true;
return this;
}
@Override
public Set getCurr() {
return curr;
}
@Override
public OFPortDesc.Builder setCurr(Set curr) {
this.curr = curr;
this.currSet = true;
return this;
}
@Override
public Set getAdvertised() {
return advertised;
}
@Override
public OFPortDesc.Builder setAdvertised(Set advertised) {
this.advertised = advertised;
this.advertisedSet = true;
return this;
}
@Override
public Set getSupported() {
return supported;
}
@Override
public OFPortDesc.Builder setSupported(Set supported) {
this.supported = supported;
this.supportedSet = true;
return this;
}
@Override
public Set getPeer() {
return peer;
}
@Override
public OFPortDesc.Builder setPeer(Set peer) {
this.peer = peer;
this.peerSet = true;
return this;
}
@Override
public long getCurrSpeed() {
return currSpeed;
}
@Override
public OFPortDesc.Builder setCurrSpeed(long currSpeed) {
this.currSpeed = currSpeed;
this.currSpeedSet = true;
return this;
}
@Override
public long getMaxSpeed() {
return maxSpeed;
}
@Override
public OFPortDesc.Builder setMaxSpeed(long maxSpeed) {
this.maxSpeed = maxSpeed;
this.maxSpeedSet = true;
return this;
}
@Override
public List getProperties()throws UnsupportedOperationException {
throw new UnsupportedOperationException("Property properties not supported in version 1.1");
}
@Override
public OFPortDesc.Builder setProperties(List properties) throws UnsupportedOperationException {
throw new UnsupportedOperationException("Property properties not supported in version 1.1");
}
@Override
public OFVersion getVersion() {
return OFVersion.OF_11;
}
//
@Override
public OFPortDesc build() {
OFPort portNo = this.portNoSet ? this.portNo : DEFAULT_PORT_NO;
if(portNo == null)
throw new NullPointerException("Property portNo must not be null");
MacAddress hwAddr = this.hwAddrSet ? this.hwAddr : DEFAULT_HW_ADDR;
if(hwAddr == null)
throw new NullPointerException("Property hwAddr must not be null");
String name = this.nameSet ? this.name : DEFAULT_NAME;
if(name == null)
throw new NullPointerException("Property name must not be null");
Set config = this.configSet ? this.config : DEFAULT_CONFIG;
if(config == null)
throw new NullPointerException("Property config must not be null");
Set state = this.stateSet ? this.state : DEFAULT_STATE;
if(state == null)
throw new NullPointerException("Property state must not be null");
Set curr = this.currSet ? this.curr : DEFAULT_CURR;
if(curr == null)
throw new NullPointerException("Property curr must not be null");
Set advertised = this.advertisedSet ? this.advertised : DEFAULT_ADVERTISED;
if(advertised == null)
throw new NullPointerException("Property advertised must not be null");
Set supported = this.supportedSet ? this.supported : DEFAULT_SUPPORTED;
if(supported == null)
throw new NullPointerException("Property supported must not be null");
Set peer = this.peerSet ? this.peer : DEFAULT_PEER;
if(peer == null)
throw new NullPointerException("Property peer must not be null");
long currSpeed = this.currSpeedSet ? this.currSpeed : DEFAULT_CURR_SPEED;
long maxSpeed = this.maxSpeedSet ? this.maxSpeed : DEFAULT_MAX_SPEED;
return new OFPortDescVer11(
portNo,
hwAddr,
name,
config,
state,
curr,
advertised,
supported,
peer,
currSpeed,
maxSpeed
);
}
}
final static Reader READER = new Reader();
static class Reader implements OFMessageReader {
@Override
public OFPortDesc readFrom(ByteBuf bb) throws OFParseError {
OFPort portNo = OFPort.read4Bytes(bb);
// pad: 4 bytes
bb.skipBytes(4);
MacAddress hwAddr = MacAddress.read6Bytes(bb);
// pad: 2 bytes
bb.skipBytes(2);
String name = ChannelUtils.readFixedLengthString(bb, 16);
Set config = OFPortConfigSerializerVer11.readFrom(bb);
Set state = OFPortStateSerializerVer11.readFrom(bb);
Set curr = OFPortFeaturesSerializerVer11.readFrom(bb);
Set advertised = OFPortFeaturesSerializerVer11.readFrom(bb);
Set supported = OFPortFeaturesSerializerVer11.readFrom(bb);
Set peer = OFPortFeaturesSerializerVer11.readFrom(bb);
long currSpeed = U32.f(bb.readInt());
long maxSpeed = U32.f(bb.readInt());
OFPortDescVer11 portDescVer11 = new OFPortDescVer11(
portNo,
hwAddr,
name,
config,
state,
curr,
advertised,
supported,
peer,
currSpeed,
maxSpeed
);
if(logger.isTraceEnabled())
logger.trace("readFrom - read={}", portDescVer11);
return portDescVer11;
}
}
public void putTo(PrimitiveSink sink) {
FUNNEL.funnel(this, sink);
}
final static OFPortDescVer11Funnel FUNNEL = new OFPortDescVer11Funnel();
static class OFPortDescVer11Funnel implements Funnel {
private static final long serialVersionUID = 1L;
@Override
public void funnel(OFPortDescVer11 message, PrimitiveSink sink) {
message.portNo.putTo(sink);
// skip pad (4 bytes)
message.hwAddr.putTo(sink);
// skip pad (2 bytes)
sink.putUnencodedChars(message.name);
OFPortConfigSerializerVer11.putTo(message.config, sink);
OFPortStateSerializerVer11.putTo(message.state, sink);
OFPortFeaturesSerializerVer11.putTo(message.curr, sink);
OFPortFeaturesSerializerVer11.putTo(message.advertised, sink);
OFPortFeaturesSerializerVer11.putTo(message.supported, sink);
OFPortFeaturesSerializerVer11.putTo(message.peer, sink);
sink.putLong(message.currSpeed);
sink.putLong(message.maxSpeed);
}
}
public void writeTo(ByteBuf bb) {
WRITER.write(bb, this);
}
final static Writer WRITER = new Writer();
static class Writer implements OFMessageWriter {
@Override
public void write(ByteBuf bb, OFPortDescVer11 message) {
message.portNo.write4Bytes(bb);
// pad: 4 bytes
bb.writeZero(4);
message.hwAddr.write6Bytes(bb);
// pad: 2 bytes
bb.writeZero(2);
ChannelUtils.writeFixedLengthString(bb, message.name, 16);
OFPortConfigSerializerVer11.writeTo(bb, message.config);
OFPortStateSerializerVer11.writeTo(bb, message.state);
OFPortFeaturesSerializerVer11.writeTo(bb, message.curr);
OFPortFeaturesSerializerVer11.writeTo(bb, message.advertised);
OFPortFeaturesSerializerVer11.writeTo(bb, message.supported);
OFPortFeaturesSerializerVer11.writeTo(bb, message.peer);
bb.writeInt(U32.t(message.currSpeed));
bb.writeInt(U32.t(message.maxSpeed));
}
}
@Override
public String toString() {
StringBuilder b = new StringBuilder("OFPortDescVer11(");
b.append("portNo=").append(portNo);
b.append(", ");
b.append("hwAddr=").append(hwAddr);
b.append(", ");
b.append("name=").append(name);
b.append(", ");
b.append("config=").append(config);
b.append(", ");
b.append("state=").append(state);
b.append(", ");
b.append("curr=").append(curr);
b.append(", ");
b.append("advertised=").append(advertised);
b.append(", ");
b.append("supported=").append(supported);
b.append(", ");
b.append("peer=").append(peer);
b.append(", ");
b.append("currSpeed=").append(currSpeed);
b.append(", ");
b.append("maxSpeed=").append(maxSpeed);
b.append(")");
return b.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
OFPortDescVer11 other = (OFPortDescVer11) obj;
if (portNo == null) {
if (other.portNo != null)
return false;
} else if (!portNo.equals(other.portNo))
return false;
if (hwAddr == null) {
if (other.hwAddr != null)
return false;
} else if (!hwAddr.equals(other.hwAddr))
return false;
if (name == null) {
if (other.name != null)
return false;
} else if (!name.equals(other.name))
return false;
if (config == null) {
if (other.config != null)
return false;
} else if (!config.equals(other.config))
return false;
if (state == null) {
if (other.state != null)
return false;
} else if (!state.equals(other.state))
return false;
if (curr == null) {
if (other.curr != null)
return false;
} else if (!curr.equals(other.curr))
return false;
if (advertised == null) {
if (other.advertised != null)
return false;
} else if (!advertised.equals(other.advertised))
return false;
if (supported == null) {
if (other.supported != null)
return false;
} else if (!supported.equals(other.supported))
return false;
if (peer == null) {
if (other.peer != null)
return false;
} else if (!peer.equals(other.peer))
return false;
if( currSpeed != other.currSpeed)
return false;
if( maxSpeed != other.maxSpeed)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((portNo == null) ? 0 : portNo.hashCode());
result = prime * result + ((hwAddr == null) ? 0 : hwAddr.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((config == null) ? 0 : config.hashCode());
result = prime * result + ((state == null) ? 0 : state.hashCode());
result = prime * result + ((curr == null) ? 0 : curr.hashCode());
result = prime * result + ((advertised == null) ? 0 : advertised.hashCode());
result = prime * result + ((supported == null) ? 0 : supported.hashCode());
result = prime * result + ((peer == null) ? 0 : peer.hashCode());
result = prime * (int) (currSpeed ^ (currSpeed >>> 32));
result = prime * (int) (maxSpeed ^ (maxSpeed >>> 32));
return result;
}
}