Search in sources :

Example 1 with EROIpv4PrefixSubobjectParser

use of org.opendaylight.protocol.pcep.parser.subobject.EROIpv4PrefixSubobjectParser in project bgpcep by opendaylight.

the class BaseParserExtensionActivator method registerEROParsers.

private static void registerEROParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context, final LabelRegistry labelReg) {
    final EROIpv4PrefixSubobjectParser ipv4prefixParser = new EROIpv4PrefixSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
    regs.add(context.registerEROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
    regs.add(context.registerEROSubobjectParser(EROIpv6PrefixSubobjectParser.TYPE, new EROIpv6PrefixSubobjectParser()));
    final EROAsNumberSubobjectParser asNumberParser = new EROAsNumberSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROAsNumberSubobjectParser.TYPE, asNumberParser));
    regs.add(context.registerEROSubobjectSerializer(AsNumberCase.class, asNumberParser));
    final EROUnnumberedInterfaceSubobjectParser unnumberedParser = new EROUnnumberedInterfaceSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
    regs.add(context.registerEROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
    final EROPathKey32SubobjectParser pathKeyParser = new EROPathKey32SubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROPathKey32SubobjectParser.TYPE_32, pathKeyParser));
    regs.add(context.registerEROSubobjectParser(EROPathKey128SubobjectParser.TYPE_128, new EROPathKey128SubobjectParser()));
    regs.add(context.registerEROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
    final EROLabelSubobjectParser labelParser = new EROLabelSubobjectParser(labelReg);
    regs.add(context.registerEROSubobjectParser(EROLabelSubobjectParser.TYPE, labelParser));
    regs.add(context.registerEROSubobjectSerializer(LabelCase.class, labelParser));
}
Also used : IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) EROUnnumberedInterfaceSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROUnnumberedInterfaceSubobjectParser) EROPathKey128SubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROPathKey128SubobjectParser) PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) Type1LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase) WavebandSwitchingLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase) GeneralizedLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase) LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase) EROIpv6PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROIpv6PrefixSubobjectParser) EROLabelSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROLabelSubobjectParser) AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase) EROIpv4PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROIpv4PrefixSubobjectParser) EROAsNumberSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROAsNumberSubobjectParser) EROPathKey32SubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROPathKey32SubobjectParser)

Example 2 with EROIpv4PrefixSubobjectParser

use of org.opendaylight.protocol.pcep.parser.subobject.EROIpv4PrefixSubobjectParser in project bgpcep by opendaylight.

the class PCEPEROSubobjectParserTest method testEROIp4PrefixSubobject.

@Test
public void testEROIp4PrefixSubobject() throws PCEPDeserializerException {
    final EROIpv4PrefixSubobjectParser parser = new EROIpv4PrefixSubobjectParser();
    final SubobjectBuilder subs = new SubobjectBuilder();
    subs.setLoose(true);
    subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/22"))).build()).build());
    assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(ip4PrefixBytes, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    assertArrayEquals(ip4PrefixBytes, ByteArray.getAllBytes(buff));
    try {
        parser.parseSubobject(null, true);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : 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) EROIpv4PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.EROIpv4PrefixSubobjectParser) ByteBuf(io.netty.buffer.ByteBuf) 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) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder) Test(org.junit.Test)

Aggregations

EROIpv4PrefixSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROIpv4PrefixSubobjectParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 EROAsNumberSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROAsNumberSubobjectParser)1 EROIpv6PrefixSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROIpv6PrefixSubobjectParser)1 EROLabelSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROLabelSubobjectParser)1 EROPathKey128SubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROPathKey128SubobjectParser)1 EROPathKey32SubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROPathKey32SubobjectParser)1 EROUnnumberedInterfaceSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.EROUnnumberedInterfaceSubobjectParser)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)1 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder)1 AsNumberCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase)1 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)1 IpPrefixCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder)1 LabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase)1 UnnumberedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase)1 IpPrefixBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder)1 PathKeyCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase)1 GeneralizedLabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase)1