Search in sources :

Example 16 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.

the class TEObjectTest method testSSRODynamicProtectionSubobjectParser.

@Test
public void testSSRODynamicProtectionSubobjectParser() throws RSVPParsingException {
    final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
    final SRRODynamicProtectionSubobjectParser dynamicParser = new SRRODynamicProtectionSubobjectParser();
    final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION.length - 2)));
    final ByteBuf output = Unpooled.buffer();
    dynamicParser.serializeSubobject(sub, output);
    assertArrayEquals(TEObjectUtil.TE_LSP_DYNAMIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer) SRRODynamicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRRODynamicProtectionSubobjectParser) SRROBasicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRROBasicProtectionSubobjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 17 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.

the class TEObjectTest method testSSROBasicProtectionSubobjectParser.

@Test
public void testSSROBasicProtectionSubobjectParser() throws RSVPParsingException {
    final SRROBasicProtectionSubobjectParser parser = new SRROBasicProtectionSubobjectParser();
    final SubobjectContainer sub = parser.parseSubobject(Unpooled.copiedBuffer(ByteArray.subByte(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, 2, TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION.length - 2)));
    final ByteBuf output = Unpooled.buffer();
    parser.serializeSubobject(sub, output);
    assertArrayEquals(TEObjectUtil.TE_LSP_BASIC_SRRO_PROTECTION, ByteArray.getAllBytes(output));
}
Also used : SubobjectContainer(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer) SRROBasicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.rro.SRROBasicProtectionSubobjectParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 18 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.

the class RROIpv6PrefixSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    checkArgument(subobject.getSubobjectType() instanceof IpPrefixCase, "Unknown subobject instance. Passed %s. Needed IpPrefixCase.", subobject.getSubobjectType().getClass());
    final IpPrefixSubobject specObj = ((IpPrefixCase) subobject.getSubobjectType()).getIpPrefix();
    final Ipv6Prefix ipv6Prefix = specObj.getIpPrefix().getIpv6Prefix();
    checkArgument(ipv6Prefix != null, "Ipv6Prefix is mandatory.");
    serializeSubobject(buffer, subobject, ipv6Prefix);
}
Also used : IpPrefixSubobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase) Ipv6Prefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)

Example 19 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.

the class RROPathKey128SubobjectParser method serializeSubobject.

public static void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    final PathKeyCase pkcase = (PathKeyCase) subobject.getSubobjectType();
    RROSubobjectUtil.formatSubobject(TYPE, PathKeyUtils.serializePathKey(pkcase.getPathKey()), buffer);
}
Also used : PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.subobject.type.PathKeyCase)

Example 20 with SubobjectContainer

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer in project bgpcep by opendaylight.

the class XROAsNumberSubobjectParser method serializeSubobject.

@Override
public void serializeSubobject(final SubobjectContainer subobject, final ByteBuf buffer) {
    Preconditions.checkArgument(subobject.getSubobjectType() instanceof AsNumberCase, "Unknown subobject instance. Passed %s. Needed AsNumberCase.", subobject.getSubobjectType().getClass());
    final ByteBuf body = AsNumberCaseParser.serializeSubobject((AsNumberCase) subobject.getSubobjectType());
    XROSubobjectUtil.formatSubobject(TYPE, subobject.getMandatory(), body, buffer);
}
Also used : AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)34 RSVPParsingException (org.opendaylight.protocol.rsvp.parser.spi.RSVPParsingException)23 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)11 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)9 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainerBuilder)9 Test (org.junit.Test)8 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder)8 ArrayList (java.util.ArrayList)7 BitArray (org.opendaylight.protocol.util.BitArray)7 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route.subobjects.list.SubobjectContainer)7 Ipv6Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix)6 IpPrefixSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.IpPrefixSubobject)6 ProtectionSubobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.protection.subobject.ProtectionSubobject)6 LabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCaseBuilder)5 SubobjectContainer (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainer)5 Preconditions (com.google.common.base.Preconditions)4 Attribute (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute)4 SubobjectType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType)4 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)4 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)3