Bgp and Pcep maintaiability
Change-Id: I2c14cc29d4900ef2f0fbffd4761b0d78e282910f
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
index e205246..9587cc5 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsSourcePrefix.java
@@ -15,17 +15,16 @@
*/
package org.onosproject.bgpio.types;
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
+import com.google.common.base.MoreObjects;
+import com.google.common.base.Preconditions;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onlab.packet.IpPrefix;
import org.onosproject.bgpio.exceptions.BgpParseException;
import org.onosproject.bgpio.util.Constants;
import org.onosproject.bgpio.util.Validation;
-import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
+import java.nio.ByteBuffer;
+import java.util.Objects;
/**
* Provides implementation of IPv4AddressTlv.
@@ -33,13 +32,14 @@
public class BgpFsSourcePrefix implements BgpValueType {
public static final byte FLOW_SPEC_TYPE = Constants.BGP_FLOWSPEC_SRC_PREFIX;
+ public static final int BYTE_IN_BITS = 8;
private byte length;
private IpPrefix ipPrefix;
- public static final int BYTE_IN_BITS = 8;
+
/**
* Constructor to initialize parameters.
*
- * @param length length of the prefix
+ * @param length length of the prefix
* @param ipPrefix ip prefix
*/
public BgpFsSourcePrefix(byte length, IpPrefix ipPrefix) {
@@ -48,6 +48,50 @@
}
/**
+ * Reads the channel buffer and returns object of IPv4AddressTlv.
+ *
+ * @param cb channelBuffer
+ * @return object of flow spec source prefix
+ * @throws BgpParseException while parsing BgpFsSourcePrefix
+ */
+ public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
+ IpPrefix ipPrefix;
+
+ int length = cb.readByte();
+ if (length == 0) {
+ byte[] prefix = new byte[]{0};
+ ipPrefix = Validation.bytesToPrefix(prefix, length);
+ return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+ }
+
+ int len = length / BYTE_IN_BITS;
+ int reminder = length % BYTE_IN_BITS;
+ if (reminder > 0) {
+ len = len + 1;
+ }
+ if (cb.readableBytes() < len) {
+ Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
+ BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
+ }
+ byte[] prefix = new byte[len];
+ cb.readBytes(prefix, 0, len);
+ ipPrefix = Validation.bytesToPrefix(prefix, length);
+
+ return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
+ }
+
+ /**
+ * Returns object of this class with specified values.
+ *
+ * @param ipPrefix ip prefix
+ * @param length length of ip prefix
+ * @return object of this class
+ */
+ public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
+ return new BgpFsSourcePrefix(length, ipPrefix);
+ }
+
+ /**
* Returns ip prefix.
*
* @return ipPrefix ip prefix
@@ -87,50 +131,6 @@
return cb.writerIndex() - iLenStartIndex;
}
- /**
- * Reads the channel buffer and returns object of IPv4AddressTlv.
- *
- * @param cb channelBuffer
- * @return object of flow spec source prefix
- * @throws BgpParseException while parsing BgpFsSourcePrefix
- */
- public static BgpFsSourcePrefix read(ChannelBuffer cb) throws BgpParseException {
- IpPrefix ipPrefix;
-
- int length = cb.readByte();
- if (length == 0) {
- byte[] prefix = new byte[] {0};
- ipPrefix = Validation.bytesToPrefix(prefix, length);
- return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
- }
-
- int len = length / BYTE_IN_BITS;
- int reminder = length % BYTE_IN_BITS;
- if (reminder > 0) {
- len = len + 1;
- }
- if (cb.readableBytes() < len) {
- Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
- BgpErrorType.MALFORMED_ATTRIBUTE_LIST, cb.readableBytes());
- }
- byte[] prefix = new byte[len];
- cb.readBytes(prefix, 0, len);
- ipPrefix = Validation.bytesToPrefix(prefix, length);
-
- return new BgpFsSourcePrefix((byte) ipPrefix.prefixLength(), ipPrefix);
- }
-
- /**
- * Returns object of this class with specified values.
- *
- * @param ipPrefix ip prefix
- * @param length length of ip prefix
- * @return object of this class
- */
- public static BgpFsSourcePrefix of(final IpPrefix ipPrefix, final byte length) {
- return new BgpFsSourcePrefix(length, ipPrefix);
- }
-
@Override
public int compareTo(Object o) {
if (this.equals(o)) {
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
index 3fb8d3b..32aaa71 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpValueType.java
@@ -44,4 +44,4 @@
* @return result after comparing two objects
*/
int compareTo(Object o);
-}
\ No newline at end of file
+}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
index 605e7e3..f7f783e 100644
--- a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpAttrNodeName.java
@@ -80,6 +80,7 @@
nodeName = new byte[lsAttrLength];
cb.readBytes(nodeName);
+ log.debug("LS attribute node name read");
return BgpAttrNodeName.of(nodeName);
}