use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengths in project bgpcep by opendaylight.
the class FSPacketLengthHandler method parsePacketLength.
private static List<PacketLengths> parsePacketLength(final ByteBuf nlri) {
final List<PacketLengths> packetLengths = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final PacketLengthsBuilder builder = new PacketLengthsBuilder();
while (!end) {
final byte b = nlri.readByte();
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
final short length = AbstractOperandParser.parseLength(b);
builder.setValue(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length)));
end = op.isEndOfList();
packetLengths.add(builder.build());
}
return packetLengths;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.flowspec.destination.flowspec.flowspec.type.packet.length._case.PacketLengths in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createPacketLengths.
private static List<PacketLengths> createPacketLengths(final UnkeyedListNode packetLengthsData) {
final List<PacketLengths> packetLengths = new ArrayList<>();
for (final UnkeyedListEntryNode node : packetLengthsData.getValue()) {
final PacketLengthsBuilder packetLengthsBuilder = new PacketLengthsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
packetLengthsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
packetLengthsBuilder.setValue((Integer) valueNode.get().getValue());
}
packetLengths.add(packetLengthsBuilder.build());
}
return packetLengths;
}
Aggregations