Search in sources :

Example 1 with PCEPIncludeRouteObjectParser

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

the class PCEPObjectParserTest method testIRObject.

@Test
public void testIRObject() throws Exception {
    final PCEPIncludeRouteObjectParser parser = new PCEPIncludeRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
    final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin"));
    final byte[] ip6PrefixBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    final IroBuilder builder = new IroBuilder();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject> subs = Lists.newArrayList();
    subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x10L)).build()).build()).setLoose(true).build());
    subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("18.52.80.0/21"))).build()).build()).setLoose(true).build());
    subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).build()).setLoose(true).build());
    subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectBuilder().setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(new UnnumberedBuilder().setRouterId(0x1245678L).setInterfaceId(0x9abcdef0L).build()).build()).setLoose(true).build());
    builder.setSubobject(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());
    }
    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) AsNumberCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) AsNumberBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder) 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) UnnumberedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder) UnnumberedCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) PCEPIncludeRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser) IpPrefixCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder) IroBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.IroBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Example 2 with PCEPIncludeRouteObjectParser

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

the class BaseParserExtensionActivator method registerObjectParsers.

private static void registerObjectParsers(final List<AutoCloseable> 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(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, openParser));
    regs.add(context.registerObjectSerializer(Open.class, openParser));
    final PCEPRequestParameterObjectParser rpParser = new PCEPRequestParameterObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE, rpParser));
    regs.add(context.registerObjectSerializer(Rp.class, rpParser));
    final PCEPNoPathObjectParser noPathParser = new PCEPNoPathObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, noPathParser));
    regs.add(context.registerObjectSerializer(NoPath.class, noPathParser));
    final PCEPEndPointsIpv4ObjectParser endpoints4Parser = new PCEPEndPointsIpv4ObjectParser();
    final PCEPEndPointsIpv6ObjectParser endpoints6Parser = new PCEPEndPointsIpv6ObjectParser();
    regs.add(context.registerObjectParser(PCEPEndPointsIpv4ObjectParser.CLASS, PCEPEndPointsIpv4ObjectParser.TYPE, endpoints4Parser));
    regs.add(context.registerObjectParser(PCEPEndPointsIpv6ObjectParser.CLASS, PCEPEndPointsIpv6ObjectParser.TYPE, endpoints6Parser));
    regs.add(context.registerObjectSerializer(EndpointsObj.class, endpoints4Parser));
    final PCEPBandwidthObjectParser bwParser = new PCEPBandwidthObjectParser();
    final PCEPExistingBandwidthObjectParser bwExistingParser = new PCEPExistingBandwidthObjectParser();
    regs.add(context.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, bwParser));
    regs.add(context.registerObjectParser(PCEPExistingBandwidthObjectParser.CLASS, PCEPExistingBandwidthObjectParser.TYPE, 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.rev131005.reoptimization.bandwidth.object.ReoptimizationBandwidth.class, bwExistingParser));
    final PCEPMetricObjectParser metricParser = new PCEPMetricObjectParser();
    regs.add(context.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, metricParser));
    regs.add(context.registerObjectSerializer(Metric.class, metricParser));
    final EROSubobjectRegistry eroSubReg = context.getEROSubobjectHandlerRegistry();
    final PCEPExplicitRouteObjectParser eroParser = new PCEPExplicitRouteObjectParser(eroSubReg);
    regs.add(context.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE, eroParser));
    regs.add(context.registerObjectSerializer(Ero.class, eroParser));
    final PCEPReportedRouteObjectParser rroParser = new PCEPReportedRouteObjectParser(context.getRROSubobjectHandlerRegistry());
    regs.add(context.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE, rroParser));
    regs.add(context.registerObjectSerializer(Rro.class, rroParser));
    final PCEPLspaObjectParser lspaParser = new PCEPLspaObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, lspaParser));
    regs.add(context.registerObjectSerializer(Lspa.class, lspaParser));
    final PCEPIncludeRouteObjectParser iroParser = new PCEPIncludeRouteObjectParser(eroSubReg);
    regs.add(context.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE, iroParser));
    regs.add(context.registerObjectSerializer(Iro.class, iroParser));
    final PCEPSvecObjectParser svecParser = new PCEPSvecObjectParser();
    regs.add(context.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, svecParser));
    regs.add(context.registerObjectSerializer(Svec.class, svecParser));
    final PCEPNotificationObjectParser notParser = new PCEPNotificationObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE, notParser));
    regs.add(context.registerObjectSerializer(CNotification.class, notParser));
    final PCEPErrorObjectParser errParser = new PCEPErrorObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, errParser));
    regs.add(context.registerObjectSerializer(ErrorObject.class, errParser));
    final PCEPLoadBalancingObjectParser lbParser = new PCEPLoadBalancingObjectParser();
    regs.add(context.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE, lbParser));
    regs.add(context.registerObjectSerializer(LoadBalancing.class, lbParser));
    final PCEPCloseObjectParser closeParser = new PCEPCloseObjectParser(tlvReg, viTlvReg);
    regs.add(context.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, closeParser));
    regs.add(context.registerObjectSerializer(CClose.class, closeParser));
    registerExtensionsObjectParsers(regs, context, tlvReg, viTlvReg, eroSubReg);
}
Also used : CClose(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose) Ero(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero) PCEPBandwidthObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser) Svec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.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.rev131005.include.route.object.Iro) PCEPLspaObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser) PCEPEndPointsIpv4ObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPEndPointsIpv4ObjectParser) PCEPMetricObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser) Rro(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro) Open(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open) EROSubobjectRegistry(org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry) PCEPEndPointsIpv6ObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPEndPointsIpv6ObjectParser) Bandwidth(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth) VendorInformationTlvRegistry(org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry) PCEPNoPathObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser) EndpointsObj(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj) Rp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp) CNotification(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification) ErrorObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject) PCEPReportedRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser) LoadBalancing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.load.balancing.object.LoadBalancing) PCEPExplicitRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPExplicitRouteObjectParser) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) PCEPNotificationObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser) TlvRegistry(org.opendaylight.protocol.pcep.spi.TlvRegistry) VendorInformationTlvRegistry(org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry) PCEPExistingBandwidthObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPExistingBandwidthObjectParser) PCEPIncludeRouteObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser) PCEPSvecObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser) PCEPErrorObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser) PCEPOpenObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser) NoPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.NoPath) Metric(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric) Lspa(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa) PCEPLoadBalancingObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPLoadBalancingObjectParser)

Aggregations

PCEPIncludeRouteObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser)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 PCEPEndPointsIpv4ObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPEndPointsIpv4ObjectParser)1 PCEPEndPointsIpv6ObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPEndPointsIpv6ObjectParser)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 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 EROSubobjectRegistry (org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry)1