Search in sources :

Example 11 with Tlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv in project jmulticard by ctt-gob-es.

the class TestTlvCreation method testTlv.

/**
 * Prueba la creación de TLV con volcados de CDF.
 * @throws Exception en caso de cualquier tipo de error
 */
public static void testTlv() throws Exception {
    byte[] cdfdata;
    for (final String element : TEST_FILES) {
        cdfdata = getDataFromInputStream(ClassLoader.getSystemResourceAsStream(element));
        final Tlv tlv = new Tlv(cdfdata);
        Assert.assertNotNull(tlv);
        LOGGER.info(tlv.toString());
        // $NON-NLS-1$
        LOGGER.info("\n\nProbando " + element);
        // $NON-NLS-1$ //$NON-NLS-2$
        LOGGER.info("\nTLV completo (" + Integer.toString(tlv.getBytes().length) + "):");
        LOGGER.info(HexUtils.hexify(tlv.getBytes(), true));
        // $NON-NLS-1$
        LOGGER.info("\nTipo TLV:");
        LOGGER.info(HexUtils.hexify(new byte[] { tlv.getTag() }, true));
        // $NON-NLS-1$
        LOGGER.info("\nLongitud TLV:");
        LOGGER.info(Integer.toString(tlv.getLength()));
        // $NON-NLS-1$ //$NON-NLS-2$
        LOGGER.info("\nValor TLV (" + Integer.toString(tlv.getValue().length) + "):");
        LOGGER.info(HexUtils.hexify(tlv.getValue(), true));
    }
}
Also used : Tlv(es.gob.jmulticard.asn1.Tlv)

Example 12 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 Ipv6BgpPrefixSidParserTest method testHandling.

@Test
public void testHandling() {
    final Ipv6SidTlvBuilder tlv = new Ipv6SidTlvBuilder();
    tlv.setProcessIpv6HeadAbility(Boolean.TRUE);
    final ByteBuf serialized = Unpooled.buffer(3);
    this.handler.serializeBgpPrefixSidTlv(tlv.build(), serialized);
    assertArrayEquals(this.expected, serialized.array());
    assertTrue(this.handler.parseBgpPrefixSidTlv(serialized).getProcessIpv6HeadAbility());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) Ipv6SidTlvBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.Ipv6SidTlvBuilder) Test(org.junit.Test)

Example 13 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 LinkstateAttributeParserTest method testPositiveV4Prefixes.

@Test
public void testPositiveV4Prefixes() throws BGPParsingException, BGPDocumentedException {
    final AttributesBuilder builder = createUnreachBuilder(new PrefixCaseBuilder().setPrefixDescriptors(new PrefixDescriptorsBuilder().setIpReachabilityInformation(new IpPrefix(new Ipv4Prefix("127.0.0.1/32"))).build()).build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(P4_ATTR), builder, null);
    final Attributes1 attrs = builder.augmentation(Attributes1.class);
    final PrefixAttributes ls = ((PrefixAttributesCase) attrs.getLinkStateAttribute()).getPrefixAttributes();
    assertNotNull(ls);
    assertNotNull(ls.getSrRange());
    assertFalse(ls.getSrRange().getInterArea());
    assertEquals(1, ls.getSrRange().getSubTlvs().size());
    assertNotNull(ls.getSrBindingSidLabels());
    final IgpBits ispBits = ls.getIgpBits();
    assertTrue(ispBits.getUpDown().getUpDown());
    assertTrue(ispBits.getIsIsUpDown());
    assertTrue(ispBits.getOspfNoUnicast());
    assertTrue(ispBits.getOspfLocalAddress());
    assertTrue(ispBits.getOspfPropagateNssa());
    assertEquals(2, ls.getRouteTags().size());
    assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }, ls.getRouteTags().get(0).getValue());
    assertEquals(1, ls.getExtendedTags().size());
    assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70 }, ls.getExtendedTags().get(0).getValue());
    assertEquals(10, ls.getPrefixMetric().getValue().intValue());
    assertEquals("10.25.2.27", ls.getOspfForwardingAddress().getIpv4AddressNoZone().getValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    buff.skipBytes(3);
    // there is unresolved TLV at the end, that needs to be cut off
    assertArrayEquals(P4_ATTR, ByteArray.getAllBytes(buff));
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) PrefixDescriptorsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.prefix._case.PrefixDescriptorsBuilder) PrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.PrefixCaseBuilder) PrefixAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.prefix.attributes._case.PrefixAttributes) PrefixAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.PrefixAttributesCase) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1) IgpBits(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.prefix.state.IgpBits) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Test(org.junit.Test)

Example 14 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 LinkstateAttributeParserTest method testPositiveLinks.

