1 package org.openflow.codec.protocol.statistics;
3 import java.io.Serializable;
5 import org.openflow.codec.io.IDataBuffer;
6 import org.openflow.codec.protocol.OFPMatch;
9 * Represents an ofp_flow_stats_request structure
11 * @author David Erickson (daviderickson@cs.stanford.edu)
14 public class OFPFlowStatisticsRequest implements OFPStatistics, Serializable {
15 private static final int MINIMUM_LENGTH = 40;
17 protected byte tableId;
18 protected int outPort;
21 private long cookieMask;
22 protected OFPMatch match;
27 public OFPMatch getMatch() {
35 public void setMatch(OFPMatch match) {
42 public byte getTableId() {
50 public void setTableId(byte tableId) {
51 this.tableId = tableId;
57 public int getOutPort() {
65 public void setOutPort(int outPort) {
66 this.outPort = outPort;
73 public int getOutGroup() {
82 public void setOutGroup(int outGroup) {
83 this.outGroup = outGroup;
90 public long getCookie() {
98 public void setCookie(long cookie) {
106 public long getCookieMask() {
114 public void setCookieMask(long cookieMask) {
115 this.cookieMask = cookieMask;
119 public int getLength() {
120 return MINIMUM_LENGTH;
124 public void readFrom(IDataBuffer data) {
126 this.tableId = data.get();
128 data.getShort(); // pad
129 this.outPort = data.getInt();
130 this.setOutGroup(data.getInt());
131 data.getInt(); // pad
132 this.setCookie(data.getLong());
133 this.setCookieMask(data.getLong());
134 if (this.match == null)
135 this.match = new OFPMatch();
136 this.match.readFrom(data);
140 public void writeTo(IDataBuffer data) {
141 data.put(this.tableId);
143 data.putShort((short) 0);
144 data.putInt(this.outPort);
145 data.putInt(this.getOutGroup());
147 data.putLong(this.getCookie());
148 data.putLong(this.getCookieMask());
149 this.match.writeTo(data);
153 public int hashCode() {
154 final int prime = 421;
156 result = prime * result + ((match == null) ? 0 : match.hashCode());
157 result = prime * result + (int) (cookie ^ (cookie >>> 32));
158 result = prime * result + (int) (cookieMask ^ (cookieMask >>> 32));
159 result = prime * result + outPort;
160 result = prime * result + outGroup;
161 result = prime * result + tableId;
166 public boolean equals(Object obj) {
173 if (!(obj instanceof OFPFlowStatisticsRequest)) {
176 OFPFlowStatisticsRequest other = (OFPFlowStatisticsRequest) obj;
177 if (tableId != other.tableId) {
180 if (outPort != other.outPort) {
183 if (getOutGroup() != other.getOutGroup()) {
186 if (getCookie() != other.getCookie()) {
189 if (getCookieMask() != other.getCookieMask()) {
193 if (other.match != null) {
196 } else if (!match.equals(other.match)) {