Search in sources :

Example 1 with OfList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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 = Lists.newArrayList();
    ids.add(new OfId(0x1234));
    ids.add(new OfId(0x5678));
    final OfList tlv = new OfListBuilder().setCodes(ids).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(ofListBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(ofListBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : OfList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId) OfListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfListBuilder) OFListTlvParser(org.opendaylight.protocol.pcep.parser.tlv.OFListTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with OfList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList in project bgpcep by opendaylight.

the class OFListTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.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) {
        writeUnsignedShort(id.getValue(), body);
    }
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : OfList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 OfId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId)2 OfList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfList)2 Test (org.junit.Test)1 OFListTlvParser (org.opendaylight.protocol.pcep.parser.tlv.OFListTlvParser)1 OfListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.list.tlv.OfListBuilder)1