* 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;
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;
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;
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.
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()) {
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);