Search in sources :

Example 51 with Tlv

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

the class SyncOptimizationsOpenObjectParser method addTlv.

@Override
public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
    super.addTlv(tbuilder, tlv);
    final Tlvs3Builder syncOptTlvsBuilder = new Tlvs3Builder();
    if (tbuilder.getAugmentation(Tlvs3.class) != null) {
        final Tlvs3 t = tbuilder.getAugmentation(Tlvs3.class);
        if (t.getLspDbVersion() != null) {
            syncOptTlvsBuilder.setLspDbVersion(t.getLspDbVersion());
        }
        if (t.getSpeakerEntityId() != null) {
            syncOptTlvsBuilder.setSpeakerEntityId(t.getSpeakerEntityId());
        }
    }
    if (tlv instanceof LspDbVersion) {
        syncOptTlvsBuilder.setLspDbVersion((LspDbVersion) tlv);
    }
    if (tlv instanceof SpeakerEntityId) {
        syncOptTlvsBuilder.setSpeakerEntityId((SpeakerEntityId) tlv);
    }
    tbuilder.addAugmentation(Tlvs3.class, syncOptTlvsBuilder.build());
}
Also used : LspDbVersion(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion) SpeakerEntityId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityId) Tlvs3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder) Tlvs3(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3)

Example 52 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv 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 53 with Tlv

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

the class PCEPTlvParserTest method testSymbolicNameTlv.

@Test
public void testSymbolicNameTlv() throws PCEPDeserializerException {
    final Stateful07LspSymbolicNameTlvParser parser = new Stateful07LspSymbolicNameTlvParser();
    final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName("Med test of symbolic nameeee".getBytes())).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(symbolicNameBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(symbolicNameBytes, ByteArray.getAllBytes(buff));
}
Also used : SymbolicPathNameBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder) SymbolicPathName(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName) ByteBuf(io.netty.buffer.ByteBuf) Stateful07LspSymbolicNameTlvParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07LspSymbolicNameTlvParser) Test(org.junit.Test)

Example 54 with Tlv

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

the class PCEPTlvParserTest method testRSVPError4SpecTlv.

@Test
public void testRSVPError4SpecTlv() throws PCEPDeserializerException {
    final Stateful07RSVPErrorSpecTlvParser parser = new Stateful07RSVPErrorSpecTlvParser();
    final RsvpErrorBuilder builder = new RsvpErrorBuilder();
    builder.setNode(new IpAddress(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }))));
    builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags(false, true));
    builder.setCode((short) 146);
    builder.setValue(5634);
    final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(rsvpErrorBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(rsvpErrorBytes, ByteArray.getAllBytes(buff));
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) RsvpErrorSpecBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpecBuilder) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec) Stateful07RSVPErrorSpecTlvParser(org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser) RsvpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) RsvpErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder) Test(org.junit.Test)

Example 55 with Tlv

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

the class PCEPTlvParserTest method testStatefulTlvSyncOptimizationExtension.

@Test
public void testStatefulTlvSyncOptimizationExtension() throws PCEPDeserializerException {
    final SyncOptimizationsCapabilityTlvParser parser = new SyncOptimizationsCapabilityTlvParser();
    final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Stateful1Builder().setTriggeredInitialSync(Boolean.TRUE).setDeltaLspSyncCapability(Boolean.TRUE).setIncludeDbVersion(Boolean.TRUE).build()).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(STATEFUL_SYNC_OPT_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(STATEFUL_SYNC_OPT_BYTES, ByteArray.getAllBytes(buff));
}
Also used : Stateful(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.StatefulBuilder) ByteBuf(io.netty.buffer.ByteBuf) SyncOptimizationsCapabilityTlvParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)53 Test (org.junit.Test)29 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)8 TlvException (es.gob.jmulticard.asn1.TlvException)6 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiersBuilder)4 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)4 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)4 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)4 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.identifiers.tlv.LspIdentifiers)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.rsvp.error.spec.tlv.RsvpErrorSpec)3 VendorInformationTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.tlvs.VendorInformationTlv)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BmpDeserializationException (org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException)2 Stateful07RSVPErrorSpecTlvParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07RSVPErrorSpecTlvParser)2 BitArray (org.opendaylight.protocol.util.BitArray)2