use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testOFListTlv.
@Test
public void testOFListTlv() throws PCEPDeserializerException {
final OFListTlvParser parser = new OFListTlvParser();
final List<OfId> ids = new ArrayList<>();
ids.add(new OfId(Uint16.valueOf(0x1234)));
ids.add(new OfId(Uint16.valueOf(0x5678)));
final OfList tlv = new OfListBuilder().setCodes(ids).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(OF_LIST_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(OF_LIST_BYTES, ByteArray.getAllBytes(buff));
assertNull(parser.parseTlv(null));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList in project bgpcep by opendaylight.
the class OFListTlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
checkArgument(tlv instanceof OfList, "OFListTlv is mandatory.");
final OfList oft = (OfList) tlv;
final ByteBuf body = Unpooled.buffer();
final List<OfId> ofCodes = oft.getCodes();
for (OfId id : ofCodes) {
ByteBufUtils.write(body, id.getValue());
}
TlvUtil.formatTlv(TYPE, body, buffer);
}
Aggregations