Search in sources :

Example 1 with BranchNodeListObjectParser

use of org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser in project bgpcep by opendaylight.

the class BaseParserExtensionActivator method registerObjectParsers.

private static void registerObjectParsers(final List<Registration> regs, final PCEPExtensionProviderContext context) {
    final TlvRegistry tlvReg = context.getTlvHandlerRegistry();
    final VendorInformationTlvRegistry viTlvReg = context.getVendorInformationTlvRegistry();
    final PCEPOpenObjectParser openParser = new PCEPOpenObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(openParser));
    regs.add(context.registerObjectSerializer(Open.class, openParser));
    final PCEPRequestParameterObjectParser rpParser = new PCEPRequestParameterObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(rpParser));
    regs.add(context.registerObjectSerializer(Rp.class, rpParser));
    final PCEPNoPathObjectParser noPathParser = new PCEPNoPathObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(noPathParser));
    regs.add(context.registerObjectSerializer(NoPath.class, noPathParser));
    final PCEPEndPointsObjectSerializer endpointsSerializer = new PCEPEndPointsObjectSerializer();
    regs.add(context.registerObjectSerializer(EndpointsObj.class, endpointsSerializer));
    final PCEPEndPointsIpv4ObjectParser endpoints4Parser = new PCEPEndPointsIpv4ObjectParser();
    regs.add(context.registerObjectParser(endpoints4Parser));
    final PCEPEndPointsIpv6ObjectParser endpoints6Parser = new PCEPEndPointsIpv6ObjectParser();
    regs.add(context.registerObjectParser(endpoints6Parser));
    final PCEPIpv4UnreachDestinationParser unreachIpv4Parser = new PCEPIpv4UnreachDestinationParser();
    final PCEPIpv6UnreachDestinationParser unreachIpv6Parser = new PCEPIpv6UnreachDestinationParser();
    regs.add(context.registerObjectParser(unreachIpv4Parser));
    regs.add(context.registerObjectParser(unreachIpv6Parser));
    final PCEPUnreachDestinationSerializer unreachSerializer = new PCEPUnreachDestinationSerializer();
    regs.add(context.registerObjectSerializer(UnreachDestinationObj.class, unreachSerializer));
    final PCEPP2MPEndPointsIpv4ObjectParser endpoints4Pp2mparser = new PCEPP2MPEndPointsIpv4ObjectParser();
    regs.add(context.registerObjectParser(endpoints4Pp2mparser));
    final PCEPP2MPEndPointsIpv6ObjectParser endpoints6Pp2mparser = new PCEPP2MPEndPointsIpv6ObjectParser();
    regs.add(context.registerObjectParser(endpoints6Pp2mparser));
    final EROSubobjectRegistry subRegistry = context.getEROSubobjectHandlerRegistry();
    final BranchNodeListObjectParser bncPArser = new BranchNodeListObjectParser(subRegistry);
    regs.add(context.registerObjectParser(bncPArser));
    regs.add(context.registerObjectSerializer(BranchNodeList.class, bncPArser));
    final NonBranchNodeListObjectParser nonBncPArser = new NonBranchNodeListObjectParser(subRegistry);
    regs.add(context.registerObjectParser(nonBncPArser));
    final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser();
    final PCEPExistingBandwidthObjectParser bwExistingParser = new PCEPExistingBandwidthObjectParser();
    regs.add(context.registerObjectParser(bwParser));
    regs.add(context.registerObjectParser(bwExistingParser));
    regs.add(context.registerObjectSerializer(Bandwidth.class, bwParser));
    regs.add(context.registerObjectSerializer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidth.class, bwExistingParser));
    final PCEPMetricObjectParser metricParser = new PCEPMetricObjectParser();
    regs.add(context.registerObjectParser(metricParser));
    regs.add(context.registerObjectSerializer(Metric.class, metricParser));
    final EROSubobjectRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
    final PCEPExplicitRouteObjectParser eroParser = new PCEPExplicitRouteObjectParser(eroSubReg);
    regs.add(context.registerObjectParser(eroParser));
    regs.add(context.registerObjectSerializer(Ero.class, eroParser));
    final RROSubobjectRegistry rroSubReg = context.getRROSubobjectHandlerRegistry();
    final PCEPReportedRouteObjectParser rroParser = new PCEPReportedRouteObjectParser(rroSubReg);
    regs.add(context.registerObjectParser(rroParser));
    regs.add(context.registerObjectSerializer(Rro.class, rroParser));
    final PCEPLspaObjectParser lspaParser = new PCEPLspaObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(lspaParser));
    regs.add(context.registerObjectSerializer(Lspa.class, lspaParser));
    final PCEPIncludeRouteObjectParser iroParser = new PCEPIncludeRouteObjectParser(eroSubReg);
    regs.add(context.registerObjectParser(iroParser));
    regs.add(context.registerObjectSerializer(Iro.class, iroParser));
    final PCEPSvecObjectParser svecParser = new PCEPSvecObjectParser();
    regs.add(context.registerObjectParser(svecParser));
    regs.add(context.registerObjectSerializer(Svec.class, svecParser));
    final PCEPNotificationObjectParser notParser = new PCEPNotificationObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(notParser));
    regs.add(context.registerObjectSerializer(CNotification.class, notParser));
    final PCEPErrorObjectParser errParser = new PCEPErrorObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(errParser));
    regs.add(context.registerObjectSerializer(ErrorObject.class, errParser));
    final PCEPLoadBalancingObjectParser lbParser = new PCEPLoadBalancingObjectParser();
    regs.add(context.registerObjectParser(lbParser));
    regs.add(context.registerObjectSerializer(LoadBalancing.class, lbParser));
    final PCEPCloseObjectParser closeParser = new PCEPCloseObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(closeParser));
    regs.add(context.registerObjectSerializer(CClose.class, closeParser));
    registerExtensionsObjectParsers(regs, context, tlvReg, viTlvReg, eroSubReg, rroSubReg);
}
Also used : NonBranchNodeListObjectParser(org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser) BranchNodeListObjectParser(org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser) PCEPEndPointsIpv4ObjectParser(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro) EROSubobjectRegistry(org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry) PCEPEndPointsIpv6ObjectParser(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv6ObjectParser) PCEPEndPointsObjectSerializer(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer) PCEPNoPathObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser) PCEPUnreachDestinationSerializer(org.opendaylight.protocol.pcep.parser.object.unreach.PCEPUnreachDestinationSerializer) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancing) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) PCEPNotificationObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser) BranchNodeList(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeList) PCEPExistingBandwidthObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPExistingBandwidthObjectParser) PCEPOpenObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser) NonBranchNodeListObjectParser(org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser) CClose(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CClose) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero) PCEPBandwidthObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser) PCEPIpv4UnreachDestinationParser(org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv4UnreachDestinationParser) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec) PCEPCloseObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPCloseObjectParser) Iro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro) PCEPLspaObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser) PCEPMetricObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open) PCEPP2MPEndPointsIpv6ObjectParser(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv6ObjectParser) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.Bandwidth) VendorInformationTlvRegistry(org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp) CNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotification) UnreachDestinationObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObj) RROSubobjectRegistry(org.opendaylight.protocol.pcep.spi.RROSubobjectRegistry) PCEPIpv6UnreachDestinationParser(org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv6UnreachDestinationParser) PCEPReportedRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser) PCEPP2MPEndPointsIpv4ObjectParser(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv4ObjectParser) PCEPExplicitRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPExplicitRouteObjectParser) TlvRegistry(org.opendaylight.protocol.pcep.spi.TlvRegistry) VendorInformationTlvRegistry(org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry) PCEPIncludeRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser) PCEPSvecObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser) PCEPErrorObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser) NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa) PCEPLoadBalancingObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPLoadBalancingObjectParser)

