1 package org.openflow.codec.protocol;
3 import java.io.Serializable;
5 import org.openflow.codec.io.IDataBuffer;
6 import org.openflow.codec.util.U16;
9 * Represents a features reply message struct ofp_switch_features
11 * @author David Erickson (daviderickson@cs.stanford.edu)
14 public class OFPSwitchFeaturesReply extends OFPMessage implements Serializable {
15 public static int MINIMUM_LENGTH = 32;
18 * Corresponds to bits on the capabilities field enum ofp_capabilities
20 public enum OFCapabilities {
21 OFPC_FLOW_STATS(1 << 0), OFPC_TABLE_STATS(1 << 1), OFPC_PORT_STATS(1 << 2), OFPC_GROUP_STATS(1 << 3), OFPC_IP_REASM(
22 1 << 5), OFPC_QUEUE_STATS(1 << 6), OFPC_PORT_BLOCKED(1 << 8);
26 private OFCapabilities(int value) {
33 public int getValue() {
38 protected long datapathId;
39 protected int buffers;
40 protected byte tables;
41 protected byte auxiliaryId;
42 protected int capabilities;
43 protected int reserved;
45 public OFPSwitchFeaturesReply() {
47 this.type = OFPType.FEATURES_REPLY;
48 this.length = U16.t(MINIMUM_LENGTH);
52 * @return the datapathId
54 public long getDatapathId() {
60 * the datapathId to set
62 public void setDatapathId(long datapathId) {
63 this.datapathId = datapathId;
69 public int getBuffers() {
77 public void setBuffers(int buffers) {
78 this.buffers = buffers;
84 public byte getTables() {
92 public void setTables(byte tables) {
97 * type of connection with switch.
99 * @return 0 - main connection , non zero - auxiliary connection
101 public byte getAuxiliaryId() {
109 public void setAuxiliaryId(byte auxiliaryId) {
110 this.auxiliaryId = auxiliaryId;
114 * @return the capabilities
116 public int getCapabilities() {
121 * @param capabilities
122 * the capabilities to set
124 public void setCapabilities(int capabilities) {
125 this.capabilities = capabilities;
128 public int getReserved() {
132 public void setReserved(int reserved) {
133 this.reserved = reserved;
137 public void readFrom(IDataBuffer data) {
138 super.readFrom(data);
139 this.datapathId = data.getLong();
140 this.buffers = data.getInt();
141 this.tables = data.get();
142 this.auxiliaryId = data.get();
143 data.getShort(); // pad
144 this.capabilities = data.getInt();
145 this.reserved = data.getInt();
149 public void writeTo(IDataBuffer data) {
151 data.putLong(this.datapathId);
152 data.putInt(this.buffers);
153 data.put(this.tables);
154 data.put(this.auxiliaryId);
155 data.putShort((short) 0); // pad
156 data.putInt(this.capabilities);
157 data.putInt(this.reserved);
161 public int hashCode() {
162 final int prime = 139;
163 int result = super.hashCode();
164 result = prime * result + auxiliaryId;
165 result = prime * result + buffers;
166 result = prime * result + capabilities;
167 result = prime * result + reserved;
168 result = prime * result + (int) (datapathId ^ (datapathId >>> 32));
169 result = prime * result + tables;
174 public boolean equals(Object obj) {
178 if (!super.equals(obj)) {
181 if (!(obj instanceof OFPSwitchFeaturesReply)) {
184 OFPSwitchFeaturesReply other = (OFPSwitchFeaturesReply) obj;
185 if (auxiliaryId != other.auxiliaryId) {
188 if (reserved != other.reserved) {
191 if (buffers != other.buffers) {
194 if (capabilities != other.capabilities) {
197 if (datapathId != other.datapathId) {
200 if (tables != other.tables) {