Search in sources :

Example 1 with TeLspAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes in project bgpcep by opendaylight.

the class TeLspAttributesParser method serializeLspAttributes.

static void serializeLspAttributes(final RSVPTeObjectRegistry registry, final TeLspAttributesCase linkState, final ByteBuf output) {
    LOG.trace("Started serializing TE LSP Objects");
    final ByteBuf byteBuf = Unpooled.buffer();
    final TeLspAttributes teLspAttribute = linkState.getTeLspAttributes();
    final TspecObject tSpec = teLspAttribute.getTspecObject();
    registry.serializeRSPVTe(tSpec, byteBuf);
    final FlowSpecObject flow = teLspAttribute.getFlowSpecObject();
    registry.serializeRSPVTe(flow, byteBuf);
    final SessionAttributeObject sao = teLspAttribute.getSessionAttributeObject();
    if (sao instanceof BasicSessionAttributeObject) {
        registry.serializeRSPVTe((BasicSessionAttributeObject) sao, byteBuf);
    } else if (sao instanceof SessionAttributeObjectWithResourcesAffinities) {
        registry.serializeRSPVTe((SessionAttributeObjectWithResourcesAffinities) sao, byteBuf);
    }
    final ExplicitRouteObject ero = teLspAttribute.getExplicitRouteObject();
    registry.serializeRSPVTe(ero, byteBuf);
    final RecordRouteObject rro = teLspAttribute.getRecordRouteObject();
    registry.serializeRSPVTe(rro, byteBuf);
    final FastRerouteObject fro = teLspAttribute.getFastRerouteObject();
    if (fro instanceof BasicFastRerouteObject) {
        registry.serializeRSPVTe((BasicFastRerouteObject) fro, byteBuf);
    } else if (fro instanceof LegacyFastRerouteObject) {
        registry.serializeRSPVTe((LegacyFastRerouteObject) fro, byteBuf);
    }
    final DetourObject dto = teLspAttribute.getDetourObject();
    if (dto instanceof Ipv4DetourObject) {
        registry.serializeRSPVTe((Ipv4DetourObject) dto, byteBuf);
    } else if (dto instanceof Ipv6DetourObject) {
        registry.serializeRSPVTe((Ipv6DetourObject) dto, byteBuf);
    }
    final ExcludeRouteObject exro = teLspAttribute.getExcludeRouteObject();
    registry.serializeRSPVTe(exro, byteBuf);
    final SecondaryExplicitRouteObject sero = teLspAttribute.getSecondaryExplicitRouteObject();
    registry.serializeRSPVTe(sero, byteBuf);
    final SecondaryRecordRouteObject srro = teLspAttribute.getSecondaryRecordRouteObject();
    registry.serializeRSPVTe(srro, byteBuf);
    final LspAttributesObject lspAtt = teLspAttribute.getLspAttributesObject();
    registry.serializeRSPVTe(lspAtt, byteBuf);
    final LspRequiredAttributesObject rao = teLspAttribute.getLspRequiredAttributesObject();
    registry.serializeRSPVTe(rao, byteBuf);
    final ProtectionObject po = teLspAttribute.getProtectionObject();
    if (po instanceof DynamicControlProtectionObject) {
        registry.serializeRSPVTe((DynamicControlProtectionObject) po, byteBuf);
    } else if (po instanceof BasicProtectionObject) {
        registry.serializeRSPVTe((BasicProtectionObject) po, byteBuf);
    }
    final AssociationObject aso = teLspAttribute.getAssociationObject();
    registry.serializeRSPVTe(aso, byteBuf);
    final PrimaryPathRouteObject ppr = teLspAttribute.getPrimaryPathRouteObject();
    registry.serializeRSPVTe(ppr, byteBuf);
    final AdminStatusObject adso = teLspAttribute.getAdminStatusObject();
    registry.serializeRSPVTe(adso, byteBuf);
    final BandwidthObject bo = teLspAttribute.getBandwidthObject();
    if (bo instanceof BasicBandwidthObject) {
        registry.serializeRSPVTe((BasicBandwidthObject) bo, byteBuf);
    } else if (bo instanceof ReoptimizationBandwidthObject) {
        registry.serializeRSPVTe((ReoptimizationBandwidthObject) bo, byteBuf);
    }
    final MetricObject mo = teLspAttribute.getMetricObject();
    registry.serializeRSPVTe(mo, byteBuf);
    output.writeShort(MAGIC_NUMBER);
    output.writeShort(byteBuf.readableBytes());
    output.writeBytes(byteBuf);
    LOG.trace("Finished serializing TE LSP Objects");
}
Also used : DynamicControlProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.dynamic.control.protection.object._case.DynamicControlProtectionObject) ByteBuf(io.netty.buffer.ByteBuf) LspRequiredAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.required.attributes.object.LspRequiredAttributesObject) FlowSpecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.flow.spec.object.FlowSpecObject) TspecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject) BasicFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.basic.fast.reroute.object._case.BasicFastRerouteObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObject) ReoptimizationBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.reoptimization.bandwidth.object._case.ReoptimizationBandwidthObject) BandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.BandwidthObject) MetricObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.metric.object.MetricObject) BasicProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.basic.protection.object._case.BasicProtectionObject) LspAttributesObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.lsp.attributes.object.LspAttributesObject) AssociationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject) BasicSessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.basic.session.attribute.object._case.BasicSessionAttributeObject) SessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.SessionAttributeObject) SessionAttributeObjectWithResourcesAffinities(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.session.attribute.object.with.resources.affinities._case.SessionAttributeObjectWithResourcesAffinities) Ipv4DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject) Ipv6DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject) DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.DetourObject) SecondaryRecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.SecondaryRecordRouteObject) RecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.object.RecordRouteObject) TeLspAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes) BasicSessionAttributeObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.session.attribute.object.session.attribute.object.basic.session.attribute.object._case.BasicSessionAttributeObject) LegacyFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.legacy.fast.reroute.object._case.LegacyFastRerouteObject) ProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.ProtectionObject) BasicProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.basic.protection.object._case.BasicProtectionObject) DynamicControlProtectionObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.object.protection.object.dynamic.control.protection.object._case.DynamicControlProtectionObject) BasicBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObject) SecondaryRecordRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary._record.route.object.SecondaryRecordRouteObject) FastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.FastRerouteObject) LegacyFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.legacy.fast.reroute.object._case.LegacyFastRerouteObject) BasicFastRerouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.fast.reroute.object.fast.reroute.object.basic.fast.reroute.object._case.BasicFastRerouteObject) Ipv6DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject) ExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.object.ExplicitRouteObject) SecondaryExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.SecondaryExplicitRouteObject) PrimaryPathRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.primary.path.route.object.PrimaryPathRouteObject) AdminStatusObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject) ReoptimizationBandwidthObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.reoptimization.bandwidth.object._case.ReoptimizationBandwidthObject) SecondaryExplicitRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.SecondaryExplicitRouteObject) ExcludeRouteObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.ExcludeRouteObject) Ipv4DetourObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject)