Example 2 with BranchNodeListObjectParser

use of org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testBranchNodeListObject.

@Test
public void testBranchNodeListObject() throws Exception {
    final byte[] expected = { 0x1f, 0x10, 0x0, 0xc, (byte) 0x81, 0x8, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0 };
    final BranchNodeListObjectParser parser = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
    final ByteBuf result = Unpooled.wrappedBuffer(expected);
    final BranchNodeListBuilder builder = new BranchNodeListBuilder();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> subs = new ArrayList<>();
    subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(true).setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
    builder.setSubobject(BNCUtil.toBncSubobject(subs));
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) NonBranchNodeListObjectParser(org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser) BranchNodeListObjectParser(org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) IpPrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder) NonBranchNodeListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeListBuilder) BranchNodeListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder) IpPrefixBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder) Ipv4Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Aggregations

BranchNodeListObjectParser (org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser)2 NonBranchNodeListObjectParser (org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 PCEPBandwidthObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser)1 PCEPCloseObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPCloseObjectParser)1 PCEPErrorObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser)1 PCEPExistingBandwidthObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPExistingBandwidthObjectParser)1 PCEPExplicitRouteObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPExplicitRouteObjectParser)1 PCEPIncludeRouteObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser)1 PCEPLoadBalancingObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPLoadBalancingObjectParser)1 PCEPLspaObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser)1 PCEPMetricObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser)1 PCEPNoPathObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser)1 PCEPNotificationObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser)1 PCEPOpenObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser)1 PCEPReportedRouteObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser)1 PCEPRequestParameterObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser)1 PCEPSvecObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser)1