Search in sources :

Example 1 with XROIpv4PrefixSubobjectParser

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

the class BaseParserExtensionActivator method registerXROParsers.

private static void registerXROParsers(final List<AutoCloseable> regs, final PCEPExtensionProviderContext context) {
    final XROIpv4PrefixSubobjectParser ipv4prefixParser = new XROIpv4PrefixSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
    regs.add(context.registerXROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
    regs.add(context.registerXROSubobjectParser(XROIpv6PrefixSubobjectParser.TYPE, new XROIpv6PrefixSubobjectParser()));
    final XROAsNumberSubobjectParser asNumberParser = new XROAsNumberSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROAsNumberSubobjectParser.TYPE, asNumberParser));
    regs.add(context.registerXROSubobjectSerializer(AsNumberCase.class, asNumberParser));
    final XROSRLGSubobjectParser srlgParser = new XROSRLGSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROSRLGSubobjectParser.TYPE, srlgParser));
    regs.add(context.registerXROSubobjectSerializer(SrlgCase.class, srlgParser));
    final XROUnnumberedInterfaceSubobjectParser unnumberedParser = new XROUnnumberedInterfaceSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
    regs.add(context.registerXROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
    final XROPathKey32SubobjectParser pathKeyParser = new XROPathKey32SubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROPathKey32SubobjectParser.TYPE, pathKeyParser));
    regs.add(context.registerXROSubobjectParser(XROPathKey128SubobjectParser.TYPE, new XROPathKey128SubobjectParser()));
    regs.add(context.registerXROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
}
Also used : XROAsNumberSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROAsNumberSubobjectParser) XROSRLGSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROSRLGSubobjectParser) XROPathKey128SubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROPathKey128SubobjectParser) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) SrlgCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCase) PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) XROPathKey32SubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROPathKey32SubobjectParser) XROIpv6PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROIpv6PrefixSubobjectParser) AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) XROUnnumberedInterfaceSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROUnnumberedInterfaceSubobjectParser) UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase) XROIpv4PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROIpv4PrefixSubobjectParser)

Example 2 with XROIpv4PrefixSubobjectParser

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

the class PCEPXROSubobjectParserTest method testXROIp4PrefixSubobject.

@Test
public void testXROIp4PrefixSubobject() throws PCEPDeserializerException {
    final XROIpv4PrefixSubobjectParser parser = new XROIpv4PrefixSubobjectParser();
    final SubobjectBuilder subs = new SubobjectBuilder();
    subs.setMandatory(false);
    subs.setAttribute(Attribute.Interface);
    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)), false));
    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) 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) XROIpv4PrefixSubobjectParser(org.opendaylight.protocol.pcep.parser.subobject.XROIpv4PrefixSubobjectParser) SubobjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder) Test(org.junit.Test)

Aggregations

XROIpv4PrefixSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROIpv4PrefixSubobjectParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 XROAsNumberSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROAsNumberSubobjectParser)1 XROIpv6PrefixSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROIpv6PrefixSubobjectParser)1 XROPathKey128SubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROPathKey128SubobjectParser)1 XROPathKey32SubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROPathKey32SubobjectParser)1 XROSRLGSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROSRLGSubobjectParser)1 XROUnnumberedInterfaceSubobjectParser (org.opendaylight.protocol.pcep.parser.subobject.XROUnnumberedInterfaceSubobjectParser)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.exclude.route.object.xro.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 SrlgCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCase)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