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