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.vendor.openflow;
19 import java.util.ArrayList;
20 import java.util.List;
22 import org.jboss.netty.buffer.ChannelBuffer;
23 import org.openflow.protocol.OFPacketQueue;
26 * Class that represents the vendor data in a queue modify or delete request
28 * @author Andrew Ferguson (adf@cs.brown.edu)
30 public class OFQueueVendorData extends OFOpenFlowVendorData {
31 public static int MINIMUM_LENGTH = 8;
33 protected short portNumber;
34 protected List<OFPacketQueue> queues = new ArrayList<OFPacketQueue>();
36 public OFQueueVendorData(int dataType) {
41 * @return the portNumber
43 public short getPortNumber() {
48 * @param port the port on which the queue is
50 public void setPortNumber(short portNumber) {
51 this.portNumber = portNumber;
58 public List<OFPacketQueue> getQueues() {
63 * @param queues the queues to modify or delete
65 public void setQueues(List<OFPacketQueue> queues) {
70 * @return the total length of the queue modify or delete msg
73 public int getLength() {
76 for (OFPacketQueue queue : queues) {
77 queuesLength += queue.getLength();
80 return super.getLength() + MINIMUM_LENGTH + queuesLength;
84 * Read the queue message data from the ChannelBuffer
85 * @param data the channel buffer from which we're deserializing
86 * @param length the length to the end of the enclosing message
88 public void readFrom(ChannelBuffer data, int length) {
89 super.readFrom(data, length);
90 portNumber = data.readShort();
91 data.readInt(); // pad
92 data.readShort(); // pad
94 int availLength = (length - MINIMUM_LENGTH);
97 while (availLength > 0) {
98 OFPacketQueue queue = new OFPacketQueue();
101 availLength -= queue.getLength();
106 * Write the queue message data to the ChannelBuffer
107 * @param data the channel buffer to which we're serializing
109 public void writeTo(ChannelBuffer data) {
111 data.writeShort(this.portNumber);
112 data.writeInt(0); // pad
113 data.writeShort(0); // pad
115 for (OFPacketQueue queue : queues) {