blob: 33314539f62b1bbb21e59a92c07712e653b2584e [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;
22
23/**
24 * Represents an ofp_queue_stats_request structure
25 * @author David Erickson (daviderickson@cs.stanford.edu)
26 */
27public class OFQueueStatisticsRequest implements OFStatistics {
28 protected short portNumber;
29 protected int queueId;
30
31 /**
32 * @return the portNumber
33 */
34 public short getPortNumber() {
35 return portNumber;
36 }
37
38 /**
39 * @param portNumber the portNumber to set
40 */
41 public void setPortNumber(short portNumber) {
42 this.portNumber = portNumber;
43 }
44
45 /**
46 * @return the queueId
47 */
48 public int getQueueId() {
49 return queueId;
50 }
51
52 /**
53 * @param queueId the queueId to set
54 */
55 public void setQueueId(int queueId) {
56 this.queueId = queueId;
57 }
58
59 @Override
60 public int getLength() {
61 return 8;
62 }
63
64 @Override
65 public void readFrom(ChannelBuffer data) {
66 this.portNumber = data.readShort();
67 data.readShort(); // pad
68 this.queueId = data.readInt();
69 }
70
71 @Override
72 public void writeTo(ChannelBuffer data) {
73 data.writeShort(this.portNumber);
74 data.writeShort((short) 0); // pad
75 data.writeInt(this.queueId);
76 }
77
78 @Override
79 public int hashCode() {
80 final int prime = 443;
81 int result = 1;
82 result = prime * result + portNumber;
83 result = prime * result + queueId;
84 return result;
85 }
86
87 @Override
88 public boolean equals(Object obj) {
89 if (this == obj) {
90 return true;
91 }
92 if (obj == null) {
93 return false;
94 }
95 if (!(obj instanceof OFQueueStatisticsRequest)) {
96 return false;
97 }
98 OFQueueStatisticsRequest other = (OFQueueStatisticsRequest) obj;
99 if (portNumber != other.portNumber) {
100 return false;
101 }
102 if (queueId != other.queueId) {
103 return false;
104 }
105 return true;
106 }
107}