use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project bgpcep by opendaylight.
the class FSSourcePortHandler method parseSourcePort.
private static List<SourcePorts> parseSourcePort(final ByteBuf nlri) {
final List<SourcePorts> ports = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final SourcePortsBuilder builder = new SourcePortsBuilder();
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(Uint16.valueOf(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length))));
end = op.getEndOfList();
ports.add(builder.build());
}
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project bgpcep by opendaylight.
the class NumericOperandParserTest method testSerializeTwoByte.
@Test
public void testSerializeTwoByte() {
final ByteBuf nlriByteBuf = Unpooled.buffer();
final List<Ports> ports = new ArrayList<>();
// create 3 ports without end-of-list bit set
for (int i = 0; i < 3; i++) {
ports.add(new PortsBuilder().setOp(new NumericOperand(false, false, true, false, false)).setValue(Uint16.valueOf(100 + i)).build());
}
NumericTwoByteOperandParser.INSTANCE.serialize(ports, nlriByteBuf);
assertArrayEquals(ONE_BYTE_CODE_LIST, ByteArray.readAllBytes(nlriByteBuf));
}
Aggregations