use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.
the class NumericOperandParserTest method testSerializeOneByte.
@Test
public void testSerializeOneByte() {
final ByteBuf nlriByteBuf = Unpooled.buffer();
final List<Codes> codes = new ArrayList<>();
// create 3 ports without end-of-list bit set
for (int i = 0; i < 3; i++) {
codes.add(new CodesBuilder().setOp(new NumericOperand(false, false, true, false, false)).setValue(Uint8.valueOf(100 + i)).build());
}
NumericOneByteOperandParser.INSTANCE.serialize(codes, nlriByteBuf);
assertArrayEquals(ONE_BYTE_CODE_LIST, ByteArray.readAllBytes(nlriByteBuf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createCodes.
private static List<Codes> createCodes(final UnkeyedListNode codesData) {
final List<Codes> codes = new ArrayList<>();
for (final UnkeyedListEntryNode node : codesData.body()) {
final CodesBuilder codesBuilder = new CodesBuilder();
node.findChildByArg(OP_NID).ifPresent(dataContainerChild -> codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) dataContainerChild.body())));
node.findChildByArg(VALUE_NID).ifPresent(dataContainerChild -> codesBuilder.setValue((Uint8) dataContainerChild.body()));
codes.add(codesBuilder.build());
}
return codes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.icmp.code._case.Codes in project bgpcep by opendaylight.
the class FSIcmpCodeHandler method parseIcmpCode.
private static List<Codes> parseIcmpCode(final ByteBuf nlri) {
final List<Codes> codes = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final CodesBuilder builder = new CodesBuilder();
while (!end) {
final byte b = nlri.readByte();
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
builder.setValue(ByteBufUtils.readUint8(nlri));
end = op.getEndOfList();
codes.add(builder.build());
}
return codes;
}
Aggregations