Search in sources :

Example 1 with LabelStackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder in project bgpcep by opendaylight.

the class AbstractLabeledUnicastRIBSupport method extractLabel.

public static List<LabelStack> extractLabel(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
    final List<LabelStack> labels = new ArrayList<>();
    final Optional<DataContainerChild<? extends PathArgument, ?>> labelStacks = route.getChild(labelStackNid);
    if (labelStacks.isPresent()) {
        for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks.get()).getValue()) {
            final Optional<DataContainerChild<? extends PathArgument, ?>> labelStack = label.getChild(labelValueNid);
            if (labelStack.isPresent()) {
                final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
                labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
                labels.add(labelStackbuilder.build());
            }
        }
    }
    return labels;
}
Also used : LabelStackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStackBuilder) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)

Example 2 with LabelStackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder in project bgpcep by opendaylight.

the class LUNlriParser method parseLabel.

public static List<LabelStack> parseLabel(final ByteBuf nlri) {
    if (!nlri.isReadable()) {
        return null;
    }
    final List<LabelStack> labels = new ArrayList<>();
    boolean bottomBit;
    do {
        final ByteBuf slice = nlri.readSlice(LABEL_LENGTH);
        bottomBit = MplsLabelUtil.getBottomBit(slice);
        final MplsLabel mplsLabel = MplsLabelUtil.mplsLabelForByteBuf(slice);
        if (MplsLabelUtil.intForMplsLabel(mplsLabel) == WITHDRAW_LABEL_INT_VALUE) {
            return null;
        }
        labels.add(new LabelStackBuilder().setLabelValue(mplsLabel).build());
    } while (!bottomBit);
    return labels;
}
Also used : LabelStackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack) ArrayList(java.util.ArrayList) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) ByteBuf(io.netty.buffer.ByteBuf)

Example 3 with LabelStackBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder in project bgpcep by opendaylight.

the class AbstractLabeledUnicastRIBSupport method extractLabel.

public static List<LabelStack> extractLabel(final DataContainerNode route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
    final List<LabelStack> labels = new ArrayList<>();
    final DataContainerChild labelStacks = route.childByArg(labelStackNid);
    if (labelStacks != null) {
        for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks).body()) {
            final DataContainerChild labelStack = label.childByArg(labelValueNid);
            if (labelStack != null) {
                labels.add(new LabelStackBuilder().setLabelValue(new MplsLabel((Uint32) labelStack.body())).build());
            }
        }
    }
    return labels;
}
Also used : LabelStackBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder) LabelStack(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) Uint32(org.opendaylight.yangtools.yang.common.Uint32)

Aggregations

ArrayList (java.util.ArrayList)3 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)3 LabelStack (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStack)2 LabelStackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329.labeled.unicast.LabelStackBuilder)2 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)2 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)2 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)2 ByteBuf (io.netty.buffer.ByteBuf)1 LabelStack (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStack)1 LabelStackBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.labeled.unicast.LabelStackBuilder)1 Uint32 (org.opendaylight.yangtools.yang.common.Uint32)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1