diff --git a/lib/gen-java/net/floodlightcontroller/packetstreamer/thrift/OFMessageType.java b/lib/gen-java/net/floodlightcontroller/packetstreamer/thrift/OFMessageType.java index b9b2843485cfbb2e925eae132a5c4ff127853b32..ebbb6c166dd2a844acfe188dea42886f88372ff4 100644 --- a/lib/gen-java/net/floodlightcontroller/packetstreamer/thrift/OFMessageType.java +++ b/lib/gen-java/net/floodlightcontroller/packetstreamer/thrift/OFMessageType.java @@ -34,7 +34,9 @@ import org.apache.thrift.TEnum; STATS_REQUEST(16), STATS_REPLY(17), BARRIER_REQUEST(18), - BARRIER_REPLY(19); + BARRIER_REPLY(19), + QUEUE_GET_CONFIG_REQUEST(20), + QUEUE_GET_CONFIG_REPLY(21); private final int value; @@ -95,6 +97,10 @@ import org.apache.thrift.TEnum; return BARRIER_REQUEST; case 19: return BARRIER_REPLY; + case 20: + return QUEUE_GET_CONFIG_REQUEST; + case 21: + return QUEUE_GET_CONFIG_REPLY; default: return null; } diff --git a/src/main/java/org/openflow/protocol/OFPacketQueue.java b/src/main/java/org/openflow/protocol/OFPacketQueue.java new file mode 100644 index 0000000000000000000000000000000000000000..c48a1b1d356806fd7ad98d89f1a33c223a23b812 --- /dev/null +++ b/src/main/java/org/openflow/protocol/OFPacketQueue.java @@ -0,0 +1,142 @@ +/** +* Copyright 2012, Andrew Ferguson, Brown University +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. You may obtain +* a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +**/ + +package org.openflow.protocol; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.openflow.util.U16; + +/** + * Represents ofp_packet_queue + * @author Andrew Ferguson (adf@cs.brown.edu) + */ +public class OFPacketQueue { + public static int MINIMUM_LENGTH = 8; + + protected int queueId; + protected short length; + protected List<OFQueueProp> properties = new ArrayList<OFQueueProp>(); + + public OFPacketQueue() { + this.queueId = -1; + this.length = -1; + } + + public OFPacketQueue(int queueId) { + this.queueId = queueId; + this.length = U16.t(MINIMUM_LENGTH); + } + + /** + * @return the queueId + */ + public long getQueueId() { + return queueId; + } + + /** + * @param queueId the queueId to set + */ + public void setQueueId(int queueId) { + this.queueId = queueId; + } + + /** + * @return the queue's properties + */ + public List<OFQueueProp> getProperties() { + return properties; + } + + /** + * @param properties the properties to set + */ + public void setProperties(List<OFQueueProp> properties) { + this.properties = properties; + + this.length = U16.t(MINIMUM_LENGTH); + for (OFQueueProp prop : properties) { + this.length += prop.getLength(); + } + } + + /** + * @return the length + */ + public short getLength() { + return length; + } + + public void readFrom(ChannelBuffer data) { + this.queueId = data.readInt(); + this.length = data.readShort(); + data.readShort(); // pad + + int availLength = (this.length - MINIMUM_LENGTH); + this.properties.clear(); + + while (availLength > 0) { + OFQueueProp prop = new OFQueueProp(); + prop.readFrom(data); + properties.add(prop); + availLength -= prop.getLength(); + } + } + + public void writeTo(ChannelBuffer data) { + data.writeInt(queueId); + data.writeShort(length); + data.writeShort(0); // pad + + for (OFQueueProp prop : properties) { + prop.writeTo(data); + } + } + + @Override + public int hashCode() { + final int prime = 359; + int result = super.hashCode(); + result = prime * result + queueId; + result = prime * result + length; + result = prime * result + properties.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof OFPacketQueue)) { + return false; + } + OFPacketQueue other = (OFPacketQueue) obj; + if (queueId != other.queueId) { + return false; + } + if (! properties.equals(other.properties)) { + return false; + } + return true; + } +} diff --git a/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java b/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java new file mode 100644 index 0000000000000000000000000000000000000000..62be90d59f4106e8a6581dcf81bc5153cee83ce1 --- /dev/null +++ b/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java @@ -0,0 +1,125 @@ +/** +* Copyright 2012, Andrew Ferguson, Brown University +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. You may obtain +* a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +**/ + +package org.openflow.protocol; + +import java.util.ArrayList; +import java.util.List; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.openflow.util.U16; + +/** + * Represents an ofp_queue_get_config_request message + * @author Andrew Ferguson (adf@cs.brown.edu) + */ +public class OFQueueGetConfigReply extends OFMessage { + public static int MINIMUM_LENGTH = 16; + + protected short portNumber; + protected List<OFPacketQueue> queues = new ArrayList<OFPacketQueue>(); + + public OFQueueGetConfigReply() { + super(); + this.type = OFType.QUEUE_GET_CONFIG_REPLY; + this.length = U16.t(MINIMUM_LENGTH); + } + + /** + * @return the portNumber + */ + public short getPortNumber() { + return portNumber; + } + + /** + * @param portNumber the portNumber to set + */ + public void setPortNumber(short portNumber) { + this.portNumber = portNumber; + } + + /** + * @return the port's queues + */ + public List<OFPacketQueue> getQueues() { + return queues; + } + + /** + * @param queues the queues to set + */ + public void setQueues(List<OFPacketQueue> queues) { + this.queues.clear(); + this.queues.addAll(queues); + } + + @Override + public void readFrom(ChannelBuffer data) { + super.readFrom(data); + this.portNumber = data.readShort(); + data.readInt(); // pad + data.readShort(); // pad + + int availLength = (this.length - MINIMUM_LENGTH); + this.queues.clear(); + + while (availLength > 0) { + OFPacketQueue queue = new OFPacketQueue(); + queue.readFrom(data); + queues.add(queue); + availLength -= queue.getLength(); + } + } + + @Override + public void writeTo(ChannelBuffer data) { + super.writeTo(data); + data.writeShort(this.portNumber); + data.writeInt(0); // pad + data.writeShort(0); // pad + + for (OFPacketQueue queue : queues) { + queue.writeTo(data); + } + } + + @Override + public int hashCode() { + final int prime = 349; + int result = super.hashCode(); + result = prime * result + portNumber; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof OFQueueGetConfigReply)) { + return false; + } + OFQueueGetConfigReply other = (OFQueueGetConfigReply) obj; + if (portNumber != other.portNumber) { + return false; + } + return true; + } +} diff --git a/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java b/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java new file mode 100644 index 0000000000000000000000000000000000000000..cbb4a3734b9bc6510362afa237b6121398d9e4cd --- /dev/null +++ b/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java @@ -0,0 +1,95 @@ +/** +* Copyright 2012, Andrew Ferguson, Brown University +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. You may obtain +* a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +**/ + +package org.openflow.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.openflow.util.U16; + +/** + * Represents an ofp_queue_get_config_request message + * @author Andrew Ferguson (adf@cs.brown.edu) + */ +public class OFQueueGetConfigRequest extends OFMessage { + public static int MINIMUM_LENGTH = 12; + + protected short portNumber; + + public OFQueueGetConfigRequest(short portNumber) { + super(); + this.type = OFType.QUEUE_GET_CONFIG_REQUEST; + this.length = U16.t(MINIMUM_LENGTH); + this.portNumber = portNumber; + } + + public OFQueueGetConfigRequest() { + this((short) 0); + } + + /** + * @return the portNumber + */ + public short getPortNumber() { + return portNumber; + } + + /** + * @param portNumber the portNumber to set + */ + public void setPortNumber(short portNumber) { + this.portNumber = portNumber; + } + + @Override + public void readFrom(ChannelBuffer data) { + super.readFrom(data); + this.portNumber = data.readShort(); + data.readShort(); // pad + } + + @Override + public void writeTo(ChannelBuffer data) { + super.writeTo(data); + data.writeShort(this.portNumber); + data.writeShort(0); // pad + } + + @Override + public int hashCode() { + final int prime = 347; + int result = super.hashCode(); + result = prime * result + portNumber; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof OFQueueGetConfigRequest)) { + return false; + } + OFQueueGetConfigRequest other = (OFQueueGetConfigRequest) obj; + if (portNumber != other.portNumber) { + return false; + } + return true; + } +} diff --git a/src/main/java/org/openflow/protocol/OFQueueProp.java b/src/main/java/org/openflow/protocol/OFQueueProp.java new file mode 100644 index 0000000000000000000000000000000000000000..55c4d33e40f7b4cd4ed191f980fbf584d2e9000f --- /dev/null +++ b/src/main/java/org/openflow/protocol/OFQueueProp.java @@ -0,0 +1,166 @@ +/** +* Copyright 2012, Andrew Ferguson, Brown University +* +* Licensed under the Apache License, Version 2.0 (the "License"); you may +* not use this file except in compliance with the License. You may obtain +* a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +* License for the specific language governing permissions and limitations +* under the License. +**/ + +package org.openflow.protocol; + +import org.jboss.netty.buffer.ChannelBuffer; +import org.openflow.util.U16; + +public class OFQueueProp { + private int NONE_MINIMUM_LENGTH = 8; + private int MIN_RATE_MINIMUM_LENGTH = 16; + + public enum OFQueuePropType { + OFPQT_NONE (0), + OFPQT_MIN_RATE (1); + + protected int value; + + private OFQueuePropType(int value) { + this.value = value; + } + + /** + * @return the value + */ + public int getValue() { + return value; + } + + public static OFQueuePropType fromShort(short x) { + switch (x) { + case 0: + return OFPQT_NONE; + case 1: + return OFPQT_MIN_RATE; + } + return null; + } + } + + protected OFQueuePropType type; + protected short length; + protected short rate = -1; // not valid unless type == OFPQT_MIN_RATE + + public OFQueueProp() { + this.type = OFQueuePropType.OFPQT_NONE; + this.length = U16.t(NONE_MINIMUM_LENGTH); + } + + /** + * @return the type + */ + public OFQueuePropType getType() { + return type; + } + + /** + * @param type the type to set + */ + public void setType(OFQueuePropType type) { + this.type = type; + + switch (type) { + case OFPQT_NONE: + this.length = U16.t(NONE_MINIMUM_LENGTH); + break; + case OFPQT_MIN_RATE: + this.length = U16.t(MIN_RATE_MINIMUM_LENGTH); + break; + } + } + + /** + * @return the rate + */ + public short getRate() { + return rate; + } + + /** + * @param rate the rate to set + */ + public void setRate(short rate) { + this.rate = rate; + } + + /** + * @return the length + */ + public short getLength() { + return length; + } + + public void readFrom(ChannelBuffer data) { + this.type = OFQueuePropType.fromShort(data.readShort()); + this.length = data.readShort(); + data.readInt(); // pad + + if (this.type == OFQueuePropType.OFPQT_MIN_RATE) { + assert(this.length == MIN_RATE_MINIMUM_LENGTH); + + this.rate = data.readShort(); + data.readInt(); // pad + data.readShort(); // pad + } else { + assert(this.length == NONE_MINIMUM_LENGTH); + } + } + + public void writeTo(ChannelBuffer data) { + data.writeShort(this.type.getValue()); + data.writeShort(this.length); + data.writeInt(0); // pad + + if (this.type == OFQueuePropType.OFPQT_MIN_RATE) { + data.writeShort(this.rate); + data.writeInt(0); // pad + data.writeShort(0); // pad + } + } + + @Override + public int hashCode() { + final int prime = 353; + int result = super.hashCode(); + result = prime * result + type.getValue(); + result = prime * result + rate; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof OFQueueProp)) { + return false; + } + OFQueueProp other = (OFQueueProp) obj; + if (type != other.type) { + return false; + } + if (type == OFQueuePropType.OFPQT_MIN_RATE) { + if (rate != other.rate) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/org/openflow/protocol/OFType.java b/src/main/java/org/openflow/protocol/OFType.java index c828f0a928ec4ae798a2445972ee9d0681ad0ca1..f1c81e2884b0f850efe420aa54c1fe810869442e 100644 --- a/src/main/java/org/openflow/protocol/OFType.java +++ b/src/main/java/org/openflow/protocol/OFType.java @@ -127,7 +127,17 @@ public enum OFType { @Override public OFMessage instantiate() { return new OFBarrierReply(); - }}); + }}), + QUEUE_GET_CONFIG_REQUEST (20, OFQueueGetConfigRequest.class, new Instantiable<OFMessage>() { + @Override + public OFMessage instantiate() { + return new OFQueueGetConfigRequest(); + }}), + QUEUE_GET_CONFIG_REPLY (21, OFQueueGetConfigReply.class, new Instantiable<OFMessage>() { + @Override + public OFMessage instantiate() { + return new OFQueueGetConfigReply(); + }}); static OFType[] mapping; diff --git a/src/main/thrift/packetstreamer.thrift b/src/main/thrift/packetstreamer.thrift index 827dd8525d1a9a22f0a218911e05d4669cafe2e4..ca683014219af978cafbba7bd1a579be89415298 100644 --- a/src/main/thrift/packetstreamer.thrift +++ b/src/main/thrift/packetstreamer.thrift @@ -38,6 +38,8 @@ enum OFMessageType { STATS_REPLY = 17, BARRIER_REQUEST = 18, BARRIER_REPLY = 19, + QUEUE_GET_CONFIG_REQUEST = 20, + QUEUE_GET_CONFIG_REPLY = 21, } /**