use of org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser 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);
}
use of org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testNonBranchNodeListObject.
@Test
public void testNonBranchNodeListObject() throws Exception {
final byte[] expected = { 0x1f, 0x20, 0x0, 0xc, (byte) 0x81, 0x8, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0 };
final NonBranchNodeListObjectParser parser = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(expected);
final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
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());
}
}
Aggregations