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()));
}
}
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();
}
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;
}
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;
}
Aggregations