Search in sources :

Example 1 with PCEPEndPointsIpv4ObjectParser

use of org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser 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 PCEPEndPointsIpv4ObjectParser

use of org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testEndPointsObjectIPv4.

@Test
public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
    final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
    final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
    final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));
    final EndpointsObjBuilder builder = new EndpointsObjBuilder().setProcessingRule(true).setIgnore(false).setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setSourceIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes))).setDestinationIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(destIPBytes))).build()).build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
    serializer.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());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) P2mpIpv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder) Ipv4CaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder) PCEPEndPointsObjectSerializer(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer) PCEPEndPointsIpv4ObjectParser(org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser) P2mpIpv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder) Ipv4Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder) ByteBuf(io.netty.buffer.ByteBuf) EndpointsObjBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder) Test(org.junit.Test)

Aggregations

PCEPEndPointsIpv4ObjectParser (org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser)2 PCEPEndPointsObjectSerializer (org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer)2 ByteBuf (io.netty.buffer.ByteBuf)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 BranchNodeListObjectParser (org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser)1