Search in sources :

Example 1 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments in project bgpcep by opendaylight.

the class AbstractFSFragmentHandler method serializeFragments.

private void serializeFragments(final List<Fragments> fragments, final ByteBuf nlriByteBuf) {
    for (final Iterator<Fragments> it = fragments.iterator(); it.hasNext(); ) {
        final Fragments fragment = it.next();
        BitmaskOperandParser.INSTANCE.serialize(fragment.getOp(), 1, !it.hasNext(), nlriByteBuf);
        nlriByteBuf.writeByte(serializeFragment(fragment.getValue()));
    }
}
Also used : Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments)

Example 2 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method stringFragment.

private static String stringFragment(final List<Fragments> fragments) {
    final StringBuilder buffer = new StringBuilder("where fragment ");
    boolean isFirst = true;
    for (final Fragments item : fragments) {
        buffer.append(BitmaskOperandParser.INSTANCE.toString(item.getOp(), isFirst));
        buffer.append(stringFragment(item.getValue()));
        if (isFirst) {
            isFirst = false;
        }
    }
    return buffer.toString();
}
Also used : Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments)

Example 3 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments in project bgpcep by opendaylight.

the class AbstractFlowspecNlriParser method createFragments.

private static List<Fragments> createFragments(final UnkeyedListNode fragmentsData) {
    final List<Fragments> fragments = new ArrayList<>();
    for (final UnkeyedListEntryNode node : fragmentsData.getValue()) {
        final FragmentsBuilder fragmentsBuilder = new FragmentsBuilder();
        final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
        if (opValue.isPresent()) {
            fragmentsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
        }
        final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
        if (valueNode.isPresent()) {
            fragmentsBuilder.setValue(createFragment((Set<String>) valueNode.get().getValue()));
        }
        fragments.add(fragmentsBuilder.build());
    }
    return fragments;
}
Also used : FragmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder) Set(java.util.Set) DataContainerChild(org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild) Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)

Example 4 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments in project bgpcep by opendaylight.

the class AbstractFSFragmentHandler method parseFragments.

private List<Fragments> parseFragments(final ByteBuf nlri) {
    final List<Fragments> fragments = new ArrayList<>();
    boolean end = false;
    // we can do this as all fields will be rewritten in the cycle
    final FragmentsBuilder builder = new FragmentsBuilder();
    while (!end) {
        final byte b = nlri.readByte();
        final BitmaskOperand op = BitmaskOperandParser.INSTANCE.parse(b);
        builder.setOp(op);
        builder.setValue(parseFragment(nlri.readByte()));
        end = op.isEndOfList();
        fragments.add(builder.build());
    }
    return fragments;
}
Also used : FragmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder) Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments) ArrayList(java.util.ArrayList) BitmaskOperand(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.BitmaskOperand)

Aggregations

Fragments (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments)4 ArrayList (java.util.ArrayList)2 FragmentsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder)2 Set (java.util.Set)1 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.BitmaskOperand)1 PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataContainerChild (org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1