ONOS-4083,ONOS-4084:ISIS PDU TLV Data Structures
Change-Id: Ice0d42f2c886fa5f398b562e126614ed45f858a2
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java
old mode 100755
new mode 100644
index abc2bee..1c41d12
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/tlv/ProtocolSupportedTlv.java
@@ -15,21 +15,22 @@
*/
package org.onosproject.isis.io.isispacket.tlv;
+import com.google.common.base.MoreObjects;
import com.google.common.primitives.Bytes;
-import io.netty.buffer.ByteBuf;
+import org.jboss.netty.buffer.ChannelBuffer;
import java.util.ArrayList;
import java.util.List;
/**
- * Represents Protocol supported TLV.
+ * Representation of protocol supported TLV.
*/
public class ProtocolSupportedTlv extends TlvHeader implements IsisTlv {
- private List<Byte> protocolSupported = new ArrayList();
+ private List<Byte> protocolSupported = new ArrayList<>();
/**
- * Sets TLV type and TLV length of protocol supported TLV.
+ * Creates an instance of protocol supported TLV.
*
* @param tlvHeader tlvHeader.
*/
@@ -41,21 +42,27 @@
}
/**
- * Gets the Protocol Supported by the TLV.
+ * Adds the protocol supported to protocol supported TLV.
*
- * @return Protocol Supported
+ * @param protocolValue protocol supported
+ */
+ public void addProtocolSupported(byte protocolValue) {
+ protocolSupported.add(protocolValue);
+ }
+
+ /**
+ * Returns protocols supported of protocol supported TLV.
+ *
+ * @return protocol supported
*/
public List<Byte> protocolSupported() {
-
return this.protocolSupported;
-
}
@Override
- public void readFrom(ByteBuf byteBuf) {
-
- while (byteBuf.readableBytes() > 0) {
- this.protocolSupported.add(byteBuf.readByte());
+ public void readFrom(ChannelBuffer channelBuffer) {
+ while (channelBuffer.readableBytes() > 0) {
+ this.protocolSupported.add(channelBuffer.readByte());
}
}
@@ -65,8 +72,8 @@
byte[] tlvHeader = tlvHeaderAsByteArray();
byte[] tlvBody = tlvBodyAsBytes();
+ tlvHeader[1] = (byte) tlvBody.length;
bytes = Bytes.concat(tlvHeader, tlvBody);
-
return bytes;
}
@@ -75,9 +82,8 @@
*
* @return byteArray TLV body of protocol supported TLV
*/
- public byte[] tlvBodyAsBytes() {
-
- List<Byte> bytes = new ArrayList();
+ private byte[] tlvBodyAsBytes() {
+ List<Byte> bytes = new ArrayList<>();
for (byte byt : this.protocolSupported) {
bytes.add(byt);
}
@@ -88,4 +94,12 @@
}
return byteArray;
}
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .omitNullValues()
+ .add("protocolSupported", protocolSupported)
+ .toString();
+ }
}
\ No newline at end of file