Search in sources :

Example 76 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.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(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev200720.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.rev200720.stateful.capability.tlv.Stateful) StatefulBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder) SyncOptimizationsCapabilityTlvParser(org.opendaylight.protocol.pcep.sync.optimizations.SyncOptimizationsCapabilityTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 77 with Tlv

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

the class PCEPTlvParserTest method testRSVPError4SpecTlv.

@Test
public void testRSVPError4SpecTlv() throws PCEPDeserializerException {
    final StatefulRSVPErrorSpecTlvParser parser = new StatefulRSVPErrorSpecTlvParser();
    final RsvpErrorBuilder builder = new RsvpErrorBuilder().setNode(new IpAddressNoZone(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })))).setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ErrorSpec.Flags(false, true)).setCode(Uint8.valueOf(146)).setValue(Uint16.valueOf(5634));
    final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(RSVP_ERROR_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(RSVP_ERROR_BYTES, 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.rev200720.rsvp.error.spec.tlv.RsvpErrorSpecBuilder) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec) StatefulRSVPErrorSpecTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulRSVPErrorSpecTlvParser) RsvpErrorSpec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec) RsvpCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) RsvpErrorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder) Test(org.junit.Test)

Example 78 with Tlv

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

the class PCEPTlvParserTest method testLspIdentifiers6Tlv.

@Test
public void testLspIdentifiers6Tlv() throws PCEPDeserializerException {
    final StatefulLSPIdentifierIpv6TlvParser parser = new StatefulLSPIdentifierIpv6TlvParser();
    final Ipv6Builder afi = new Ipv6Builder();
    afi.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 })));
    afi.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67 }))));
    afi.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 })));
    final LspIdentifiers tlv = new LspIdentifiersBuilder().setAddressFamily(new Ipv6CaseBuilder().setIpv6(afi.build()).build()).setLspId(new LspId(Uint32.valueOf(4660))).setTunnelId(new TunnelId(Uint16.MAX_VALUE)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(LSP_IDENTIFIERS6_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(LSP_IDENTIFIERS6_BYTES, ByteArray.getAllBytes(buff));
}
Also used : LspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId) StatefulLSPIdentifierIpv6TlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulLSPIdentifierIpv6TlvParser) LspIdentifiersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiersBuilder) LspIdentifiers(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiers) Ipv6CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv6CaseBuilder) Ipv6Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.address.family.ipv6._case.Ipv6Builder) ByteBuf(io.netty.buffer.ByteBuf) Ipv6ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId) TunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId) Ipv4ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId) Ipv6ExtendedTunnelId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId) Test(org.junit.Test)

Example 79 with Tlv

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

the class PCEPTlvParserTest method testPathBindingTlvMplsLabelEntry.

@Test
public void testPathBindingTlvMplsLabelEntry() {
    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(Uint8.valueOf(6)).setTimeToLive(Uint8.valueOf(173)).setBottomOfStack(true).setLabel(new MplsLabel(Uint32.valueOf(688374))).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.rev200720.path.binding.tlv.path.binding.binding.type.value.MplsLabelEntryBuilder) PathBindingTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.PathBindingTlvParser) PathBindingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.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.rev200720.path.binding.tlv.PathBinding) Test(org.junit.Test)

Example 80 with Tlv

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

the class PCEPTlvParserTest method testLspErrorCodeTlv.

@Test
public void testLspErrorCodeTlv() throws PCEPDeserializerException {
    final StatefulLspUpdateErrorTlvParser parser = new StatefulLspUpdateErrorTlvParser();
    final LspErrorCode tlv = new LspErrorCodeBuilder().setErrorCode(Uint32.valueOf(627610883)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(LSP_UPDATE_ERROR_BYTES, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(LSP_UPDATE_ERROR_BYTES, ByteArray.getAllBytes(buff));
}
Also used : StatefulLspUpdateErrorTlvParser(org.opendaylight.protocol.pcep.ietf.stateful.StatefulLspUpdateErrorTlvParser) LspErrorCode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.error.code.tlv.LspErrorCode) LspErrorCodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.error.code.tlv.LspErrorCodeBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)59 Test (org.junit.Test)28 Tlv (es.gob.jmulticard.asn1.Tlv)11 ArrayList (java.util.ArrayList)10 TunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.TunnelId)8 LspId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.LspId)7 TlvException (es.gob.jmulticard.asn1.TlvException)6 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.Stateful)5 Ipv4ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv4ExtendedTunnelId)5 Asn1Exception (es.gob.jmulticard.asn1.Asn1Exception)4 DecoderObject (es.gob.jmulticard.asn1.DecoderObject)4 BitArray (org.opendaylight.protocol.util.BitArray)4 Ipv6ExtendedTunnelId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.Ipv6ExtendedTunnelId)4 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)3 EnterpriseNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber)3 Stateful (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.stateful.capability.tlv.Stateful)3 LspIdentifiers (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiers)3 LspIdentifiersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.LspIdentifiersBuilder)3 AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.identifiers.tlv.lsp.identifiers.AddressFamily)3 RsvpErrorSpec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.rsvp.error.spec.tlv.RsvpErrorSpec)3