Search in sources :

Example 1 with OverloadDuration

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

the class OverloadedDurationTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof OverloadDuration, "OverloadedTlv is mandatory.");
    final ByteBuf body = Unpooled.buffer();
    writeUnsignedInt(((OverloadDuration) tlv).getDuration(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : OverloadDuration(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.rev131005.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(0x7FFFFFFFL).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(overloadedBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(overloadedBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : OverloadDurationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder) OverloadDuration(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.rev131005.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.rev131005.overload.duration.tlv.OverloadDurationBuilder)1