Search in sources :

Example 1 with OfList

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));
}
Also used : OfList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId) ArrayList(java.util.ArrayList) OfListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.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);
}
Also used : OfList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList) OfId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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.rev181109.OfId)2 OfList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.list.tlv.OfList)2 ArrayList (java.util.ArrayList)1 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.rev181109.of.list.tlv.OfListBuilder)1