use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.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((short) (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.rev171207.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.getValue()) {
final CodesBuilder codesBuilder = new CodesBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
codesBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
codesBuilder.setValue((Short) valueNode.get().getValue());
}
codes.add(codesBuilder.build());
}
return codes;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev171207.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(nlri.readUnsignedByte());
end = op.isEndOfList();
codes.add(builder.build());
}
return codes;
}
Aggregations