Search in sources :

Example 1 with OverloadDuration

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration in project bgpcep by opendaylight.

the class OverloadedDurationTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    checkArgument(tlv instanceof OverloadDuration, "OverloadedTlv is mandatory.");
    final ByteBuf body = Unpooled.buffer();
    ByteBufUtils.writeOrZero(body, ((OverloadDuration) tlv).getDuration());
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : OverloadDuration(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with OverloadDuration

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testOverloadedDurationTlv.

@Test
public void testOverloadedDurationTlv() throws PCEPDeserializerException {
    final OverloadedDurationTlvParser parser = new OverloadedDurationTlvParser();
    final OverloadDuration tlv = new OverloadDurationBuilder().setDuration(Uint32.valueOf(0x7FFFFFFFL)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(OVERLOADED_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(OVERLOADED_BYTES, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : OverloadDurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDurationBuilder) OverloadDuration(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration) OverloadedDurationTlvParser(org.opendaylight.protocol.pcep.parser.tlv.OverloadedDurationTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 OverloadDuration (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDuration)2 Test (org.junit.Test)1 OverloadedDurationTlvParser (org.opendaylight.protocol.pcep.parser.tlv.OverloadedDurationTlvParser)1 OverloadDurationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDurationBuilder)1