blob: c07a895afeb355678db7bf7251e12054369c1c92 [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_port_stats_request structure
25 * @author David Erickson (daviderickson@cs.stanford.edu)
26 */
27public class OFPortStatisticsRequest implements OFStatistics {
28 protected short portNumber;
29
30 /**
31 * @return the portNumber
32 */
33 public short getPortNumber() {
34 return portNumber;
35 }
36
37 /**
38 * @param portNumber the portNumber to set
39 */
40 public void setPortNumber(short portNumber) {
41 this.portNumber = portNumber;
42 }
43
44 @Override
45 public int getLength() {
46 return 8;
47 }
48
49 @Override
50 public void readFrom(ChannelBuffer data) {
51 this.portNumber = data.readShort();
52 data.readShort(); // pad
53 data.readInt(); // pad
54 }
55
56 @Override
57 public void writeTo(ChannelBuffer data) {
58 data.writeShort(this.portNumber);
59 data.writeShort((short) 0); // pad
60 data.writeInt(0); // pad
61 }
62
63 @Override
64 public int hashCode() {
65 final int prime = 433;
66 int result = 1;
67 result = prime * result + portNumber;
68 return result;
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76 if (obj == null) {
77 return false;
78 }
79 if (!(obj instanceof OFPortStatisticsRequest)) {
80 return false;
81 }
82 OFPortStatisticsRequest other = (OFPortStatisticsRequest) obj;
83 if (portNumber != other.portNumber) {
84 return false;
85 }
86 return true;
87 }
88}