1 package org.openflow.protocol.statistics;
3 import java.io.Serializable;
4 import java.nio.ByteBuffer;
6 import org.openflow.util.StringByteSerializer;
9 * Represents an ofp_table_stats structure
10 * @author David Erickson (daviderickson@cs.stanford.edu)
12 public class OFTableStatistics implements OFStatistics, Serializable {
13 public static int MAX_TABLE_NAME_LEN = 32;
15 protected byte tableId;
16 protected String name;
17 protected int wildcards;
18 protected int maximumEntries;
19 protected int activeCount;
20 protected long lookupCount;
21 protected long matchedCount;
26 public byte getTableId() {
31 * @param tableId the tableId to set
33 public void setTableId(byte tableId) {
34 this.tableId = tableId;
40 public String getName() {
45 * @param name the name to set
47 public void setName(String name) {
52 * @return the wildcards
54 public int getWildcards() {
59 * @param wildcards the wildcards to set
61 public void setWildcards(int wildcards) {
62 this.wildcards = wildcards;
66 * @return the maximumEntries
68 public int getMaximumEntries() {
69 return maximumEntries;
73 * @param maximumEntries the maximumEntries to set
75 public void setMaximumEntries(int maximumEntries) {
76 this.maximumEntries = maximumEntries;
80 * @return the activeCount
82 public int getActiveCount() {
87 * @param activeCount the activeCount to set
89 public void setActiveCount(int activeCount) {
90 this.activeCount = activeCount;
94 * @return the lookupCount
96 public long getLookupCount() {
101 * @param lookupCount the lookupCount to set
103 public void setLookupCount(long lookupCount) {
104 this.lookupCount = lookupCount;
108 * @return the matchedCount
110 public long getMatchedCount() {
115 * @param matchedCount the matchedCount to set
117 public void setMatchedCount(long matchedCount) {
118 this.matchedCount = matchedCount;
122 public int getLength() {
127 public void readFrom(ByteBuffer data) {
128 this.tableId = data.get();
132 this.name = StringByteSerializer.readFrom(data, MAX_TABLE_NAME_LEN);
133 this.wildcards = data.getInt();
134 this.maximumEntries = data.getInt();
135 this.activeCount = data.getInt();
136 this.lookupCount = data.getLong();
137 this.matchedCount = data.getLong();
141 public void writeTo(ByteBuffer data) {
142 data.put(this.tableId);
143 data.put((byte) 0); // pad
144 data.put((byte) 0); // pad
145 data.put((byte) 0); // pad
146 StringByteSerializer.writeTo(data, MAX_TABLE_NAME_LEN, this.name);
147 data.putInt(this.wildcards);
148 data.putInt(this.maximumEntries);
149 data.putInt(this.activeCount);
150 data.putLong(this.lookupCount);
151 data.putLong(this.matchedCount);
155 public int hashCode() {
156 final int prime = 449;
158 result = prime * result + activeCount;
159 result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
160 result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
161 result = prime * result + maximumEntries;
162 result = prime * result + ((name == null) ? 0 : name.hashCode());
163 result = prime * result + tableId;
164 result = prime * result + wildcards;
169 public boolean equals(Object obj) {
176 if (!(obj instanceof OFTableStatistics)) {
179 OFTableStatistics other = (OFTableStatistics) obj;
180 if (activeCount != other.activeCount) {
183 if (lookupCount != other.lookupCount) {
186 if (matchedCount != other.matchedCount) {
189 if (maximumEntries != other.maximumEntries) {
193 if (other.name != null) {
196 } else if (!name.equals(other.name)) {
199 if (tableId != other.tableId) {
202 if (wildcards != other.wildcards) {