Example 2 with TeLspAttributes

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes in project bgpcep by opendaylight.

the class LinkstateAttributeParserTest method testPositiveTELspAttribute.

@Test
public void testPositiveTELspAttribute() throws BGPParsingException, BGPDocumentedException {
    final AttributesBuilder builder = createBuilder(new TeLspCaseBuilder().build());
    this.parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder, null);
    final Attributes1 attrs = builder.augmentation(Attributes1.class);
    final TeLspAttributes teLspAttributes = ((TeLspAttributesCase) attrs.getLinkStateAttribute()).getTeLspAttributes();
    assertNotNull(teLspAttributes);
    final TspecObject tSpec = teLspAttributes.getTspecObject();
    assertNotNull(tSpec);
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 }), tSpec.getTokenBucketRate());
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02 }), teLspAttributes.getTspecObject().getTokenBucketSize());
    assertEquals(new Float32(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x03 }), tSpec.getPeakDataRate());
    assertEquals(Uint32.valueOf(4), tSpec.getMinimumPolicedUnit());
    assertEquals(Uint32.valueOf(5), tSpec.getMaximumPacketSize());
    final AssociationObject associationObject = teLspAttributes.getAssociationObject();
    assertEquals(AssociationType.Recovery, associationObject.getAssociationType());
    final IpAddressNoZone ipv4 = new IpAddressNoZone(Ipv4Util.addressForByteBuf(Unpooled.copiedBuffer(new byte[] { 0x01, 0x02, 0x03, 0x04 })));
    assertEquals(ipv4, associationObject.getIpAddress());
    final short associationId = 2;
    assertEquals(associationId, associationObject.getAssociationId().shortValue());
    // serialization
    final ByteBuf buff = Unpooled.buffer();
    this.parser.serializeAttribute(builder.build(), buff);
    assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
    assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
Also used : TspecObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject) AssociationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject) Float32(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32) TeLspAttributesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.TeLspAttributesCase) TeLspCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1) IpAddressNoZone(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone) ByteBuf(io.netty.buffer.ByteBuf) AttributesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder) TeLspAttributes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 TeLspAttributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.te.lsp.attributes._case.TeLspAttributes)2 AssociationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject)2 TspecObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject)2 Test (org.junit.Test)1 IpAddressNoZone (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone)1 Attributes1 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.Attributes1)1 TeLspCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.object.type.TeLspCaseBuilder)1 TeLspAttributesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.path.attribute.link.state.attribute.TeLspAttributesCase)1 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)1 Float32 (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32)1 RecordRouteObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.object.RecordRouteObject)1 AdminStatusObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.admin.status.object.AdminStatusObject)1 BandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.BandwidthObject)1 BasicBandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.basic.bandwidth.object._case.BasicBandwidthObject)1 ReoptimizationBandwidthObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.bandwidth.object.bandwidth.object.reoptimization.bandwidth.object._case.ReoptimizationBandwidthObject)1 DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.DetourObject)1 Ipv4DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv4DetourObject)1 Ipv6DetourObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.detour.object.detour.object.Ipv6DetourObject)1 ExcludeRouteObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.ExcludeRouteObject)1