blob: f41a4f1d57c15a341aeb66f54cc0a87cf011ec61 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
2* Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior
3* University
4*
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
8*
9* http://www.apache.org/licenses/LICENSE-2.0
10*
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
15* under the License.
16**/
17
18package org.openflow.protocol.statistics;
19
20
21import org.jboss.netty.buffer.ChannelBuffer;
22import org.openflow.protocol.OFMatch;
23
24/**
25 * Represents an ofp_aggregate_stats_request structure
26 * @author David Erickson (daviderickson@cs.stanford.edu)
27 */
28public class OFAggregateStatisticsRequest implements OFStatistics {
29 protected OFMatch match;
30 protected byte tableId;
31 protected short outPort;
32
33 /**
34 * @return the match
35 */
36 public OFMatch getMatch() {
37 return match;
38 }
39
40 /**
41 * @param match the match to set
42 */
43 public void setMatch(OFMatch match) {
44 this.match = match;
45 }
46
47 /**
48 * @return the tableId
49 */
50 public byte getTableId() {
51 return tableId;
52 }
53
54 /**
55 * @param tableId the tableId to set
56 */
57 public void setTableId(byte tableId) {
58 this.tableId = tableId;
59 }
60
61 /**
62 * @return the outPort
63 */
64 public short getOutPort() {
65 return outPort;
66 }
67
68 /**
69 * @param outPort the outPort to set
70 */
71 public void setOutPort(short outPort) {
72 this.outPort = outPort;
73 }
74
75 @Override
76 public int getLength() {
77 return 44;
78 }
79
80 @Override
81 public void readFrom(ChannelBuffer data) {
82 if (this.match == null)
83 this.match = new OFMatch();
84 this.match.readFrom(data);
85 this.tableId = data.readByte();
86 data.readByte(); // pad
87 this.outPort = data.readShort();
88 }
89
90 @Override
91 public void writeTo(ChannelBuffer data) {
92 this.match.writeTo(data);
93 data.writeByte(this.tableId);
94 data.writeByte((byte) 0);
95 data.writeShort(this.outPort);
96 }
97
98 @Override
99 public int hashCode() {
100 final int prime = 401;
101 int result = 1;
102 result = prime * result + ((match == null) ? 0 : match.hashCode());
103 result = prime * result + outPort;
104 result = prime * result + tableId;
105 return result;
106 }
107
108 @Override
109 public boolean equals(Object obj) {
110 if (this == obj) {
111 return true;
112 }
113 if (obj == null) {
114 return false;
115 }
116 if (!(obj instanceof OFAggregateStatisticsRequest)) {
117 return false;
118 }
119 OFAggregateStatisticsRequest other = (OFAggregateStatisticsRequest) obj;
120 if (match == null) {
121 if (other.match != null) {
122 return false;
123 }
124 } else if (!match.equals(other.match)) {
125 return false;
126 }
127 if (outPort != other.outPort) {
128 return false;
129 }
130 if (tableId != other.tableId) {
131 return false;
132 }
133 return true;
134 }
135}