Search in sources :

Example 1 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.rev200120.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.rev200120.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.rev200120.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.rev200120.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.getEndOfList();
        fragments.add(builder.build());
    }
    return fragments;
}
Also used : FragmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder) Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.rev200120.BitmaskOperand)

Example 4 with Fragments

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.body()) {
        final FragmentsBuilder fragmentsBuilder = new FragmentsBuilder();
        node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> fragmentsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
        node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> fragmentsBuilder.setValue(createFragment((Set<String>) dataContainerChild.body())));
        fragments.add(fragmentsBuilder.build());
    }
    return fragments;
}
Also used : FragmentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder) Fragments(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.Fragments) ArrayList(java.util.ArrayList) UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)

Aggregations

Fragments (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.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.rev200120.flowspec.destination.flowspec.flowspec.type.fragment._case.FragmentsBuilder)2 BitmaskOperand (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.BitmaskOperand)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1