Search in sources :

Example 6 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testPathSetupTypeTlvParser.

@Test
public void testPathSetupTypeTlvParser() throws PCEPDeserializerException {
    final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
    final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst(Uint8.ZERO).build();
    assertEquals(pstTlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(PST_TLV_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(pstTlv, buff);
    assertArrayEquals(PST_TLV_BYTES, ByteArray.getAllBytes(buff));
}
Also used : PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf) PathSetupTypeTlvParser(org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser) Test(org.junit.Test)

Example 7 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testUnsupportedPSTSerializer.

@Test(expected = IllegalArgumentException.class)
public void testUnsupportedPSTSerializer() {
    final PathSetupTypeTlvParser parser = new PathSetupTypeTlvParser();
    final PathSetupType pstTlv = new PathSetupTypeBuilder().setPst(Uint8.ONE).build();
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(pstTlv, buff);
}
Also used : PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder) PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf) PathSetupTypeTlvParser(org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser) Test(org.junit.Test)

Example 8 with PathSetupType

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType in project bgpcep by opendaylight.

the class PathSetupTypeTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    checkArgument(tlv instanceof PathSetupType, "PathSetupType is mandatory.");
    final PathSetupType pstTlv = (PathSetupType) tlv;
    checkArgument(checkPST(pstTlv.getPst()), UNSUPPORTED_PST);
    final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
    body.writeZero(OFFSET);
    ByteBufUtils.writeOrZero(body, pstTlv.getPst());
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : PathSetupType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

PathSetupType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType)6 ByteBuf (io.netty.buffer.ByteBuf)4 Collections (java.util.Collections)4 Test (org.junit.Test)3 PathSetupTypeBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder)3 Preconditions (com.google.common.base.Preconditions)2 PathSetupTypeTlvParser (org.opendaylight.protocol.pcep.parser.tlv.PathSetupTypeTlvParser)2 PathSetupType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupType)2 Srp1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Srp1Builder)1 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.RequestsBuilder)1 Srp1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Srp1Builder)1 RequestsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.pcinitiate.message.pcinitiate.message.RequestsBuilder)1 Path1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Path1Builder)1 StatefulTlv1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.StatefulTlv1)1 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder)1 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.updates.PathBuilder)1 SrpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.SrpBuilder)1 Path1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Path1Builder)1 LspBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.LspBuilder)1 PathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcupd.message.pcupd.message.updates.PathBuilder)1