Search in sources :

Example 1 with PathBindingTlvParser

use of org.opendaylight.protocol.pcep.ietf.stateful07.PathBindingTlvParser in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testPathBindingTlvMplsLabelEntry.

@Test
public void testPathBindingTlvMplsLabelEntry() throws PCEPDeserializerException {
    final byte[] pathBindingBytes = { 0x00, 0x1f, 0x00, 0x06, 0x00, 0x01, (byte) 0xA8, (byte) 0x0F, (byte) 0x6D, (byte) 0xAD, 0x00, 0x00 };
    final PathBindingTlvParser parser = new PathBindingTlvParser();
    final PathBindingBuilder builder = new PathBindingBuilder();
    builder.setBindingTypeValue(new MplsLabelEntryBuilder().setTrafficClass((short) 6).setTimeToLive((short) 173).setBottomOfStack(true).setLabel(new MplsLabel(688_374L)).build());
    final PathBinding tlv = builder.build();
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(pathBindingBytes, ByteArray.readAllBytes(buff));
}
Also used : MplsLabelEntryBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder) PathBindingTlvParser(org.opendaylight.protocol.pcep.ietf.stateful07.PathBindingTlvParser) PathBindingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBindingBuilder) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) ByteBuf(io.netty.buffer.ByteBuf) PathBinding(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBinding) Test(org.junit.Test)

Example 2 with PathBindingTlvParser

use of org.opendaylight.protocol.pcep.ietf.stateful07.PathBindingTlvParser in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testPathBindingTlvMplsLabel.

@Test
public void testPathBindingTlvMplsLabel() throws PCEPDeserializerException {
    final byte[] pathBindingBytes = { 0x00, 0x1f, 0x00, 0x06, 0x00, 0x00, (byte) 0xA8, 0x0F, (byte) 0x60, 0x00, 0x00, 0x00 };
    final PathBindingTlvParser parser = new PathBindingTlvParser();
    final PathBindingBuilder builder = new PathBindingBuilder();
    builder.setBindingTypeValue(new MplsLabelBuilder().setMplsLabel(new MplsLabel(688_374L)).build());
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(builder.build(), buff);
    assertArrayEquals(pathBindingBytes, ByteArray.readAllBytes(buff));
    try {
        final byte[] wrong = { 0, 0x1f, 0, 4, 1, 1, 2, 3 };
        parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(wrong, 4)));
        fail();
    } catch (final PCEPDeserializerException e) {
        assertEquals("Unsupported Path Binding Type: 257", e.getMessage());
    }
}
Also used : PathBindingTlvParser(org.opendaylight.protocol.pcep.ietf.stateful07.PathBindingTlvParser) PathBindingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBindingBuilder) MplsLabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.path.binding.binding.type.value.MplsLabelBuilder) MplsLabel(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel) ByteBuf(io.netty.buffer.ByteBuf) PCEPDeserializerException(org.opendaylight.protocol.pcep.spi.PCEPDeserializerException) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 PathBindingTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.PathBindingTlvParser)2 MplsLabel (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel)2 PathBindingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBindingBuilder)2 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)1 PathBinding (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.PathBinding)1 MplsLabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.path.binding.binding.type.value.MplsLabelBuilder)1 MplsLabelEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder)1