Search in sources :

Example 1 with NodeAttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder in project bgpcep by opendaylight.

the class NodeAttributesParser method parseNodeAttributes.

/**
 * Parse Node Attributes.
 *
 * @param attributes key is the tlv type and value is the value of the tlv
 * @param protocolId to differentiate parsing methods
 * @return {@link LinkStateAttribute}
 */
static LinkStateAttribute parseNodeAttributes(final Multimap<Integer, ByteBuf> attributes, final ProtocolId protocolId) {
    final List<TopologyIdentifier> topologyMembership = new ArrayList<>();
    final List<IsisAreaIdentifier> areaMembership = new ArrayList<>();
    final NodeAttributesBuilder builder = new NodeAttributesBuilder();
    for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
        final int key = entry.getKey();
        final ByteBuf value = entry.getValue();
        LOG.trace("Node attribute TLV {}", key);
        switch(key) {
            case TlvUtil.MULTI_TOPOLOGY_ID:
                parseTopologyId(topologyMembership, value);
                break;
            case NODE_FLAG_BITS:
                parseNodeFlags(value, builder);
                break;
            case NODE_OPAQUE:
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Ignoring opaque value: {}.", ByteBufUtil.hexDump(value));
                }
                break;
            case DYNAMIC_HOSTNAME:
                builder.setDynamicHostname(new String(ByteArray.readAllBytes(value), StandardCharsets.US_ASCII));
                LOG.debug("Parsed Node Name {}", builder.getDynamicHostname());
                break;
            case ISIS_AREA_IDENTIFIER:
                final IsisAreaIdentifier ai = new IsisAreaIdentifier(ByteArray.readAllBytes(value));
                areaMembership.add(ai);
                LOG.debug("Parsed AreaIdentifier {}", ai);
                break;
            case TlvUtil.LOCAL_IPV4_ROUTER_ID:
                final Ipv4RouterIdentifier ip4 = new Ipv4RouterIdentifier(Ipv4Util.addressForByteBuf(value));
                builder.setIpv4RouterId(ip4);
                LOG.debug("Parsed IPv4 Router Identifier {}", ip4);
                break;
            case TlvUtil.LOCAL_IPV6_ROUTER_ID:
                final Ipv6RouterIdentifier ip6 = new Ipv6RouterIdentifier(Ipv6Util.addressForByteBuf(value));
                builder.setIpv6RouterId(ip6);
                LOG.debug("Parsed IPv6 Router Identifier {}", ip6);
                break;
            case SR_CAPABILITIES:
                final SrCapabilities caps = SrNodeAttributesParser.parseSrCapabilities(value, protocolId);
                builder.setSrCapabilities(caps);
                LOG.debug("Parsed SR Capabilities {}", caps);
                break;
            case SR_ALGORITHMS:
                final SrAlgorithm algs = SrNodeAttributesParser.parseSrAlgorithms(value);
                builder.setSrAlgorithm(algs);
                LOG.debug("Parsed SR Algorithms {}", algs);
                break;
            default:
                LOG.warn("TLV {} is not a valid node attribute, ignoring it", key);
        }
    }
    LOG.trace("Finished parsing Node Attributes.");
    builder.setTopologyIdentifier(topologyMembership);
    builder.setIsisAreaId(areaMembership);
    return new NodeAttributesCaseBuilder().setNodeAttributes(builder.build()).build();
}
Also used : IsisAreaIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.IsisAreaIdentifier) Ipv4RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv4RouterIdentifier) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) SrAlgorithm(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithm) SrCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrCapabilities) NodeAttributesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.NodeAttributesCaseBuilder) Ipv6RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv6RouterIdentifier) NodeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder) TopologyIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.TopologyIdentifier)

Example 2 with NodeAttributesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder in project bgpcep by opendaylight.

the class NodeAttributesParser method parseNodeFlags.

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));
}
Also used : NodeFlagBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeFlagBits) BitArray(org.opendaylight.protocol.util.BitArray)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 BitArray (org.opendaylight.protocol.util.BitArray)1 Ipv4RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv4RouterIdentifier)1 Ipv6RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Ipv6RouterIdentifier)1 IsisAreaIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.IsisAreaIdentifier)1 NodeFlagBits (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeFlagBits)1 TopologyIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.TopologyIdentifier)1 NodeAttributesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.NodeAttributesCaseBuilder)1 NodeAttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder)1 SrAlgorithm (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrAlgorithm)1 SrCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.state.SrCapabilities)1