Search in sources :

Example 1 with TopologyIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier 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.rev171207.IsisAreaIdentifier) Ipv4RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv4RouterIdentifier) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) SrAlgorithm(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrAlgorithm) SrCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.node.state.SrCapabilities) NodeAttributesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.NodeAttributesCaseBuilder) Ipv6RouterIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv6RouterIdentifier) NodeAttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.path.attribute.link.state.attribute.node.attributes._case.NodeAttributesBuilder) TopologyIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier)

Example 2 with TopologyIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier in project bgpcep by opendaylight.

the class NodeAttributesParser method serializeTopologyId.

private static void serializeTopologyId(final List<TopologyIdentifier> topList, final ByteBuf byteAggregator) {
    if (topList != null) {
        final ByteBuf mpIdBuf = Unpooled.buffer();
        for (final TopologyIdentifier topologyIdentifier : topList) {
            mpIdBuf.writeShort(topologyIdentifier.getValue());
        }
        TlvUtil.writeTLV(TlvUtil.MULTI_TOPOLOGY_ID, mpIdBuf, byteAggregator);
    }
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) TopologyIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier)

Example 3 with TopologyIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier in project bgpcep by opendaylight.

the class AbstractPrefixNlriParser method parsePrefixDescriptor.

private static PrefixDescriptors parsePrefixDescriptor(final ByteBuf buffer) {
    final Map<QName, Object> tlvs = SimpleNlriTypeRegistry.getInstance().parseSubTlvs(buffer);
    final PrefixDescriptorsBuilder builder = new PrefixDescriptorsBuilder();
    builder.setMultiTopologyId((TopologyIdentifier) tlvs.get(MultiTopoIdTlvParser.MULTI_TOPOLOGY_ID_QNAME));
    builder.setOspfRouteType((OspfRouteType) tlvs.get(OspfRouteTlvParser.OSPF_ROUTE_TYPE_QNAME));
    builder.setIpReachabilityInformation((IpPrefix) tlvs.get(ReachTlvParser.IP_REACHABILITY_QNAME));
    return builder.build();
}
Also used : PrefixDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.prefix._case.PrefixDescriptorsBuilder) QName(org.opendaylight.yangtools.yang.common.QName)

Example 4 with TopologyIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier in project bgpcep by opendaylight.

the class ProtocolUtil method isisLinkAttributes.

private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1 isisLinkAttributes(final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
    final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.isis.link.attributes.TedBuilder();
    if (la != null) {
        if (la.getAdminGroup() != null) {
            tb.setColor(la.getAdminGroup().getValue());
        }
        if (la.getTeMetric() != null) {
            tb.setTeDefaultMetric(la.getTeMetric().getValue());
        }
        if (la.getUnreservedBandwidth() != null) {
            tb.setUnreservedBandwidth(unreservedBandwidthList(la.getUnreservedBandwidth()));
        }
        if (la.getMaxLinkBandwidth() != null) {
            tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
        }
        if (la.getMaxReservableBandwidth() != null) {
            tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
        }
        if (la.getSharedRiskLinkGroups() != null) {
            final List<SrlgValues> srlgs = new ArrayList<>();
            for (final SrlgId id : la.getSharedRiskLinkGroups()) {
                srlgs.add(new SrlgValuesBuilder().setSrlgValue(id.getValue()).build());
            }
            tb.setSrlg(new SrlgBuilder().setSrlgValues(srlgs).build());
        }
    }
    final IsisLinkAttributesBuilder ilab = new IsisLinkAttributesBuilder();
    ilab.setTed(tb.build());
    if (topologyIdentifier != null) {
        ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
    }
    return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.IgpLinkAttributes1Builder().setIsisLinkAttributes(ilab.build()).build();
}
Also used : SrlgValues(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValues) ArrayList(java.util.ArrayList) SrlgBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.ted.link.attributes.SrlgBuilder) IsisLinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.isis.topology.rev131021.isis.link.attributes.IsisLinkAttributesBuilder) SrlgValuesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValuesBuilder) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId)

Example 5 with TopologyIdentifier

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier in project bgpcep by opendaylight.

the class ProtocolUtil method ospfLinkAttributes.

private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1 ospfLinkAttributes(final TopologyIdentifier topologyIdentifier, final LinkAttributes la) {
    final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.ospf.link.attributes.TedBuilder();
    if (la != null) {
        if (la.getAdminGroup() != null) {
            tb.setColor(la.getAdminGroup().getValue());
        }
        if (la.getTeMetric() != null) {
            tb.setTeDefaultMetric(la.getTeMetric().getValue());
        }
        if (la.getUnreservedBandwidth() != null) {
            tb.setUnreservedBandwidth(unreservedBandwidthList(la.getUnreservedBandwidth()));
        }
        if (la.getMaxLinkBandwidth() != null) {
            tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
        }
        if (la.getMaxReservableBandwidth() != null) {
            tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
        }
        if (la.getSharedRiskLinkGroups() != null) {
            final List<SrlgValues> srlgs = new ArrayList<>();
            for (final SrlgId id : la.getSharedRiskLinkGroups()) {
                srlgs.add(new SrlgValuesBuilder().setSrlgValue(id.getValue()).build());
            }
            tb.setSrlg(new SrlgBuilder().setSrlgValues(srlgs).build());
        }
    }
    final OspfLinkAttributesBuilder ilab = new OspfLinkAttributesBuilder();
    ilab.setTed(tb.build());
    if (topologyIdentifier != null) {
        ilab.setMultiTopologyId(topologyIdentifier.getValue().shortValue());
    }
    return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpLinkAttributes1Builder().setOspfLinkAttributes(ilab.build()).build();
}
Also used : SrlgValues(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValues) ArrayList(java.util.ArrayList) SrlgBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.ted.link.attributes.SrlgBuilder) SrlgValuesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValuesBuilder) SrlgId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId) OspfLinkAttributesBuilder(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.link.attributes.OspfLinkAttributesBuilder)

Aggregations

TopologyIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.TopologyIdentifier)6 ByteBuf (io.netty.buffer.ByteBuf)3 ArrayList (java.util.ArrayList)3 LinkDescriptorsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.link._case.LinkDescriptorsBuilder)3 Test (org.junit.Test)2 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)2 DomainIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.DomainIdentifier)2 Ipv4InterfaceIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv4InterfaceIdentifier)2 IsoSystemIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.IsoSystemIdentifier)2 SrlgId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.SrlgId)2 SrlgValues (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValues)2 SrlgValuesBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.srlg.attributes.SrlgValuesBuilder)2 SrlgBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.ted.rev131021.ted.link.attributes.SrlgBuilder)2 QName (org.opendaylight.yangtools.yang.common.QName)2 BigInteger (java.math.BigInteger)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 AreaIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.AreaIdentifier)1 Identifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Identifier)1 Ipv4RouterIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv4RouterIdentifier)1 Ipv6InterfaceIdentifier (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Ipv6InterfaceIdentifier)1