use of org.opendaylight.protocol.pcep.parser.object.unreach.PCEPUnreachDestinationSerializer 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.unreach.PCEPUnreachDestinationSerializer in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testPCEPIpv6UnreachDestinationObject.
@Test
public void testPCEPIpv6UnreachDestinationObject() throws Exception {
final byte[] expected = { 0x1c, 0x20, 0x0, 0x14, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1 };
final PCEPIpv6UnreachDestinationParser parser = new PCEPIpv6UnreachDestinationParser();
final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
final ByteBuf result = Unpooled.wrappedBuffer(expected);
final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder().setDestinationIpv6Address(Collections.singletonList(new Ipv6AddressNoZone("::1"))).build();
builder.setDestination(dest);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
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());
}
}
use of org.opendaylight.protocol.pcep.parser.object.unreach.PCEPUnreachDestinationSerializer in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testPCEPIpv4UnreachDestinationObject.
@Test
public void testPCEPIpv4UnreachDestinationObject() throws Exception {
final byte[] expected = { 0x1c, 0x10, 0x0, 0x8, (byte) 0x7F, (byte) 0x0, (byte) 0x0, (byte) 0x1 };
final PCEPIpv4UnreachDestinationParser parser = new PCEPIpv4UnreachDestinationParser();
final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
final ByteBuf result = Unpooled.wrappedBuffer(expected);
final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder().setDestinationIpv4Address(Collections.singletonList(new Ipv4AddressNoZone("127.0.0.1"))).build();
builder.setDestination(dest);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
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());
}
}
Aggregations