2 * Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
18 package org.openflow.protocol.statistics;
21 import org.jboss.netty.buffer.ChannelBuffer;
22 import org.openflow.util.StringByteSerializer;
25 * Represents an ofp_table_stats structure
26 * @author David Erickson (daviderickson@cs.stanford.edu)
28 public class OFTableStatistics implements OFStatistics {
29 public static int MAX_TABLE_NAME_LEN = 32;
31 protected byte tableId;
32 protected String name;
33 protected int wildcards;
34 protected int maximumEntries;
35 protected int activeCount;
36 protected long lookupCount;
37 protected long matchedCount;
42 public byte getTableId() {
47 * @param tableId the tableId to set
49 public void setTableId(byte tableId) {
50 this.tableId = tableId;
56 public String getName() {
61 * @param name the name to set
63 public void setName(String name) {
68 * @return the wildcards
70 public int getWildcards() {
75 * @param wildcards the wildcards to set
77 public void setWildcards(int wildcards) {
78 this.wildcards = wildcards;
82 * @return the maximumEntries
84 public int getMaximumEntries() {
85 return maximumEntries;
89 * @param maximumEntries the maximumEntries to set
91 public void setMaximumEntries(int maximumEntries) {
92 this.maximumEntries = maximumEntries;
96 * @return the activeCount
98 public int getActiveCount() {
103 * @param activeCount the activeCount to set
105 public void setActiveCount(int activeCount) {
106 this.activeCount = activeCount;
110 * @return the lookupCount
112 public long getLookupCount() {
117 * @param lookupCount the lookupCount to set
119 public void setLookupCount(long lookupCount) {
120 this.lookupCount = lookupCount;
124 * @return the matchedCount
126 public long getMatchedCount() {
131 * @param matchedCount the matchedCount to set
133 public void setMatchedCount(long matchedCount) {
134 this.matchedCount = matchedCount;
138 public int getLength() {
143 public void readFrom(ChannelBuffer data) {
144 this.tableId = data.readByte();
145 data.readByte(); // pad
146 data.readByte(); // pad
147 data.readByte(); // pad
148 this.name = StringByteSerializer.readFrom(data, MAX_TABLE_NAME_LEN);
149 this.wildcards = data.readInt();
150 this.maximumEntries = data.readInt();
151 this.activeCount = data.readInt();
152 this.lookupCount = data.readLong();
153 this.matchedCount = data.readLong();
157 public void writeTo(ChannelBuffer data) {
158 data.writeByte(this.tableId);
159 data.writeByte((byte) 0); // pad
160 data.writeByte((byte) 0); // pad
161 data.writeByte((byte) 0); // pad
162 StringByteSerializer.writeTo(data, MAX_TABLE_NAME_LEN, this.name);
163 data.writeInt(this.wildcards);
164 data.writeInt(this.maximumEntries);
165 data.writeInt(this.activeCount);
166 data.writeLong(this.lookupCount);
167 data.writeLong(this.matchedCount);
171 public int hashCode() {
172 final int prime = 449;
174 result = prime * result + activeCount;
175 result = prime * result + (int) (lookupCount ^ (lookupCount >>> 32));
176 result = prime * result + (int) (matchedCount ^ (matchedCount >>> 32));
177 result = prime * result + maximumEntries;
178 result = prime * result + ((name == null) ? 0 : name.hashCode());
179 result = prime * result + tableId;
180 result = prime * result + wildcards;
185 public boolean equals(Object obj) {
192 if (!(obj instanceof OFTableStatistics)) {
195 OFTableStatistics other = (OFTableStatistics) obj;
196 if (activeCount != other.activeCount) {
199 if (lookupCount != other.lookupCount) {
202 if (matchedCount != other.matchedCount) {
205 if (maximumEntries != other.maximumEntries) {
209 if (other.name != null) {
212 } else if (!name.equals(other.name)) {
215 if (tableId != other.tableId) {
218 if (wildcards != other.wildcards) {