BUG 5031:
[bgpcep.git] / bgp / linkstate / src / main / java / org / opendaylight / protocol / bgp / linkstate / impl / attribute / NodeAttributesParser.java
similarity index 93%
rename from bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/attribute/NodeAttributesParser.java
rename to bgp/linkstate/src/main/java/org/opendaylight/protocol/bgp/linkstate/impl/attribute/NodeAttributesParser.java
index 3a0469e4824ecd7531fb56621521aa1d6644369d..39979b9d906a708e6bc688cc96cc3db5a3e0b304 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.protocol.bgp.linkstate.attribute;
+package org.opendaylight.protocol.bgp.linkstate.impl.attribute;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Charsets;
@@ -16,7 +16,7 @@ import io.netty.buffer.Unpooled;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map.Entry;
-import org.opendaylight.protocol.bgp.linkstate.attribute.sr.SrNodeAttributesParser;
+import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrNodeAttributesParser;
 import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
 import org.opendaylight.protocol.util.BitArray;
 import org.opendaylight.protocol.util.ByteArray;
@@ -42,13 +42,7 @@ import org.slf4j.LoggerFactory;
 public final class NodeAttributesParser {
 
     private static final Logger LOG = LoggerFactory.getLogger(NodeAttributesParser.class);
-
-    private NodeAttributesParser() {
-        throw new UnsupportedOperationException();
-    }
-
     private static final int FLAGS_SIZE = 8;
-
     // node flag bits
     private static final int OVERLOAD_BIT = 0;
     private static final int ATTACHED_BIT = 1;
@@ -56,16 +50,18 @@ public final class NodeAttributesParser {
     private static final int ABBR_BIT = 3;
     private static final int ROUTER_BIT = 4;
     private static final int V6_BIT = 5;
-
     /* Node Attribute TLVs */
     private static final int NODE_FLAG_BITS = 1024;
     private static final int NODE_OPAQUE = 1025;
     private static final int DYNAMIC_HOSTNAME = 1026;
     private static final int ISIS_AREA_IDENTIFIER = 1027;
-
     /* Segment routing TLVs */
     private static final int SR_CAPABILITIES = 1034;
     private static final int SR_ALGORITHMS = 1035;
+    
+    private NodeAttributesParser() {
+        throw new UnsupportedOperationException();
+    }
 
     /**
      * Parse Node Attributes.
@@ -87,11 +83,7 @@ public final class NodeAttributesParser {
                 parseTopologyId(topologyMembership, value);
                 break;
             case NODE_FLAG_BITS:
-                final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
-                builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get
-                    (EXTERNAL_BIT), flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
-                LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.",
-                    flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
+                parseNodeFlags(value, builder);
                 break;
             case NODE_OPAQUE:
                 if (LOG.isDebugEnabled()) {
@@ -137,6 +129,14 @@ public final class NodeAttributesParser {
         return new NodeAttributesCaseBuilder().setNodeAttributes(builder.build()).build();
     }
 
+    private static void parseNodeFlags(final ByteBuf value, final NodeAttributesBuilder builder) {
+        final BitArray flags = BitArray.valueOf(value, FLAGS_SIZE);
+        builder.setNodeFlags(new NodeFlagBits(flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get
+            (EXTERNAL_BIT), flags.get(ABBR_BIT), flags.get(ROUTER_BIT), flags.get(V6_BIT)));
+        LOG.debug("Parsed Overload bit: {}, attached bit: {}, external bit: {}, area border router: {}.",
+            flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
+    }
+
     private static void parseTopologyId(final List<TopologyIdentifier> topologyMembership, final ByteBuf value) {
         while (value.isReadable()) {
             final TopologyIdentifier topId = new TopologyIdentifier(value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET);