diff --git a/src/main/java/org/openflow/protocol/OFPacketQueue.java b/src/main/java/org/openflow/protocol/OFPacketQueue.java index 78dfe9ae2c83be27b5ea9154e49e2938005363d3..39cd0d36aeb3666f7553e100fb3a48f992ee29e3 100644 --- a/src/main/java/org/openflow/protocol/OFPacketQueue.java +++ b/src/main/java/org/openflow/protocol/OFPacketQueue.java @@ -18,12 +18,12 @@ public class OFPacketQueue { protected List<OFQueueProp> properties = new ArrayList<OFQueueProp>(); public OFPacketQueue() { - this.queueId = -1; - this.length = -1; + this.queueId = -1; + this.length = -1; } - + public OFPacketQueue(int queueId) { - this.queueId = queueId; + this.queueId = queueId; this.length = U16.t(MINIMUM_LENGTH); } @@ -40,59 +40,59 @@ public class OFPacketQueue { public void setQueueId(int queueId) { this.queueId = queueId; } - + /** * @return the queue's properties */ public List<OFQueueProp> getProperties() { - return properties; - } + 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(); - } - } - - /** + 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(); + 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); - } + 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; @@ -119,7 +119,7 @@ public class OFPacketQueue { return false; } if (! properties.equals(other.properties)) { - return false; + return false; } return true; } diff --git a/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java b/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java index 7ca85aa3c3f607e4635697c7f455bd0ae570cacf..c7309ceb4f6802886edd5007c66a690c782e32d6 100644 --- a/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java +++ b/src/main/java/org/openflow/protocol/OFQueueGetConfigReply.java @@ -21,7 +21,7 @@ public class OFQueueGetConfigReply extends OFMessage { this.type = OFType.QUEUE_GET_CONFIG_REPLY; this.length = U16.t(MINIMUM_LENGTH); } - + /** * @return the portNumber */ @@ -40,31 +40,31 @@ public class OFQueueGetConfigReply extends OFMessage { * @return the port's queues */ public List<OFPacketQueue> getQueues() { - return queues; - } + return queues; + } /** * @param queues the queues to set */ - public void setQueues(List<OFPacketQueue> queues) { - this.queues = queues; - } + public void setQueues(List<OFPacketQueue> queues) { + this.queues = queues; + } - @Override + @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(); + OFPacketQueue queue = new OFPacketQueue(); + queue.readFrom(data); + queues.add(queue); + availLength -= queue.getLength(); } } @@ -74,12 +74,12 @@ public class OFQueueGetConfigReply extends OFMessage { data.writeShort(this.portNumber); data.writeInt(0); // pad data.writeShort(0); // pad - + for (OFPacketQueue queue : queues) { - queue.writeTo(data); + queue.writeTo(data); } } - + @Override public int hashCode() { final int prime = 349; diff --git a/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java b/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java index f3267e6b50f57dfec4298a96b3a22e10e05800c8..5d64c2024ecb86214dea0ef1ba88688fd8eed4ef 100644 --- a/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java +++ b/src/main/java/org/openflow/protocol/OFQueueGetConfigRequest.java @@ -17,7 +17,7 @@ public class OFQueueGetConfigRequest extends OFMessage { this.type = OFType.QUEUE_GET_CONFIG_REQUEST; this.length = U16.t(MINIMUM_LENGTH); } - + /** * @return the portNumber */ @@ -45,7 +45,7 @@ public class OFQueueGetConfigRequest extends OFMessage { data.writeShort(this.portNumber); data.writeShort(0); // pad } - + @Override public int hashCode() { final int prime = 347; diff --git a/src/main/java/org/openflow/protocol/OFQueueProp.java b/src/main/java/org/openflow/protocol/OFQueueProp.java index c0bf4b8c1500c3ac3d818bff0a234e314c6716e5..6ebe1e11d771fae00c1c1a7c5af2301755cc547c 100644 --- a/src/main/java/org/openflow/protocol/OFQueueProp.java +++ b/src/main/java/org/openflow/protocol/OFQueueProp.java @@ -4,13 +4,13 @@ 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; + private int NONE_MINIMUM_LENGTH = 8; + private int MIN_RATE_MINIMUM_LENGTH = 16; public enum OFQueuePropType { - OFPQT_NONE (0), - OFPQT_MIN_RATE (1); - + OFPQT_NONE (0), + OFPQT_MIN_RATE (1); + protected int value; private OFQueuePropType(int value) { @@ -23,15 +23,15 @@ public class OFQueueProp { 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; + switch (x) { + case 0: + return OFPQT_NONE; + case 1: + return OFPQT_MIN_RATE; + } + return null; } } @@ -43,79 +43,79 @@ public class OFQueueProp { this.type = OFQueuePropType.OFPQT_NONE; this.length = U16.t(NONE_MINIMUM_LENGTH); } - + /** * @return the type */ public OFQueuePropType getType() { - return type; - } + 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); + 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; - } + public short getRate() { + return rate; + } - /** + /** * @param rate the rate to set */ - public void setRate(short rate) { - this.rate = rate; - } - + public void setRate(short rate) { + this.rate = rate; + } + /** * @return the length */ - public short getLength() { - return length; - } + public short getLength() { + return length; + } - public void readFrom(ChannelBuffer data) { + 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 + assert(this.length == MIN_RATE_MINIMUM_LENGTH); + + this.rate = data.readShort(); + data.readInt(); // pad + data.readShort(); // pad } else { - assert(this.length == NONE_MINIMUM_LENGTH); + 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 - } + 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; @@ -141,9 +141,9 @@ public class OFQueueProp { return false; } if (type == OFQueuePropType.OFPQT_MIN_RATE) { - if (rate != other.rate) { - return false; - } + if (rate != other.rate) { + return false; + } } return true; }