/*
* Copyright (c) 2013 Big Switch Networks, Inc.
*
* Licensed under the Eclipse Public License, Version 1.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.eclipse.org/legal/epl-v10.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package org.sdnplatform.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);
}
}