Performacne improvements via adding a netty-based openflowj and openflow plugin;...
[controller.git] / third-party / openflowj_netty / src / main / java / org / openflow / protocol / OFQueueGetConfigRequest.java
1 /**
2 *    Copyright 2012, Andrew Ferguson, Brown University
3 *
4 *    Licensed under the Apache License, Version 2.0 (the "License"); you may
5 *    not use this file except in compliance with the License. You may obtain
6 *    a copy of the License at
7 *
8 *         http://www.apache.org/licenses/LICENSE-2.0
9 *
10 *    Unless required by applicable law or agreed to in writing, software
11 *    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 *    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 *    License for the specific language governing permissions and limitations
14 *    under the License.
15 **/
16
17 package org.openflow.protocol;
18
19 import org.jboss.netty.buffer.ChannelBuffer;
20 import org.openflow.util.U16;
21
22 /**
23  * Represents an ofp_queue_get_config_request message
24  * @author Andrew Ferguson (adf@cs.brown.edu)
25  */
26 public class OFQueueGetConfigRequest extends OFMessage {
27     public static int MINIMUM_LENGTH = 12;
28
29     protected short portNumber;
30
31     public OFQueueGetConfigRequest(short portNumber) {
32         super();
33         this.type = OFType.QUEUE_GET_CONFIG_REQUEST;
34         this.length = U16.t(MINIMUM_LENGTH);
35         this.portNumber = portNumber;
36     }
37
38     public OFQueueGetConfigRequest() {
39         this((short) 0);
40     }
41
42     /**
43      * @return the portNumber
44      */
45     public short getPortNumber() {
46         return portNumber;
47     }
48
49     /**
50      * @param portNumber the portNumber to set
51      */
52     public void setPortNumber(short portNumber) {
53         this.portNumber = portNumber;
54     }
55
56     @Override
57     public void readFrom(ChannelBuffer data) {
58         super.readFrom(data);
59         this.portNumber = data.readShort();
60         data.readShort(); // pad
61     }
62
63     @Override
64     public void writeTo(ChannelBuffer data) {
65         super.writeTo(data);
66         data.writeShort(this.portNumber);
67         data.writeShort(0); // pad
68     }
69
70     @Override
71     public int hashCode() {
72         final int prime = 347;
73         int result = super.hashCode();
74         result = prime * result + portNumber;
75         return result;
76     }
77
78     @Override
79     public boolean equals(Object obj) {
80         if (this == obj) {
81             return true;
82         }
83         if (!super.equals(obj)) {
84             return false;
85         }
86         if (!(obj instanceof OFQueueGetConfigRequest)) {
87             return false;
88         }
89         OFQueueGetConfigRequest other = (OFQueueGetConfigRequest) obj;
90         if (portNumber != other.portNumber) {
91             return false;
92         }
93         return true;
94     }
95 }