Search in sources :

Example 1 with NoPathVectorTlv

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

the class PCEPTlvParserTest method testNoPathVectorTlv.

@Test
public void testNoPathVectorTlv() throws PCEPDeserializerException {
    final NoPathVectorTlvParser parser = new NoPathVectorTlvParser();
    final NoPathVectorTlv tlv = new NoPathVectorBuilder().setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(noPathVectorBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(noPathVectorBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : NoPathVectorTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv) NoPathVectorTlvParser(org.opendaylight.protocol.pcep.parser.tlv.NoPathVectorTlvParser) ByteBuf(io.netty.buffer.ByteBuf) NoPathVectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder) Test(org.junit.Test)

Example 2 with NoPathVectorTlv

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

the class NoPathVectorTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof NoPathVector, "NoPathVectorTlv is mandatory.");
    final NoPathVector noPath = (NoPathVector) tlv;
    final ByteBuf body = Unpooled.buffer();
    final BitArray flags = new BitArray(FLAGS_SIZE);
    final Flags f = noPath.getFlags();
    flags.set(REACHABLITY_PROBLEM, f.isP2mpUnreachable());
    flags.set(NO_GCO_SOLUTION, f.isNoGcoSolution());
    flags.set(NO_GCO_MIGRATION_PATH, f.isNoGcoMigration());
    flags.set(PATH_KEY, f.isPathKey());
    flags.set(CHAIN_UNAVAILABLE, f.isChainUnavailable());
    flags.set(UNKNOWN_SRC, f.isUnknownSource());
    flags.set(UNKNOWN_DEST, f.isUnknownDestination());
    flags.set(PCE_UNAVAILABLE, f.isPceUnavailable());
    flags.toByteBuf(body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : NoPathVector(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector) BitArray(org.opendaylight.protocol.util.BitArray) Flags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)1 NoPathVectorTlvParser (org.opendaylight.protocol.pcep.parser.tlv.NoPathVectorTlvParser)1 BitArray (org.opendaylight.protocol.util.BitArray)1 NoPathVectorTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv)1 Flags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags)1 NoPathVector (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVector)1 NoPathVectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder)1