Skip to content
Snippets Groups Projects
Commit c884235c authored by Gregor Maier's avatar Gregor Maier
Browse files

Merge remote-tracking branch 'bigswitch/master' into zeromacfix

parents c8dfacd2 8d66fd68
No related branches found
No related tags found
No related merge requests found
Showing
with 1313 additions and 0 deletions
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.action.OFActionVendor;
public abstract class OFActionBigSwitchVendor extends OFActionVendor {
public static int MINIMUM_LENGTH = 12;
public static int BSN_VENDOR_ID = OFBigSwitchVendorData.BSN_VENDOR_ID;
protected int subtype;
protected OFActionBigSwitchVendor(int subtype) {
super();
super.setLength((short)MINIMUM_LENGTH);
super.setVendor(BSN_VENDOR_ID);
this.subtype = subtype;
}
public int getSubtype() {
return this.subtype;
}
public void setSubtype(int subtype) {
this.subtype = subtype;
}
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
this.subtype = data.readInt();
}
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeInt(this.subtype);
}
@Override
public int hashCode() {
final int prime = 379;
int result = super.hashCode();
result = prime * result + vendor;
result = prime * result + subtype;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof OFActionBigSwitchVendor)) {
return false;
}
OFActionBigSwitchVendor other = (OFActionBigSwitchVendor) obj;
if (subtype != other.subtype) {
return false;
}
return true;
}
@Override
public String toString() {
return super.toString() + "; subtype=" + subtype;
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFActionMirror extends OFActionBigSwitchVendor {
public final static int MINIMUM_LENGTH = 12;
public final static int BSN_ACTION_MIRROR = 1;
protected int destPort;
protected int vlanTag;
protected byte copyStage;
protected byte pad0;
protected byte pad1;
protected byte pad2;
public OFActionMirror(short portNumber) {
super(BSN_ACTION_MIRROR);
super.setLength((short) (OFActionBigSwitchVendor.MINIMUM_LENGTH + OFActionMirror.MINIMUM_LENGTH));
this.destPort = portNumber;
this.vlanTag = 0;
this.copyStage = 0;
}
public int getDestPort() {
return destPort;
}
public void setDestPort(int destPort) {
this.destPort = destPort;
}
public int getVlanTag() {
return vlanTag;
}
public void setVlanTag(int vlanTag) {
this.vlanTag = vlanTag;
}
public byte getCopyStage() {
return copyStage;
}
public void setCopyStage(byte copyStage) {
this.copyStage = copyStage;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + copyStage;
result = prime * result + destPort;
result = prime * result + pad0;
result = prime * result + pad1;
result = prime * result + pad2;
result = prime * result + vlanTag;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!super.equals(obj)) return false;
if (getClass() != obj.getClass()) return false;
OFActionMirror other = (OFActionMirror) obj;
if (copyStage != other.copyStage) return false;
if (destPort != other.destPort) return false;
if (pad0 != other.pad0) return false;
if (pad1 != other.pad1) return false;
if (pad2 != other.pad2) return false;
if (vlanTag != other.vlanTag) return false;
return true;
}
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
this.destPort = data.readInt();
this.vlanTag = data.readInt();
this.copyStage = data.readByte();
this.pad0 = data.readByte();
this.pad1 = data.readByte();
this.pad2 = data.readByte();
}
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeInt(this.destPort);
data.writeInt(this.vlanTag);
data.writeByte(this.copyStage);
data.writeByte(this.pad0);
data.writeByte(this.pad1);
data.writeByte(this.pad2);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFActionNiciraTtlDecrement extends OFActionNiciraVendor {
public static int MINIMUM_LENGTH_TTL_DECREMENT = 16;
public static final short TTL_DECREMENT_SUBTYPE = 18;
public OFActionNiciraTtlDecrement() {
super(TTL_DECREMENT_SUBTYPE);
super.setLength((short)MINIMUM_LENGTH_TTL_DECREMENT);
}
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
data.skipBytes(6); // pad
}
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeZero(6);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.action.OFActionVendor;
import org.openflow.vendor.nicira.OFNiciraVendorData;
/**
* FIXME: this should really be handled by a consistent parse tree for
* different vendor actions but for the time being this works and gets the
* job done.
*
* @author gregor
*
*/
public class OFActionNiciraVendor extends OFActionVendor {
public static int MINIMUM_LENGTH = 16;
public static int NICIRA_VENDOR_ID = OFNiciraVendorData.NX_VENDOR_ID;
protected short subtype;
protected OFActionNiciraVendor(short subtype) {
// We don't allow direct instantiation of this class because its
// minimum length is 16 and the only way to guarantee this is by
// having a subclass that properly adds padding.
super();
super.setLength((short)MINIMUM_LENGTH);
super.setVendor(NICIRA_VENDOR_ID);
this.subtype = subtype;
}
public short getSubtype() {
return this.subtype;
}
public void setSubtype(short subtype) {
this.subtype = subtype;
}
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
this.subtype = data.readShort();
}
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeShort(this.subtype);
}
@Override
public int hashCode() {
final int prime = 379;
int result = super.hashCode();
result = prime * result + vendor;
result = prime * result + subtype;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof OFActionNiciraVendor)) {
return false;
}
OFActionNiciraVendor other = (OFActionNiciraVendor) obj;
if (subtype != other.subtype) {
return false;
}
return true;
}
}
package com.bigswitch.floodlight.vendor;
import net.floodlightcontroller.packet.IPv4;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFActionTunnelDstIP extends OFActionBigSwitchVendor {
public final static int MINIMUM_LENGTH_TUNNEL_DST = 16;
public final static int SET_TUNNEL_DST_SUBTYPE = 2;
protected int dstIPAddr;
public OFActionTunnelDstIP() {
super(SET_TUNNEL_DST_SUBTYPE);
super.setLength((short)MINIMUM_LENGTH_TUNNEL_DST);
}
public OFActionTunnelDstIP(int dstIPAddr) {
this();
this.dstIPAddr = dstIPAddr;
}
public int getTunnelDstIP() {
return this.dstIPAddr;
}
public void setTunnelDstIP(int ipAddr) {
this.dstIPAddr = ipAddr;
}
@Override
public void readFrom(ChannelBuffer data) {
super.readFrom(data);
this.dstIPAddr = data.readInt();
}
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeInt(this.dstIPAddr);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + dstIPAddr;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!super.equals(obj)) return false;
if (getClass() != obj.getClass()) return false;
OFActionTunnelDstIP other = (OFActionTunnelDstIP) obj;
if (dstIPAddr != other.dstIPAddr) return false;
return true;
}
@Override
public String toString() {
return super.toString() + "; dstIP=" + IPv4.fromIPv4Address(dstIPAddr);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.action.OFActionVendor;
import org.openflow.protocol.factory.OFVendorActionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OFBigSwitchVendorActionFactory implements OFVendorActionFactory {
protected static Logger logger =
LoggerFactory.getLogger(OFBigSwitchVendorActionFactory.class);
static class OFActionBigSwitchVendorDemux extends OFActionBigSwitchVendor {
OFActionBigSwitchVendorDemux() {
super((short) 0);
}
}
@Override
public OFActionVendor readFrom(ChannelBuffer data) {
data.markReaderIndex();
OFActionBigSwitchVendor demux = new OFActionBigSwitchVendorDemux();
demux.readFrom(data);
data.resetReaderIndex();
switch(demux.getSubtype()) {
case OFActionMirror.BSN_ACTION_MIRROR:
OFActionMirror mirrorAction = new OFActionMirror((short) 0);
mirrorAction.readFrom(data);
return mirrorAction;
case OFActionTunnelDstIP.SET_TUNNEL_DST_SUBTYPE:
OFActionTunnelDstIP tunnelAction = new OFActionTunnelDstIP();
tunnelAction.readFrom(data);
return tunnelAction;
default:
logger.error("Unknown BSN vendor action subtype: "+demux.getSubtype());
return null;
}
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.vendor.OFVendorData;
/**
* Base class for vendor data corresponding to BigSwitch vendor extensions
* BigSwitch vendor data always starts with a 4-byte integer data type value
*
* @author Munish Mehta (munish.mehta@bigswitch.com)
*/
public class OFBigSwitchVendorData implements OFVendorData {
public static final int BSN_VENDOR_ID = 0x005c16c7;
/**
* The value of the integer data type at the beginning of the vendor data
*/
protected int dataType;
/**
* Construct BigSwitch vendor data with the specified data type
* @param dataType : the data type value at the beginning (opcode)
*/
public OFBigSwitchVendorData(int dataType) {
super();
this.dataType = dataType;
}
/**
* Get the data type value at the beginning of the vendor data
* @return
*/
public int getDataType() {
return dataType;
}
/**
* Set the data type value
* @param dataType
*/
public void setDataType(int dataType) {
this.dataType = dataType;
}
/**
* Get the length of the vendor data. This implementation will normally be
* the superclass for another class that will override this to return the
* overall vendor data length. This implementation just returns the length
* of the part that includes the 4-byte integer data type value at the
* beginning of the vendor data
*/
@Override
public int getLength() {
return 4;
}
/**
* Read the vendor data from the ChannelBuffer
* @param data the channel buffer from which we're deserializing
* @param length the length to the end of the enclosing message
*/
@Override
public void readFrom(ChannelBuffer data, int length) {
dataType = data.readInt();
}
/**
* Write the vendor data to the ChannelBuffer
* @param data the channel buffer to which we're serializing
*/
@Override
public void writeTo(ChannelBuffer data) {
data.writeInt(dataType);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.vendor.OFBasicVendorDataType;
import org.openflow.protocol.vendor.OFBasicVendorId;
import org.openflow.protocol.vendor.OFVendorId;
public class OFBigSwitchVendorExtensions {
private static boolean initialized = false;
public static synchronized void initialize() {
if (initialized)
return;
OFBasicVendorId bsnVendorId =
new OFBasicVendorId(OFBigSwitchVendorData.BSN_VENDOR_ID, 4);
OFVendorId.registerVendorId(bsnVendorId);
// register data types used for big tap
OFBasicVendorDataType setEntryVendorData =
new OFBasicVendorDataType(
OFNetmaskSetVendorData.BSN_SET_IP_MASK_ENTRY,
OFNetmaskSetVendorData.getInstantiable());
bsnVendorId.registerVendorDataType(setEntryVendorData);
OFBasicVendorDataType getEntryVendorDataRequest =
new OFBasicVendorDataType(
OFNetmaskGetVendorDataRequest.BSN_GET_IP_MASK_ENTRY_REQUEST,
OFNetmaskGetVendorDataRequest.getInstantiable());
bsnVendorId.registerVendorDataType(getEntryVendorDataRequest);
OFBasicVendorDataType getEntryVendorDataReply =
new OFBasicVendorDataType(
OFNetmaskGetVendorDataReply.BSN_GET_IP_MASK_ENTRY_REPLY,
OFNetmaskGetVendorDataReply.getInstantiable());
bsnVendorId.registerVendorDataType(getEntryVendorDataReply);
// register data types used for tunneling
OFBasicVendorDataType getIntfIPVendorDataRequest =
new OFBasicVendorDataType(
OFInterfaceIPRequestVendorData.BSN_GET_INTERFACE_IP_REQUEST,
OFInterfaceIPRequestVendorData.getInstantiable());
bsnVendorId.registerVendorDataType(getIntfIPVendorDataRequest);
OFBasicVendorDataType getIntfIPVendorDataReply =
new OFBasicVendorDataType(
OFInterfaceIPReplyVendorData.BSN_GET_INTERFACE_IP_REPLY,
OFInterfaceIPReplyVendorData.getInstantiable());
bsnVendorId.registerVendorDataType(getIntfIPVendorDataReply);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
public class OFBsnL2TableSetVendorData extends OFBsnL2TableVendorData {
protected static Instantiable<OFVendorData> instantiableSingleton =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFBsnL2TableSetVendorData();
}
};
public static final int BSN_L2_TABLE_SET = 12;
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFBsnL2TableSetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiableSingleton;
}
public OFBsnL2TableSetVendorData() {
super(BSN_L2_TABLE_SET);
}
public OFBsnL2TableSetVendorData(boolean l2TableEnabled,
short l2TablePriority) {
super(BSN_L2_TABLE_SET, l2TableEnabled, l2TablePriority);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFBsnL2TableVendorData extends OFBigSwitchVendorData {
/*
* uint8_t l2_table_enable; // 1 == enabled, 0 == disabled
* uint8_t pad;
* uint16_t l2_table_priority; // priority of all flows in L2 table
* uint8_t pad[4];
*/
protected boolean l2TableEnabled;
protected short l2TablePriority;
public OFBsnL2TableVendorData(int dataType) {
super(dataType);
this.l2TableEnabled = false;
this.l2TablePriority = (short)0;
}
public OFBsnL2TableVendorData(int dataType, boolean l2TableEnabled,
short l2TablePriority) {
super(dataType);
this.l2TableEnabled = l2TableEnabled;
this.l2TablePriority = l2TablePriority;
}
public boolean isL2TableEnabled() {
return l2TableEnabled;
}
public short getL2TablePriority() {
return l2TablePriority;
}
public void setL2TableEnabled(boolean l2TableEnabled) {
this.l2TableEnabled = l2TableEnabled;
}
public void setL2TablePriority(short l2TablePriority) {
this.l2TablePriority = l2TablePriority;
}
@Override
public int getLength() {
return super.getLength() + 8; // 8 additional bytes
}
/*
* (non-Javadoc)
* @see com.bigswitch.floodlight.vendor.OFBigSwitchVendorData#readFrom(org.jboss.netty.buffer.ChannelBuffer, int)
*/
@Override
public void readFrom(ChannelBuffer data, int length) {
super.readFrom(data, length);
l2TableEnabled = (data.readByte() == 0) ? false : true;
data.readByte(); // pad
l2TablePriority = data.readShort();
data.readInt(); // 4 bad bytes
}
/*
* (non-Javadoc)
* @see com.bigswitch.floodlight.vendor.OFBigSwitchVendorData#writeTo(org.jboss.netty.buffer.ChannelBuffer)
*/
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeByte(isL2TableEnabled() ? 1 : 0);
data.writeByte(0); // pad
data.writeShort(l2TablePriority);
data.writeInt(0); // 4 pad bytes
}
}
package com.bigswitch.floodlight.vendor;
import java.util.ArrayList;
import java.util.List;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
public class OFInterfaceIPReplyVendorData extends OFBigSwitchVendorData {
protected List<OFInterfaceVendorData> interfaces;
protected int length;
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFInterfaceIPReplyVendorData();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFInterfaceIPReplyVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to reply with IP addresses of all interfaces
*/
public static final int BSN_GET_INTERFACE_IP_REPLY = 10;
/**
* Construct an interface IP reply vendor data
*/
public OFInterfaceIPReplyVendorData() {
super(BSN_GET_INTERFACE_IP_REPLY);
}
/**
* @return the total length of the vendor-data part of the interface IP reply
* message. The OF header (8B) and vendor (4B) are taken care of by the
* OFVendor class MINIMUM_LENGTH. This method returns the length of the
* vendor-extension-subtype (4B) + the length of the interfaces
*/
@Override
public int getLength() {
return length;
}
/**
* Set the length of this message
*
* @param length
*/
public void setLength(int length) {
this.length = length;
}
/**
* @return the interfaces
*/
public List<OFInterfaceVendorData> getInterfaces() {
return interfaces;
}
/**
* @param intfs the ones to set
*/
public void setInterfaces(List<OFInterfaceVendorData> intfs) {
this.interfaces = intfs;
if (intfs == null) {
this.setLength(super.getLength());
} else {
this.setLength(super.getLength() + intfs.size()
* OFInterfaceVendorData.MINIMUM_LENGTH);
}
}
/**
* Read from the ChannelBuffer
* @param data the channel buffer from which we're deserializing
* @param length the length to the end of the enclosing message
*/
@Override
public void readFrom(ChannelBuffer data, int length) {
//datatype read by super class
super.readFrom(data, length);
if (this.interfaces == null) {
this.interfaces = new ArrayList<OFInterfaceVendorData>();
} else {
this.interfaces.clear();
}
int intfCount = (length - 4)
/ OFInterfaceVendorData.MINIMUM_LENGTH;
OFInterfaceVendorData intf;
for (int i = 0; i < intfCount; ++i) {
intf = new OFInterfaceVendorData();
intf.readFrom(data);
this.interfaces.add(intf);
}
}
/**
* Write to the ChannelBuffer
* @param data the channel buffer to which we're serializing
*/
@Override
public void writeTo(ChannelBuffer data) {
// datatype written by super class
super.writeTo(data);
if (this.interfaces != null) {
for (OFInterfaceVendorData intf : this.interfaces) {
intf.writeTo(data);
}
}
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
public class OFInterfaceIPRequestVendorData extends OFBigSwitchVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFInterfaceIPRequestVendorData();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFInterfaceIPRequestVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to request IP addresses of all interfaces
*/
public static final int BSN_GET_INTERFACE_IP_REQUEST = 9;
/**
* Construct an interface IP request vendor data
*/
public OFInterfaceIPRequestVendorData() {
super(BSN_GET_INTERFACE_IP_REQUEST);
}
/**
* @return the total length of the interface IP request message
* the length is already accounted for in the super class
*/
@Override
public int getLength() {
return super.getLength();
}
/**
* Read from the ChannelBuffer
* @param data the channel buffer from which we're deserializing
* @param length the length to the end of the enclosing message
*/
@Override
public void readFrom(ChannelBuffer data, int length) {
super.readFrom(data, length);
}
/**
* Write to the ChannelBuffer
* @param data the channel buffer to which we're serializing
*/
@Override
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
}
}
package com.bigswitch.floodlight.vendor;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.Arrays;
import net.floodlightcontroller.core.web.serializers.ByteArrayMACSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFInterfaceVendorData {
public static int MINIMUM_LENGTH = 32;
private static int OFP_ETH_ALEN = 6;
private static int OFP_MAX_PORT_NAME_LEN = 16;
protected byte[] hardwareAddress;
protected String name;
protected int ipv4Addr;
protected int ipv4AddrMask;
/**
* @return the hardwareAddress
*/
@JsonSerialize(using=ByteArrayMACSerializer.class)
public byte[] getHardwareAddress() {
return hardwareAddress;
}
/**
* @param hardwareAddress the hardwareAddress to set
*/
public void setHardwareAddress(byte[] hardwareAddress) {
if (hardwareAddress.length != OFP_ETH_ALEN)
throw new RuntimeException("Hardware address must have length "
+ OFP_ETH_ALEN);
this.hardwareAddress = hardwareAddress;
}
public int getIpv4Addr() {
return ipv4Addr;
}
public void setIpv4Addr(int ipv4Addr) {
this.ipv4Addr = ipv4Addr;
}
public int getIpv4AddrMask() {
return ipv4AddrMask;
}
public void setIpv4AddrMask(int ipv4AddrMask) {
this.ipv4AddrMask = ipv4AddrMask;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Write this message's binary format to the specified ByteBuffer
* @param data
*/
public void writeTo(ChannelBuffer data) {
data.writeBytes(hardwareAddress);
data.writeBytes(new byte[] {0, 0});
try {
byte[] name = this.name.getBytes("ASCII");
if (name.length < OFP_MAX_PORT_NAME_LEN) {
data.writeBytes(name);
for (int i = name.length; i < OFP_MAX_PORT_NAME_LEN; ++i) {
data.writeByte((byte) 0);
}
} else {
data.writeBytes(name, 0, 15);
data.writeByte((byte) 0);
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
data.writeInt(ipv4Addr);
data.writeInt(ipv4AddrMask);
}
/**
* Read this message off the wire from the specified ByteBuffer
* @param data
*/
public void readFrom(ChannelBuffer data) {
if (this.hardwareAddress == null)
this.hardwareAddress = new byte[OFP_ETH_ALEN];
data.readBytes(this.hardwareAddress);
data.readBytes(new byte[2]);
byte[] name = new byte[16];
data.readBytes(name);
// find the first index of 0
int index = 0;
for (byte b : name) {
if (0 == b)
break;
++index;
}
this.name = new String(Arrays.copyOf(name, index),
Charset.forName("ascii"));
ipv4Addr = data.readInt();
ipv4AddrMask = data.readInt();
}
}
\ No newline at end of file
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
/**
* Subclass of OFVendorData
*/
public class OFMirrorGetVendorDataReply extends OFNetmaskVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFMirrorGetVendorDataReply();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFNetmaskGetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to represent REPLY of GET_MASK request
*/
public static final int BSN_GET_MIRRORING_REPLY = 5;
/**
* Construct a get network mask vendor data
*/
public OFMirrorGetVendorDataReply() {
super(BSN_GET_MIRRORING_REPLY);
}
/**
* Construct a get network mask vendor data for a specific table entry
*/
public OFMirrorGetVendorDataReply(byte tableIndex, int netMask) {
super(BSN_GET_MIRRORING_REPLY, tableIndex, netMask);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
/**
* Subclass of OFVendorData
*/
public class OFMirrorGetVendorDataRequest extends OFNetmaskVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFMirrorGetVendorDataRequest();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFNetmaskGetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to request an entry in the switch netmask table
*/
public static final int BSN_GET_MIRRORING_REQUEST = 4;
/**
* Construct a get network mask vendor data
*/
public OFMirrorGetVendorDataRequest() {
super(BSN_GET_MIRRORING_REQUEST);
}
/**
* Construct a get network mask vendor data for a specific table entry
*/
public OFMirrorGetVendorDataRequest(byte tableIndex, int netMask) {
super(BSN_GET_MIRRORING_REQUEST, tableIndex, netMask);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
public class OFMirrorSetVendorData extends OFBigSwitchVendorData {
/**
* Opcode/dataType to set mirroring
*/
public static final int BSN_SET_MIRRORING = 3;
protected byte reportMirrorPorts;
protected byte pad1;
protected byte pad2;
protected byte pad3;
public OFMirrorSetVendorData() {
super(BSN_SET_MIRRORING);
this.reportMirrorPorts=1;
}
public byte getReportMirrorPorts() {
return reportMirrorPorts;
}
public void setReportMirrorPorts(byte report) {
this.reportMirrorPorts = report;
}
/**
* @return the total length vendor date
*/
@Override
public int getLength() {
return super.getLength() + 4; // 4 extra bytes
}
/**
* Read the vendor data from the channel buffer
* @param data: the channel buffer from which we are deserializing
* @param length: the length to the end of the enclosing message
*/
public void readFrom(ChannelBuffer data, int length) {
super.readFrom(data, length);
reportMirrorPorts = data.readByte();
pad1 = data.readByte();
pad2 = data.readByte();
pad3 = data.readByte();
}
/**
* Write the vendor data to the channel buffer
*/
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeByte(reportMirrorPorts);
data.writeByte(pad1);
data.writeByte(pad2);
data.writeByte(pad3);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
/**
* Subclass of OFVendorData
*
* @author munish_mehta
*/
public class OFNetmaskGetVendorDataReply extends OFNetmaskVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFNetmaskGetVendorDataReply();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFNetmaskGetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to represent REPLY of GET_MASK request
*/
public static final int BSN_GET_IP_MASK_ENTRY_REPLY = 2;
/**
* Construct a get network mask vendor data
*/
public OFNetmaskGetVendorDataReply() {
super(BSN_GET_IP_MASK_ENTRY_REPLY);
}
/**
* Construct a get network mask vendor data for a specific table entry
*/
public OFNetmaskGetVendorDataReply(byte tableIndex, int netMask) {
super(BSN_GET_IP_MASK_ENTRY_REPLY, tableIndex, netMask);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
/**
* Subclass of OFVendorData
*
* @author munish_mehta
*/
public class OFNetmaskGetVendorDataRequest extends OFNetmaskVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFNetmaskGetVendorDataRequest();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFNetmaskGetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to request an entry in the switch netmask table
*/
public static final int BSN_GET_IP_MASK_ENTRY_REQUEST = 1;
/**
* Construct a get network mask vendor data
*/
public OFNetmaskGetVendorDataRequest() {
super(BSN_GET_IP_MASK_ENTRY_REQUEST);
}
/**
* Construct a get network mask vendor data for a specific table entry
*/
public OFNetmaskGetVendorDataRequest(byte tableIndex, int netMask) {
super(BSN_GET_IP_MASK_ENTRY_REQUEST, tableIndex, netMask);
}
}
package com.bigswitch.floodlight.vendor;
import org.openflow.protocol.Instantiable;
import org.openflow.protocol.vendor.OFVendorData;
public class OFNetmaskSetVendorData extends OFNetmaskVendorData {
protected static Instantiable<OFVendorData> instantiable =
new Instantiable<OFVendorData>() {
public OFVendorData instantiate() {
return new OFNetmaskSetVendorData();
}
};
/**
* @return a subclass of Instantiable<OFVendorData> that instantiates
* an instance of OFNetmaskSetVendorData.
*/
public static Instantiable<OFVendorData> getInstantiable() {
return instantiable;
}
/**
* Opcode/dataType to set an entry in the switch netmask table
*/
public static final int BSN_SET_IP_MASK_ENTRY = 0;
/**
* Construct a get network mask vendor data
*/
public OFNetmaskSetVendorData() {
super(BSN_SET_IP_MASK_ENTRY);
}
/**
* Construct a get network mask vendor data for a specific table entry
*/
public OFNetmaskSetVendorData(byte tableIndex, int netMask) {
super(BSN_SET_IP_MASK_ENTRY, tableIndex, netMask);
}
}
package com.bigswitch.floodlight.vendor;
import org.jboss.netty.buffer.ChannelBuffer;
/**
* Class that represents the vendor data in the netmask table request
* extension implemented by Arista switches
*
* @author munish_mehta (munish.mehta@bigswitch.com)
*/
public class OFNetmaskVendorData extends OFBigSwitchVendorData {
/**
* Table index for set or get of the the entry from netmask table
*/
protected byte tableIndex;
protected byte pad1;
protected byte pad2;
protected byte pad3;
protected int netMask;
public OFNetmaskVendorData(int dataType) {
super(dataType);
this.tableIndex = 0;
this.netMask = (int)0xffffffffL;
}
public OFNetmaskVendorData(int dataType, byte table_index, int netmask) {
super(dataType);
this.tableIndex = table_index;
this.netMask = netmask;
}
public byte getTableIndex() {
return tableIndex;
}
public void setTableIndex(byte tableIndex) {
this.tableIndex = tableIndex;
}
public int getNetMask() {
return netMask;
}
public void setNetMask(int netMask) {
this.netMask = netMask;
}
/**
* @return the total length of the netmask vendor data
*/
@Override
public int getLength() {
return super.getLength() + 8; // 8 extra bytes
}
/**
* Read the vendor data from the channel buffer
* @param data: the channel buffer from which we are deserializing
* @param length: the length to the end of the enclosing message
*/
public void readFrom(ChannelBuffer data, int length) {
super.readFrom(data, length);
tableIndex = data.readByte();
pad1 = data.readByte();
pad2 = data.readByte();
pad3 = data.readByte();
netMask = data.readInt();
}
/**
* Write the vendor data to the channel buffer
*/
public void writeTo(ChannelBuffer data) {
super.writeTo(data);
data.writeByte(tableIndex);
data.writeByte(pad1);
data.writeByte(pad2);
data.writeByte(pad3);
data.writeInt(netMask);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment