2 * Copyright 2012, Andrew Ferguson, Brown University
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
17 package org.openflow.protocol;
19 import java.util.ArrayList;
20 import java.util.List;
22 import org.jboss.netty.buffer.ChannelBuffer;
23 import org.openflow.util.U16;
26 * Represents an ofp_queue_get_config_request message
27 * @author Andrew Ferguson (adf@cs.brown.edu)
29 public class OFQueueGetConfigReply extends OFMessage {
30 public static int MINIMUM_LENGTH = 16;
32 protected short portNumber;
33 protected List<OFPacketQueue> queues = new ArrayList<OFPacketQueue>();
35 public OFQueueGetConfigReply() {
37 this.type = OFType.QUEUE_GET_CONFIG_REPLY;
38 this.length = U16.t(MINIMUM_LENGTH);
42 * @return the portNumber
44 public short getPortNumber() {
49 * @param portNumber the portNumber to set
51 public void setPortNumber(short portNumber) {
52 this.portNumber = portNumber;
56 * @return the port's queues
58 public List<OFPacketQueue> getQueues() {
63 * @param queues the queues to set
65 public void setQueues(List<OFPacketQueue> queues) {
67 this.queues.addAll(queues);
71 public void readFrom(ChannelBuffer data) {
73 this.portNumber = data.readShort();
74 data.readInt(); // pad
75 data.readShort(); // pad
77 int availLength = (this.length - MINIMUM_LENGTH);
80 while (availLength > 0) {
81 OFPacketQueue queue = new OFPacketQueue();
84 availLength -= queue.getLength();
89 public void writeTo(ChannelBuffer data) {
91 data.writeShort(this.portNumber);
92 data.writeInt(0); // pad
93 data.writeShort(0); // pad
95 for (OFPacketQueue queue : queues) {
101 public int hashCode() {
102 final int prime = 349;
103 int result = super.hashCode();
104 result = prime * result + portNumber;
109 public boolean equals(Object obj) {
113 if (!super.equals(obj)) {
116 if (!(obj instanceof OFQueueGetConfigReply)) {
119 OFQueueGetConfigReply other = (OFQueueGetConfigReply) obj;
120 if (portNumber != other.portNumber) {