@Test
public void testPositiveLinks() throws BGPParsingException, BGPDocumentedException {
    final AttributesBuilder builder = createBuilder(new LinkCaseBuilder().build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder, null);
    final Attributes1 attrs = builder.augmentation(Attributes1.class);
    final LinkAttributes ls = ((LinkAttributesCase) attrs.getLinkStateAttribute()).getLinkAttributes();
    assertNotNull(ls);
    assertEquals("42.42.42.42", ls.getLocalIpv4RouterId().getValue());
    assertEquals("43.43.43.43", ls.getRemoteIpv4RouterId().getValue());
    assertEquals(Uint32.ZERO, ls.getAdminGroup().getValue());
    assertArrayEquals(new byte[] { (byte) 0x49, (byte) 0x98, (byte) 0x96, (byte) 0x80 }, ls.getMaxLinkBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getMaxReservableBandwidth().getValue());
    assertNotNull(ls.getUnreservedBandwidth());
    assertEquals(8, ls.getUnreservedBandwidth().size());
    assertEquals(LinkProtectionType.Dedicated1to1, ls.getLinkProtection());
    assertTrue(ls.getMplsProtocol().getLdp());
    assertTrue(ls.getMplsProtocol().getRsvpte());
    assertEquals(Uint32.TEN, ls.getMetric().getValue());
    assertEquals(2, ls.getSharedRiskLinkGroups().size());
    assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
    assertEquals("12K-2", ls.getLinkName());
    final IsisAdjFlagsCase flags = new IsisAdjFlagsCaseBuilder().setIsisAdjFlags(new IsisAdjFlagsBuilder().setAddressFamily(Boolean.TRUE).setBackup(Boolean.FALSE).setSet(Boolean.FALSE).build()).build();
    assertEquals(flags, ls.getSrAdjIds().get(0).getFlags());
    assertEquals(flags, ls.getSrAdjIds().get(1).getFlags());
    assertEquals(Uint32.valueOf(1048575L), ((LocalLabelCase) ls.getSrAdjIds().get(0).getSidLabelIndex()).getLocalLabel().getValue());
    assertEquals(Uint32.valueOf(1048559L), ((LocalLabelCase) ls.getSrAdjIds().get(1).getSidLabelIndex()).getLocalLabel().getValue());
    assertEquals(Uint32.valueOf(168496141L), ((SidCase) ls.getPeerNodeSid().getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerNodeSid().getWeight().getValue());
    assertEquals(Uint32.valueOf(168496142L), ((SidCase) ls.getPeerSetSids().get(0).getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerSetSids().get(0).getWeight().getValue());
    assertEquals(Uint32.valueOf(168496143L), ((SidCase) ls.getPeerAdjSid().getSidLabelIndex()).getSid());
    assertEquals(Uint8.valueOf(5), ls.getPeerAdjSid().getWeight().getValue());
    // Performance Metrics
    assertEquals(Uint32.valueOf(10000L), ls.getLinkDelay().getValue());
    assertEquals(Uint32.valueOf(5000L), ls.getLinkMinMaxDelay().getMinDelay().getValue());
    assertEquals(Uint32.valueOf(20000L), ls.getLinkMinMaxDelay().getMaxDelay().getValue());
    assertEquals(Uint32.valueOf(10000L), ls.getDelayVariation().getValue());
    assertEquals(Uint32.ZERO, ls.getLinkLoss().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getResidualBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x46, (byte) 0x43, (byte) 0x50, (byte) 0x00 }, ls.getAvailableBandwidth().getValue());
    assertArrayEquals(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }, ls.getUtilizedBandwidth().getValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    // The LINK_ATTR buffer is now greater than 255 bytes. Need to skip one more byte
    buff.skipBytes(4);
    // there is unresolved TLV at the end, that needs to be cut off
    assertArrayEquals(ByteArray.subByte(LINK_ATTR, 0, LINK_ATTR.length - 5), ByteArray.getAllBytes(buff));
}
Also used : LinkAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.link.attributes._case.LinkAttributes) LinkCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.LinkCaseBuilder) LocalLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.sid.label.index.LocalLabelCase) IsisAdjFlagsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.IsisAdjFlagsCaseBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1) IsisAdjFlagsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.IsisAdjFlagsCase) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) LinkAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.LinkAttributesCase) IsisAdjFlagsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.adj.flags.flags.isis.adj.flags._case.IsisAdjFlagsBuilder) Test(org.junit.Test)

Example 15 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 RouterIdTlvParser method serializeTlvBody.

@Override
public void serializeTlvBody(final CRouterIdentifier tlv, final ByteBuf body) {
    if (tlv instanceof IsisNodeCase) {
        final IsisNode isis = ((IsisNodeCase) tlv).getIsisNode();
        body.writeBytes(isis.getIsoSystemId().getValue());
    } else if (tlv instanceof IsisPseudonodeCase) {
        final IsisPseudonode isis = ((IsisPseudonodeCase) tlv).getIsisPseudonode();
        body.writeBytes(isis.getIsIsRouterIdentifier().getIsoSystemId().getValue());
        ByteBufUtils.writeOrZero(body, isis.getPsn());
    } else if (tlv instanceof OspfNodeCase) {
        ByteBufUtils.writeOrZero(body, ((OspfNodeCase) tlv).getOspfNode().getOspfRouterId());
    } else if (tlv instanceof OspfPseudonodeCase) {
        final OspfPseudonode node = ((OspfPseudonodeCase) tlv).getOspfPseudonode();
        ByteBufUtils.writeOrZero(body, node.getOspfRouterId());
        ByteBufUtils.write(body, node.getLanInterface().getValue());
    }
}
Also used : OspfPseudonode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.ospf.pseudonode._case.OspfPseudonode) IsisNodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisNodeCase) OspfPseudonodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.OspfPseudonodeCase) OspfNodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.OspfNodeCase) IsisPseudonodeCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisPseudonodeCase) IsisPseudonode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.isis.pseudonode._case.IsisPseudonode) IsisNode(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.isis.node._case.IsisNode)

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