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));
}
}
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());
}
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));
}
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));
}
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());
}
}
Aggregations